Slowly adding multiple return values
This commit is contained in:
18
ast.cpp
18
ast.cpp
@@ -139,7 +139,7 @@ struct Ast_Builtin: Ast_Expr{
|
||||
//
|
||||
|
||||
struct Ast_Return: Ast{
|
||||
Ast_Expr *expr;
|
||||
Array<Ast_Expr *> expr;
|
||||
};
|
||||
|
||||
struct Ast_If_Node: Ast{
|
||||
@@ -164,7 +164,7 @@ struct Ast_For: Ast{
|
||||
|
||||
struct Ast_Lambda : Ast_Expr {
|
||||
Array<Ast_Decl *> args;
|
||||
Ast_Expr *ret;
|
||||
Array<Ast_Expr *> ret;
|
||||
Ast_Scope *scope;
|
||||
};
|
||||
|
||||
@@ -331,14 +331,12 @@ ast_expr_index(Token *pos, Ast_Expr *expr, Ast_Expr *index){
|
||||
}
|
||||
|
||||
function Ast_Lambda *
|
||||
ast_lambda(Token *pos, Array<Ast_Decl *> params, Ast_Expr *ret, Ast_Scope *scope){
|
||||
ast_lambda(Token *pos, Array<Ast_Decl *> params, Array<Ast_Expr *> ret, Ast_Scope *scope){
|
||||
AST_NEW(Lambda, LAMBDA_EXPR, pos, AST_EXPR);
|
||||
result->flags = AST_EXPR;
|
||||
result->args = params.tight_copy(pctx->perm);
|
||||
result->ret = ret.tight_copy(pctx->perm);
|
||||
result->scope = scope;
|
||||
result->ret = ret;
|
||||
if(!ret) result->ret = ast_ident(result->pos, intern_void);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -372,11 +370,11 @@ ast_break(Token *pos){
|
||||
}
|
||||
|
||||
function Ast_Return *
|
||||
ast_return(Token *pos, Ast_Expr *expr){
|
||||
ast_return(Token *pos, Array<Ast_Expr *> expr){
|
||||
AST_NEW(Return, RETURN, pos, AST_STMT);
|
||||
if(expr){
|
||||
assert(is_flag_set(expr->flags, AST_EXPR));
|
||||
result->expr = expr;
|
||||
if(expr.len){
|
||||
For(expr) assert(is_flag_set(it->flags, AST_EXPR));
|
||||
result->expr = expr.tight_copy(pctx->perm);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user