mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 21:08:36 +00:00
fix next_node_index on wrong struct
no more nondeterministic error messages closes #65
This commit is contained in:
parent
1645fa681f
commit
68c4f617ed
@ -890,6 +890,7 @@ struct CodeGen {
|
||||
LLVMValueRef memcpy_fn_val;
|
||||
LLVMValueRef memset_fn_val;
|
||||
bool error_during_imports;
|
||||
uint32_t next_node_index;
|
||||
};
|
||||
|
||||
struct VariableTableEntry {
|
||||
|
||||
@ -2658,7 +2658,8 @@ static ImportTableEntry *codegen_add_code(CodeGen *g, Buf *abs_full_path,
|
||||
import_entry->path = full_path;
|
||||
import_entry->fn_table.init(32);
|
||||
|
||||
import_entry->root = ast_parse(source_code, tokenization.tokens, import_entry, g->err_color);
|
||||
import_entry->root = ast_parse(source_code, tokenization.tokens, import_entry, g->err_color,
|
||||
&g->next_node_index);
|
||||
assert(import_entry->root);
|
||||
if (g->verbose) {
|
||||
ast_print(import_entry->root, 0);
|
||||
|
||||
@ -401,7 +401,7 @@ struct ParseContext {
|
||||
ZigList<AstNode *> *directive_list;
|
||||
ImportTableEntry *owner;
|
||||
ErrColor err_color;
|
||||
uint32_t next_create_index;
|
||||
uint32_t *next_node_index;
|
||||
};
|
||||
|
||||
__attribute__ ((format (printf, 4, 5)))
|
||||
@ -457,8 +457,8 @@ static AstNode *ast_create_node_no_line_info(ParseContext *pc, NodeType type) {
|
||||
AstNode *node = allocate<AstNode>(1);
|
||||
node->type = type;
|
||||
node->owner = pc->owner;
|
||||
node->create_index = pc->next_create_index;
|
||||
pc->next_create_index += 1;
|
||||
node->create_index = *pc->next_node_index;
|
||||
*pc->next_node_index += 1;
|
||||
return node;
|
||||
}
|
||||
|
||||
@ -2724,12 +2724,15 @@ static AstNode *ast_parse_root(ParseContext *pc, int *token_index) {
|
||||
return node;
|
||||
}
|
||||
|
||||
AstNode *ast_parse(Buf *buf, ZigList<Token> *tokens, ImportTableEntry *owner, ErrColor err_color) {
|
||||
AstNode *ast_parse(Buf *buf, ZigList<Token> *tokens, ImportTableEntry *owner,
|
||||
ErrColor err_color, uint32_t *next_node_index)
|
||||
{
|
||||
ParseContext pc = {0};
|
||||
pc.err_color = err_color;
|
||||
pc.owner = owner;
|
||||
pc.buf = buf;
|
||||
pc.tokens = tokens;
|
||||
pc.next_node_index = next_node_index;
|
||||
int token_index = 0;
|
||||
pc.root = ast_parse_root(&pc, &token_index);
|
||||
return pc.root;
|
||||
|
||||
@ -17,7 +17,8 @@ void ast_token_error(Token *token, const char *format, ...);
|
||||
|
||||
|
||||
// This function is provided by generated code, generated by parsergen.cpp
|
||||
AstNode * ast_parse(Buf *buf, ZigList<Token> *tokens, ImportTableEntry *owner, ErrColor err_color);
|
||||
AstNode * ast_parse(Buf *buf, ZigList<Token> *tokens, ImportTableEntry *owner, ErrColor err_color,
|
||||
uint32_t *next_node_index);
|
||||
|
||||
const char *node_type_str(NodeType node_type);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user