コード例 #1
0
        public override VisitorEnterResult Visit(GenericIntSyntaxNode node)
        {
            var type = _solving.GetSyntaxNodeTypeOrNull(node.OrderNumber);

            if (type == null)
            {
                node.OutputType = FunnyType.Empty;
            }
            else
            {
                node.OutputType = _tiToLangTypeConverter.Convert(type);
            }

            return(VisitorEnterResult.Continue);
        }
コード例 #2
0
        public IExpressionNode Visit(GenericIntSyntaxNode node)
        {
            var type = _typesConverter.Convert(_typeInferenceResults.GetSyntaxNodeTypeOrNull(node.OrderNumber));

            if (node.Value is long l)
            {
                return(ConstantExpressionNode.CreateConcrete(type, l, node.Interval));
            }
            else if (node.Value is ulong u)
            {
                return(ConstantExpressionNode.CreateConcrete(type, u, node.Interval));
            }
            else if (node.Value is double d)
            {
                return(new ConstantExpressionNode(node.Value, type, node.Interval));
            }
            else
            {
                throw new ImpossibleException($"Generic syntax node has wrong value type: {node.Value.GetType().Name}");
            }
        }
コード例 #3
0
        private static (object, FunnyType) ParseGenericIntConstant(GenericIntSyntaxNode constant)
        {
            if (constant.IsHexOrBin)
            {
                //0xff, 0xFFFF or 0b1110101010
                if (constant.Value is long l)
                {
                    if (l <= int.MaxValue)
                    {
                        return((int)l, FunnyType.Int32);
                    }
                    else
                    {
                        return(l, FunnyType.Int64);
                    }
                }
                else if (constant.Value is ulong u)
                {
                    return(u, FunnyType.UInt64);
                }
                else
                {
                    throw new NotSupportedException();
                }
            }
            else
            {
                //1,2,3..
                if (constant.Value is long l)
                {
                    return((double)l, FunnyType.Real);
                }
                if (constant.Value is ulong u)
                {
                    return((double)u, FunnyType.Real);
                }

                throw new NotSupportedException();
            }
        }
コード例 #4
0
ファイル: EnterVisitorBase.cs プロジェクト: tmteam/NFun
 public virtual VisitorEnterResult Visit(GenericIntSyntaxNode node) => DefaultVisitEnter(node);
コード例 #5
0
 public string Visit(GenericIntSyntaxNode node) => node.Value.ToString();
コード例 #6
0
ファイル: ExitVisitorBase.cs プロジェクト: tmteam/NFun
 public virtual bool Visit(GenericIntSyntaxNode node) => true;