@@ -921,11 +921,13 @@ Ref Wasm2JSBuilder::processFunction(Module* m,
921921 IString name = fromName (func->getLocalNameOrGeneric (i), NameScope::Local);
922922 ValueBuilder::appendArgumentToFunction (ret, name);
923923 if (needCoercions) {
924- ret[3 ]->push_back (ValueBuilder::makeStatement (ValueBuilder::makeBinary (
925- ValueBuilder::makeName (name),
926- SET,
927- makeJsCoercion (ValueBuilder::makeName (name),
928- wasmToJsType (func->getLocalType (i))))));
924+ auto jsType = wasmToJsType (func->getLocalType (i));
925+ if (needsJsCoercion (jsType)) {
926+ ret[3 ]->push_back (ValueBuilder::makeStatement (ValueBuilder::makeBinary (
927+ ValueBuilder::makeName (name),
928+ SET,
929+ makeJsCoercion (ValueBuilder::makeName (name), jsType))));
930+ }
929931 }
930932 }
931933 Ref theVar = ValueBuilder::makeVar ();
@@ -2219,21 +2221,19 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m,
22192221 visit (curr->value , EXPRESSION_RESULT),
22202222 visit (curr->size , EXPRESSION_RESULT));
22212223 }
2222- Ref visitRefNull (RefNull* curr) {
2223- unimplemented (curr);
2224- WASM_UNREACHABLE (" unimp" );
2225- }
2224+ Ref visitRefNull (RefNull* curr) { return ValueBuilder::makeName (" null" ); }
22262225 Ref visitRefIsNull (RefIsNull* curr) {
2227- unimplemented (curr);
2228- WASM_UNREACHABLE (" unimp" );
2226+ return ValueBuilder::makeBinary (visit (curr->value , EXPRESSION_RESULT),
2227+ EQ,
2228+ ValueBuilder::makeName (" null" ));
22292229 }
22302230 Ref visitRefFunc (RefFunc* curr) {
2231- unimplemented (curr);
2232- WASM_UNREACHABLE (" unimp" );
2231+ return ValueBuilder::makeName (fromName (curr->func , NameScope::Top));
22332232 }
22342233 Ref visitRefEq (RefEq* curr) {
2235- unimplemented (curr);
2236- WASM_UNREACHABLE (" unimp" );
2234+ return ValueBuilder::makeBinary (visit (curr->left , EXPRESSION_RESULT),
2235+ EQ,
2236+ visit (curr->right , EXPRESSION_RESULT));
22372237 }
22382238 Ref visitTableGet (TableGet* curr) {
22392239 unimplemented (curr);
0 commit comments