示例#1
0
 public string Visit(ConstantSyntaxNode node)
 {
     if (node.OutputType.Equals(FunnyType.Text))
     {
         var str = node.Value.ToString();
         return($"'{(str.Length > 20 ? (str.Substring(17) + "...") : str)}'");
     }
     return($"{node.Value}");
 }
示例#2
0
        public bool Visit(ConstantSyntaxNode node)
        {
#if DEBUG
            Trace(node, $"Constant {node.Value}:{node.ClrTypeName}");
#endif
            var type = LangTiHelper.ConvertToTiType(node.OutputType);

            if (type is StatePrimitive p)
            {
                _ticTypeGraph.SetConst(node.OrderNumber, p);
            }
            else if (type is StateArray a && a.Element is StatePrimitive primitiveElement)
            {
                _ticTypeGraph.SetArrayConst(node.OrderNumber, primitiveElement);
            }
示例#3
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));
            }
        }
示例#4
0
 public virtual VisitorEnterResult Visit(ConstantSyntaxNode node) => DefaultVisitEnter(node);
示例#5
0
 private static (object, FunnyType) ParseConstant(ConstantSyntaxNode constant) =>
示例#6
0
 public virtual bool Visit(ConstantSyntaxNode node) => true;