コード例 #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
ファイル: AbstractTypes.cs プロジェクト: CheezLang/CheezLang
 public GenericType(AstGenericExpr expr)
 {
     Expression = expr;
 }
コード例 #4
0
 public virtual ReturnType VisitGenericExpr(AstGenericExpr expr, DataType data         = default) => default;
コード例 #5
0
ファイル: RawAstPrinter.cs プロジェクト: CheezLang/CheezLang
        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)}");
        }