MCPcopy Create free account
hub / github.com/WasmVM/WasmVM / parse_modulefield

Method parse_modulefield

src/lib/parse/ParseContext.cpp:100–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100void ParseContext::parse_modulefield() {
101 // Each modulefield is '(' keyword ... ')'.
102 // Peek inside to see which section.
103 if (tok_.peek().type != TokenType::LParen)
104 throw Exception::Parse("expected '('", tok_.location());
105
106 const Token& kw = tok_.peek2();
107 if (kw.type != TokenType::Keyword)
108 throw Exception::Parse("expected section keyword", {kw.line, kw.column});
109
110 const std::string& name = kw.text;
111 if (name == "type") parse_typesection();
112 else if (name == "import") parse_importsection();
113 else if (name == "func") parse_funcsection();
114 else if (name == "table") parse_tablesection();
115 else if (name == "memory") parse_memorysection();
116 else if (name == "global") parse_globalsection();
117 else if (name == "export") parse_exportsection();
118 else if (name == "start") parse_startsection();
119 else if (name == "elem") parse_elemsection();
120 else if (name == "data") parse_datasection();
121 else if (name == "tag") parse_tagsection();
122 else throw Exception::Parse("unknown module section '" + name + "'", {kw.line, kw.column});
123}
124
125// ── Type section ──────────────────────────────────────────────────────────────
126

Callers

nothing calls this directly

Calls 3

ParseClass · 0.85
peekMethod · 0.80
locationMethod · 0.45

Tested by

no test coverage detected