Browse Source

* simplified if-then-else code generation, since we now support void 'if' instructions

git-svn-id: branches/wasm@48029 -
nickysn 4 years ago
parent
commit
0fae32d2b7
1 changed files with 1 additions and 16 deletions
  1. 1 16
      compiler/wasm32/nwasmflw.pas

+ 1 - 16
compiler/wasm32/nwasmflw.pas

@@ -152,34 +152,19 @@ begin
 
   secondpass(left); // condition exprssions
 
-  current_asmdata.CurrAsmList.concat(taicpu.op_functype(a_if,TWasmFuncType.Create([],[wbt_i32])));
+  current_asmdata.CurrAsmList.concat(taicpu.op_none(a_if));
   thlcgwasm(hlcg).incblock;
 
   secondpass(right); // then branchs
 
   if Assigned(t1) then // else branch
     begin
-      // 0 const on stack if used to return IF value
-      current_asmdata.CurrAsmList.concat(taicpu.op_const(a_i32_const, 1));
       current_asmdata.CurrAsmList.concat(taicpu.op_none(a_else));
       secondpass(t1);
-    end
-  else // else dummy-branch
-    begin
-      // dummy else branch! todo: to be removed, when it's decided
-      // how to handle typeless-IF instructions (If without else)
-      current_asmdata.CurrAsmList.concat(taicpu.op_const(a_i32_const, 0));
-      current_asmdata.CurrAsmList.concat(taicpu.op_none(a_else));
-      current_asmdata.CurrAsmList.concat(taicpu.op_none(a_nop));
     end;
 
-  // 0 const on stack if used to return IF value
-  current_asmdata.CurrAsmList.concat(taicpu.op_const(a_i32_const, 0));
   current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_if));
   thlcgwasm(hlcg).decblock;
-
-  // clearing IF return value
-  current_asmdata.CurrAsmList.concat(taicpu.op_none(a_drop));
 end;
 
 initialization