| author | |
| committer | |
| log | 7411a88d5f8109ced238cf14205ae36575f02f21 |
| tree | c61dd9c7a046e113509dc96c8a1bd42d57ce21dc |
| parent | 33371ab55c01d896b91df13eafe6e5c601400a07 |
| signature |
5 files changed, 33 insertions(+), 30 deletions(-)
BRANCH_TODO+2-2| ... | @@ -1,7 +1,7 @@ | ... | @@ -1,7 +1,7 @@ |
| 1 | Scratch pad for stuff to do before merging master | 1 | Scratch pad for stuff to do before merging master |
| 2 | ================================================= | 2 | ================================================= |
| 3 | 3 | ||
| 4 | uncomment all the behavior tests | ||
| 5 | |||
| 4 | look at all the ir_gen_node ir_gen_node_extra calls and make sure result locations are properly propagated | 6 | look at all the ir_gen_node ir_gen_node_extra calls and make sure result locations are properly propagated |
| 5 | return ir_gen_comptime(irb, scope, node, lval); | 7 | return ir_gen_comptime(irb, scope, node, lval); |
| 6 | |||
| 7 | comptime expressions |
src/analyze.cpp+28| ... | @@ -7293,3 +7293,31 @@ void src_assert(bool ok, AstNode *source_node) { | ... | @@ -7293,3 +7293,31 @@ void src_assert(bool ok, AstNode *source_node) { |
| 7293 | const char *msg = "assertion failed. This is a bug in the Zig compiler."; | 7293 | const char *msg = "assertion failed. This is a bug in the Zig compiler."; |
| 7294 | stage2_panic(msg, strlen(msg)); | 7294 | stage2_panic(msg, strlen(msg)); |
| 7295 | } | 7295 | } |
| 7296 | |||
| 7297 | bool scope_is_elided(Scope *scope) { | ||
| 7298 | for (;;) { | ||
| 7299 | switch (scope->id) { | ||
| 7300 | case ScopeIdElide: | ||
| 7301 | if (reinterpret_cast<ScopeElide *>(scope)->activated) | ||
| 7302 | return true; | ||
| 7303 | // fallthrough | ||
| 7304 | case ScopeIdBlock: | ||
| 7305 | case ScopeIdDefer: | ||
| 7306 | case ScopeIdDeferExpr: | ||
| 7307 | case ScopeIdVarDecl: | ||
| 7308 | case ScopeIdLoop: | ||
| 7309 | case ScopeIdSuspend: | ||
| 7310 | case ScopeIdCoroPrelude: | ||
| 7311 | case ScopeIdRuntime: | ||
| 7312 | scope = scope->parent; | ||
| 7313 | continue; | ||
| 7314 | case ScopeIdFnDef: | ||
| 7315 | case ScopeIdCompTime: | ||
| 7316 | case ScopeIdDecls: | ||
| 7317 | case ScopeIdCImport: | ||
| 7318 | return false; | ||
| 7319 | } | ||
| 7320 | zig_unreachable(); | ||
| 7321 | } | ||
| 7322 | } | ||
| 7323 |
src/analyze.hpp+1| ... | @@ -253,5 +253,6 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa | ... | @@ -253,5 +253,6 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa |
| 253 | void src_assert(bool ok, AstNode *source_node); | 253 | void src_assert(bool ok, AstNode *source_node); |
| 254 | bool is_container(ZigType *type_entry); | 254 | bool is_container(ZigType *type_entry); |
| 255 | ConstExprValue *analyze_const_value(CodeGen *g, Scope *scope, AstNode *node, ZigType *type_entry, Buf *type_name); | 255 | ConstExprValue *analyze_const_value(CodeGen *g, Scope *scope, AstNode *node, ZigType *type_entry, Buf *type_name); |
| 256 | bool scope_is_elided(Scope *scope); | ||
| 256 | 257 | ||
| 257 | #endif | 258 | #endif |
src/codegen.cpp-28| ... | @@ -5709,34 +5709,6 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable, | ... | @@ -5709,34 +5709,6 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable, |
| 5709 | zig_unreachable(); | 5709 | zig_unreachable(); |
| 5710 | } | 5710 | } |
| 5711 | 5711 | ||
| 5712 | static bool scope_is_elided(Scope *scope) { | ||
| 5713 | for (;;) { | ||
| 5714 | switch (scope->id) { | ||
| 5715 | case ScopeIdDecls: | ||
| 5716 | case ScopeIdCompTime: | ||
| 5717 | case ScopeIdCImport: | ||
| 5718 | zig_unreachable(); | ||
| 5719 | case ScopeIdElide: | ||
| 5720 | if (reinterpret_cast<ScopeElide *>(scope)->activated) | ||
| 5721 | return true; | ||
| 5722 | // fallthrough | ||
| 5723 | case ScopeIdBlock: | ||
| 5724 | case ScopeIdDefer: | ||
| 5725 | case ScopeIdDeferExpr: | ||
| 5726 | case ScopeIdVarDecl: | ||
| 5727 | case ScopeIdLoop: | ||
| 5728 | case ScopeIdSuspend: | ||
| 5729 | case ScopeIdCoroPrelude: | ||
| 5730 | case ScopeIdRuntime: | ||
| 5731 | scope = scope->parent; | ||
| 5732 | continue; | ||
| 5733 | case ScopeIdFnDef: | ||
| 5734 | return false; | ||
| 5735 | } | ||
| 5736 | zig_unreachable(); | ||
| 5737 | } | ||
| 5738 | } | ||
| 5739 | |||
| 5740 | static void ir_render(CodeGen *g, ZigFn *fn_entry) { | 5712 | static void ir_render(CodeGen *g, ZigFn *fn_entry) { |
| 5741 | assert(fn_entry); | 5713 | assert(fn_entry); |
| 5742 | 5714 |
src/ir.cpp+2| ... | @@ -8503,6 +8503,8 @@ static ConstExprValue *ir_exec_const_result(CodeGen *codegen, IrExecutable *exec | ... | @@ -8503,6 +8503,8 @@ static ConstExprValue *ir_exec_const_result(CodeGen *codegen, IrExecutable *exec |
| 8503 | IrBasicBlock *bb = exec->basic_block_list.at(0); | 8503 | IrBasicBlock *bb = exec->basic_block_list.at(0); |
| 8504 | for (size_t i = 0; i < bb->instruction_list.length; i += 1) { | 8504 | for (size_t i = 0; i < bb->instruction_list.length; i += 1) { |
| 8505 | IrInstruction *instruction = bb->instruction_list.at(i); | 8505 | IrInstruction *instruction = bb->instruction_list.at(i); |
| 8506 | if (scope_is_elided(instruction->scope)) | ||
| 8507 | continue; | ||
| 8506 | if (instruction->id == IrInstructionIdReturn) { | 8508 | if (instruction->id == IrInstructionIdReturn) { |
| 8507 | IrInstructionReturn *ret_inst = (IrInstructionReturn *)instruction; | 8509 | IrInstructionReturn *ret_inst = (IrInstructionReturn *)instruction; |
| 8508 | IrInstruction *value = ret_inst->value; | 8510 | IrInstruction *value = ret_inst->value; |