mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Remove tmp_allocator from Checker
This commit is contained in:
@@ -27,7 +27,9 @@ The Odin programming language is fast, concise, readable, pragmatic and open sou
|
|||||||
Website: [https://odin.handmade.network/](https://odin.handmade.network/)
|
Website: [https://odin.handmade.network/](https://odin.handmade.network/)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
import "core:fmt.odin"
|
package main
|
||||||
|
|
||||||
|
import "core:fmt"
|
||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
program := "+ + * 😃 - /";
|
program := "+ + * 😃 - /";
|
||||||
|
|||||||
@@ -416,7 +416,7 @@ String get_fullpath_core(gbAllocator a, String path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String const ODIN_VERSION = str_lit("0.8.2");
|
String const ODIN_VERSION = str_lit("0.9.0");
|
||||||
String cross_compile_target = str_lit("");
|
String cross_compile_target = str_lit("");
|
||||||
String cross_compile_lib_dir = str_lit("");
|
String cross_compile_lib_dir = str_lit("");
|
||||||
|
|
||||||
|
|||||||
+12
-17
@@ -95,12 +95,10 @@ void check_init_variables(Checker *c, Entity **lhs, isize lhs_count, Array<AstNo
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&c->tmp_arena);
|
|
||||||
defer (gb_temp_arena_memory_end(tmp));
|
|
||||||
|
|
||||||
// NOTE(bill): If there is a bad syntax error, rhs > lhs which would mean there would need to be
|
// NOTE(bill): If there is a bad syntax error, rhs > lhs which would mean there would need to be
|
||||||
// an extra allocation
|
// an extra allocation
|
||||||
auto operands = array_make<Operand>(c->tmp_allocator, 0, 2*lhs_count);
|
auto operands = array_make<Operand>(c->allocator, 0, 2*lhs_count);
|
||||||
|
defer (array_free(&operands));
|
||||||
check_unpack_arguments(c, lhs, lhs_count, &operands, inits, true);
|
check_unpack_arguments(c, lhs, lhs_count, &operands, inits, true);
|
||||||
|
|
||||||
isize rhs_count = operands.count;
|
isize rhs_count = operands.count;
|
||||||
@@ -582,7 +580,7 @@ void check_proc_decl(Checker *c, Entity *e, DeclInfo *d) {
|
|||||||
|
|
||||||
GB_ASSERT(pl->body->kind == AstNode_BlockStmt);
|
GB_ASSERT(pl->body->kind == AstNode_BlockStmt);
|
||||||
if (!pt->is_polymorphic) {
|
if (!pt->is_polymorphic) {
|
||||||
check_procedure_later(c, c->curr_ast_file, e->token, d, proc_type, pl->body, pl->tags);
|
check_procedure_later(c, c->context.file, e->token, d, proc_type, pl->body, pl->tags);
|
||||||
}
|
}
|
||||||
} else if (!is_foreign) {
|
} else if (!is_foreign) {
|
||||||
if (e->Procedure.is_export) {
|
if (e->Procedure.is_export) {
|
||||||
@@ -963,6 +961,7 @@ void check_proc_body(Checker *c, Token token, DeclInfo *decl, Type *type, AstNod
|
|||||||
c->context.decl = decl;
|
c->context.decl = decl;
|
||||||
c->context.proc_name = proc_name;
|
c->context.proc_name = proc_name;
|
||||||
c->context.curr_proc_decl = decl;
|
c->context.curr_proc_decl = decl;
|
||||||
|
c->context.curr_proc_sig = type;
|
||||||
|
|
||||||
GB_ASSERT(type->kind == Type_Proc);
|
GB_ASSERT(type->kind == Type_Proc);
|
||||||
if (type->Proc.param_count > 0) {
|
if (type->Proc.param_count > 0) {
|
||||||
@@ -1006,21 +1005,17 @@ void check_proc_body(Checker *c, Token token, DeclInfo *decl, Type *type, AstNod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
push_procedure(c, type);
|
ast_node(bs, BlockStmt, body);
|
||||||
{
|
check_stmt_list(c, bs->stmts, Stmt_CheckScopeDecls);
|
||||||
ast_node(bs, BlockStmt, body);
|
if (type->Proc.result_count > 0) {
|
||||||
check_stmt_list(c, bs->stmts, Stmt_CheckScopeDecls);
|
if (!check_is_terminating(body)) {
|
||||||
if (type->Proc.result_count > 0) {
|
if (token.kind == Token_Ident) {
|
||||||
if (!check_is_terminating(body)) {
|
error(bs->close, "Missing return statement at the end of the procedure '%.*s'", LIT(token.string));
|
||||||
if (token.kind == Token_Ident) {
|
} else {
|
||||||
error(bs->close, "Missing return statement at the end of the procedure '%.*s'", LIT(token.string));
|
error(bs->close, "Missing return statement at the end of the procedure");
|
||||||
} else {
|
|
||||||
error(bs->close, "Missing return statement at the end of the procedure");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pop_procedure(c);
|
|
||||||
|
|
||||||
check_scope_usage(c, c->context.scope);
|
check_scope_usage(c, c->context.scope);
|
||||||
|
|
||||||
|
|||||||
+15
-25
@@ -664,11 +664,6 @@ void check_assignment(Checker *c, Operand *operand, Type *type, String context_n
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (operand->mode == Addressing_ProcGroup) {
|
if (operand->mode == Addressing_ProcGroup) {
|
||||||
// GB_PANIC("HERE!\n");
|
|
||||||
|
|
||||||
gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&c->tmp_arena);
|
|
||||||
defer (gb_temp_arena_memory_end(tmp));
|
|
||||||
|
|
||||||
Array<Entity *> procs = proc_group_entities(c, *operand);
|
Array<Entity *> procs = proc_group_entities(c, *operand);
|
||||||
bool good = false;
|
bool good = false;
|
||||||
// NOTE(bill): These should be done
|
// NOTE(bill): These should be done
|
||||||
@@ -980,9 +975,6 @@ Entity *check_ident(Checker *c, Operand *o, AstNode *n, Type *named_type, Type *
|
|||||||
bool skip = false;
|
bool skip = false;
|
||||||
|
|
||||||
if (type_hint != nullptr) {
|
if (type_hint != nullptr) {
|
||||||
gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&c->tmp_arena);
|
|
||||||
defer (gb_temp_arena_memory_end(tmp));
|
|
||||||
|
|
||||||
// NOTE(bill): These should be done
|
// NOTE(bill): These should be done
|
||||||
for_array(i, procs) {
|
for_array(i, procs) {
|
||||||
Type *t = base_type(procs[i]->type);
|
Type *t = base_type(procs[i]->type);
|
||||||
@@ -1497,8 +1489,6 @@ void check_comparison(Checker *c, Operand *x, Operand *y, TokenKind op) {
|
|||||||
defer (if (err_str != nullptr) {
|
defer (if (err_str != nullptr) {
|
||||||
gb_string_free(err_str);
|
gb_string_free(err_str);
|
||||||
});
|
});
|
||||||
gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&c->tmp_arena);
|
|
||||||
defer (gb_temp_arena_memory_end(tmp));
|
|
||||||
|
|
||||||
if (check_is_assignable_to(c, x, y->type) ||
|
if (check_is_assignable_to(c, x, y->type) ||
|
||||||
check_is_assignable_to(c, y, x->type)) {
|
check_is_assignable_to(c, y, x->type)) {
|
||||||
@@ -1525,7 +1515,7 @@ void check_comparison(Checker *c, Operand *x, Operand *y, TokenKind op) {
|
|||||||
}
|
}
|
||||||
gbString type_string = type_to_string(err_type);
|
gbString type_string = type_to_string(err_type);
|
||||||
defer (gb_string_free(type_string));
|
defer (gb_string_free(type_string));
|
||||||
err_str = gb_string_make(c->tmp_allocator,
|
err_str = gb_string_make(c->allocator,
|
||||||
gb_bprintf("operator '%.*s' not defined for type '%s'", LIT(token_strings[op]), type_string));
|
gb_bprintf("operator '%.*s' not defined for type '%s'", LIT(token_strings[op]), type_string));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1540,7 +1530,7 @@ void check_comparison(Checker *c, Operand *x, Operand *y, TokenKind op) {
|
|||||||
} else {
|
} else {
|
||||||
yt = type_to_string(y->type);
|
yt = type_to_string(y->type);
|
||||||
}
|
}
|
||||||
err_str = gb_string_make(c->tmp_allocator,
|
err_str = gb_string_make(c->allocator,
|
||||||
gb_bprintf("mismatched types '%s' and '%s'", xt, yt));
|
gb_bprintf("mismatched types '%s' and '%s'", xt, yt));
|
||||||
gb_string_free(yt);
|
gb_string_free(yt);
|
||||||
gb_string_free(xt);
|
gb_string_free(xt);
|
||||||
@@ -2365,10 +2355,9 @@ void convert_to_typed(Checker *c, Operand *operand, Type *target_type) {
|
|||||||
|
|
||||||
case Type_Union:
|
case Type_Union:
|
||||||
if (!is_operand_nil(*operand) && !is_operand_undef(*operand)) {
|
if (!is_operand_nil(*operand) && !is_operand_undef(*operand)) {
|
||||||
gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&c->tmp_arena);
|
|
||||||
defer (gb_temp_arena_memory_end(tmp));
|
|
||||||
isize count = t->Union.variants.count;
|
isize count = t->Union.variants.count;
|
||||||
ValidIndexAndScore *valids = gb_alloc_array(c->tmp_allocator, ValidIndexAndScore, count);
|
ValidIndexAndScore *valids = gb_alloc_array(c->allocator, ValidIndexAndScore, count);
|
||||||
|
defer (gb_free(c->allocator, valids));
|
||||||
isize valid_count = 0;
|
isize valid_count = 0;
|
||||||
isize first_success_index = -1;
|
isize first_success_index = -1;
|
||||||
for_array(i, t->Union.variants) {
|
for_array(i, t->Union.variants) {
|
||||||
@@ -4428,13 +4417,11 @@ CALL_ARGUMENT_CHECKER(check_named_call_arguments) {
|
|||||||
bool show_error = show_error_mode == CallArgumentMode_ShowErrors;
|
bool show_error = show_error_mode == CallArgumentMode_ShowErrors;
|
||||||
CallArgumentError err = CallArgumentError_None;
|
CallArgumentError err = CallArgumentError_None;
|
||||||
|
|
||||||
gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&c->tmp_arena);
|
|
||||||
defer (gb_temp_arena_memory_end(tmp));
|
|
||||||
|
|
||||||
isize param_count = pt->param_count;
|
isize param_count = pt->param_count;
|
||||||
bool *visited = gb_alloc_array(c->tmp_allocator, bool, param_count);
|
bool *visited = gb_alloc_array(c->allocator, bool, param_count);
|
||||||
|
defer (gb_free(c->allocator, visited));
|
||||||
auto ordered_operands = array_make<Operand>(c->tmp_allocator, param_count);
|
auto ordered_operands = array_make<Operand>(c->allocator, param_count);
|
||||||
|
defer (array_free(&ordered_operands));
|
||||||
|
|
||||||
for_array(i, ce->args) {
|
for_array(i, ce->args) {
|
||||||
AstNode *arg = ce->args[i];
|
AstNode *arg = ce->args[i];
|
||||||
@@ -4812,7 +4799,8 @@ CallArgumentError check_polymorphic_struct_type(Checker *c, Operand *operand, As
|
|||||||
if (named_fields) {
|
if (named_fields) {
|
||||||
bool *visited = gb_alloc_array(c->allocator, bool, param_count);
|
bool *visited = gb_alloc_array(c->allocator, bool, param_count);
|
||||||
|
|
||||||
ordered_operands = array_make<Operand>(c->tmp_allocator, param_count);
|
// LEAK(bill)
|
||||||
|
ordered_operands = array_make<Operand>(c->allocator, param_count);
|
||||||
|
|
||||||
for_array(i, ce->args) {
|
for_array(i, ce->args) {
|
||||||
AstNode *arg = ce->args[i];
|
AstNode *arg = ce->args[i];
|
||||||
@@ -5294,7 +5282,9 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: GB_PANIC("Unknown literal"); break;
|
default:
|
||||||
|
GB_PANIC("Unknown literal");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
o->mode = Addressing_Constant;
|
o->mode = Addressing_Constant;
|
||||||
o->type = t;
|
o->type = t;
|
||||||
@@ -5309,7 +5299,7 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
|
|||||||
o->type = t_untyped_integer;
|
o->type = t_untyped_integer;
|
||||||
o->value = exact_value_i64(bd->token.pos.line);
|
o->value = exact_value_i64(bd->token.pos.line);
|
||||||
} else if (bd->name == "procedure") {
|
} else if (bd->name == "procedure") {
|
||||||
if (c->proc_stack.count == 0) {
|
if (c->context.curr_proc_decl == nullptr) {
|
||||||
error(node, "#procedure may only be used within procedures");
|
error(node, "#procedure may only be used within procedures");
|
||||||
o->type = t_untyped_string;
|
o->type = t_untyped_string;
|
||||||
o->value = exact_value_string(str_lit(""));
|
o->value = exact_value_string(str_lit(""));
|
||||||
@@ -5362,7 +5352,7 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
|
|||||||
return kind;
|
return kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
check_procedure_later(c, c->curr_ast_file, empty_token, decl, type, pl->body, pl->tags);
|
check_procedure_later(c, c->context.file, empty_token, decl, type, pl->body, pl->tags);
|
||||||
}
|
}
|
||||||
check_close_scope(c);
|
check_close_scope(c);
|
||||||
|
|
||||||
|
|||||||
+16
-20
@@ -413,7 +413,7 @@ void check_label(Checker *c, AstNode *label) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (c->proc_stack.count == 0) {
|
if (c->context.curr_proc_decl == nullptr) {
|
||||||
error(l->name, "A label is only allowed within a procedure");
|
error(l->name, "A label is only allowed within a procedure");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -569,11 +569,9 @@ void add_constant_switch_case(Checker *c, Map<TypeAndToken> *seen, Operand opera
|
|||||||
HashKey key = hash_exact_value(operand.value);
|
HashKey key = hash_exact_value(operand.value);
|
||||||
TypeAndToken *found = map_get(seen, key);
|
TypeAndToken *found = map_get(seen, key);
|
||||||
if (found != nullptr) {
|
if (found != nullptr) {
|
||||||
gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&c->tmp_arena);
|
|
||||||
defer (gb_temp_arena_memory_end(tmp));
|
|
||||||
|
|
||||||
isize count = multi_map_count(seen, key);
|
isize count = multi_map_count(seen, key);
|
||||||
TypeAndToken *taps = gb_alloc_array(c->tmp_allocator, TypeAndToken, count);
|
TypeAndToken *taps = gb_alloc_array(c->allocator, TypeAndToken, count);
|
||||||
|
defer (gb_free(c->allocator, taps));
|
||||||
|
|
||||||
multi_map_get_all(seen, key, taps);
|
multi_map_get_all(seen, key, taps);
|
||||||
for (isize i = 0; i < count; i++) {
|
for (isize i = 0; i < count; i++) {
|
||||||
@@ -788,10 +786,8 @@ void check_switch_stmt(Checker *c, AstNode *node, u32 mod_flags) {
|
|||||||
GB_ASSERT(is_type_enum(et));
|
GB_ASSERT(is_type_enum(et));
|
||||||
auto fields = et->Enum.fields;
|
auto fields = et->Enum.fields;
|
||||||
|
|
||||||
gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&c->tmp_arena);
|
auto unhandled = array_make<Entity *>(c->allocator, 0, fields.count);
|
||||||
defer (gb_temp_arena_memory_end(tmp));
|
defer (array_free(&unhandled));
|
||||||
|
|
||||||
auto unhandled = array_make<Entity *>(c->tmp_allocator, 0, fields.count);
|
|
||||||
|
|
||||||
for_array(i, fields) {
|
for_array(i, fields) {
|
||||||
Entity *f = fields[i];
|
Entity *f = fields[i];
|
||||||
@@ -1020,10 +1016,8 @@ void check_type_switch_stmt(Checker *c, AstNode *node, u32 mod_flags) {
|
|||||||
GB_ASSERT(is_type_union(ut));
|
GB_ASSERT(is_type_union(ut));
|
||||||
auto variants = ut->Union.variants;
|
auto variants = ut->Union.variants;
|
||||||
|
|
||||||
gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&c->tmp_arena);
|
auto unhandled = array_make<Type *>(c->allocator, 0, variants.count);
|
||||||
defer (gb_temp_arena_memory_end(tmp));
|
defer (array_free(&unhandled));
|
||||||
|
|
||||||
auto unhandled = array_make<Type *>(c->tmp_allocator, 0, variants.count);
|
|
||||||
|
|
||||||
for_array(i, variants) {
|
for_array(i, variants) {
|
||||||
Type *t = variants[i];
|
Type *t = variants[i];
|
||||||
@@ -1114,13 +1108,12 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&c->tmp_arena);
|
|
||||||
defer (gb_temp_arena_memory_end(tmp));
|
|
||||||
|
|
||||||
// NOTE(bill): If there is a bad syntax error, rhs > lhs which would mean there would need to be
|
// NOTE(bill): If there is a bad syntax error, rhs > lhs which would mean there would need to be
|
||||||
// an extra allocation
|
// an extra allocation
|
||||||
auto lhs_operands = array_make<Operand>(c->tmp_allocator, lhs_count);
|
auto lhs_operands = array_make<Operand>(c->allocator, lhs_count);
|
||||||
auto rhs_operands = array_make<Operand>(c->tmp_allocator, 0, 2*lhs_count);
|
auto rhs_operands = array_make<Operand>(c->allocator, 0, 2*lhs_count);
|
||||||
|
defer (array_free(&lhs_operands));
|
||||||
|
defer (array_free(&rhs_operands));
|
||||||
|
|
||||||
for_array(i, as->lhs) {
|
for_array(i, as->lhs) {
|
||||||
if (is_blank_ident(as->lhs[i])) {
|
if (is_blank_ident(as->lhs[i])) {
|
||||||
@@ -1226,14 +1219,17 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
|
|||||||
case_end;
|
case_end;
|
||||||
|
|
||||||
case_ast_node(rs, ReturnStmt, node);
|
case_ast_node(rs, ReturnStmt, node);
|
||||||
GB_ASSERT(c->proc_stack.count > 0);
|
GB_ASSERT(c->context.curr_proc_sig != nullptr);
|
||||||
|
|
||||||
if (c->context.in_defer) {
|
if (c->context.in_defer) {
|
||||||
error(rs->token, "You cannot 'return' within a defer statement");
|
error(rs->token, "You cannot 'return' within a defer statement");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Type *proc_type = c->proc_stack[c->proc_stack.count-1];
|
Type *proc_type = c->context.curr_proc_sig;
|
||||||
|
GB_ASSERT(proc_type != nullptr);
|
||||||
|
GB_ASSERT(proc_type->kind == Type_Proc);
|
||||||
|
// Type *proc_type = c->proc_stack[c->proc_stack.count-1];
|
||||||
TypeProc *pt = &proc_type->Proc;
|
TypeProc *pt = &proc_type->Proc;
|
||||||
isize result_count = 0;
|
isize result_count = 0;
|
||||||
bool has_named_results = pt->has_named_results;
|
bool has_named_results = pt->has_named_results;
|
||||||
|
|||||||
+6
-15
@@ -36,13 +36,11 @@ void populate_using_entity_map(Checker *c, AstNode *node, Type *t, Map<Entity *>
|
|||||||
|
|
||||||
void check_struct_fields(Checker *c, AstNode *node, Array<Entity *> *fields, Array<AstNode *> params,
|
void check_struct_fields(Checker *c, AstNode *node, Array<Entity *> *fields, Array<AstNode *> params,
|
||||||
isize init_field_capacity, Type *named_type, String context) {
|
isize init_field_capacity, Type *named_type, String context) {
|
||||||
gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&c->tmp_arena);
|
|
||||||
defer (gb_temp_arena_memory_end(tmp));
|
|
||||||
|
|
||||||
*fields = array_make<Entity *>(heap_allocator(), 0, init_field_capacity);
|
*fields = array_make<Entity *>(heap_allocator(), 0, init_field_capacity);
|
||||||
|
|
||||||
Map<Entity *> entity_map = {};
|
Map<Entity *> entity_map = {};
|
||||||
map_init(&entity_map, c->tmp_allocator, 2*init_field_capacity);
|
map_init(&entity_map, c->allocator, 2*init_field_capacity);
|
||||||
|
defer (map_destroy(&entity_map));
|
||||||
|
|
||||||
|
|
||||||
GB_ASSERT(node->kind == AstNode_StructType);
|
GB_ASSERT(node->kind == AstNode_StructType);
|
||||||
@@ -444,9 +442,6 @@ void check_union_type(Checker *c, Type *union_type, AstNode *node) {
|
|||||||
|
|
||||||
isize variant_count = ut->variants.count;
|
isize variant_count = ut->variants.count;
|
||||||
|
|
||||||
gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&c->tmp_arena);
|
|
||||||
defer (gb_temp_arena_memory_end(tmp));
|
|
||||||
|
|
||||||
Entity *using_index_expr = nullptr;
|
Entity *using_index_expr = nullptr;
|
||||||
|
|
||||||
auto variants = array_make<Type *>(c->allocator, 0, variant_count);
|
auto variants = array_make<Type *>(c->allocator, 0, variant_count);
|
||||||
@@ -499,9 +494,6 @@ void check_enum_type(Checker *c, Type *enum_type, Type *named_type, AstNode *nod
|
|||||||
ast_node(et, EnumType, node);
|
ast_node(et, EnumType, node);
|
||||||
GB_ASSERT(is_type_enum(enum_type));
|
GB_ASSERT(is_type_enum(enum_type));
|
||||||
|
|
||||||
gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&c->tmp_arena);
|
|
||||||
defer (gb_temp_arena_memory_end(tmp));
|
|
||||||
|
|
||||||
Type *base_type = t_int;
|
Type *base_type = t_int;
|
||||||
if (et->base_type != nullptr) {
|
if (et->base_type != nullptr) {
|
||||||
base_type = check_type(c, et->base_type);
|
base_type = check_type(c, et->base_type);
|
||||||
@@ -521,7 +513,8 @@ void check_enum_type(Checker *c, Type *enum_type, Type *named_type, AstNode *nod
|
|||||||
enum_type->Enum.scope = c->context.scope;
|
enum_type->Enum.scope = c->context.scope;
|
||||||
|
|
||||||
Map<Entity *> entity_map = {}; // Key: String
|
Map<Entity *> entity_map = {}; // Key: String
|
||||||
map_init(&entity_map, c->tmp_allocator, 2*(et->fields.count));
|
map_init(&entity_map, c->allocator, 2*(et->fields.count));
|
||||||
|
defer (map_destroy(&entity_map));
|
||||||
|
|
||||||
auto fields = array_make<Entity *>(c->allocator, 0, et->fields.count);
|
auto fields = array_make<Entity *>(c->allocator, 0, et->fields.count);
|
||||||
|
|
||||||
@@ -649,11 +642,9 @@ void check_bit_field_type(Checker *c, Type *bit_field_type, AstNode *node) {
|
|||||||
ast_node(bft, BitFieldType, node);
|
ast_node(bft, BitFieldType, node);
|
||||||
GB_ASSERT(is_type_bit_field(bit_field_type));
|
GB_ASSERT(is_type_bit_field(bit_field_type));
|
||||||
|
|
||||||
gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&c->tmp_arena);
|
|
||||||
defer (gb_temp_arena_memory_end(tmp));
|
|
||||||
|
|
||||||
Map<Entity *> entity_map = {}; // Key: String
|
Map<Entity *> entity_map = {}; // Key: String
|
||||||
map_init(&entity_map, c->tmp_allocator, 2*(bft->fields.count));
|
map_init(&entity_map, c->allocator, 2*(bft->fields.count));
|
||||||
|
defer (map_destroy(&entity_map));
|
||||||
|
|
||||||
auto fields = array_make<Entity*>(c->allocator, 0, bft->fields.count);
|
auto fields = array_make<Entity*>(c->allocator, 0, bft->fields.count);
|
||||||
auto sizes = array_make<u32> (c->allocator, 0, bft->fields.count);
|
auto sizes = array_make<u32> (c->allocator, 0, bft->fields.count);
|
||||||
|
|||||||
+14
-35
@@ -652,20 +652,16 @@ void init_checker(Checker *c, Parser *parser) {
|
|||||||
init_checker_info(&c->info);
|
init_checker_info(&c->info);
|
||||||
gb_mutex_init(&c->mutex);
|
gb_mutex_init(&c->mutex);
|
||||||
|
|
||||||
array_init(&c->proc_stack, a);
|
array_init(&c->procs_to_check, a);
|
||||||
array_init(&c->procs, a);
|
|
||||||
|
|
||||||
// NOTE(bill): Is this big enough or too small?
|
// NOTE(bill): Is this big enough or too small?
|
||||||
isize item_size = gb_max3(gb_size_of(Entity), gb_size_of(Type), gb_size_of(Scope));
|
isize item_size = gb_max3(gb_size_of(Entity), gb_size_of(Type), gb_size_of(Scope));
|
||||||
isize total_token_count = c->parser->total_token_count;
|
isize total_token_count = c->parser->total_token_count;
|
||||||
isize arena_size = 2 * item_size * total_token_count;
|
isize arena_size = 2 * item_size * total_token_count;
|
||||||
gb_arena_init_from_allocator(&c->tmp_arena, a, arena_size);
|
// gb_arena_init_from_allocator(&c->tmp_arena, a, arena_size);
|
||||||
gb_arena_init_from_allocator(&c->arena, a, arena_size);
|
|
||||||
|
|
||||||
// c->allocator = pool_allocator(&c->pool);
|
|
||||||
c->allocator = heap_allocator();
|
c->allocator = heap_allocator();
|
||||||
// c->allocator = gb_arena_allocator(&c->arena);
|
// c->tmp_allocator = gb_arena_allocator(&c->tmp_arena);
|
||||||
c->tmp_allocator = gb_arena_allocator(&c->tmp_arena);
|
|
||||||
|
|
||||||
isize pkg_cap = 2*c->parser->packages.count;
|
isize pkg_cap = 2*c->parser->packages.count;
|
||||||
|
|
||||||
@@ -674,7 +670,8 @@ void init_checker(Checker *c, Parser *parser) {
|
|||||||
array_init(&c->package_order, heap_allocator(), 0, c->parser->packages.count);
|
array_init(&c->package_order, heap_allocator(), 0, c->parser->packages.count);
|
||||||
|
|
||||||
// Init context
|
// Init context
|
||||||
c->context.scope = universal_scope;
|
c->context.checker = c;
|
||||||
|
c->context.scope = universal_scope;
|
||||||
|
|
||||||
c->context.type_path = new_checker_type_path();
|
c->context.type_path = new_checker_type_path();
|
||||||
c->context.type_level = 0;
|
c->context.type_level = 0;
|
||||||
@@ -684,10 +681,9 @@ void destroy_checker(Checker *c) {
|
|||||||
destroy_checker_info(&c->info);
|
destroy_checker_info(&c->info);
|
||||||
gb_mutex_destroy(&c->mutex);
|
gb_mutex_destroy(&c->mutex);
|
||||||
|
|
||||||
array_free(&c->proc_stack);
|
array_free(&c->procs_to_check);
|
||||||
array_free(&c->procs);
|
|
||||||
|
|
||||||
gb_arena_free(&c->tmp_arena);
|
// gb_arena_free(&c->tmp_arena);
|
||||||
|
|
||||||
map_destroy(&c->package_scopes);
|
map_destroy(&c->package_scopes);
|
||||||
array_free(&c->package_order);
|
array_free(&c->package_order);
|
||||||
@@ -1138,7 +1134,7 @@ void add_type_info_type(Checker *c, Type *t) {
|
|||||||
|
|
||||||
void check_procedure_later(Checker *c, ProcedureInfo info) {
|
void check_procedure_later(Checker *c, ProcedureInfo info) {
|
||||||
GB_ASSERT(info.decl != nullptr);
|
GB_ASSERT(info.decl != nullptr);
|
||||||
array_add(&c->procs, info);
|
array_add(&c->procs_to_check, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_procedure_later(Checker *c, AstFile *file, Token token, DeclInfo *decl, Type *type, AstNode *body, u64 tags) {
|
void check_procedure_later(Checker *c, AstFile *file, Token token, DeclInfo *decl, Type *type, AstNode *body, u64 tags) {
|
||||||
@@ -1152,30 +1148,14 @@ void check_procedure_later(Checker *c, AstFile *file, Token token, DeclInfo *dec
|
|||||||
check_procedure_later(c, info);
|
check_procedure_later(c, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_procedure(Checker *c, Type *type) {
|
|
||||||
array_add(&c->proc_stack, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
void pop_procedure(Checker *c) {
|
|
||||||
array_pop(&c->proc_stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
Type *const curr_procedure_type(Checker *c) {
|
|
||||||
isize count = c->proc_stack.count;
|
|
||||||
if (count > 0) {
|
|
||||||
return c->proc_stack[count-1];
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void add_curr_ast_file(Checker *c, AstFile *file) {
|
void add_curr_ast_file(Checker *c, AstFile *file) {
|
||||||
if (file != nullptr) {
|
if (file != nullptr) {
|
||||||
TokenPos zero_pos = {};
|
TokenPos zero_pos = {};
|
||||||
global_error_collector.prev = zero_pos;
|
global_error_collector.prev = zero_pos;
|
||||||
c->curr_ast_file = file;
|
c->context.file = file;
|
||||||
c->context.decl = file->pkg->decl_info;
|
c->context.decl = file->pkg->decl_info;
|
||||||
c->context.scope = file->scope;
|
c->context.scope = file->scope;
|
||||||
c->context.pkg = file->pkg;
|
c->context.pkg = file->pkg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2980,10 +2960,9 @@ void check_parsed_files(Checker *c) {
|
|||||||
init_preload(c); // NOTE(bill): This could be setup previously through the use of 'type_info_of'
|
init_preload(c); // NOTE(bill): This could be setup previously through the use of 'type_info_of'
|
||||||
|
|
||||||
TIME_SECTION("check procedure bodies");
|
TIME_SECTION("check procedure bodies");
|
||||||
// Check procedure bodies
|
|
||||||
// NOTE(bill): Nested procedures bodies will be added to this "queue"
|
// NOTE(bill): Nested procedures bodies will be added to this "queue"
|
||||||
for_array(i, c->procs) {
|
for_array(i, c->procs_to_check) {
|
||||||
ProcedureInfo *pi = &c->procs[i];
|
ProcedureInfo *pi = &c->procs_to_check[i];
|
||||||
if (pi->type == nullptr) {
|
if (pi->type == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-8
@@ -5,6 +5,7 @@ struct Entity;
|
|||||||
struct Scope;
|
struct Scope;
|
||||||
struct DeclInfo;
|
struct DeclInfo;
|
||||||
struct AstFile;
|
struct AstFile;
|
||||||
|
struct Checker;
|
||||||
|
|
||||||
enum AddressingMode {
|
enum AddressingMode {
|
||||||
Addressing_Invalid, // invalid addressing mode
|
Addressing_Invalid, // invalid addressing mode
|
||||||
@@ -274,13 +275,17 @@ struct ForeignContext {
|
|||||||
typedef Array<Entity *> CheckerTypePath;
|
typedef Array<Entity *> CheckerTypePath;
|
||||||
|
|
||||||
struct CheckerContext {
|
struct CheckerContext {
|
||||||
|
Checker * checker;
|
||||||
AstPackage * pkg;
|
AstPackage * pkg;
|
||||||
|
AstFile * file;
|
||||||
Scope * scope;
|
Scope * scope;
|
||||||
DeclInfo * decl;
|
DeclInfo * decl;
|
||||||
|
|
||||||
u32 stmt_state_flags;
|
u32 stmt_state_flags;
|
||||||
bool in_defer; // TODO(bill): Actually handle correctly
|
bool in_defer; // TODO(bill): Actually handle correctly
|
||||||
String proc_name;
|
|
||||||
Type * type_hint;
|
Type * type_hint;
|
||||||
|
|
||||||
|
String proc_name;
|
||||||
DeclInfo * curr_proc_decl;
|
DeclInfo * curr_proc_decl;
|
||||||
Type * curr_proc_sig;
|
Type * curr_proc_sig;
|
||||||
ForeignContext foreign_context;
|
ForeignContext foreign_context;
|
||||||
@@ -326,20 +331,14 @@ struct Checker {
|
|||||||
gbMutex mutex;
|
gbMutex mutex;
|
||||||
|
|
||||||
|
|
||||||
AstFile * curr_ast_file;
|
Array<ProcedureInfo> procs_to_check;
|
||||||
// NOTE(bill): Procedures to check
|
|
||||||
Array<ProcedureInfo> procs;
|
|
||||||
Map<Scope *> package_scopes; // Key: String (fullpath)
|
Map<Scope *> package_scopes; // Key: String (fullpath)
|
||||||
Array<ImportGraphNode *> package_order;
|
Array<ImportGraphNode *> package_order;
|
||||||
|
|
||||||
gbAllocator allocator;
|
gbAllocator allocator;
|
||||||
gbArena arena;
|
|
||||||
gbArena tmp_arena;
|
|
||||||
gbAllocator tmp_allocator;
|
|
||||||
|
|
||||||
CheckerContext context;
|
CheckerContext context;
|
||||||
|
|
||||||
Array<Type *> proc_stack;
|
|
||||||
bool done_preload;
|
bool done_preload;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+68
-121
@@ -287,160 +287,107 @@ gb_global u64 const unsigned_integer_maxs[] = {
|
|||||||
gb_global String global_module_path = {0};
|
gb_global String global_module_path = {0};
|
||||||
gb_global bool global_module_path_set = false;
|
gb_global bool global_module_path_set = false;
|
||||||
|
|
||||||
gb_global gbScratchMemory scratch_memory = {0};
|
#if 0
|
||||||
|
|
||||||
void init_scratch_memory(isize size) {
|
|
||||||
void *memory = gb_alloc(heap_allocator(), size);
|
|
||||||
gb_scratch_memory_init(&scratch_memory, memory, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
gbAllocator scratch_allocator(void) {
|
|
||||||
return gb_scratch_allocator(&scratch_memory);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Pool {
|
struct Pool {
|
||||||
isize memblock_size;
|
gbAllocator backing;
|
||||||
isize out_of_band_size;
|
u8 *ptr;
|
||||||
isize alignment;
|
u8 *end;
|
||||||
|
Array<u8 *> blocks;
|
||||||
Array<u8 *> unused_memblock;
|
isize block_size;
|
||||||
Array<u8 *> used_memblock;
|
isize alignment;
|
||||||
Array<u8 *> out_of_band_allocations;
|
|
||||||
|
|
||||||
u8 * current_memblock;
|
|
||||||
u8 * current_pos;
|
|
||||||
isize bytes_left;
|
|
||||||
|
|
||||||
gbAllocator block_allocator;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
#define POOL_BLOCK_SIZE (8*1024*1024)
|
||||||
POOL_BUCKET_SIZE_DEFAULT = 65536,
|
#define POOL_ALIGNMENT 16
|
||||||
POOL_OUT_OF_BAND_SIZE_DEFAULT = 6554,
|
|
||||||
};
|
|
||||||
|
|
||||||
void pool_init(Pool *pool,
|
#define ALIGN_DOWN(n, a) ((n) & ~((a) - 1))
|
||||||
isize memblock_size = POOL_BUCKET_SIZE_DEFAULT,
|
#define ALIGN_UP(n, a) ALIGN_DOWN((n) + (a) - 1, (a))
|
||||||
isize out_of_band_size = POOL_OUT_OF_BAND_SIZE_DEFAULT,
|
#define ALIGN_DOWN_PTR(p, a) ((void *)ALIGN_DOWN((uintptr)(p), (a)))
|
||||||
isize alignment = 8,
|
#define ALIGN_UP_PTR(p, a) ((void *)ALIGN_UP((uintptr)(p), (a)))
|
||||||
gbAllocator block_allocator = heap_allocator(),
|
|
||||||
gbAllocator array_allocator = heap_allocator()) {
|
void pool_init(Pool *pool, gbAllocator backing, isize block_size=POOL_BLOCK_SIZE, isize alignment=POOL_ALIGNMENT) {
|
||||||
pool->memblock_size = memblock_size;
|
pool->ptr = nullptr;
|
||||||
pool->out_of_band_size = out_of_band_size;
|
pool->end = nullptr;
|
||||||
|
pool->backing = backing;
|
||||||
|
pool->block_size = block_size;
|
||||||
pool->alignment = alignment;
|
pool->alignment = alignment;
|
||||||
pool->block_allocator = block_allocator;
|
array_init(&pool->blocks, backing);
|
||||||
|
|
||||||
array_init(&pool->unused_memblock, array_allocator);
|
|
||||||
array_init(&pool->used_memblock, array_allocator);
|
|
||||||
array_init(&pool->out_of_band_allocations, array_allocator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void pool_free_all(Pool *p) {
|
void pool_free_all(Pool *pool) {
|
||||||
if (p->current_memblock != nullptr) {
|
for_array(i, pool->blocks) {
|
||||||
array_add(&p->unused_memblock, p->current_memblock);
|
gb_free(pool->backing, pool->blocks[i]);
|
||||||
p->current_memblock = nullptr;
|
|
||||||
}
|
}
|
||||||
|
array_clear(&pool->blocks);
|
||||||
for_array(i, p->used_memblock) {
|
|
||||||
array_add(&p->unused_memblock, p->used_memblock[i]);
|
|
||||||
}
|
|
||||||
array_clear(&p->unused_memblock);
|
|
||||||
|
|
||||||
for_array(i, p->out_of_band_allocations) {
|
|
||||||
gb_free(p->block_allocator, p->out_of_band_allocations[i]);
|
|
||||||
}
|
|
||||||
array_clear(&p->out_of_band_allocations);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void pool_destroy(Pool *p) {
|
void pool_destroy(Pool *pool) {
|
||||||
pool_free_all(p);
|
pool_free_all(pool);
|
||||||
|
array_free(&pool->blocks);
|
||||||
for_array(i, p->unused_memblock) {
|
|
||||||
gb_free(p->block_allocator, p->unused_memblock[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void pool_cycle_new_block(Pool *p) {
|
void pool_grow(Pool *pool, isize min_size) {
|
||||||
GB_ASSERT_MSG(p->block_allocator.proc != nullptr,
|
isize size = ALIGN_UP(gb_max(min_size, pool->block_size), pool->alignment);
|
||||||
"You must call pool_init on a Pool before using it!");
|
pool->ptr = cast(u8 *)gb_alloc(pool->backing, size);
|
||||||
|
GB_ASSERT(pool->ptr == ALIGN_DOWN_PTR(pool->ptr, pool->alignment));
|
||||||
if (p->current_memblock != nullptr) {
|
pool->end = pool->ptr + size;
|
||||||
array_add(&p->used_memblock, p->current_memblock);
|
array_add(&pool->blocks, pool->ptr);
|
||||||
}
|
|
||||||
|
|
||||||
u8 *new_block = nullptr;
|
|
||||||
|
|
||||||
if (p->unused_memblock.count > 0) {
|
|
||||||
new_block = array_pop(&p->unused_memblock);
|
|
||||||
} else {
|
|
||||||
GB_ASSERT(p->block_allocator.proc != nullptr);
|
|
||||||
new_block = cast(u8 *)gb_alloc_align(p->block_allocator, p->memblock_size, p->alignment);
|
|
||||||
}
|
|
||||||
|
|
||||||
p->bytes_left = p->memblock_size;
|
|
||||||
p->current_memblock = new_block;
|
|
||||||
p->current_memblock = new_block;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *pool_get(Pool *p,
|
void *pool_alloc(Pool *pool, isize size, isize align) {
|
||||||
isize size, isize alignment = 0) {
|
if (size > (pool->end - pool->ptr)) {
|
||||||
if (alignment <= 0) alignment = p->alignment;
|
pool_grow(pool, size);
|
||||||
|
GB_ASSERT(size <= (pool->end - pool->ptr));
|
||||||
isize extra = alignment - (size & alignment);
|
|
||||||
size += extra;
|
|
||||||
if (size >= p->out_of_band_size) {
|
|
||||||
GB_ASSERT(p->block_allocator.proc != nullptr);
|
|
||||||
u8 *memory = cast(u8 *)gb_alloc_align(p->block_allocator, p->memblock_size, alignment);
|
|
||||||
if (memory != nullptr) {
|
|
||||||
array_add(&p->out_of_band_allocations, memory);
|
|
||||||
}
|
|
||||||
return memory;
|
|
||||||
}
|
}
|
||||||
|
align = gb_max(align, pool->alignment);
|
||||||
if (p->bytes_left < size) {
|
void *ptr = pool->ptr;
|
||||||
pool_cycle_new_block(p);
|
pool->ptr = cast(u8 *)ALIGN_UP_PTR(pool->ptr + size, align);
|
||||||
if (p->current_memblock != nullptr) {
|
GB_ASSERT(pool->ptr <= pool->end);
|
||||||
return nullptr;
|
GB_ASSERT(ptr == ALIGN_DOWN_PTR(ptr, align));
|
||||||
}
|
return ptr;
|
||||||
}
|
|
||||||
|
|
||||||
u8 *res = p->current_pos;
|
|
||||||
p->current_pos += size;
|
|
||||||
p->bytes_left -= size;
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GB_ALLOCATOR_PROC(pool_allocator_proc) {
|
||||||
|
void *ptr = NULL;
|
||||||
|
Pool *pool = cast(Pool *)allocator_data;
|
||||||
|
|
||||||
gbAllocator pool_allocator(Pool *pool);
|
|
||||||
|
|
||||||
GB_ALLOCATOR_PROC(pool_allocator_procedure) {
|
|
||||||
Pool *p = cast(Pool *)allocator_data;
|
|
||||||
void *ptr = nullptr;
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case gbAllocation_Alloc:
|
case gbAllocation_Alloc:
|
||||||
return pool_get(p, size, alignment);
|
ptr = pool_alloc(pool, size, alignment);
|
||||||
case gbAllocation_Free:
|
|
||||||
// Does nothing
|
|
||||||
break;
|
break;
|
||||||
case gbAllocation_FreeAll:
|
case gbAllocation_FreeAll:
|
||||||
pool_free_all(p);
|
pool_free_all(pool);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case gbAllocation_Free:
|
||||||
case gbAllocation_Resize:
|
case gbAllocation_Resize:
|
||||||
return gb_default_resize_align(pool_allocator(p), old_memory, old_size, size, alignment);
|
GB_PANIC("A pool allocator does not support free or resize");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
gbAllocator pool_allocator(Pool *pool) {
|
gbAllocator pool_allocator(Pool *pool) {
|
||||||
gbAllocator allocator;
|
gbAllocator a;
|
||||||
allocator.proc = pool_allocator_procedure;
|
a.proc = pool_allocator_proc;
|
||||||
allocator.data = pool;
|
a.data = pool;
|
||||||
return allocator;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gb_global Pool global_pool = {};
|
||||||
|
|
||||||
|
gbAllocator perm_allocator(void) {
|
||||||
|
return pool_allocator(&global_pool);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
i32 next_pow2(i32 n) {
|
i32 next_pow2(i32 n) {
|
||||||
if (n <= 0) {
|
if (n <= 0) {
|
||||||
|
|||||||
@@ -708,7 +708,6 @@ int main(int arg_count, char **arg_ptr) {
|
|||||||
defer (timings_destroy(&timings));
|
defer (timings_destroy(&timings));
|
||||||
|
|
||||||
init_string_buffer_memory();
|
init_string_buffer_memory();
|
||||||
init_scratch_memory(gb_megabytes(10));
|
|
||||||
init_global_error_collector();
|
init_global_error_collector();
|
||||||
|
|
||||||
array_init(&library_collections, heap_allocator());
|
array_init(&library_collections, heap_allocator());
|
||||||
|
|||||||
+70
-70
@@ -421,7 +421,7 @@ bool ast_node_expect(AstNode *node, AstNodeKind kind) {
|
|||||||
|
|
||||||
|
|
||||||
// NOTE(bill): And this below is why is I/we need a new language! Discriminated unions are a pain in C/C++
|
// NOTE(bill): And this below is why is I/we need a new language! Discriminated unions are a pain in C/C++
|
||||||
AstNode *make_ast_node(AstFile *f, AstNodeKind kind) {
|
AstNode *alloc_ast_node(AstFile *f, AstNodeKind kind) {
|
||||||
gbArena *arena = &f->arena;
|
gbArena *arena = &f->arena;
|
||||||
if (gb_arena_size_remaining(arena, GB_DEFAULT_MEMORY_ALIGNMENT) <= gb_size_of(AstNode)) {
|
if (gb_arena_size_remaining(arena, GB_DEFAULT_MEMORY_ALIGNMENT) <= gb_size_of(AstNode)) {
|
||||||
// NOTE(bill): If a syntax error is so bad, just quit!
|
// NOTE(bill): If a syntax error is so bad, just quit!
|
||||||
@@ -434,14 +434,14 @@ AstNode *make_ast_node(AstFile *f, AstNodeKind kind) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_bad_expr(AstFile *f, Token begin, Token end) {
|
AstNode *ast_bad_expr(AstFile *f, Token begin, Token end) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_BadExpr);
|
AstNode *result = alloc_ast_node(f, AstNode_BadExpr);
|
||||||
result->BadExpr.begin = begin;
|
result->BadExpr.begin = begin;
|
||||||
result->BadExpr.end = end;
|
result->BadExpr.end = end;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_tag_expr(AstFile *f, Token token, Token name, AstNode *expr) {
|
AstNode *ast_tag_expr(AstFile *f, Token token, Token name, AstNode *expr) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_TagExpr);
|
AstNode *result = alloc_ast_node(f, AstNode_TagExpr);
|
||||||
result->TagExpr.token = token;
|
result->TagExpr.token = token;
|
||||||
result->TagExpr.name = name;
|
result->TagExpr.name = name;
|
||||||
result->TagExpr.expr = expr;
|
result->TagExpr.expr = expr;
|
||||||
@@ -449,7 +449,7 @@ AstNode *ast_tag_expr(AstFile *f, Token token, Token name, AstNode *expr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_run_expr(AstFile *f, Token token, Token name, AstNode *expr) {
|
AstNode *ast_run_expr(AstFile *f, Token token, Token name, AstNode *expr) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_RunExpr);
|
AstNode *result = alloc_ast_node(f, AstNode_RunExpr);
|
||||||
result->RunExpr.token = token;
|
result->RunExpr.token = token;
|
||||||
result->RunExpr.name = name;
|
result->RunExpr.name = name;
|
||||||
result->RunExpr.expr = expr;
|
result->RunExpr.expr = expr;
|
||||||
@@ -458,7 +458,7 @@ AstNode *ast_run_expr(AstFile *f, Token token, Token name, AstNode *expr) {
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_tag_stmt(AstFile *f, Token token, Token name, AstNode *stmt) {
|
AstNode *ast_tag_stmt(AstFile *f, Token token, Token name, AstNode *stmt) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_TagStmt);
|
AstNode *result = alloc_ast_node(f, AstNode_TagStmt);
|
||||||
result->TagStmt.token = token;
|
result->TagStmt.token = token;
|
||||||
result->TagStmt.name = name;
|
result->TagStmt.name = name;
|
||||||
result->TagStmt.stmt = stmt;
|
result->TagStmt.stmt = stmt;
|
||||||
@@ -466,14 +466,14 @@ AstNode *ast_tag_stmt(AstFile *f, Token token, Token name, AstNode *stmt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_unary_expr(AstFile *f, Token op, AstNode *expr) {
|
AstNode *ast_unary_expr(AstFile *f, Token op, AstNode *expr) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_UnaryExpr);
|
AstNode *result = alloc_ast_node(f, AstNode_UnaryExpr);
|
||||||
result->UnaryExpr.op = op;
|
result->UnaryExpr.op = op;
|
||||||
result->UnaryExpr.expr = expr;
|
result->UnaryExpr.expr = expr;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_binary_expr(AstFile *f, Token op, AstNode *left, AstNode *right) {
|
AstNode *ast_binary_expr(AstFile *f, Token op, AstNode *left, AstNode *right) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_BinaryExpr);
|
AstNode *result = alloc_ast_node(f, AstNode_BinaryExpr);
|
||||||
|
|
||||||
if (left == nullptr) {
|
if (left == nullptr) {
|
||||||
syntax_error(op, "No lhs expression for binary expression '%.*s'", LIT(op.string));
|
syntax_error(op, "No lhs expression for binary expression '%.*s'", LIT(op.string));
|
||||||
@@ -492,7 +492,7 @@ AstNode *ast_binary_expr(AstFile *f, Token op, AstNode *left, AstNode *right) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_paren_expr(AstFile *f, AstNode *expr, Token open, Token close) {
|
AstNode *ast_paren_expr(AstFile *f, AstNode *expr, Token open, Token close) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_ParenExpr);
|
AstNode *result = alloc_ast_node(f, AstNode_ParenExpr);
|
||||||
result->ParenExpr.expr = expr;
|
result->ParenExpr.expr = expr;
|
||||||
result->ParenExpr.open = open;
|
result->ParenExpr.open = open;
|
||||||
result->ParenExpr.close = close;
|
result->ParenExpr.close = close;
|
||||||
@@ -500,7 +500,7 @@ AstNode *ast_paren_expr(AstFile *f, AstNode *expr, Token open, Token close) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_call_expr(AstFile *f, AstNode *proc, Array<AstNode *> args, Token open, Token close, Token ellipsis) {
|
AstNode *ast_call_expr(AstFile *f, AstNode *proc, Array<AstNode *> args, Token open, Token close, Token ellipsis) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_CallExpr);
|
AstNode *result = alloc_ast_node(f, AstNode_CallExpr);
|
||||||
result->CallExpr.proc = proc;
|
result->CallExpr.proc = proc;
|
||||||
result->CallExpr.args = args;
|
result->CallExpr.args = args;
|
||||||
result->CallExpr.open = open;
|
result->CallExpr.open = open;
|
||||||
@@ -511,14 +511,14 @@ AstNode *ast_call_expr(AstFile *f, AstNode *proc, Array<AstNode *> args, Token o
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_selector_expr(AstFile *f, Token token, AstNode *expr, AstNode *selector) {
|
AstNode *ast_selector_expr(AstFile *f, Token token, AstNode *expr, AstNode *selector) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_SelectorExpr);
|
AstNode *result = alloc_ast_node(f, AstNode_SelectorExpr);
|
||||||
result->SelectorExpr.expr = expr;
|
result->SelectorExpr.expr = expr;
|
||||||
result->SelectorExpr.selector = selector;
|
result->SelectorExpr.selector = selector;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_index_expr(AstFile *f, AstNode *expr, AstNode *index, Token open, Token close) {
|
AstNode *ast_index_expr(AstFile *f, AstNode *expr, AstNode *index, Token open, Token close) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_IndexExpr);
|
AstNode *result = alloc_ast_node(f, AstNode_IndexExpr);
|
||||||
result->IndexExpr.expr = expr;
|
result->IndexExpr.expr = expr;
|
||||||
result->IndexExpr.index = index;
|
result->IndexExpr.index = index;
|
||||||
result->IndexExpr.open = open;
|
result->IndexExpr.open = open;
|
||||||
@@ -528,7 +528,7 @@ AstNode *ast_index_expr(AstFile *f, AstNode *expr, AstNode *index, Token open, T
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_slice_expr(AstFile *f, AstNode *expr, Token open, Token close, Token interval, AstNode *low, AstNode *high) {
|
AstNode *ast_slice_expr(AstFile *f, AstNode *expr, Token open, Token close, Token interval, AstNode *low, AstNode *high) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_SliceExpr);
|
AstNode *result = alloc_ast_node(f, AstNode_SliceExpr);
|
||||||
result->SliceExpr.expr = expr;
|
result->SliceExpr.expr = expr;
|
||||||
result->SliceExpr.open = open;
|
result->SliceExpr.open = open;
|
||||||
result->SliceExpr.close = close;
|
result->SliceExpr.close = close;
|
||||||
@@ -539,7 +539,7 @@ AstNode *ast_slice_expr(AstFile *f, AstNode *expr, Token open, Token close, Toke
|
|||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_deref_expr(AstFile *f, AstNode *expr, Token op) {
|
AstNode *ast_deref_expr(AstFile *f, AstNode *expr, Token op) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_DerefExpr);
|
AstNode *result = alloc_ast_node(f, AstNode_DerefExpr);
|
||||||
result->DerefExpr.expr = expr;
|
result->DerefExpr.expr = expr;
|
||||||
result->DerefExpr.op = op;
|
result->DerefExpr.op = op;
|
||||||
return result;
|
return result;
|
||||||
@@ -549,38 +549,38 @@ AstNode *ast_deref_expr(AstFile *f, AstNode *expr, Token op) {
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_ident(AstFile *f, Token token) {
|
AstNode *ast_ident(AstFile *f, Token token) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_Ident);
|
AstNode *result = alloc_ast_node(f, AstNode_Ident);
|
||||||
result->Ident.token = token;
|
result->Ident.token = token;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_implicit(AstFile *f, Token token) {
|
AstNode *ast_implicit(AstFile *f, Token token) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_Implicit);
|
AstNode *result = alloc_ast_node(f, AstNode_Implicit);
|
||||||
result->Implicit = token;
|
result->Implicit = token;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
AstNode *ast_undef(AstFile *f, Token token) {
|
AstNode *ast_undef(AstFile *f, Token token) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_Undef);
|
AstNode *result = alloc_ast_node(f, AstNode_Undef);
|
||||||
result->Undef = token;
|
result->Undef = token;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AstNode *ast_basic_lit(AstFile *f, Token basic_lit) {
|
AstNode *ast_basic_lit(AstFile *f, Token basic_lit) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_BasicLit);
|
AstNode *result = alloc_ast_node(f, AstNode_BasicLit);
|
||||||
result->BasicLit.token = basic_lit;
|
result->BasicLit.token = basic_lit;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_basic_directive(AstFile *f, Token token, String name) {
|
AstNode *ast_basic_directive(AstFile *f, Token token, String name) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_BasicDirective);
|
AstNode *result = alloc_ast_node(f, AstNode_BasicDirective);
|
||||||
result->BasicDirective.token = token;
|
result->BasicDirective.token = token;
|
||||||
result->BasicDirective.name = name;
|
result->BasicDirective.name = name;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_ellipsis(AstFile *f, Token token, AstNode *expr) {
|
AstNode *ast_ellipsis(AstFile *f, Token token, AstNode *expr) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_Ellipsis);
|
AstNode *result = alloc_ast_node(f, AstNode_Ellipsis);
|
||||||
result->Ellipsis.token = token;
|
result->Ellipsis.token = token;
|
||||||
result->Ellipsis.expr = expr;
|
result->Ellipsis.expr = expr;
|
||||||
return result;
|
return result;
|
||||||
@@ -588,7 +588,7 @@ AstNode *ast_ellipsis(AstFile *f, Token token, AstNode *expr) {
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_proc_group(AstFile *f, Token token, Token open, Token close, Array<AstNode *> args) {
|
AstNode *ast_proc_group(AstFile *f, Token token, Token open, Token close, Array<AstNode *> args) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_ProcGroup);
|
AstNode *result = alloc_ast_node(f, AstNode_ProcGroup);
|
||||||
result->ProcGroup.token = token;
|
result->ProcGroup.token = token;
|
||||||
result->ProcGroup.open = open;
|
result->ProcGroup.open = open;
|
||||||
result->ProcGroup.close = close;
|
result->ProcGroup.close = close;
|
||||||
@@ -597,7 +597,7 @@ AstNode *ast_proc_group(AstFile *f, Token token, Token open, Token close, Array<
|
|||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_proc_lit(AstFile *f, AstNode *type, AstNode *body, u64 tags) {
|
AstNode *ast_proc_lit(AstFile *f, AstNode *type, AstNode *body, u64 tags) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_ProcLit);
|
AstNode *result = alloc_ast_node(f, AstNode_ProcLit);
|
||||||
result->ProcLit.type = type;
|
result->ProcLit.type = type;
|
||||||
result->ProcLit.body = body;
|
result->ProcLit.body = body;
|
||||||
result->ProcLit.tags = tags;
|
result->ProcLit.tags = tags;
|
||||||
@@ -605,7 +605,7 @@ AstNode *ast_proc_lit(AstFile *f, AstNode *type, AstNode *body, u64 tags) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_field_value(AstFile *f, AstNode *field, AstNode *value, Token eq) {
|
AstNode *ast_field_value(AstFile *f, AstNode *field, AstNode *value, Token eq) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_FieldValue);
|
AstNode *result = alloc_ast_node(f, AstNode_FieldValue);
|
||||||
result->FieldValue.field = field;
|
result->FieldValue.field = field;
|
||||||
result->FieldValue.value = value;
|
result->FieldValue.value = value;
|
||||||
result->FieldValue.eq = eq;
|
result->FieldValue.eq = eq;
|
||||||
@@ -613,7 +613,7 @@ AstNode *ast_field_value(AstFile *f, AstNode *field, AstNode *value, Token eq) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_compound_lit(AstFile *f, AstNode *type, Array<AstNode *> elems, Token open, Token close) {
|
AstNode *ast_compound_lit(AstFile *f, AstNode *type, Array<AstNode *> elems, Token open, Token close) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_CompoundLit);
|
AstNode *result = alloc_ast_node(f, AstNode_CompoundLit);
|
||||||
result->CompoundLit.type = type;
|
result->CompoundLit.type = type;
|
||||||
result->CompoundLit.elems = elems;
|
result->CompoundLit.elems = elems;
|
||||||
result->CompoundLit.open = open;
|
result->CompoundLit.open = open;
|
||||||
@@ -623,28 +623,28 @@ AstNode *ast_compound_lit(AstFile *f, AstNode *type, Array<AstNode *> elems, Tok
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_ternary_expr(AstFile *f, AstNode *cond, AstNode *x, AstNode *y) {
|
AstNode *ast_ternary_expr(AstFile *f, AstNode *cond, AstNode *x, AstNode *y) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_TernaryExpr);
|
AstNode *result = alloc_ast_node(f, AstNode_TernaryExpr);
|
||||||
result->TernaryExpr.cond = cond;
|
result->TernaryExpr.cond = cond;
|
||||||
result->TernaryExpr.x = x;
|
result->TernaryExpr.x = x;
|
||||||
result->TernaryExpr.y = y;
|
result->TernaryExpr.y = y;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
AstNode *ast_type_assertion(AstFile *f, AstNode *expr, Token dot, AstNode *type) {
|
AstNode *ast_type_assertion(AstFile *f, AstNode *expr, Token dot, AstNode *type) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_TypeAssertion);
|
AstNode *result = alloc_ast_node(f, AstNode_TypeAssertion);
|
||||||
result->TypeAssertion.expr = expr;
|
result->TypeAssertion.expr = expr;
|
||||||
result->TypeAssertion.dot = dot;
|
result->TypeAssertion.dot = dot;
|
||||||
result->TypeAssertion.type = type;
|
result->TypeAssertion.type = type;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
AstNode *ast_type_cast(AstFile *f, Token token, AstNode *type, AstNode *expr) {
|
AstNode *ast_type_cast(AstFile *f, Token token, AstNode *type, AstNode *expr) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_TypeCast);
|
AstNode *result = alloc_ast_node(f, AstNode_TypeCast);
|
||||||
result->TypeCast.token = token;
|
result->TypeCast.token = token;
|
||||||
result->TypeCast.type = type;
|
result->TypeCast.type = type;
|
||||||
result->TypeCast.expr = expr;
|
result->TypeCast.expr = expr;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
AstNode *ast_auto_cast(AstFile *f, Token token, AstNode *expr) {
|
AstNode *ast_auto_cast(AstFile *f, Token token, AstNode *expr) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_AutoCast);
|
AstNode *result = alloc_ast_node(f, AstNode_AutoCast);
|
||||||
result->AutoCast.token = token;
|
result->AutoCast.token = token;
|
||||||
result->AutoCast.expr = expr;
|
result->AutoCast.expr = expr;
|
||||||
return result;
|
return result;
|
||||||
@@ -655,26 +655,26 @@ AstNode *ast_auto_cast(AstFile *f, Token token, AstNode *expr) {
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_bad_stmt(AstFile *f, Token begin, Token end) {
|
AstNode *ast_bad_stmt(AstFile *f, Token begin, Token end) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_BadStmt);
|
AstNode *result = alloc_ast_node(f, AstNode_BadStmt);
|
||||||
result->BadStmt.begin = begin;
|
result->BadStmt.begin = begin;
|
||||||
result->BadStmt.end = end;
|
result->BadStmt.end = end;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_empty_stmt(AstFile *f, Token token) {
|
AstNode *ast_empty_stmt(AstFile *f, Token token) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_EmptyStmt);
|
AstNode *result = alloc_ast_node(f, AstNode_EmptyStmt);
|
||||||
result->EmptyStmt.token = token;
|
result->EmptyStmt.token = token;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_expr_stmt(AstFile *f, AstNode *expr) {
|
AstNode *ast_expr_stmt(AstFile *f, AstNode *expr) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_ExprStmt);
|
AstNode *result = alloc_ast_node(f, AstNode_ExprStmt);
|
||||||
result->ExprStmt.expr = expr;
|
result->ExprStmt.expr = expr;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_assign_stmt(AstFile *f, Token op, Array<AstNode *> lhs, Array<AstNode *> rhs) {
|
AstNode *ast_assign_stmt(AstFile *f, Token op, Array<AstNode *> lhs, Array<AstNode *> rhs) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_AssignStmt);
|
AstNode *result = alloc_ast_node(f, AstNode_AssignStmt);
|
||||||
result->AssignStmt.op = op;
|
result->AssignStmt.op = op;
|
||||||
result->AssignStmt.lhs = lhs;
|
result->AssignStmt.lhs = lhs;
|
||||||
result->AssignStmt.rhs = rhs;
|
result->AssignStmt.rhs = rhs;
|
||||||
@@ -683,7 +683,7 @@ AstNode *ast_assign_stmt(AstFile *f, Token op, Array<AstNode *> lhs, Array<AstNo
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_inc_dec_stmt(AstFile *f, Token op, AstNode *expr) {
|
AstNode *ast_inc_dec_stmt(AstFile *f, Token op, AstNode *expr) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_IncDecStmt);
|
AstNode *result = alloc_ast_node(f, AstNode_IncDecStmt);
|
||||||
result->IncDecStmt.op = op;
|
result->IncDecStmt.op = op;
|
||||||
result->IncDecStmt.expr = expr;
|
result->IncDecStmt.expr = expr;
|
||||||
return result;
|
return result;
|
||||||
@@ -692,7 +692,7 @@ AstNode *ast_inc_dec_stmt(AstFile *f, Token op, AstNode *expr) {
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_block_stmt(AstFile *f, Array<AstNode *> stmts, Token open, Token close) {
|
AstNode *ast_block_stmt(AstFile *f, Array<AstNode *> stmts, Token open, Token close) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_BlockStmt);
|
AstNode *result = alloc_ast_node(f, AstNode_BlockStmt);
|
||||||
result->BlockStmt.stmts = stmts;
|
result->BlockStmt.stmts = stmts;
|
||||||
result->BlockStmt.open = open;
|
result->BlockStmt.open = open;
|
||||||
result->BlockStmt.close = close;
|
result->BlockStmt.close = close;
|
||||||
@@ -700,7 +700,7 @@ AstNode *ast_block_stmt(AstFile *f, Array<AstNode *> stmts, Token open, Token cl
|
|||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_if_stmt(AstFile *f, Token token, AstNode *init, AstNode *cond, AstNode *body, AstNode *else_stmt) {
|
AstNode *ast_if_stmt(AstFile *f, Token token, AstNode *init, AstNode *cond, AstNode *body, AstNode *else_stmt) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_IfStmt);
|
AstNode *result = alloc_ast_node(f, AstNode_IfStmt);
|
||||||
result->IfStmt.token = token;
|
result->IfStmt.token = token;
|
||||||
result->IfStmt.init = init;
|
result->IfStmt.init = init;
|
||||||
result->IfStmt.cond = cond;
|
result->IfStmt.cond = cond;
|
||||||
@@ -710,7 +710,7 @@ AstNode *ast_if_stmt(AstFile *f, Token token, AstNode *init, AstNode *cond, AstN
|
|||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_when_stmt(AstFile *f, Token token, AstNode *cond, AstNode *body, AstNode *else_stmt) {
|
AstNode *ast_when_stmt(AstFile *f, Token token, AstNode *cond, AstNode *body, AstNode *else_stmt) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_WhenStmt);
|
AstNode *result = alloc_ast_node(f, AstNode_WhenStmt);
|
||||||
result->WhenStmt.token = token;
|
result->WhenStmt.token = token;
|
||||||
result->WhenStmt.cond = cond;
|
result->WhenStmt.cond = cond;
|
||||||
result->WhenStmt.body = body;
|
result->WhenStmt.body = body;
|
||||||
@@ -720,7 +720,7 @@ AstNode *ast_when_stmt(AstFile *f, Token token, AstNode *cond, AstNode *body, As
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_return_stmt(AstFile *f, Token token, Array<AstNode *> results) {
|
AstNode *ast_return_stmt(AstFile *f, Token token, Array<AstNode *> results) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_ReturnStmt);
|
AstNode *result = alloc_ast_node(f, AstNode_ReturnStmt);
|
||||||
result->ReturnStmt.token = token;
|
result->ReturnStmt.token = token;
|
||||||
result->ReturnStmt.results = results;
|
result->ReturnStmt.results = results;
|
||||||
return result;
|
return result;
|
||||||
@@ -728,7 +728,7 @@ AstNode *ast_return_stmt(AstFile *f, Token token, Array<AstNode *> results) {
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_for_stmt(AstFile *f, Token token, AstNode *init, AstNode *cond, AstNode *post, AstNode *body) {
|
AstNode *ast_for_stmt(AstFile *f, Token token, AstNode *init, AstNode *cond, AstNode *post, AstNode *body) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_ForStmt);
|
AstNode *result = alloc_ast_node(f, AstNode_ForStmt);
|
||||||
result->ForStmt.token = token;
|
result->ForStmt.token = token;
|
||||||
result->ForStmt.init = init;
|
result->ForStmt.init = init;
|
||||||
result->ForStmt.cond = cond;
|
result->ForStmt.cond = cond;
|
||||||
@@ -738,7 +738,7 @@ AstNode *ast_for_stmt(AstFile *f, Token token, AstNode *init, AstNode *cond, Ast
|
|||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_range_stmt(AstFile *f, Token token, AstNode *val0, AstNode *val1, Token in_token, AstNode *expr, AstNode *body) {
|
AstNode *ast_range_stmt(AstFile *f, Token token, AstNode *val0, AstNode *val1, Token in_token, AstNode *expr, AstNode *body) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_RangeStmt);
|
AstNode *result = alloc_ast_node(f, AstNode_RangeStmt);
|
||||||
result->RangeStmt.token = token;
|
result->RangeStmt.token = token;
|
||||||
result->RangeStmt.val0 = val0;
|
result->RangeStmt.val0 = val0;
|
||||||
result->RangeStmt.val1 = val1;
|
result->RangeStmt.val1 = val1;
|
||||||
@@ -749,7 +749,7 @@ AstNode *ast_range_stmt(AstFile *f, Token token, AstNode *val0, AstNode *val1, T
|
|||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_switch_stmt(AstFile *f, Token token, AstNode *init, AstNode *tag, AstNode *body) {
|
AstNode *ast_switch_stmt(AstFile *f, Token token, AstNode *init, AstNode *tag, AstNode *body) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_SwitchStmt);
|
AstNode *result = alloc_ast_node(f, AstNode_SwitchStmt);
|
||||||
result->SwitchStmt.token = token;
|
result->SwitchStmt.token = token;
|
||||||
result->SwitchStmt.init = init;
|
result->SwitchStmt.init = init;
|
||||||
result->SwitchStmt.tag = tag;
|
result->SwitchStmt.tag = tag;
|
||||||
@@ -759,7 +759,7 @@ AstNode *ast_switch_stmt(AstFile *f, Token token, AstNode *init, AstNode *tag, A
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_type_switch_stmt(AstFile *f, Token token, AstNode *tag, AstNode *body) {
|
AstNode *ast_type_switch_stmt(AstFile *f, Token token, AstNode *tag, AstNode *body) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_TypeSwitchStmt);
|
AstNode *result = alloc_ast_node(f, AstNode_TypeSwitchStmt);
|
||||||
result->TypeSwitchStmt.token = token;
|
result->TypeSwitchStmt.token = token;
|
||||||
result->TypeSwitchStmt.tag = tag;
|
result->TypeSwitchStmt.tag = tag;
|
||||||
result->TypeSwitchStmt.body = body;
|
result->TypeSwitchStmt.body = body;
|
||||||
@@ -767,7 +767,7 @@ AstNode *ast_type_switch_stmt(AstFile *f, Token token, AstNode *tag, AstNode *bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_case_clause(AstFile *f, Token token, Array<AstNode *> list, Array<AstNode *> stmts) {
|
AstNode *ast_case_clause(AstFile *f, Token token, Array<AstNode *> list, Array<AstNode *> stmts) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_CaseClause);
|
AstNode *result = alloc_ast_node(f, AstNode_CaseClause);
|
||||||
result->CaseClause.token = token;
|
result->CaseClause.token = token;
|
||||||
result->CaseClause.list = list;
|
result->CaseClause.list = list;
|
||||||
result->CaseClause.stmts = stmts;
|
result->CaseClause.stmts = stmts;
|
||||||
@@ -776,27 +776,27 @@ AstNode *ast_case_clause(AstFile *f, Token token, Array<AstNode *> list, Array<A
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_defer_stmt(AstFile *f, Token token, AstNode *stmt) {
|
AstNode *ast_defer_stmt(AstFile *f, Token token, AstNode *stmt) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_DeferStmt);
|
AstNode *result = alloc_ast_node(f, AstNode_DeferStmt);
|
||||||
result->DeferStmt.token = token;
|
result->DeferStmt.token = token;
|
||||||
result->DeferStmt.stmt = stmt;
|
result->DeferStmt.stmt = stmt;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_branch_stmt(AstFile *f, Token token, AstNode *label) {
|
AstNode *ast_branch_stmt(AstFile *f, Token token, AstNode *label) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_BranchStmt);
|
AstNode *result = alloc_ast_node(f, AstNode_BranchStmt);
|
||||||
result->BranchStmt.token = token;
|
result->BranchStmt.token = token;
|
||||||
result->BranchStmt.label = label;
|
result->BranchStmt.label = label;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_using_stmt(AstFile *f, Token token, Array<AstNode *> list) {
|
AstNode *ast_using_stmt(AstFile *f, Token token, Array<AstNode *> list) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_UsingStmt);
|
AstNode *result = alloc_ast_node(f, AstNode_UsingStmt);
|
||||||
result->UsingStmt.token = token;
|
result->UsingStmt.token = token;
|
||||||
result->UsingStmt.list = list;
|
result->UsingStmt.list = list;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
AstNode *ast_using_in_stmt(AstFile *f, Token using_token, Array<AstNode *> list, Token in_token, AstNode *expr) {
|
AstNode *ast_using_in_stmt(AstFile *f, Token using_token, Array<AstNode *> list, Token in_token, AstNode *expr) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_UsingInStmt);
|
AstNode *result = alloc_ast_node(f, AstNode_UsingInStmt);
|
||||||
result->UsingInStmt.using_token = using_token;
|
result->UsingInStmt.using_token = using_token;
|
||||||
result->UsingInStmt.list = list;
|
result->UsingInStmt.list = list;
|
||||||
result->UsingInStmt.in_token = in_token;
|
result->UsingInStmt.in_token = in_token;
|
||||||
@@ -806,7 +806,7 @@ AstNode *ast_using_in_stmt(AstFile *f, Token using_token, Array<AstNode *> list,
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_push_context(AstFile *f, Token token, AstNode *expr, AstNode *body) {
|
AstNode *ast_push_context(AstFile *f, Token token, AstNode *expr, AstNode *body) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_PushContext);
|
AstNode *result = alloc_ast_node(f, AstNode_PushContext);
|
||||||
result->PushContext.token = token;
|
result->PushContext.token = token;
|
||||||
result->PushContext.expr = expr;
|
result->PushContext.expr = expr;
|
||||||
result->PushContext.body = body;
|
result->PushContext.body = body;
|
||||||
@@ -817,7 +817,7 @@ AstNode *ast_push_context(AstFile *f, Token token, AstNode *expr, AstNode *body)
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_bad_decl(AstFile *f, Token begin, Token end) {
|
AstNode *ast_bad_decl(AstFile *f, Token begin, Token end) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_BadDecl);
|
AstNode *result = alloc_ast_node(f, AstNode_BadDecl);
|
||||||
result->BadDecl.begin = begin;
|
result->BadDecl.begin = begin;
|
||||||
result->BadDecl.end = end;
|
result->BadDecl.end = end;
|
||||||
return result;
|
return result;
|
||||||
@@ -825,7 +825,7 @@ AstNode *ast_bad_decl(AstFile *f, Token begin, Token end) {
|
|||||||
|
|
||||||
AstNode *ast_field(AstFile *f, Array<AstNode *> names, AstNode *type, AstNode *default_value, u32 flags,
|
AstNode *ast_field(AstFile *f, Array<AstNode *> names, AstNode *type, AstNode *default_value, u32 flags,
|
||||||
CommentGroup docs, CommentGroup comment) {
|
CommentGroup docs, CommentGroup comment) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_Field);
|
AstNode *result = alloc_ast_node(f, AstNode_Field);
|
||||||
result->Field.names = names;
|
result->Field.names = names;
|
||||||
result->Field.type = type;
|
result->Field.type = type;
|
||||||
result->Field.default_value = default_value;
|
result->Field.default_value = default_value;
|
||||||
@@ -836,14 +836,14 @@ AstNode *ast_field(AstFile *f, Array<AstNode *> names, AstNode *type, AstNode *d
|
|||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_field_list(AstFile *f, Token token, Array<AstNode *> list) {
|
AstNode *ast_field_list(AstFile *f, Token token, Array<AstNode *> list) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_FieldList);
|
AstNode *result = alloc_ast_node(f, AstNode_FieldList);
|
||||||
result->FieldList.token = token;
|
result->FieldList.token = token;
|
||||||
result->FieldList.list = list;
|
result->FieldList.list = list;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_union_field(AstFile *f, AstNode *name, AstNode *list) {
|
AstNode *ast_union_field(AstFile *f, AstNode *name, AstNode *list) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_UnionField);
|
AstNode *result = alloc_ast_node(f, AstNode_UnionField);
|
||||||
result->UnionField.name = name;
|
result->UnionField.name = name;
|
||||||
result->UnionField.list = list;
|
result->UnionField.list = list;
|
||||||
return result;
|
return result;
|
||||||
@@ -851,28 +851,28 @@ AstNode *ast_union_field(AstFile *f, AstNode *name, AstNode *list) {
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_type_type(AstFile *f, Token token, AstNode *specialization) {
|
AstNode *ast_type_type(AstFile *f, Token token, AstNode *specialization) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_TypeType);
|
AstNode *result = alloc_ast_node(f, AstNode_TypeType);
|
||||||
result->TypeType.token = token;
|
result->TypeType.token = token;
|
||||||
result->TypeType.specialization = specialization;
|
result->TypeType.specialization = specialization;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_helper_type(AstFile *f, Token token, AstNode *type) {
|
AstNode *ast_helper_type(AstFile *f, Token token, AstNode *type) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_HelperType);
|
AstNode *result = alloc_ast_node(f, AstNode_HelperType);
|
||||||
result->HelperType.token = token;
|
result->HelperType.token = token;
|
||||||
result->HelperType.type = type;
|
result->HelperType.type = type;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_distinct_type(AstFile *f, Token token, AstNode *type) {
|
AstNode *ast_distinct_type(AstFile *f, Token token, AstNode *type) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_DistinctType);
|
AstNode *result = alloc_ast_node(f, AstNode_DistinctType);
|
||||||
result->DistinctType.token = token;
|
result->DistinctType.token = token;
|
||||||
result->DistinctType.type = type;
|
result->DistinctType.type = type;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_poly_type(AstFile *f, Token token, AstNode *type, AstNode *specialization) {
|
AstNode *ast_poly_type(AstFile *f, Token token, AstNode *type, AstNode *specialization) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_PolyType);
|
AstNode *result = alloc_ast_node(f, AstNode_PolyType);
|
||||||
result->PolyType.token = token;
|
result->PolyType.token = token;
|
||||||
result->PolyType.type = type;
|
result->PolyType.type = type;
|
||||||
result->PolyType.specialization = specialization;
|
result->PolyType.specialization = specialization;
|
||||||
@@ -881,7 +881,7 @@ AstNode *ast_poly_type(AstFile *f, Token token, AstNode *type, AstNode *speciali
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_proc_type(AstFile *f, Token token, AstNode *params, AstNode *results, u64 tags, ProcCallingConvention calling_convention, bool generic) {
|
AstNode *ast_proc_type(AstFile *f, Token token, AstNode *params, AstNode *results, u64 tags, ProcCallingConvention calling_convention, bool generic) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_ProcType);
|
AstNode *result = alloc_ast_node(f, AstNode_ProcType);
|
||||||
result->ProcType.token = token;
|
result->ProcType.token = token;
|
||||||
result->ProcType.params = params;
|
result->ProcType.params = params;
|
||||||
result->ProcType.results = results;
|
result->ProcType.results = results;
|
||||||
@@ -893,14 +893,14 @@ AstNode *ast_proc_type(AstFile *f, Token token, AstNode *params, AstNode *result
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_pointer_type(AstFile *f, Token token, AstNode *type) {
|
AstNode *ast_pointer_type(AstFile *f, Token token, AstNode *type) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_PointerType);
|
AstNode *result = alloc_ast_node(f, AstNode_PointerType);
|
||||||
result->PointerType.token = token;
|
result->PointerType.token = token;
|
||||||
result->PointerType.type = type;
|
result->PointerType.type = type;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_array_type(AstFile *f, Token token, AstNode *count, AstNode *elem) {
|
AstNode *ast_array_type(AstFile *f, Token token, AstNode *count, AstNode *elem) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_ArrayType);
|
AstNode *result = alloc_ast_node(f, AstNode_ArrayType);
|
||||||
result->ArrayType.token = token;
|
result->ArrayType.token = token;
|
||||||
result->ArrayType.count = count;
|
result->ArrayType.count = count;
|
||||||
result->ArrayType.elem = elem;
|
result->ArrayType.elem = elem;
|
||||||
@@ -908,7 +908,7 @@ AstNode *ast_array_type(AstFile *f, Token token, AstNode *count, AstNode *elem)
|
|||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_dynamic_array_type(AstFile *f, Token token, AstNode *elem) {
|
AstNode *ast_dynamic_array_type(AstFile *f, Token token, AstNode *elem) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_DynamicArrayType);
|
AstNode *result = alloc_ast_node(f, AstNode_DynamicArrayType);
|
||||||
result->DynamicArrayType.token = token;
|
result->DynamicArrayType.token = token;
|
||||||
result->DynamicArrayType.elem = elem;
|
result->DynamicArrayType.elem = elem;
|
||||||
return result;
|
return result;
|
||||||
@@ -917,7 +917,7 @@ AstNode *ast_dynamic_array_type(AstFile *f, Token token, AstNode *elem) {
|
|||||||
AstNode *ast_struct_type(AstFile *f, Token token, Array<AstNode *> fields, isize field_count,
|
AstNode *ast_struct_type(AstFile *f, Token token, Array<AstNode *> fields, isize field_count,
|
||||||
AstNode *polymorphic_params, bool is_packed, bool is_raw_union,
|
AstNode *polymorphic_params, bool is_packed, bool is_raw_union,
|
||||||
AstNode *align) {
|
AstNode *align) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_StructType);
|
AstNode *result = alloc_ast_node(f, AstNode_StructType);
|
||||||
result->StructType.token = token;
|
result->StructType.token = token;
|
||||||
result->StructType.fields = fields;
|
result->StructType.fields = fields;
|
||||||
result->StructType.field_count = field_count;
|
result->StructType.field_count = field_count;
|
||||||
@@ -930,7 +930,7 @@ AstNode *ast_struct_type(AstFile *f, Token token, Array<AstNode *> fields, isize
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_union_type(AstFile *f, Token token, Array<AstNode *> variants, AstNode *align) {
|
AstNode *ast_union_type(AstFile *f, Token token, Array<AstNode *> variants, AstNode *align) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_UnionType);
|
AstNode *result = alloc_ast_node(f, AstNode_UnionType);
|
||||||
result->UnionType.token = token;
|
result->UnionType.token = token;
|
||||||
result->UnionType.variants = variants;
|
result->UnionType.variants = variants;
|
||||||
result->UnionType.align = align;
|
result->UnionType.align = align;
|
||||||
@@ -939,7 +939,7 @@ AstNode *ast_union_type(AstFile *f, Token token, Array<AstNode *> variants, AstN
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_enum_type(AstFile *f, Token token, AstNode *base_type, bool is_export, Array<AstNode *> fields) {
|
AstNode *ast_enum_type(AstFile *f, Token token, AstNode *base_type, bool is_export, Array<AstNode *> fields) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_EnumType);
|
AstNode *result = alloc_ast_node(f, AstNode_EnumType);
|
||||||
result->EnumType.token = token;
|
result->EnumType.token = token;
|
||||||
result->EnumType.base_type = base_type;
|
result->EnumType.base_type = base_type;
|
||||||
result->EnumType.is_export = is_export;
|
result->EnumType.is_export = is_export;
|
||||||
@@ -948,7 +948,7 @@ AstNode *ast_enum_type(AstFile *f, Token token, AstNode *base_type, bool is_expo
|
|||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_bit_field_type(AstFile *f, Token token, Array<AstNode *> fields, AstNode *align) {
|
AstNode *ast_bit_field_type(AstFile *f, Token token, Array<AstNode *> fields, AstNode *align) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_BitFieldType);
|
AstNode *result = alloc_ast_node(f, AstNode_BitFieldType);
|
||||||
result->BitFieldType.token = token;
|
result->BitFieldType.token = token;
|
||||||
result->BitFieldType.fields = fields;
|
result->BitFieldType.fields = fields;
|
||||||
result->BitFieldType.align = align;
|
result->BitFieldType.align = align;
|
||||||
@@ -956,7 +956,7 @@ AstNode *ast_bit_field_type(AstFile *f, Token token, Array<AstNode *> fields, As
|
|||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_map_type(AstFile *f, Token token, AstNode *key, AstNode *value) {
|
AstNode *ast_map_type(AstFile *f, Token token, AstNode *key, AstNode *value) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_MapType);
|
AstNode *result = alloc_ast_node(f, AstNode_MapType);
|
||||||
result->MapType.token = token;
|
result->MapType.token = token;
|
||||||
result->MapType.key = key;
|
result->MapType.key = key;
|
||||||
result->MapType.value = value;
|
result->MapType.value = value;
|
||||||
@@ -966,7 +966,7 @@ AstNode *ast_map_type(AstFile *f, Token token, AstNode *key, AstNode *value) {
|
|||||||
|
|
||||||
AstNode *ast_foreign_block_decl(AstFile *f, Token token, AstNode *foreign_library, Token open, Token close, Array<AstNode *> decls,
|
AstNode *ast_foreign_block_decl(AstFile *f, Token token, AstNode *foreign_library, Token open, Token close, Array<AstNode *> decls,
|
||||||
CommentGroup docs) {
|
CommentGroup docs) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_ForeignBlockDecl);
|
AstNode *result = alloc_ast_node(f, AstNode_ForeignBlockDecl);
|
||||||
result->ForeignBlockDecl.token = token;
|
result->ForeignBlockDecl.token = token;
|
||||||
result->ForeignBlockDecl.foreign_library = foreign_library;
|
result->ForeignBlockDecl.foreign_library = foreign_library;
|
||||||
result->ForeignBlockDecl.open = open;
|
result->ForeignBlockDecl.open = open;
|
||||||
@@ -979,7 +979,7 @@ AstNode *ast_foreign_block_decl(AstFile *f, Token token, AstNode *foreign_librar
|
|||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_label_decl(AstFile *f, Token token, AstNode *name) {
|
AstNode *ast_label_decl(AstFile *f, Token token, AstNode *name) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_Label);
|
AstNode *result = alloc_ast_node(f, AstNode_Label);
|
||||||
result->Label.token = token;
|
result->Label.token = token;
|
||||||
result->Label.name = name;
|
result->Label.name = name;
|
||||||
return result;
|
return result;
|
||||||
@@ -987,7 +987,7 @@ AstNode *ast_label_decl(AstFile *f, Token token, AstNode *name) {
|
|||||||
|
|
||||||
AstNode *ast_value_decl(AstFile *f, Array<AstNode *> names, AstNode *type, Array<AstNode *> values, bool is_mutable,
|
AstNode *ast_value_decl(AstFile *f, Array<AstNode *> names, AstNode *type, Array<AstNode *> values, bool is_mutable,
|
||||||
CommentGroup docs, CommentGroup comment) {
|
CommentGroup docs, CommentGroup comment) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_ValueDecl);
|
AstNode *result = alloc_ast_node(f, AstNode_ValueDecl);
|
||||||
result->ValueDecl.names = names;
|
result->ValueDecl.names = names;
|
||||||
result->ValueDecl.type = type;
|
result->ValueDecl.type = type;
|
||||||
result->ValueDecl.values = values;
|
result->ValueDecl.values = values;
|
||||||
@@ -1000,7 +1000,7 @@ AstNode *ast_value_decl(AstFile *f, Array<AstNode *> names, AstNode *type, Array
|
|||||||
}
|
}
|
||||||
|
|
||||||
AstNode *ast_package_decl(AstFile *f, Token token, Token name, CommentGroup docs, CommentGroup comment) {
|
AstNode *ast_package_decl(AstFile *f, Token token, Token name, CommentGroup docs, CommentGroup comment) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_PackageDecl);
|
AstNode *result = alloc_ast_node(f, AstNode_PackageDecl);
|
||||||
result->PackageDecl.token = token;
|
result->PackageDecl.token = token;
|
||||||
result->PackageDecl.name = name;
|
result->PackageDecl.name = name;
|
||||||
result->PackageDecl.docs = docs;
|
result->PackageDecl.docs = docs;
|
||||||
@@ -1010,7 +1010,7 @@ AstNode *ast_package_decl(AstFile *f, Token token, Token name, CommentGroup docs
|
|||||||
|
|
||||||
AstNode *ast_import_decl(AstFile *f, Token token, bool is_using, Token relpath, Token import_name,
|
AstNode *ast_import_decl(AstFile *f, Token token, bool is_using, Token relpath, Token import_name,
|
||||||
CommentGroup docs, CommentGroup comment) {
|
CommentGroup docs, CommentGroup comment) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_ImportDecl);
|
AstNode *result = alloc_ast_node(f, AstNode_ImportDecl);
|
||||||
result->ImportDecl.token = token;
|
result->ImportDecl.token = token;
|
||||||
result->ImportDecl.is_using = is_using;
|
result->ImportDecl.is_using = is_using;
|
||||||
result->ImportDecl.relpath = relpath;
|
result->ImportDecl.relpath = relpath;
|
||||||
@@ -1022,7 +1022,7 @@ AstNode *ast_import_decl(AstFile *f, Token token, bool is_using, Token relpath,
|
|||||||
|
|
||||||
AstNode *ast_foreign_import_decl(AstFile *f, Token token, Token filepath, Token library_name,
|
AstNode *ast_foreign_import_decl(AstFile *f, Token token, Token filepath, Token library_name,
|
||||||
CommentGroup docs, CommentGroup comment) {
|
CommentGroup docs, CommentGroup comment) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_ForeignImportDecl);
|
AstNode *result = alloc_ast_node(f, AstNode_ForeignImportDecl);
|
||||||
result->ForeignImportDecl.token = token;
|
result->ForeignImportDecl.token = token;
|
||||||
result->ForeignImportDecl.filepath = filepath;
|
result->ForeignImportDecl.filepath = filepath;
|
||||||
result->ForeignImportDecl.library_name = library_name;
|
result->ForeignImportDecl.library_name = library_name;
|
||||||
@@ -1033,7 +1033,7 @@ AstNode *ast_foreign_import_decl(AstFile *f, Token token, Token filepath, Token
|
|||||||
|
|
||||||
|
|
||||||
AstNode *ast_attribute(AstFile *f, Token token, Token open, Token close, Array<AstNode *> elems) {
|
AstNode *ast_attribute(AstFile *f, Token token, Token open, Token close, Array<AstNode *> elems) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_Attribute);
|
AstNode *result = alloc_ast_node(f, AstNode_Attribute);
|
||||||
result->Attribute.token = token;
|
result->Attribute.token = token;
|
||||||
result->Attribute.open = open;
|
result->Attribute.open = open;
|
||||||
result->Attribute.elems = elems;
|
result->Attribute.elems = elems;
|
||||||
|
|||||||
Reference in New Issue
Block a user