예제 #1
0
 public void VisitBinaryOperation(IBinaryOperationNode node)
 {
     if (BinaryOperationVisitor != null)
     {
         node.AcceptBinaryOperationVisitor(BinaryOperationVisitor);
     }
 }
예제 #2
0
        public void VisitBinaryOperation(IBinaryOperationNode node)
        {
            BinaryOperationCodeGenVisitor binOpVisitor = new BinaryOperationCodeGenVisitor(this, _functionBuilder);

            node.AcceptBinaryOperationVisitor(binOpVisitor);

            _functionBuilder.AddDebugSymbol(binOpVisitor.ComparisonOperationAddress, node);
        }
예제 #3
0
        private void BasicComparison(IBinaryOperationNode node, OpCode opCode)
        {
            node.RHS.AcceptExpressionVisitor(_expressionVisitor);
            node.LHS.AcceptExpressionVisitor(_expressionVisitor);

            ComparisonOperationAddress = _functionBuilder.InstructionCount;
            _functionBuilder.AddInstruction(opCode);
        }
예제 #4
0
        public void VisitBinaryOperation(IBinaryOperationNode node)
        {
            // Don't insert unreachable code
            if (!_builder.InsertBlock.IsValid)
            {
                return;
            }

            node.AcceptBinaryOperationVisitor(new BinaryOperationCodeGenVisitor(this));
        }
예제 #5
0
        public void VisitBinaryOperation(IBinaryOperationNode node)
        {
            VisitPreOrder(node);

            // NOTE: We may want to make this recursion of LHS and RHS optional, in case the outer visitor uses a
            // IBinaryOperationVisitor.
            node.LHS.AcceptExpressionVisitor(this);
            node.RHS.AcceptExpressionVisitor(this);

            VisitPostOrder(node);
        }
예제 #6
0
        public void VisitBinaryOperation(IBinaryOperationNode node)
        {
            IType lhsType = GetExpressionType(node.LHS);
            IType rhsType = GetExpressionType(node.RHS);

            // Both sides must be of same type. (No implicit conversions in MonC)
            if (lhsType != rhsType)
            {
                string message = "Type mismatch between binary operator.\n" +
                                 $"  LHS: {lhsType.Represent()}\n" +
                                 $"  RHS: {rhsType.Represent()}";
                _errors.AddError(message, node);
            }

            // TODO: Ensure operator is valid based on type.

            SetAndCacheType(node, lhsType);
        }
예제 #7
0
        private void GenerateRelationalComparison(IBinaryOperationNode node)
        {
            node.RHS.AcceptExpressionVisitor(_expressionVisitor);
            node.LHS.AcceptExpressionVisitor(_expressionVisitor);
            ComparisonOperationAddress = _functionBuilder.InstructionCount;

            bool isGreaterThan = node is CompareGtBinOpNode || node is CompareGteBinOpNode;
            bool includeEquals = (node is CompareLteBinOpNode || node is CompareGteBinOpNode) ^ isGreaterThan;

            if (includeEquals)
            {
                _functionBuilder.AddInstruction(OpCode.CMPLTE);
            }
            else
            {
                _functionBuilder.AddInstruction(OpCode.CMPLT);
            }

            if (isGreaterThan)
            {
                _functionBuilder.AddInstruction(OpCode.LNOT);
            }
        }
예제 #8
0
 public void VisitBinaryOperation(IBinaryOperationNode node)
 {
     Print($"{node.GetType().Name}");
     VisitSubnode(node.LHS);
     VisitSubnode(node.RHS);
 }
예제 #9
0
 public void VisitBinaryOperation(IBinaryOperationNode node)
 {
     _visitor.Visit(node);
 }
예제 #10
0
 public void VisitUnknown(IBinaryOperationNode node)
 {
     throw new InvalidOperationException("Unexpected binary operation node type. Was replacement of a parse tree node missed?");
 }
예제 #11
0
 public virtual void VisitBinaryOperation(IBinaryOperationNode node)
 {
     VisitDefaultExpression(node);
 }
예제 #12
0
 public virtual void VisitUnknown(IBinaryOperationNode node)
 {
     ThrowForUnknown();
 }
 public void VisitBinaryOperation(IBinaryOperationNode node)
 {
     // TODO: Should this be optional to allow more flexibility with a IBinaryOperationVisitor?
     node.LHS = _processor.ProcessReplacement(node.LHS);
     node.RHS = _processor.ProcessReplacement(node.RHS);
 }
예제 #14
0
 public void VisitUnknown(IBinaryOperationNode node)
 {
     UnknownVisitor?.Visit(node);
 }
예제 #15
0
 public void VisitBinaryOperation(IBinaryOperationNode node)
 {
 }