Example #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}");
 }
Example #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);
            }
Example #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));
            }
        }
Example #4
0
 public virtual VisitorEnterResult Visit(ConstantSyntaxNode node) => DefaultVisitEnter(node);
Example #5
0
 private static (object, FunnyType) ParseConstant(ConstantSyntaxNode constant) =>
Example #6
0
 public virtual bool Visit(ConstantSyntaxNode node) => true;