Пример #1
0
        private AstExpression InferTypeGenericExpr(AstGenericExpr expr, CheezType expected, TypeInferenceContext context)
        {
            foreach (var param in expr.Parameters)
            {
                param.Scope = expr.Scope;
                param.TypeExpr.AttachTo(expr);
                param.TypeExpr = InferTypeHelper(param.TypeExpr, null, context);
                param.Type     = param.TypeExpr.Value as CheezType;
                if (!ValidatePolymorphicParameterType(param.Location, param.Type))
                {
                    return(expr);
                }
            }

            expr.Type  = new GenericType(expr);
            expr.Value = new PolyValue("generic");
            return(expr);
        }
Пример #2
0
 private AstExpression CallGenericExpr(AstGenericExpr expr, List <(int index, CheezType type, object value)> args, ILocation location = null)
Пример #3
0
 public GenericType(AstGenericExpr expr)
 {
     Expression = expr;
 }
Пример #4
0
 public virtual ReturnType VisitGenericExpr(AstGenericExpr expr, DataType data         = default) => default;
Пример #5
0
        public override string VisitGenericExpr(AstGenericExpr expr, int data = 0)
        {
            var args = string.Join(", ", expr.Parameters.Select(p => p.Accept(this)));

            return($"[{args}] {expr.SubExpression.Accept(this)}");
        }