Remove compiler ctx allocator
This commit is contained in:
31
Parsing.jai
31
Parsing.jai
@@ -370,19 +370,17 @@ advance_to_sync_point :: (parse_state : *Parse_State) {
|
||||
////////////////////////////
|
||||
//@nb - Base parsing functions
|
||||
|
||||
make_node :: (nodes : *[..]AST_Node, kind : AST_Kind, allocator : Allocator) -> *AST_Node {
|
||||
make_node :: (nodes : *[..]AST_Node, kind : AST_Kind) -> *AST_Node {
|
||||
node : AST_Node;
|
||||
|
||||
node.kind = kind;
|
||||
node.children.allocator = allocator;
|
||||
node.hint_tokens.allocator = allocator;
|
||||
array_add(nodes, node);
|
||||
|
||||
return *(nodes.*[nodes.count - 1]);
|
||||
}
|
||||
|
||||
make_node :: (parse_state : *Parse_State, kind : AST_Kind) -> *AST_Node {
|
||||
return make_node(*parse_state.ctx.nodes, kind, parse_state.ctx.allocator);
|
||||
return make_node(*parse_state.ctx.nodes, kind);
|
||||
}
|
||||
|
||||
// new_builtin_node :: (nodes : *[..]AST_Node, kind : AST_Kind) -> *AST_Node {
|
||||
@@ -426,13 +424,13 @@ make_builtin_token :: (tokens : *[..]Token, builder : *String_Builder, kind : To
|
||||
return *(tokens.*)[tokens.count - 1];
|
||||
}
|
||||
|
||||
new_builtin_struct_node :: (ctx : *Compiler_Context, name : string, members : []Arg, allocator : Allocator) -> *AST_Node {
|
||||
sc := get_scratch(allocator);
|
||||
new_builtin_struct_node :: (ctx : *Compiler_Context, name : string, members : []Arg) -> *AST_Node {
|
||||
sc := get_scratch(context.allocator);
|
||||
defer scratch_end(sc);
|
||||
builder : String_Builder;
|
||||
builder.allocator = sc.allocator; // I want to find a good way to use scratch here...
|
||||
|
||||
node := make_node(*ctx.nodes, .Struct, allocator);
|
||||
node := make_node(*ctx.nodes, .Struct);
|
||||
|
||||
source_location : Source_Range;
|
||||
|
||||
@@ -455,11 +453,11 @@ new_builtin_struct_node :: (ctx : *Compiler_Context, name : string, members : []
|
||||
line += 1;
|
||||
col = 0;
|
||||
|
||||
field_list := make_node(*ctx.nodes, .FieldList, allocator);
|
||||
field_list := make_node(*ctx.nodes, .FieldList);
|
||||
add_child(node, field_list);
|
||||
|
||||
for member : members {
|
||||
field := make_node(*ctx.nodes, .Field, allocator);
|
||||
field := make_node(*ctx.nodes, .Field);
|
||||
field_source_loc : Source_Range;
|
||||
|
||||
indent(*builder, 1);
|
||||
@@ -488,7 +486,7 @@ new_builtin_struct_node :: (ctx : *Compiler_Context, name : string, members : []
|
||||
|
||||
source_location.end = brace_token;
|
||||
|
||||
source := builder_to_string(*builder,, allocator);
|
||||
source := builder_to_string(*builder);
|
||||
|
||||
source_location.begin.source = *source.data[source_location.begin.column];
|
||||
source_location.end.source = *source.data[source_location.end.column];
|
||||
@@ -509,13 +507,13 @@ new_builtin_struct_node :: (ctx : *Compiler_Context, name : string, members : []
|
||||
return node;
|
||||
}
|
||||
|
||||
new_builtin_function_node :: (ctx : *Compiler_Context, name : string, members : []Arg, return_var : Arg, allocator : Allocator) -> *AST_Node {
|
||||
sc := get_scratch(allocator);
|
||||
new_builtin_function_node :: (ctx : *Compiler_Context, name : string, members : []Arg, return_var : Arg) -> *AST_Node {
|
||||
sc := get_scratch(context.allocator);
|
||||
defer scratch_end(sc);
|
||||
builder : String_Builder;
|
||||
builder.allocator = sc.allocator; // I want to find a good way to use scratch here...
|
||||
|
||||
node := make_node(*ctx.nodes, .Function, allocator);
|
||||
node := make_node(*ctx.nodes, .Function);
|
||||
|
||||
source_location : Source_Range;
|
||||
|
||||
@@ -531,11 +529,11 @@ new_builtin_function_node :: (ctx : *Compiler_Context, name : string, members :
|
||||
make_builtin_token(*ctx.tokens, *builder, .TOKEN_DOUBLECOLON, "::", *col, *line);
|
||||
append(*builder, " ");
|
||||
make_builtin_token(*ctx.tokens, *builder, .TOKEN_LEFTPAREN, "(", *col, *line);
|
||||
field_list := make_node(*ctx.nodes, .FieldList, allocator);
|
||||
field_list := make_node(*ctx.nodes, .FieldList);
|
||||
add_child(node, field_list);
|
||||
|
||||
for member : members {
|
||||
field := make_node(*ctx.nodes, .Field, allocator);
|
||||
field := make_node(*ctx.nodes, .Field);
|
||||
field_source_loc : Source_Range;
|
||||
|
||||
// field_ident := make_builtin_token(*ctx.tokens, *builder, .TOKEN_IDENTIFIER, tprint("%", member.name), *col, *line);
|
||||
@@ -559,7 +557,7 @@ new_builtin_function_node :: (ctx : *Compiler_Context, name : string, members :
|
||||
|
||||
source_location.end = semicolon_tok;
|
||||
|
||||
source := builder_to_string(*builder,, allocator);
|
||||
source := builder_to_string(*builder);
|
||||
|
||||
source_location.begin.source = *source.data[source_location.begin.column];
|
||||
source_location.end.source = *source.data[source_location.end.column];
|
||||
@@ -1591,7 +1589,6 @@ parse :: (ctx : *Compiler_Context, allocator := temp) {
|
||||
defer clear_context_allocators();
|
||||
|
||||
parse_state : Parse_State;
|
||||
ctx.nodes.allocator = ctx.allocator;
|
||||
array_reserve(*ctx.nodes, 4096);
|
||||
parse_state.current_token_index = 0;
|
||||
parse_state.ctx = ctx;
|
||||
|
||||
Reference in New Issue
Block a user