Parsing Some Opcodes
commite58190d0b24ec14b25ae95bcb80ed0b721dcd544
authorAlma Thaler <almathaler@fb.com>
Thu, 16 Jun 2022 17:48:52 +0000 (16 10:48 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Thu, 16 Jun 2022 17:48:52 +0000 (16 10:48 -0700)
tree414189f9d374d5559d88199c9606b5f7efa5853f
parentbfd5c932078c6380d730a4cf0272437fd2687531
Parsing Some Opcodes

Summary:
Can now fully parse the `.hhas` of `hello.php`, the file outlined in T118282235.
This means we can parse a limited number of opcodes as well as a partial `.hhas` outline (since `hello.hhas` doesn't have classes and its function takes no arguments, these constructs will be parsed later)

Also added some functions to `escaper.rs`. Similar to D37054531 (https://github.com/facebook/hhvm/commit/e1c5fac7d7efa0eb3c5b2dbaeee461c871f92a02), `escaper.rs` could unescape `&str` but not `&[u8]`, and to avoid risking `from_utf8` errors I added a `byte` literal escaping method to `escape.rs`.

Also made all `into_xxx` token functions have the same return type (`Result<&'a [u8]>`) so we can pass to `expect_is_str`, even though most tokens don't carry data (just return their string rep)

Reviewed By: hgoldstein

Differential Revision: D37181124

fbshipit-source-id: 310582a70f08e7c022113a0035757a784ef0263d
hphp/hack/src/hackc/hackc/assemble.rs
hphp/hack/src/utils/escaper.rs