MCPcopy Create free account
hub / github.com/GJDuck/e9patch / parseTrampoline

Function parseTrampoline

src/e9patch/e9json.cpp:858–931  ·  view source on GitHub ↗

* Parse a template object. */

Source from the content-addressed store, hash-verified

856 * Parse a template object.
857 */
858static Trampoline *parseTrampoline(Parser &parser, bool debug = false)
859{
860 std::vector<uint8_t> bytes;
861 std::vector<Entry> entries;
862
863 if (debug)
864 entries.push_back(makeDebugEntry());
865
866 char token = getToken(parser);
867 bool once = true;
868 if (token == '[')
869 {
870 once = false;
871 token = getToken(parser);
872 }
873 while (token != ']')
874 {
875 if (token == TOKEN_NUMBER)
876 {
877 if (parser.i < 0 || parser.i > UINT8_MAX)
878 parse_error(parser, "failed to parse byte; value (%zd) is "
879 "outside of the byte range (%d..%d)", parser.i, 0,
880 UINT8_MAX);
881 bytes.push_back((uint8_t)parser.i);
882 }
883 else
884 {
885 if (bytes.size() > 0)
886 {
887 entries.push_back(makeBytesEntry(bytes));
888 bytes.clear();
889 }
890 switch (token)
891 {
892 case TOKEN_STRING:
893 switch (parser.s[0])
894 {
895 case '$':
896 entries.push_back(makeMacroEntry(parser.s));
897 break;
898 case '.':
899 if (parser.s[1] == 'L')
900 {
901 entries.push_back(makeLabelEntry(parser.s));
902 break;
903 }
904 // Fallthrough:
905 default:
906 unexpectedToken(parser, "template entry", token);
907 }
908 break;
909
910 case '{':
911 entries.push_back(makeDataEntry(parser));
912 break;
913
914 case TOKEN_NULL:
915 break;

Callers 2

parseMetadataFunction · 0.70
parseParamsFunction · 0.70

Calls 10

makeDebugEntryFunction · 0.85
getTokenFunction · 0.85
makeBytesEntryFunction · 0.85
makeMacroEntryFunction · 0.85
makeLabelEntryFunction · 0.85
unexpectedTokenFunction · 0.85
makeDataEntryFunction · 0.85
expectToken2Function · 0.85
dupTrampolineFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected