Esempio n. 1
0
        public override void EnterIntegerLiteralValue(DaedalusParser.IntegerLiteralValueContext context)
        {
            if (!_assemblyBuilder.IsInsideConstDef)
            {
                bool isInsideFloatAssignment = _assemblyBuilder.IsInsideAssignment &&
                                               _assemblyBuilder.AssignmentType == DatSymbolType.Float;
                bool isInsideFloatArgument = _assemblyBuilder.IsInsideArgList &&
                                             _assemblyBuilder.FuncCallCtx.GetParameterType() == DatSymbolType.Float;

                if (isInsideFloatAssignment || isInsideFloatArgument)
                {
                    int parsedFloat = EvaluatorHelper.EvaluateFloatExpression(context.Parent.Parent.GetText());
                    _assemblyBuilder.AddInstruction(new PushInt(parsedFloat));
                }
                else
                {
                    _assemblyBuilder.AddInstruction(new PushInt(int.Parse(context.GetText())));
                }
            }
        }
Esempio n. 2
0
        public override ASTNode VisitIntegerLiteralValue([NotNull] DaedalusParser.IntegerLiteralValueContext context)
        {
            bool evaluatedCorrectly = long.TryParse(context.GetText(), out long value);

            return(new IntegerLiteralNode(GetLocation(context), value, evaluatedCorrectly));
        }