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); }
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}"); } }
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(); } }
public virtual VisitorEnterResult Visit(GenericIntSyntaxNode node) => DefaultVisitEnter(node);
public string Visit(GenericIntSyntaxNode node) => node.Value.ToString();
public virtual bool Visit(GenericIntSyntaxNode node) => true;