* Parse a bytes object. */
| 934 | * Parse a bytes object. |
| 935 | */ |
| 936 | static Trampoline *parseBytes(Parser &parser) |
| 937 | { |
| 938 | std::vector<uint8_t> bytes; |
| 939 | |
| 940 | expectToken(parser, '['); |
| 941 | char token = getToken(parser); |
| 942 | while (token != ']') |
| 943 | { |
| 944 | if (token != TOKEN_NUMBER) |
| 945 | unexpectedToken(parser, "bytes entry", token); |
| 946 | if (parser.i < 0 || parser.i > UINT8_MAX) |
| 947 | parse_error(parser, "failed to parse byte; value (%zd) is " |
| 948 | "outside of the byte range (%d..%d)", parser.i, 0, UINT8_MAX); |
| 949 | bytes.push_back((uint8_t)parser.i); |
| 950 | token = expectToken2(parser, ',', ']'); |
| 951 | if (token == ',') |
| 952 | token = getToken(parser); |
| 953 | } |
| 954 | |
| 955 | size_t num_entries = 1; |
| 956 | uint8_t *ptr = |
| 957 | new uint8_t[sizeof(Trampoline) + num_entries * sizeof(Entry)]; |
| 958 | Trampoline *T = (Trampoline *)ptr; |
| 959 | T->prot = PROT_READ | PROT_EXEC; |
| 960 | T->num_entries = num_entries; |
| 961 | T->preload = false; |
| 962 | T->entries[0] = makeBytesEntry(bytes); |
| 963 | |
| 964 | return T; |
| 965 | } |
| 966 | |
| 967 | /* |
| 968 | * Parse instruction metadata. |
no test coverage detected