<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/main/command.go
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2023-04-26 15:02:03 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2023-04-26 15:02:03 +0100
commit39f767aef901694eef14b1004b13756410f19f66 (patch)
treec26adf90b296c1e0f4029b9867fc7b71a7de20fd /main/command.go
parent1aa08f927c7043a643e847c434399fc76d053df0 (diff)
downloadstred-go-39f767aef901694eef14b1004b13756410f19f66.tar
Add labels and branches with the : and b commands
Diffstat (limited to 'main/command.go')
-rw-r--r--main/command.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/main/command.go b/main/command.go
index 44fd9eb..63cc3b8 100644
--- a/main/command.go
+++ b/main/command.go
@@ -207,4 +207,16 @@ func (cmd JumpCommand) exec(state *ProgramState) {
}
func (cmd JumpCommand) String() string {
return fmt.Sprintf("b%v", cmd.destination)
+}
+
+// Placeholder as the branch destination may not have been parsed when the branch command is
+// Should never appear in a program to actually be run
+type BranchPlaceholderCommand struct {
+ label rune
+}
+func (cmd BranchPlaceholderCommand) exec(state *ProgramState) {
+ panic("Tried to execute a BranchPlaceholderCommand!!!")
+}
+func (cmd BranchPlaceholderCommand) String() string {
+ return fmt.Sprintf("b%c", cmd.label)
} \ No newline at end of file