Last active
April 12, 2017 19:00
-
-
Save cheery/329a2c769618f6fb317452b0f1a0d691 to your computer and use it in GitHub Desktop.
Webassembly schema, and the same in json format.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # note that this is a pre-MVP version. | |
| # there is a distilled and improved version of this in the: | |
| # https://github.com/cheery/lever/blob/master/lib/webassembly-1.json | |
| file => | |
| empty_file {} | |
| section {file "section" int string} | |
| section {file "section" int string spec} | |
| table {file "table" @symbol spec table_pairs} | |
| alias {file "alias" @symbol spec} | |
| opcode {file "op" int string op_args} | |
| op_args => | |
| blank_fields {} | |
| append { op_args op_spec } | |
| op_spec => | |
| op_label_imm { @symbol ":" spec } | |
| op_imm { spec } | |
| spec => | |
| union { "union" spec "{" union_fields "}" } | |
| group { "group" "{" group_fields "}" } | |
| sequence { group { "group" "*" "{" group_fields "}" } } | |
| optional { spec "?" } | |
| sequence { spec "*" } | |
| primitive { @symbol } | |
| union_fields => | |
| blank_fields {} | |
| append { union_fields union_field } | |
| union_field => | |
| union_field { string "{" group_fields "}" } | |
| group_fields => | |
| blank_fields {} | |
| append { group_fields group_field } | |
| group_field => | |
| constant { "constant" int spec } | |
| field { @symbol spec } | |
| table_pairs => | |
| blank_table {} | |
| fill_table {table_pairs int string} | |
| string => | |
| string { @string } | |
| int => | |
| int { @int } | |
| hex { @hex } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # note that this is a pre-MVP version. | |
| # there is a distilled and improved version of this in the: | |
| # https://github.com/cheery/lever/blob/master/lib/webassembly-1.json | |
| # http://leverlanguage.com | |
| import tokenizer, chartparser, grammar_language | |
| import fs, json | |
| language = grammar_language.read_file(dir ++ "schema.grammar") | |
| language.new_parser = chartparser.preprocess( | |
| language.grammar, | |
| language.table.nonterminal("file")) | |
| main = (args): | |
| source = "webassembly-12.schema" | |
| tokens = tokenizer.read_file(source, | |
| language.table.keywords) | |
| parser = language.new_parser() | |
| for token in tokens | |
| terminal = language.table.terminal(token.name) | |
| if not parser.expecting(terminal) | |
| raise chartparser.SyntaxErrorExpected( | |
| parser.expect, token.start, source) | |
| parser.step(terminal, token, token.start, token.stop) | |
| if not parser.accepted | |
| raise chartparser.SyntaxErrorExpected( | |
| parser.expect, token.stop, source, true) | |
| argl = [] | |
| result = parser.traverse( | |
| (rule, args, start, stop): | |
| return rule.annotation(actions, args, argl) | |
| ) | |
| print(json.write_string(result, {indent=2})) | |
| #args.pop(0) | |
| #print(args) | |
| actions = :exnihilo() | |
| empty_file = (): | |
| return { | |
| sections=[] | |
| tables={} | |
| alias={} | |
| ops=[] | |
| } | |
| section = (schema, index, name, spec=null): | |
| schema["sections"].append({ | |
| id=index | |
| name=name | |
| spec=spec | |
| }) | |
| return schema | |
| table = (schema, name, spec, table): | |
| schema["tables"][name.string] = { | |
| spec=spec | |
| table=table | |
| } | |
| return schema | |
| alias = (schema, name, spec): | |
| schema["alias"][name.string] = spec | |
| return schema | |
| opcode = (schema, index, name, args): | |
| schema["ops"].append({ | |
| index=index | |
| name=name | |
| args=args | |
| }) | |
| return schema | |
| op_imm = (spec): | |
| return {type="imm", spec=spec} | |
| op_label_imm = (label, spec): | |
| return {type="imm", spec=spec, label=label.string} | |
| blank_fields = (): | |
| return [] | |
| append = (a, b): | |
| a.append(b) | |
| return a | |
| # Group fields | |
| constant = (num, spec): | |
| return {type="constant", value=num, spec=spec} | |
| field = (name, spec): | |
| return {type="field", name=name.string, spec=spec} | |
| union_field = (name, spec): | |
| return {name=name, spec=spec} | |
| # Specs | |
| group = (fields): | |
| return {type="group", fields=fields} | |
| union = (fields): | |
| return {type="union", fields=fields} | |
| primitive = (name): | |
| return {type="data", name=name.string} | |
| optional = (spec): | |
| return {type="optional", spec=spec} | |
| sequence = (spec): | |
| return {type="list", spec=spec} | |
| blank_table = (): | |
| return [] | |
| fill_table = (table, id, string): | |
| table.append({id=id, name=string}) | |
| return table | |
| # Strings in the grammar notation. | |
| string = (token): | |
| return token.string | |
| # Numbers in the grammar notation. | |
| int = (token): | |
| return parse_int(token.string) | |
| hex = (token): | |
| return parse_int(token.string, 16) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "sections": [ | |
| { | |
| "id": 1, | |
| "name": "type", | |
| "spec": { | |
| "type": "list", | |
| "spec": { | |
| "type": "group", | |
| "fields": [ | |
| { | |
| "type": "constant", | |
| "value": 64, | |
| "spec": {"type": "data", "name": "varuint7"} | |
| }, | |
| { | |
| "type": "field", | |
| "name": "argtypes", | |
| "spec": { | |
| "type": "list", | |
| "spec": {"type": "data", "name": "value_type"} | |
| } | |
| }, | |
| { | |
| "type": "field", | |
| "name": "restype", | |
| "spec": { | |
| "type": "optional", | |
| "spec": {"type": "data", "name": "value_type"} | |
| } | |
| } | |
| ] | |
| } | |
| } | |
| }, | |
| { | |
| "id": 2, | |
| "name": "import", | |
| "spec": { | |
| "type": "list", | |
| "spec": { | |
| "type": "group", | |
| "fields": [ | |
| { | |
| "type": "field", | |
| "name": "module", | |
| "spec": {"type": "data", "name": "string"} | |
| }, | |
| { | |
| "type": "field", | |
| "name": "field", | |
| "spec": {"type": "data", "name": "string"} | |
| }, | |
| { | |
| "type": "field", | |
| "name": "type", | |
| "spec": { | |
| "type": "union", | |
| "fields": {"type": "data", "name": "external_kind"} | |
| } | |
| } | |
| ] | |
| } | |
| } | |
| }, | |
| { | |
| "id": 3, | |
| "name": "function", | |
| "spec": {"type": "list", "spec": {"type": "data", "name": "varuint32"}} | |
| }, | |
| { | |
| "id": 4, | |
| "name": "table", | |
| "spec": { | |
| "type": "list", | |
| "spec": { | |
| "type": "group", | |
| "fields": [ | |
| { | |
| "type": "constant", | |
| "value": 32, | |
| "spec": {"type": "data", "name": "varuint7"} | |
| }, | |
| { | |
| "type": "field", | |
| "name": "limits", | |
| "spec": {"type": "data", "name": "resizable_limits"} | |
| } | |
| ] | |
| } | |
| } | |
| }, | |
| { | |
| "id": 5, | |
| "name": "memory", | |
| "spec": { | |
| "type": "list", | |
| "spec": {"type": "data", "name": "resizable_limits"} | |
| } | |
| }, | |
| { | |
| "id": 6, | |
| "name": "global", | |
| "spec": { | |
| "type": "list", | |
| "spec": { | |
| "type": "group", | |
| "fields": [ | |
| { | |
| "type": "field", | |
| "name": "type", | |
| "spec": {"type": "data", "name": "value_type"} | |
| }, | |
| { | |
| "type": "constant", | |
| "value": 0, | |
| "spec": {"type": "data", "name": "varuint1"} | |
| }, | |
| { | |
| "type": "field", | |
| "name": "init_expr", | |
| "spec": {"type": "data", "name": "code"} | |
| } | |
| ] | |
| } | |
| } | |
| }, | |
| { | |
| "id": 7, | |
| "name": "export", | |
| "spec": { | |
| "type": "list", | |
| "spec": { | |
| "type": "group", | |
| "fields": [ | |
| { | |
| "type": "field", | |
| "name": "field", | |
| "spec": {"type": "data", "name": "string"} | |
| }, | |
| { | |
| "type": "field", | |
| "name": "kind", | |
| "spec": {"type": "data", "name": "external_kind"} | |
| }, | |
| { | |
| "type": "field", | |
| "name": "index", | |
| "spec": {"type": "data", "name": "varuint32"} | |
| } | |
| ] | |
| } | |
| } | |
| }, | |
| { | |
| "id": 8, | |
| "name": "start", | |
| "spec": {"type": "list", "spec": {"type": "data", "name": "varuint32"}} | |
| }, | |
| { | |
| "id": 9, | |
| "name": "element", | |
| "spec": { | |
| "type": "list", | |
| "spec": { | |
| "type": "group", | |
| "fields": [ | |
| { | |
| "type": "constant", | |
| "value": 0, | |
| "spec": {"type": "data", "name": "varuint32"} | |
| }, | |
| { | |
| "type": "field", | |
| "name": "init_expr", | |
| "spec": {"type": "data", "name": "code"} | |
| }, | |
| { | |
| "type": "field", | |
| "name": "elems", | |
| "spec": { | |
| "type": "list", | |
| "spec": {"type": "data", "name": "varuint32"} | |
| } | |
| } | |
| ] | |
| } | |
| } | |
| }, | |
| { | |
| "id": 10, | |
| "name": "code", | |
| "spec": {"type": "list", "spec": {"type": "data", "name": "blob"}} | |
| }, | |
| { | |
| "id": 11, | |
| "name": "data", | |
| "spec": { | |
| "type": "list", | |
| "spec": { | |
| "type": "group", | |
| "fields": [ | |
| { | |
| "type": "constant", | |
| "value": 0, | |
| "spec": {"type": "data", "name": "varuint32"} | |
| }, | |
| { | |
| "type": "field", | |
| "name": "init_expr", | |
| "spec": {"type": "data", "name": "code"} | |
| }, | |
| { | |
| "type": "field", | |
| "name": "data", | |
| "spec": {"type": "data", "name": "blob"} | |
| } | |
| ] | |
| } | |
| } | |
| }, | |
| { | |
| "id": 12, | |
| "name": "name", | |
| "spec": { | |
| "type": "list", | |
| "spec": { | |
| "type": "group", | |
| "fields": [ | |
| { | |
| "type": "field", | |
| "name": "name", | |
| "spec": {"type": "data", "name": "string"} | |
| }, | |
| { | |
| "type": "field", | |
| "name": "locals", | |
| "spec": { | |
| "type": "list", | |
| "spec": {"type": "data", "name": "string"} | |
| } | |
| } | |
| ] | |
| } | |
| } | |
| } | |
| ], | |
| "tables": { | |
| "value_type": { | |
| "spec": {"type": "data", "name": "uint8"}, | |
| "table": [ | |
| {"id": 1, "name": "i32"}, | |
| {"id": 2, "name": "i64"}, | |
| {"id": 3, "name": "f32"}, | |
| {"id": 4, "name": "f64"} | |
| ] | |
| }, | |
| "external_kind": { | |
| "spec": {"type": "data", "name": "uint8"}, | |
| "table": [ | |
| {"id": 1, "name": "function"}, | |
| {"id": 2, "name": "table"}, | |
| {"id": 3, "name": "memory"}, | |
| {"id": 4, "name": "global"} | |
| ] | |
| } | |
| }, | |
| "alias": { | |
| "function_body": { | |
| "type": "group", | |
| "fields": [ | |
| { | |
| "type": "field", | |
| "name": "locals", | |
| "spec": { | |
| "type": "list", | |
| "spec": { | |
| "type": "group", | |
| "fields": [ | |
| { | |
| "type": "field", | |
| "name": "count", | |
| "spec": {"type": "data", "name": "varuint32"} | |
| }, | |
| { | |
| "type": "field", | |
| "name": "type", | |
| "spec": {"type": "data", "name": "value_type"} | |
| } | |
| ] | |
| } | |
| } | |
| }, | |
| { | |
| "type": "field", | |
| "name": "body", | |
| "spec": {"type": "data", "name": "code"} | |
| } | |
| ] | |
| }, | |
| "br_table": { | |
| "type": "group", | |
| "fields": [ | |
| { | |
| "type": "field", | |
| "name": "targets", | |
| "spec": { | |
| "type": "list", | |
| "spec": {"type": "data", "name": "varuint32"} | |
| } | |
| }, | |
| { | |
| "type": "field", | |
| "name": "default_target", | |
| "spec": {"type": "data", "name": "varuint32"} | |
| } | |
| ] | |
| }, | |
| "memory_immediate": { | |
| "type": "group", | |
| "fields": [ | |
| { | |
| "type": "field", | |
| "name": "flags", | |
| "spec": {"type": "data", "name": "varuint32"} | |
| }, | |
| { | |
| "type": "field", | |
| "name": "offset", | |
| "spec": {"type": "data", "name": "varuint32"} | |
| } | |
| ] | |
| } | |
| }, | |
| "ops": [ | |
| {"index": 0, "name": "unreachable", "args": []}, | |
| { | |
| "index": 1, | |
| "name": "block", | |
| "args": [ | |
| { | |
| "type": "imm", | |
| "spec": {"type": "data", "name": "inline_signature_type"} | |
| } | |
| ] | |
| }, | |
| { | |
| "index": 2, | |
| "name": "loop", | |
| "args": [ | |
| { | |
| "type": "imm", | |
| "spec": {"type": "data", "name": "inline_signature_type"} | |
| } | |
| ] | |
| }, | |
| { | |
| "index": 3, | |
| "name": "if", | |
| "args": [ | |
| { | |
| "type": "imm", | |
| "spec": {"type": "data", "name": "inline_signature_type"} | |
| } | |
| ] | |
| }, | |
| {"index": 4, "name": "else", "args": []}, | |
| {"index": 5, "name": "select", "args": []}, | |
| { | |
| "index": 6, | |
| "name": "br", | |
| "args": [ | |
| { | |
| "type": "imm", | |
| "spec": {"type": "data", "name": "varuint32"}, | |
| "label": "relative_depth" | |
| } | |
| ] | |
| }, | |
| { | |
| "index": 7, | |
| "name": "br_if", | |
| "args": [ | |
| { | |
| "type": "imm", | |
| "spec": {"type": "data", "name": "varuint32"}, | |
| "label": "relative_depth" | |
| } | |
| ] | |
| }, | |
| { | |
| "index": 8, | |
| "name": "br_table", | |
| "args": [ | |
| { | |
| "type": "imm", | |
| "spec": {"type": "data", "name": "br_table"}, | |
| "label": "br_table" | |
| } | |
| ] | |
| }, | |
| {"index": 9, "name": "return", "args": []}, | |
| {"index": 10, "name": "nop", "args": []}, | |
| {"index": 11, "name": "drop", "args": []}, | |
| {"index": 15, "name": "end", "args": []}, | |
| { | |
| "index": 16, | |
| "name": "i32.const", | |
| "args": [ | |
| { | |
| "type": "imm", | |
| "spec": {"type": "data", "name": "varint32"}, | |
| "label": "value" | |
| } | |
| ] | |
| }, | |
| { | |
| "index": 17, | |
| "name": "i64.const", | |
| "args": [ | |
| { | |
| "type": "imm", | |
| "spec": {"type": "data", "name": "varint64"}, | |
| "label": "value" | |
| } | |
| ] | |
| }, | |
| { | |
| "index": 18, | |
| "name": "f64.const", | |
| "args": [ | |
| { | |
| "type": "imm", | |
| "spec": {"type": "data", "name": "varint32"}, | |
| "label": "value" | |
| } | |
| ] | |
| }, | |
| { | |
| "index": 19, | |
| "name": "f32.const", | |
| "args": [ | |
| { | |
| "type": "imm", | |
| "spec": {"type": "data", "name": "varint64"}, | |
| "label": "value" | |
| } | |
| ] | |
| }, | |
| { | |
| "index": 20, | |
| "name": "get_local", | |
| "args": [ | |
| { | |
| "type": "imm", | |
| "spec": {"type": "data", "name": "varuint32"}, | |
| "label": "local_index" | |
| } | |
| ] | |
| }, | |
| { | |
| "index": 21, | |
| "name": "set_local", | |
| "args": [ | |
| { | |
| "type": "imm", | |
| "spec": {"type": "data", "name": "varuint32"}, | |
| "label": "local_index" | |
| } | |
| ] | |
| }, | |
| { | |
| "index": 25, | |
| "name": "tee_local", | |
| "args": [ | |
| { | |
| "type": "imm", | |
| "spec": {"type": "data", "name": "varuint32"}, | |
| "label": "local_index" | |
| } | |
| ] | |
| }, | |
| { | |
| "index": 187, | |
| "name": "get_global", | |
| "args": [ | |
| { | |
| "type": "imm", | |
| "spec": {"type": "data", "name": "varuint32"}, | |
| "label": "global_index" | |
| } | |
| ] | |
| }, | |
| { | |
| "index": 188, | |
| "name": "set_global", | |
| "args": [ | |
| { | |
| "type": "imm", | |
| "spec": {"type": "data", "name": "varuint32"}, | |
| "label": "global_index" | |
| } | |
| ] | |
| }, | |
| { | |
| "index": 22, | |
| "name": "call", | |
| "args": [ | |
| { | |
| "type": "imm", | |
| "spec": {"type": "data", "name": "varuint32"}, | |
| "label": "function_index" | |
| } | |
| ] | |
| }, | |
| { | |
| "index": 23, | |
| "name": "call_indirect", | |
| "args": [ | |
| { | |
| "type": "imm", | |
| "spec": {"type": "data", "name": "varuint32"}, | |
| "label": "type_index" | |
| } | |
| ] | |
| }, | |
| { | |
| "index": 32, | |
| "name": "i32.load8_s", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 33, | |
| "name": "i32.load8_u", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 34, | |
| "name": "i32.load16_s", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 35, | |
| "name": "i32.load16_u", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 36, | |
| "name": "i64.load8_s", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 37, | |
| "name": "i64.load8_u", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 38, | |
| "name": "i64.load16_s", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 39, | |
| "name": "i64.load16_u", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 40, | |
| "name": "i64.load32_s", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 41, | |
| "name": "i64.load32_u", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 42, | |
| "name": "i32.load", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 43, | |
| "name": "i64.load", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 44, | |
| "name": "f32.load", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 45, | |
| "name": "f64.load", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 46, | |
| "name": "i32.store8", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 47, | |
| "name": "i32.store16", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 48, | |
| "name": "i64.store8", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 49, | |
| "name": "i64.store16", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 50, | |
| "name": "i64.store32", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 51, | |
| "name": "i32.store", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 52, | |
| "name": "i64.store", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 53, | |
| "name": "f32.store", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| { | |
| "index": 54, | |
| "name": "f64.store", | |
| "args": [ | |
| {"type": "imm", "spec": {"type": "data", "name": "memory_immediate"}} | |
| ] | |
| }, | |
| {"index": 59, "name": "current_memory", "args": []}, | |
| {"index": 57, "name": "grow_memory", "args": []}, | |
| {"index": 64, "name": "i32.add", "args": []}, | |
| {"index": 65, "name": "i32.sub", "args": []}, | |
| {"index": 66, "name": "i32.mul", "args": []}, | |
| {"index": 67, "name": "i32.div_s", "args": []}, | |
| {"index": 68, "name": "i32.div_u", "args": []}, | |
| {"index": 69, "name": "i32.rem_s", "args": []}, | |
| {"index": 70, "name": "i32.rem_u", "args": []}, | |
| {"index": 71, "name": "i32.and", "args": []}, | |
| {"index": 72, "name": "i32.or", "args": []}, | |
| {"index": 73, "name": "i32.xor", "args": []}, | |
| {"index": 74, "name": "i32.shl", "args": []}, | |
| {"index": 75, "name": "i32.shr_u", "args": []}, | |
| {"index": 76, "name": "i32.shr_s", "args": []}, | |
| {"index": 182, "name": "i32.rotr", "args": []}, | |
| {"index": 183, "name": "i32.rotl", "args": []}, | |
| {"index": 77, "name": "i32.eq", "args": []}, | |
| {"index": 78, "name": "i32.ne", "args": []}, | |
| {"index": 79, "name": "i32.lt_s", "args": []}, | |
| {"index": 80, "name": "i32.le_s", "args": []}, | |
| {"index": 81, "name": "i32.lt_u", "args": []}, | |
| {"index": 82, "name": "i32.le_u", "args": []}, | |
| {"index": 83, "name": "i32.gt_s", "args": []}, | |
| {"index": 84, "name": "i32.ge_s", "args": []}, | |
| {"index": 85, "name": "i32.gt_u", "args": []}, | |
| {"index": 86, "name": "i32.ge_u", "args": []}, | |
| {"index": 87, "name": "i32.clz", "args": []}, | |
| {"index": 88, "name": "i32.ctz", "args": []}, | |
| {"index": 89, "name": "i32.popcnt", "args": []}, | |
| {"index": 90, "name": "i32.eqz", "args": []}, | |
| {"index": 91, "name": "i64.add", "args": []}, | |
| {"index": 92, "name": "i64.sub", "args": []}, | |
| {"index": 93, "name": "i64.mul", "args": []}, | |
| {"index": 94, "name": "i64.div_s", "args": []}, | |
| {"index": 95, "name": "i64.div_u", "args": []}, | |
| {"index": 96, "name": "i64.rem_s", "args": []}, | |
| {"index": 97, "name": "i64.rem_u", "args": []}, | |
| {"index": 98, "name": "i64.and", "args": []}, | |
| {"index": 99, "name": "i64.or", "args": []}, | |
| {"index": 100, "name": "i64.xor", "args": []}, | |
| {"index": 101, "name": "i64.shl", "args": []}, | |
| {"index": 102, "name": "i64.shr_u", "args": []}, | |
| {"index": 103, "name": "i64.shr_s", "args": []}, | |
| {"index": 184, "name": "i64.rotr", "args": []}, | |
| {"index": 185, "name": "i64.rotl", "args": []}, | |
| {"index": 104, "name": "i64.eq", "args": []}, | |
| {"index": 105, "name": "i64.ne", "args": []}, | |
| {"index": 106, "name": "i64.lt_s", "args": []}, | |
| {"index": 107, "name": "i64.le_s", "args": []}, | |
| {"index": 108, "name": "i64.lt_u", "args": []}, | |
| {"index": 109, "name": "i64.le_u", "args": []}, | |
| {"index": 110, "name": "i64.gt_s", "args": []}, | |
| {"index": 111, "name": "i64.ge_s", "args": []}, | |
| {"index": 112, "name": "i64.gt_u", "args": []}, | |
| {"index": 113, "name": "i64.ge_u", "args": []}, | |
| {"index": 114, "name": "i64.clz", "args": []}, | |
| {"index": 115, "name": "i64.ctz", "args": []}, | |
| {"index": 116, "name": "i64.popcnt", "args": []}, | |
| {"index": 186, "name": "i64.eqz", "args": []}, | |
| {"index": 117, "name": "f32.add", "args": []}, | |
| {"index": 118, "name": "f32.sub", "args": []}, | |
| {"index": 119, "name": "f32.mul", "args": []}, | |
| {"index": 120, "name": "f32.div", "args": []}, | |
| {"index": 121, "name": "f32.min", "args": []}, | |
| {"index": 122, "name": "f32.max", "args": []}, | |
| {"index": 123, "name": "f32.abs", "args": []}, | |
| {"index": 124, "name": "f32.neg", "args": []}, | |
| {"index": 125, "name": "f32.copysign", "args": []}, | |
| {"index": 126, "name": "f32.ceil", "args": []}, | |
| {"index": 127, "name": "f32.floor", "args": []}, | |
| {"index": 128, "name": "f32.trunc", "args": []}, | |
| {"index": 129, "name": "f32.nearest", "args": []}, | |
| {"index": 130, "name": "f32.sqrt", "args": []}, | |
| {"index": 131, "name": "f32.eq", "args": []}, | |
| {"index": 132, "name": "f32.ne", "args": []}, | |
| {"index": 133, "name": "f32.lt", "args": []}, | |
| {"index": 134, "name": "f32.le", "args": []}, | |
| {"index": 135, "name": "f32.gt", "args": []}, | |
| {"index": 136, "name": "f32.ge", "args": []}, | |
| {"index": 137, "name": "f64.add", "args": []}, | |
| {"index": 138, "name": "f64.sub", "args": []}, | |
| {"index": 139, "name": "f64.mul", "args": []}, | |
| {"index": 140, "name": "f64.div", "args": []}, | |
| {"index": 141, "name": "f64.min", "args": []}, | |
| {"index": 142, "name": "f64.max", "args": []}, | |
| {"index": 143, "name": "f64.abs", "args": []}, | |
| {"index": 144, "name": "f64.neg", "args": []}, | |
| {"index": 145, "name": "f64.copysign", "args": []}, | |
| {"index": 146, "name": "f64.ceil", "args": []}, | |
| {"index": 147, "name": "f64.floor", "args": []}, | |
| {"index": 148, "name": "f64.trunc", "args": []}, | |
| {"index": 149, "name": "f64.nearest", "args": []}, | |
| {"index": 150, "name": "f64.sqrt", "args": []}, | |
| {"index": 151, "name": "f64.eq", "args": []}, | |
| {"index": 152, "name": "f64.ne", "args": []}, | |
| {"index": 153, "name": "f64.lt", "args": []}, | |
| {"index": 154, "name": "f64.le", "args": []}, | |
| {"index": 155, "name": "f64.gt", "args": []}, | |
| {"index": 156, "name": "f64.ge", "args": []}, | |
| {"index": 157, "name": "i32.trunc_s/f32", "args": []}, | |
| {"index": 158, "name": "i32.trunc_s/f64", "args": []}, | |
| {"index": 159, "name": "i32.trunc_u/f32", "args": []}, | |
| {"index": 160, "name": "i32.trunc_u/f64", "args": []}, | |
| {"index": 161, "name": "i32.wrap/i64", "args": []}, | |
| {"index": 162, "name": "i64.trunc_s/f32", "args": []}, | |
| {"index": 163, "name": "i64.trunc_s/f64", "args": []}, | |
| {"index": 164, "name": "i64.trunc_u/f32", "args": []}, | |
| {"index": 165, "name": "i64.trunc_u/f64", "args": []}, | |
| {"index": 166, "name": "i64.extend_s/i32", "args": []}, | |
| {"index": 167, "name": "i64.extend_u/i32", "args": []}, | |
| {"index": 168, "name": "f32.convert_s/i32", "args": []}, | |
| {"index": 169, "name": "f32.convert_u/i32", "args": []}, | |
| {"index": 170, "name": "f32.convert_s/i64", "args": []}, | |
| {"index": 171, "name": "f32.convert_u/i64", "args": []}, | |
| {"index": 172, "name": "f32.demote/f64", "args": []}, | |
| {"index": 173, "name": "f32.reinterpret/i32", "args": []}, | |
| {"index": 174, "name": "f64.convert_s/i32", "args": []}, | |
| {"index": 175, "name": "f64.convert_u/i32", "args": []}, | |
| {"index": 176, "name": "f64.convert_s/i64", "args": []}, | |
| {"index": 177, "name": "f64.convert_u/i64", "args": []}, | |
| {"index": 178, "name": "f64.promote/f32", "args": []}, | |
| {"index": 179, "name": "f64.reinterpret/i64", "args": []}, | |
| {"index": 180, "name": "i32.reinterpret/f32", "args": []}, | |
| {"index": 181, "name": "i64.reinterpret/f64", "args": []} | |
| ] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # note that this is a pre-MVP version. | |
| # there is a distilled and improved version of this in the: | |
| # https://github.com/cheery/lever/blob/master/lib/webassembly-1.json | |
| section 1 "type" group* { | |
| constant 0x40 varuint7 | |
| argtypes value_type* | |
| restype value_type? | |
| } | |
| section 2 "import" group* { | |
| module string | |
| field string | |
| type union external_kind { | |
| "function" { | |
| sig_index varuint32 | |
| } | |
| "table" { | |
| constant 0x20 varuint7 | |
| limits resizable_limits | |
| } | |
| "memory" { | |
| limits resizable_limits | |
| } | |
| "global" { | |
| type value_type | |
| constant 0 varuint1 # is_mutable | |
| } | |
| } | |
| } | |
| section 3 "function" varuint32* | |
| section 4 "table" group* { | |
| constant 0x20 varuint7 | |
| limits resizable_limits | |
| } | |
| section 5 "memory" resizable_limits* | |
| section 6 "global" group* { | |
| type value_type | |
| constant 0 varuint1 # is_mutable | |
| init_expr code | |
| } | |
| section 7 "export" group* { | |
| field string | |
| kind external_kind | |
| index varuint32 | |
| } | |
| section 8 "start" varuint32* | |
| section 9 "element" group* { | |
| constant 0 varuint32 | |
| init_expr code | |
| elems varuint32* | |
| } | |
| section 10 "code" blob* | |
| section 11 "data" group* { | |
| constant 0 varuint32 | |
| init_expr code | |
| data blob | |
| } | |
| section 12 "name" group* { | |
| name string | |
| locals string* | |
| } | |
| alias function_body group { | |
| locals group* { | |
| count varuint32 | |
| type value_type | |
| } | |
| body code | |
| } | |
| table value_type uint8 | |
| 1 "i32" | |
| 2 "i64" | |
| 3 "f32" | |
| 4 "f64" | |
| table external_kind uint8 | |
| 1 "function" | |
| 2 "table" | |
| 3 "memory" | |
| 4 "global" | |
| op 0x00 "unreachable" | |
| op 0x01 "block" inline_signature_type | |
| op 0x02 "loop" inline_signature_type | |
| op 0x03 "if" inline_signature_type | |
| op 0x04 "else" | |
| op 0x05 "select" | |
| op 0x06 "br" relative_depth: varuint32 | |
| op 0x07 "br_if" relative_depth: varuint32 | |
| op 0x08 "br_table" br_table: br_table | |
| op 0x09 "return" | |
| op 0x0a "nop" | |
| op 0x0b "drop" | |
| op 0x0f "end" # end a block, loop or if | |
| alias br_table group { | |
| targets varuint32* | |
| default_target varuint32 | |
| } | |
| op 0x10 "i32.const" value: varint32 | |
| op 0x11 "i64.const" value: varint64 | |
| op 0x12 "f64.const" value: varint32 | |
| op 0x13 "f32.const" value: varint64 | |
| op 0x14 "get_local" local_index: varuint32 | |
| op 0x15 "set_local" local_index: varuint32 | |
| op 0x19 "tee_local" local_index: varuint32 | |
| op 0xbb "get_global" global_index: varuint32 | |
| op 0xbc "set_global" global_index: varuint32 | |
| op 0x16 "call" function_index: varuint32 | |
| op 0x17 "call_indirect" type_index: varuint32 | |
| op 0x20 "i32.load8_s" memory_immediate | |
| op 0x21 "i32.load8_u" memory_immediate | |
| op 0x22 "i32.load16_s" memory_immediate | |
| op 0x23 "i32.load16_u" memory_immediate | |
| op 0x24 "i64.load8_s" memory_immediate | |
| op 0x25 "i64.load8_u" memory_immediate | |
| op 0x26 "i64.load16_s" memory_immediate | |
| op 0x27 "i64.load16_u" memory_immediate | |
| op 0x28 "i64.load32_s" memory_immediate | |
| op 0x29 "i64.load32_u" memory_immediate | |
| op 0x2a "i32.load" memory_immediate | |
| op 0x2b "i64.load" memory_immediate | |
| op 0x2c "f32.load" memory_immediate | |
| op 0x2d "f64.load" memory_immediate | |
| op 0x2e "i32.store8" memory_immediate | |
| op 0x2f "i32.store16" memory_immediate | |
| op 0x30 "i64.store8" memory_immediate | |
| op 0x31 "i64.store16" memory_immediate | |
| op 0x32 "i64.store32" memory_immediate | |
| op 0x33 "i32.store" memory_immediate | |
| op 0x34 "i64.store" memory_immediate | |
| op 0x35 "f32.store" memory_immediate | |
| op 0x36 "f64.store" memory_immediate | |
| op 0x3b "current_memory" # query the size of memory | |
| op 0x39 "grow_memory" # grow the size of memory | |
| alias memory_immediate group { | |
| flags varuint32 | |
| offset varuint32 | |
| } | |
| op 0x40 "i32.add" | |
| op 0x41 "i32.sub" | |
| op 0x42 "i32.mul" | |
| op 0x43 "i32.div_s" | |
| op 0x44 "i32.div_u" | |
| op 0x45 "i32.rem_s" | |
| op 0x46 "i32.rem_u" | |
| op 0x47 "i32.and" | |
| op 0x48 "i32.or" | |
| op 0x49 "i32.xor" | |
| op 0x4a "i32.shl" | |
| op 0x4b "i32.shr_u" | |
| op 0x4c "i32.shr_s" | |
| op 0xb6 "i32.rotr" | |
| op 0xb7 "i32.rotl" | |
| op 0x4d "i32.eq" | |
| op 0x4e "i32.ne" | |
| op 0x4f "i32.lt_s" | |
| op 0x50 "i32.le_s" | |
| op 0x51 "i32.lt_u" | |
| op 0x52 "i32.le_u" | |
| op 0x53 "i32.gt_s" | |
| op 0x54 "i32.ge_s" | |
| op 0x55 "i32.gt_u" | |
| op 0x56 "i32.ge_u" | |
| op 0x57 "i32.clz" | |
| op 0x58 "i32.ctz" | |
| op 0x59 "i32.popcnt" | |
| op 0x5a "i32.eqz" | |
| op 0x5b "i64.add" | |
| op 0x5c "i64.sub" | |
| op 0x5d "i64.mul" | |
| op 0x5e "i64.div_s" | |
| op 0x5f "i64.div_u" | |
| op 0x60 "i64.rem_s" | |
| op 0x61 "i64.rem_u" | |
| op 0x62 "i64.and" | |
| op 0x63 "i64.or" | |
| op 0x64 "i64.xor" | |
| op 0x65 "i64.shl" | |
| op 0x66 "i64.shr_u" | |
| op 0x67 "i64.shr_s" | |
| op 0xb8 "i64.rotr" | |
| op 0xb9 "i64.rotl" | |
| op 0x68 "i64.eq" | |
| op 0x69 "i64.ne" | |
| op 0x6a "i64.lt_s" | |
| op 0x6b "i64.le_s" | |
| op 0x6c "i64.lt_u" | |
| op 0x6d "i64.le_u" | |
| op 0x6e "i64.gt_s" | |
| op 0x6f "i64.ge_s" | |
| op 0x70 "i64.gt_u" | |
| op 0x71 "i64.ge_u" | |
| op 0x72 "i64.clz" | |
| op 0x73 "i64.ctz" | |
| op 0x74 "i64.popcnt" | |
| op 0xba "i64.eqz" | |
| op 0x75 "f32.add" | |
| op 0x76 "f32.sub" | |
| op 0x77 "f32.mul" | |
| op 0x78 "f32.div" | |
| op 0x79 "f32.min" | |
| op 0x7a "f32.max" | |
| op 0x7b "f32.abs" | |
| op 0x7c "f32.neg" | |
| op 0x7d "f32.copysign" | |
| op 0x7e "f32.ceil" | |
| op 0x7f "f32.floor" | |
| op 0x80 "f32.trunc" | |
| op 0x81 "f32.nearest" | |
| op 0x82 "f32.sqrt" | |
| op 0x83 "f32.eq" | |
| op 0x84 "f32.ne" | |
| op 0x85 "f32.lt" | |
| op 0x86 "f32.le" | |
| op 0x87 "f32.gt" | |
| op 0x88 "f32.ge" | |
| op 0x89 "f64.add" | |
| op 0x8a "f64.sub" | |
| op 0x8b "f64.mul" | |
| op 0x8c "f64.div" | |
| op 0x8d "f64.min" | |
| op 0x8e "f64.max" | |
| op 0x8f "f64.abs" | |
| op 0x90 "f64.neg" | |
| op 0x91 "f64.copysign" | |
| op 0x92 "f64.ceil" | |
| op 0x93 "f64.floor" | |
| op 0x94 "f64.trunc" | |
| op 0x95 "f64.nearest" | |
| op 0x96 "f64.sqrt" | |
| op 0x97 "f64.eq" | |
| op 0x98 "f64.ne" | |
| op 0x99 "f64.lt" | |
| op 0x9a "f64.le" | |
| op 0x9b "f64.gt" | |
| op 0x9c "f64.ge" | |
| op 0x9d "i32.trunc_s/f32" | |
| op 0x9e "i32.trunc_s/f64" | |
| op 0x9f "i32.trunc_u/f32" | |
| op 0xa0 "i32.trunc_u/f64" | |
| op 0xa1 "i32.wrap/i64" | |
| op 0xa2 "i64.trunc_s/f32" | |
| op 0xa3 "i64.trunc_s/f64" | |
| op 0xa4 "i64.trunc_u/f32" | |
| op 0xa5 "i64.trunc_u/f64" | |
| op 0xa6 "i64.extend_s/i32" | |
| op 0xa7 "i64.extend_u/i32" | |
| op 0xa8 "f32.convert_s/i32" | |
| op 0xa9 "f32.convert_u/i32" | |
| op 0xaa "f32.convert_s/i64" | |
| op 0xab "f32.convert_u/i64" | |
| op 0xac "f32.demote/f64" | |
| op 0xad "f32.reinterpret/i32" | |
| op 0xae "f64.convert_s/i32" | |
| op 0xaf "f64.convert_u/i32" | |
| op 0xb0 "f64.convert_s/i64" | |
| op 0xb1 "f64.convert_u/i64" | |
| op 0xb2 "f64.promote/f32" | |
| op 0xb3 "f64.reinterpret/i64" | |
| op 0xb4 "i32.reinterpret/f32" | |
| op 0xb5 "i64.reinterpret/f64" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment