summaryrefslogtreecommitdiff
path: root/src/wasm.h
diff options
context:
space:
mode:
authorAbbas Mashayekh <martianboy2005@gmail.com>2021-02-10 01:17:28 +0330
committerGitHub <noreply@github.com>2021-02-09 13:47:28 -0800
commit3da8b08ecd57f5662bebc69ea73bf59e1928341e (patch)
tree2902eedc161579eaf37a1aed463de95916eee703 /src/wasm.h
parenta12a8250da24aa5b5787bf89562b243fdc514302 (diff)
downloadbinaryen-3da8b08ecd57f5662bebc69ea73bf59e1928341e.tar.gz
binaryen-3da8b08ecd57f5662bebc69ea73bf59e1928341e.tar.bz2
binaryen-3da8b08ecd57f5662bebc69ea73bf59e1928341e.zip
[reference-types] remove single table restriction in IR (#3517)
Adds support for modules with multiple tables. Adds a field for the table name to `CallIndirect` and updates the C/JS APIs accordingly.
Diffstat (limited to 'src/wasm.h')
-rw-r--r--src/wasm.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/wasm.h b/src/wasm.h
index 5e4c4668b..7fd284756 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -836,6 +836,7 @@ public:
Signature sig;
ExpressionList operands;
Expression* target;
+ Name table;
bool isReturn = false;
void finalize();
@@ -1732,18 +1733,12 @@ public:
}
};
- // Currently the wasm object always 'has' one Table. It 'exists' if it has
- // been defined or imported. The table can exist but be empty and have no
- // defined initial or max size.
- bool exists = false;
Address initial = 0;
Address max = kMaxSize;
std::vector<Segment> segments;
- Table() { name = Name::fromInt(0); }
bool hasMax() { return max != kUnlimitedSize; }
void clear() {
- exists = false;
name = "";
initial = 0;
max = kMaxSize;
@@ -1850,7 +1845,8 @@ public:
std::vector<std::unique_ptr<Global>> globals;
std::vector<std::unique_ptr<Event>> events;
- Table table;
+ std::vector<std::unique_ptr<Table>> tables;
+
Memory memory;
Name start;
@@ -1880,6 +1876,7 @@ private:
// exports map is by the *exported* name, which is unique
std::unordered_map<Name, Export*> exportsMap;
std::unordered_map<Name, Function*> functionsMap;
+ std::unordered_map<Name, Table*> tablesMap;
std::unordered_map<Name, Global*> globalsMap;
std::unordered_map<Name, Event*> eventsMap;
@@ -1888,10 +1885,12 @@ public:
Export* getExport(Name name);
Function* getFunction(Name name);
+ Table* getTable(Name name);
Global* getGlobal(Name name);
Event* getEvent(Name name);
Export* getExportOrNull(Name name);
+ Table* getTableOrNull(Name name);
Function* getFunctionOrNull(Name name);
Global* getGlobalOrNull(Name name);
Event* getEventOrNull(Name name);
@@ -1903,6 +1902,7 @@ public:
Export* addExport(std::unique_ptr<Export>&& curr);
Function* addFunction(std::unique_ptr<Function>&& curr);
+ Table* addTable(std::unique_ptr<Table>&& curr);
Global* addGlobal(std::unique_ptr<Global>&& curr);
Event* addEvent(std::unique_ptr<Event>&& curr);
@@ -1910,11 +1910,13 @@ public:
void removeExport(Name name);
void removeFunction(Name name);
+ void removeTable(Name name);
void removeGlobal(Name name);
void removeEvent(Name name);
void removeExports(std::function<bool(Export*)> pred);
void removeFunctions(std::function<bool(Function*)> pred);
+ void removeTables(std::function<bool(Table*)> pred);
void removeGlobals(std::function<bool(Global*)> pred);
void removeEvents(std::function<bool(Event*)> pred);
@@ -1939,4 +1941,4 @@ std::ostream& operator<<(std::ostream& o, wasm::StackIR& ir);
} // namespace std
-#endif // wasm_wasm_h
+#endif // wasm_wasm_h \ No newline at end of file