diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-06-26 10:04:46 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-06-26 10:04:46 -0700 |
commit | 4ad7b4317d77c161cab69f5ae2b52b1583c96f11 (patch) | |
tree | a7c683d7d4625d4eebe10dd98a33a2123e34b154 | |
parent | 287f85e3e8c247dcec669f1169b8929e095b3dc9 (diff) | |
download | binaryen-4ad7b4317d77c161cab69f5ae2b52b1583c96f11.tar.gz binaryen-4ad7b4317d77c161cab69f5ae2b52b1583c96f11.tar.bz2 binaryen-4ad7b4317d77c161cab69f5ae2b52b1583c96f11.zip |
make makeCallImport more similar to makeCall; do not assume all imports exist, let functions be created in a way independent from global state
-rw-r--r-- | src/ast_utils.h | 2 | ||||
-rw-r--r-- | src/wasm-builder.h | 4 | ||||
-rw-r--r-- | src/wasm-linker.cpp | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/src/ast_utils.h b/src/ast_utils.h index c2a3db435..77bfaf1f3 100644 --- a/src/ast_utils.h +++ b/src/ast_utils.h @@ -258,7 +258,7 @@ struct ExpressionManipulator { return ret; } Expression* visitCallImport(CallImport *curr) { - auto* ret = builder.makeCallImport(curr->target, {}); + auto* ret = builder.makeCallImport(curr->target, {}, curr->type); for (Index i = 0; i < curr->operands.size(); i++) { ret->operands.push_back(copy(curr->operands[i])); } diff --git a/src/wasm-builder.h b/src/wasm-builder.h index e58d66795..501124999 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -107,9 +107,9 @@ public: call->operands.set(args); return call; } - CallImport* makeCallImport(Name target, const std::vector<Expression*>& args) { + CallImport* makeCallImport(Name target, const std::vector<Expression*>& args, WasmType type) { auto* call = wasm.allocator.alloc<CallImport>(); - call->type = wasm.getImport(target)->type->result; + call->type = type; // similar to makeCall, for consistency call->target = target; call->operands.set(args); return call; diff --git a/src/wasm-linker.cpp b/src/wasm-linker.cpp index eb7f9e00d..34dbc7f9c 100644 --- a/src/wasm-linker.cpp +++ b/src/wasm-linker.cpp @@ -396,7 +396,7 @@ Function* Linker::getImportThunk(Name name, const FunctionType* funcType) { for (Index i = 0; i < funcType->params.size(); ++i) { args.push_back(wasmBuilder.makeGetLocal(i, funcType->params[i])); } - Expression* call = wasmBuilder.makeCallImport(name, args); + Expression* call = wasmBuilder.makeCallImport(name, args, funcType->result); f->body = call; out.wasm.addFunction(f); return f; |