public override void DoVisit(AST_BinaryOpExp node) { Console.Write("(BOP " + node.type); VisitChildren(node); Console.Write(")"); }
public override void DoVisit(AST_BinaryOpExp ast) { switch (ast.type) { case EnumBinaryOp.AND: { Visit(ast.children[0]); var jump_op = Emit(Opcodes.JumpPeekZ, new int[] { 0 /*patched later*/ }); Visit(ast.children[1]); Emit(Opcodes.And, null, ast.line_num); AddOffsetFromTo(jump_op, Peek()); } break; case EnumBinaryOp.OR: { Visit(ast.children[0]); var jump_op = Emit(Opcodes.JumpPeekNZ, new int[] { 0 /*patched later*/ }); Visit(ast.children[1]); Emit(Opcodes.Or, null, ast.line_num); AddOffsetFromTo(jump_op, Peek()); } break; case EnumBinaryOp.BIT_AND: VisitChildren(ast); Emit(Opcodes.BitAnd, null, ast.line_num); break; case EnumBinaryOp.BIT_OR: VisitChildren(ast); Emit(Opcodes.BitOr, null, ast.line_num); break; case EnumBinaryOp.MOD: VisitChildren(ast); Emit(Opcodes.Mod, null, ast.line_num); break; case EnumBinaryOp.ADD: { VisitChildren(ast); Emit(Opcodes.Add, null, ast.line_num); } break; case EnumBinaryOp.SUB: VisitChildren(ast); Emit(Opcodes.Sub, null, ast.line_num); break; case EnumBinaryOp.DIV: VisitChildren(ast); Emit(Opcodes.Div, null, ast.line_num); break; case EnumBinaryOp.MUL: VisitChildren(ast); Emit(Opcodes.Mul, null, ast.line_num); break; case EnumBinaryOp.EQ: VisitChildren(ast); Emit(Opcodes.Equal, null, ast.line_num); break; case EnumBinaryOp.NQ: VisitChildren(ast); Emit(Opcodes.NotEqual, null, ast.line_num); break; case EnumBinaryOp.LT: VisitChildren(ast); Emit(Opcodes.LT, null, ast.line_num); break; case EnumBinaryOp.LTE: VisitChildren(ast); Emit(Opcodes.LTE, null, ast.line_num); break; case EnumBinaryOp.GT: VisitChildren(ast); Emit(Opcodes.GT, null, ast.line_num); break; case EnumBinaryOp.GTE: VisitChildren(ast); Emit(Opcodes.GTE, null, ast.line_num); break; default: throw new Exception("Not supported binary type: " + ast.type); } }
public abstract void DoVisit(AST_BinaryOpExp ast);