From 50fedc8f44259f2e08add4dceebb5e12c6232e90 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 24 Feb 2024 14:29:40 -0500 Subject: Fixing up structs --- compile.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'compile.c') diff --git a/compile.c b/compile.c index 1e001c89..c0333846 100644 --- a/compile.c +++ b/compile.c @@ -457,9 +457,9 @@ CORD compile(env_t *env, ast_t *ast) CORD code = "{\n"; env = fresh_scope(env); for (ast_list_t *stmt = stmts; stmt; stmt = stmt->next) { + bind_statement(env, stmt->ast); code = CORD_cat(code, compile_statement(env, stmt->ast)); code = CORD_cat(code, "\n"); - bind_statement(env, stmt->ast); } return CORD_cat(code, "}"); } @@ -546,7 +546,7 @@ CORD compile(env_t *env, ast_t *ast) CORD name = compile(env, fndef->name); CORD_appendf(&env->code->staticdefs, "static %r %r_(", fndef->ret_type ? compile_type_ast(fndef->ret_type) : "void", name); for (arg_ast_t *arg = fndef->args; arg; arg = arg->next) { - type_t *arg_type = arg->type ? parse_type_ast(env, arg->type) : get_type(env, arg->value); + type_t *arg_type = get_arg_ast_type(env, arg); CORD_appendf(&env->code->staticdefs, "%r %s", compile_type(arg_type), arg->name); if (arg->next) env->code->staticdefs = CORD_cat(env->code->staticdefs, ", "); } @@ -558,7 +558,7 @@ CORD compile(env_t *env, ast_t *ast) env_t *body_scope = fresh_scope(env); body_scope->locals->fallback = env->globals; for (arg_ast_t *arg = fndef->args; arg; arg = arg->next) { - type_t *arg_type = arg->type ? parse_type_ast(env, arg->type) : get_type(env, arg->value); + type_t *arg_type = get_arg_ast_type(env, arg); CORD arg_typecode = compile_type(arg_type); CORD_appendf(&env->code->funcs, "%r %s", arg_typecode, arg->name); if (arg->next) env->code->funcs = CORD_cat(env->code->funcs, ", "); @@ -994,10 +994,10 @@ module_code_t compile_file(ast_t *ast) CORD_appendf(&env->code->imports, "#include \"nextlang.h\"\n"); for (ast_list_t *stmt = Match(ast, Block)->statements; stmt; stmt = stmt->next) { + bind_statement(env, stmt->ast); CORD code = compile_statement(env, stmt->ast); if (code) CORD_appendf(&env->code->main, "%r\n", code); - bind_statement(env, stmt->ast); } return (module_code_t){ -- cgit v1.2.3