예제 #1
0
파일: ast.cs 프로젝트: bitdotgames/bhl
 public override void DoVisit(AST_BinaryOpExp node)
 {
     Console.Write("(BOP " + node.type);
     VisitChildren(node);
     Console.Write(")");
 }
예제 #2
0
        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);
            }
        }
예제 #3
0
파일: ast.cs 프로젝트: bitdotgames/bhl
 public abstract void DoVisit(AST_BinaryOpExp ast);