Пример #1
0
        public IExpressionNode Visit(ConstantSyntaxNode node)
        {
            var type = _typesConverter.Convert(_typeInferenceResults.GetSyntaxNodeTypeOrNull(node.OrderNumber));

            //All integer values are encoded by ulong (if it is ulong) or long otherwise
            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 //other types have their own clr-types
            {
                return(new ConstantExpressionNode(node.Value, type, node.Interval));
            }
        }
Пример #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}");
            }
        }