summaryrefslogtreecommitdiff
path: root/src/resolve-names.cc
diff options
context:
space:
mode:
authorBen Smith <binjimin@gmail.com>2018-10-15 13:57:26 -0700
committerGitHub <noreply@github.com>2018-10-15 13:57:26 -0700
commitb234c76e30b49f75ddcd095c5f1e7d9d27d82160 (patch)
tree63b72e00f03d8637657de0fa51af0557a748f1f6 /src/resolve-names.cc
parent8292bd817c873a77d2a0a14dbbd9892b4e9c7860 (diff)
downloadwabt-b234c76e30b49f75ddcd095c5f1e7d9d27d82160.tar.gz
wabt-b234c76e30b49f75ddcd095c5f1e7d9d27d82160.tar.bz2
wabt-b234c76e30b49f75ddcd095c5f1e7d9d27d82160.zip
Add more bulk memory tests; use vars for segments (#930)
* Allow for names in data/elem segments: ``` (data $foo (i32.const 0) "abcdef") ``` * These names can be referenced by the memory/table instructions that operate on segments: ``` memory.drop $foo ``` * Fix running wasm-objdump with bulk-memory instructions * Check for valid data/elem segments in validation * Check that bulk-memory is enabled when parsing text Partial fix for #928; still needs interpreter checks too.
Diffstat (limited to 'src/resolve-names.cc')
-rw-r--r--src/resolve-names.cc34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/resolve-names.cc b/src/resolve-names.cc
index 3a3b666c..9d24f2a7 100644
--- a/src/resolve-names.cc
+++ b/src/resolve-names.cc
@@ -53,8 +53,12 @@ class NameResolver : public ExprVisitor::DelegateNop {
Result EndIfExceptExpr(IfExceptExpr*) override;
Result BeginLoopExpr(LoopExpr*) override;
Result EndLoopExpr(LoopExpr*) override;
+ Result OnMemoryDropExpr(MemoryDropExpr*) override;
+ Result OnMemoryInitExpr(MemoryInitExpr*) override;
Result OnSetGlobalExpr(SetGlobalExpr*) override;
Result OnSetLocalExpr(SetLocalExpr*) override;
+ Result OnTableDropExpr(TableDropExpr*) override;
+ Result OnTableInitExpr(TableInitExpr*) override;
Result OnTeeLocalExpr(TeeLocalExpr*) override;
Result BeginTryExpr(TryExpr*) override;
Result EndTryExpr(TryExpr*) override;
@@ -73,6 +77,8 @@ class NameResolver : public ExprVisitor::DelegateNop {
void ResolveTableVar(Var* var);
void ResolveMemoryVar(Var* var);
void ResolveExceptionVar(Var* var);
+ void ResolveDataSegmentVar(Var* var);
+ void ResolveElemSegmentVar(Var* var);
void ResolveLocalVar(Var* var);
void ResolveBlockDeclarationVar(BlockDeclaration* decl);
void VisitFunc(Func* func);
@@ -180,6 +186,14 @@ void NameResolver::ResolveExceptionVar(Var* var) {
ResolveVar(&current_module_->except_bindings, var, "exception");
}
+void NameResolver::ResolveDataSegmentVar(Var* var) {
+ ResolveVar(&current_module_->data_segment_bindings, var, "data segment");
+}
+
+void NameResolver::ResolveElemSegmentVar(Var* var) {
+ ResolveVar(&current_module_->elem_segment_bindings, var, "elem segment");
+}
+
void NameResolver::ResolveLocalVar(Var* var) {
if (var->is_name()) {
if (!current_func_) {
@@ -299,6 +313,16 @@ Result NameResolver::EndIfExceptExpr(IfExceptExpr* expr) {
return Result::Ok;
}
+Result NameResolver::OnMemoryDropExpr(MemoryDropExpr* expr) {
+ ResolveDataSegmentVar(&expr->var);
+ return Result::Ok;
+}
+
+Result NameResolver::OnMemoryInitExpr(MemoryInitExpr* expr) {
+ ResolveDataSegmentVar(&expr->var);
+ return Result::Ok;
+}
+
Result NameResolver::OnSetGlobalExpr(SetGlobalExpr* expr) {
ResolveGlobalVar(&expr->var);
return Result::Ok;
@@ -309,6 +333,16 @@ Result NameResolver::OnSetLocalExpr(SetLocalExpr* expr) {
return Result::Ok;
}
+Result NameResolver::OnTableDropExpr(TableDropExpr* expr) {
+ ResolveElemSegmentVar(&expr->var);
+ return Result::Ok;
+}
+
+Result NameResolver::OnTableInitExpr(TableInitExpr* expr) {
+ ResolveElemSegmentVar(&expr->var);
+ return Result::Ok;
+}
+
Result NameResolver::OnTeeLocalExpr(TeeLocalExpr* expr) {
ResolveLocalVar(&expr->var);
return Result::Ok;