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