From f01db8bbc28f3133dd24c01a5ab26bc2f034c8b7 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sun, 2 Feb 2020 08:10:03 -0800 Subject: 5979 Continuing to think about how to translate vars in a block when they're followed by early exits. To clean up everything between a statement and a target label, we need to know somehow the depth the target is defined at. --- apps/mu.subx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/mu.subx b/apps/mu.subx index e34ce6ac..8732e9d9 100644 --- a/apps/mu.subx +++ b/apps/mu.subx @@ -3300,7 +3300,7 @@ $parse-mu-stmt:abort: cd/syscall 0x80/imm8 # never gets here -add-operation-and-inputs-to-stmt: # stmt: (handle stmt), line: (addr stream byte) +add-operation-and-inputs-to-stmt: # stmt: (handle stmt), line: (addr stream byte), vars: (addr stack (handle var)) # pseudocode: # stmt->name = slice-to-string(next-mu-token(line)) # while true @@ -3337,7 +3337,7 @@ $add-operation-and-inputs-to-stmt:read-inouts: (slice-equal? %ecx "<-") 3d/compare-eax-and 0/imm32 0f 85/jump-if-!= $add-operation-and-inputs-to-stmt:abort/disp32 - # if (name starts with "$") treat it as a literal + # if (name starts with "$") it's a label { # var eax: byte = name[0] 8b/-> *ecx 0/r32/eax @@ -3347,6 +3347,7 @@ $add-operation-and-inputs-to-stmt:read-inouts: 3d/compare-eax-and 0x24/imm32/dollar 75/jump-if-!= break/disp8 # var eax: (handle var) + # labels aren't in vars; just create a new record on each use (new-label Heap %ecx) # => eax # stmt->inouts = append(eax, stmt->inouts) (append-list Heap %eax *(edi+8)) # Stmt1-inouts => eax -- cgit 1.4.1-2-gfad0