Skip to content

Commit

Permalink
bootstrap: Remove addr_of dedup, hotfix for #15
Browse files Browse the repository at this point in the history
  • Loading branch information
48cf committed Sep 1, 2023
1 parent 2a21857 commit bca6b84
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
3 changes: 2 additions & 1 deletion bootstrap/ir.zig
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,8 @@ fn deduplicateDecls(alloc: std.mem.Allocator, fn_blocks: *BlockList) !bool {
var current_decl = blocks.get(block).first_decl;
while(decls.getOpt(current_decl)) |decl| : (current_decl = decl.next) {
switch(decl.instr) {
.stack_ref, .global_ref, .addr_of,
// FIXME: Workaround for https://github.com/FlorenceOS/newton/issues/15
.stack_ref, .global_ref,

.add, .sub, .multiply, .divide, .modulus,
.shift_left, .shift_right, .bit_and, .bit_or, .bit_xor,
Expand Down
8 changes: 3 additions & 5 deletions selfhost/parser.n
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,6 @@ fn parse_block_statement(context: *ParserContext) u32 {
fn parse_function_expression(context: *ParserContext) u32 {
context.expect("Expected '(' before parameter list".&, .opening_paren);
var stmt_builder = builder.Builder{};
// Workaround for https://github.com/FlorenceOS/newton/issues/15
const stmt_builder_hack = stmt_builder.&;
loop(context.peek() != .closing_paren) {
if(context.peek() == .comptime_keyword) {
context.advance();
Expand All @@ -259,7 +257,7 @@ fn parse_function_expression(context: *ParserContext) u32 {
}
const decl = add_stmt_with_token(ident, .function_parameter_decl);
stmt_payload[0].get(decl).* = parse_expression(context);
stmt_builder_hack.add(decl, stmt_next_sibling.ptr());
stmt_builder.add(decl, stmt_next_sibling.ptr());
if(context.peek() == .comma) {
context.advance();
} else {
Expand All @@ -278,9 +276,9 @@ fn parse_function_expression(context: *ParserContext) u32 {
_ = parse_expression_with_precedence(context, 0);
const result = add_expr_with_token(end_paren_tok, .function_expression);
if(context.peek() == .opening_curly) {
stmt_builder_hack.append_list(parse_block_statement(context), stmt_next_sibling.ptr());
stmt_builder.append_list(parse_block_statement(context), stmt_next_sibling.ptr());
}
expr_payload.get(result).* = stmt_builder_hack.head;
expr_payload.get(result).* = stmt_builder.head;
return result;
}

Expand Down
4 changes: 1 addition & 3 deletions selfhost/tokenizer.n
Original file line number Diff line number Diff line change
Expand Up @@ -404,14 +404,12 @@ fn tokenize_file(file: u32) void {
.offset = 0,
.file_data = source_files.source_files.get(file).file_data,
};
// Workaround for https://github.com/FlorenceOS/newton/issues/15
const context_hack = context.&;

loop {
if(context.peek(0) == 0) {
context.add_token(.end_of_file);
return;
}
tokenize_one_token(context_hack);
tokenize_one_token(context.&);
}
}

0 comments on commit bca6b84

Please sign in to comment.