summaryrefslogtreecommitdiff
path: root/src/passes/TrapMode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/TrapMode.cpp')
-rw-r--r--src/passes/TrapMode.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/passes/TrapMode.cpp b/src/passes/TrapMode.cpp
index 9c9dee9ca..ee245af88 100644
--- a/src/passes/TrapMode.cpp
+++ b/src/passes/TrapMode.cpp
@@ -132,14 +132,14 @@ Function* generateBinaryFunc(Module& wasm, Binary* curr) {
builder.makeConst(zeroLit),
result);
}
- auto func = new Function;
- func->name = getBinaryFuncName(curr);
- func->sig = Signature({type, type}, type);
+ auto funcSig = Signature({type, type}, type);
+ auto func = Builder::makeFunction(getBinaryFuncName(curr), funcSig, {});
func->body =
builder.makeIf(builder.makeUnary(eqZOp, builder.makeLocalGet(1, type)),
builder.makeConst(zeroLit),
result);
- return func;
+ // TODO: use unique_ptr properly and do not release ownership.
+ return func.release();
}
template<typename IntType, typename FloatType>
@@ -193,9 +193,8 @@ Function* generateUnaryFunc(Module& wasm, Unary* curr) {
WASM_UNREACHABLE("unexpected op");
}
- auto func = new Function;
- func->name = getUnaryFuncName(curr);
- func->sig = Signature(type, retType);
+ auto func =
+ Builder::makeFunction(getUnaryFuncName(curr), Signature(type, retType), {});
func->body = builder.makeUnary(truncOp, builder.makeLocalGet(0, type));
// too small XXX this is different than asm.js, which does frem. here we
// clamp, which is much simpler/faster, and similar to native builds
@@ -218,7 +217,8 @@ Function* generateUnaryFunc(Module& wasm, Unary* curr) {
// NB: min here as well. anything invalid => to the min
builder.makeConst(iMin),
func->body);
- return func;
+ // TODO: use unique_ptr properly and do not release ownership.
+ return func.release();
}
void ensureBinaryFunc(Binary* curr,
@@ -251,7 +251,7 @@ void ensureF64ToI64JSImport(TrappingFunctionContainer& trappingFunctions) {
import->name = F64_TO_INT;
import->module = ASM2WASM;
import->base = F64_TO_INT;
- import->sig = Signature(Type::f64, Type::i32);
+ import->type = Signature(Type::f64, Type::i32);
trappingFunctions.addImport(import);
}