Initial add parent_ast to scopes

This commit is contained in:
Krzosa Karol
2023-04-21 11:38:00 +02:00
parent 29238b6cc5
commit 2578a2a31a
3 changed files with 16 additions and 27 deletions

View File

@@ -937,22 +937,23 @@ parse_decl(B32 is_global) {
// implementing actual parse_lambda or something. Probably needs less
// ambigious syntax.
if (expr->kind == AST_LAMBDA_EXPR) {
auto a = (Ast_Lambda *)expr;
if (a->scope || is_flag_set(flags, AST_FOREIGN)) {
auto lambda = (Ast_Lambda *)expr;
if (lambda->scope || is_flag_set(flags, AST_FOREIGN)) {
result->kind = AST_LAMBDA;
if (is_flag_set(a->flags, AST_POLYMORPH)) {
lambda->scope->parent_decl = result;
if (is_flag_set(lambda->flags, AST_POLYMORPH)) {
set_flag(result->flags, AST_POLYMORPH);
set_flag(result->flags, AST_PARENT_POLYMORPH);
int polymorph_count = 0;
For(a->args) {
For(lambda->args) {
if (it->flags & AST_POLYMORPH) {
polymorph_count += 1;
}
}
result->polymorph_parameters.init(pctx->perm, polymorph_count);
For(a->args) {
For(lambda->args) {
if (it->flags & AST_POLYMORPH) {
result->polymorph_parameters.add(it);
}
@@ -967,8 +968,7 @@ parse_decl(B32 is_global) {
else if (token_match(TK_StringLit, TK_DoubleColon)) {
// @cleanup: consider simplifying lambdas, removing AST_LAMBDA_EXPR and
// implementing actual parse_lambda or something. Probably needs less
// ambigious syntax.
// implementing actual parse_lambda or something.
Ast_Lambda *expr = (Ast_Lambda *)parse_expr();
if (expr->kind != AST_LAMBDA_EXPR) {
compiler_error(tname, "Operator overload is required to be a lambda function");