diff options
author | Alon Zakai <alonzakai@gmail.com> | 2017-02-17 13:49:53 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-17 13:49:53 -0800 |
commit | d946d68963d4731020d7dc0e41f331e0ab89591c (patch) | |
tree | 8e49ed84673af01166cc7101959b1423824454f4 /src/passes/LegalizeJSInterface.cpp | |
parent | 359c6133b3d7d6451cf65f3edce0bcf319f9af22 (diff) | |
download | binaryen-d946d68963d4731020d7dc0e41f331e0ab89591c.tar.gz binaryen-d946d68963d4731020d7dc0e41f331e0ab89591c.tar.bz2 binaryen-d946d68963d4731020d7dc0e41f331e0ab89591c.zip |
clean up raw pointer import->functionType, make it a Name like everything else (#915)
Diffstat (limited to 'src/passes/LegalizeJSInterface.cpp')
-rw-r--r-- | src/passes/LegalizeJSInterface.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/passes/LegalizeJSInterface.cpp b/src/passes/LegalizeJSInterface.cpp index 6e070156f..4ab6221fd 100644 --- a/src/passes/LegalizeJSInterface.cpp +++ b/src/passes/LegalizeJSInterface.cpp @@ -52,7 +52,7 @@ struct LegalizeJSInterface : public Pass { // for each illegal import, we must call a legalized stub instead std::vector<Import*> newImports; // add them at the end, to not invalidate the iter for (auto& im : module->imports) { - if (im->kind == ExternalKind::Function && isIllegal(im->functionType)) { + if (im->kind == ExternalKind::Function && isIllegal(module->getFunctionType(im->functionType))) { Name funcName; auto* legal = makeLegalStub(im.get(), module, funcName); illegalToLegal[im->name] = funcName; @@ -174,7 +174,7 @@ private: legal->module = im->module; legal->base = im->base; legal->kind = ExternalKind::Function; - legal->functionType = type; + legal->functionType = type->name; auto* func = new Function(); func->name = Name(std::string("legalfunc$") + im->name.str); funcName = func->name; @@ -182,7 +182,9 @@ private: auto* call = module->allocator.alloc<CallImport>(); call->target = legal->name; - for (auto param : im->functionType->params) { + auto* imFunctionType = module->getFunctionType(im->functionType); + + for (auto param : imFunctionType->params) { if (param == i64) { call->operands.push_back(I64Utilities::getI64Low(builder, func->params.size())); call->operands.push_back(I64Utilities::getI64High(builder, func->params.size())); @@ -198,23 +200,23 @@ private: func->params.push_back(param); } - if (im->functionType->result == i64) { + if (imFunctionType->result == i64) { call->type = i32; Expression* get; ensureTempRet0(module); get = builder.makeGetGlobal(TEMP_RET_0, i32); func->body = I64Utilities::recreateI64(builder, call, get); type->result = i32; - } else if (im->functionType->result == f32) { + } else if (imFunctionType->result == f32) { call->type = f64; func->body = builder.makeUnary(DemoteFloat64, call); type->result = f64; } else { - call->type = im->functionType->result; + call->type = imFunctionType->result; func->body = call; - type->result = im->functionType->result; + type->result = imFunctionType->result; } - func->result = im->functionType->result; + func->result = imFunctionType->result; module->addFunction(func); module->addFunctionType(type); |