protected override void VisitIntegerLiteral(IntegerLiteralNode node)
 {
     if (!node.EvaluatedCorrectly || node.Value < Int32.MinValue || node.Value > Int32.MaxValue)
     {
         node.Annotations.Add(new IntegerLiteralTooLargeError());
     }
 }
Beispiel #2
0
        protected override NodeValue VisitIntegerLiteral(IntegerLiteralNode node)
        {
            long    value          = node.Value;
            ASTNode annotateToNode = node;

            if (node.ParentNode is UnaryExpressionNode unaryExpressionNode)
            {
                switch (unaryExpressionNode.Operator)
                {
                case UnaryOperator.Minus:
                    value          = -value;
                    annotateToNode = node.ParentNode;
                    break;

                case UnaryOperator.Plus:
                    annotateToNode = node.ParentNode;
                    break;
                }
            }

            if (!node.EvaluatedCorrectly || value < Int32.MinValue || value > Int32.MaxValue)
            {
                annotateToNode.Annotations.Add(new IntegerLiteralTooLargeError());//+
                return(new UndefinedValue());
            }

            return(new IntValue(node.Value));
        }
Beispiel #3
0
        public override ASTNode VisitArrayIndex([NotNull] DaedalusParser.ArrayIndexContext context)
        {
            ExpressionNode expressionNode;

            if (context.reference() != null)
            {
                expressionNode = (ExpressionNode)VisitReference(context.reference());
            }
            else
            {
                expressionNode = new IntegerLiteralNode(GetLocation(context), long.Parse(context.GetText()));
            }

            return(new ArrayIndexNode(expressionNode, GetLocation(context)));
        }
Beispiel #4
0
        protected override void VisitIntegerLiteral(IntegerLiteralNode node)
        {
            if (IsInsideFloatExpression())
            {
                node.DoCastToFloat = true;

                if (node.ParentNode is UnaryExpressionNode unaryExpressionNode)
                {
                    switch (unaryExpressionNode.Operator)
                    {
                    case UnaryOperator.Minus:
                        node.Value = -node.Value;
                        break;
                    }
                }
            }
            node.BuiltinType = SymbolType.Int;
        }
Beispiel #5
0
 protected virtual T VisitIntegerLiteral(IntegerLiteralNode node)
 {
     return(DefaultResult);
 }
 protected virtual void VisitIntegerLiteral(IntegerLiteralNode node)
 {
 }