public override string GenCode() { BlockNode bl1 = blockAfterIf as BlockNode; BlockNode bl2 = blockAfterElse as BlockNode; if (bl1 is null || bl2 is null) { Console.WriteLine($"line {linenumber} error: syntax error"); errors++; return(null); } if (condition.CheckType() != Parser.Types.BooleanType) { Console.WriteLine($"line {linenumber} error: bad type of condition expresion"); errors++; return(null); } condition.GenCode(); EmitCode($"brfalse {bl2.blockId}"); bl1.GenCode(); EmitCode($"br {bl1.blockId}_2"); bl2.GenCode(); EmitCode($"{bl1.blockId}_2: nop"); return(null); }
public override string GenCode() { if (condition.CheckType() != Parser.Types.BooleanType) { Console.WriteLine($"line {linenumber} error: bad type of condition expresion"); errors++; return(null); } condition.GenCode(); EmitCode($"brfalse {breakJump}"); block.GenCode(); EmitCode($"{continueJump}: nop"); condition.GenCode(); EmitCode($"brtrue {block.blockId}"); EmitCode($"{breakJump}: nop"); return(null); }