diff options
author | Charlie Stanton <charlie@shtanton.xyz> | 2023-04-26 15:02:03 +0100 |
---|---|---|
committer | Charlie Stanton <charlie@shtanton.xyz> | 2023-04-26 15:02:03 +0100 |
commit | 39f767aef901694eef14b1004b13756410f19f66 (patch) | |
tree | c26adf90b296c1e0f4029b9867fc7b71a7de20fd /main/command.go | |
parent | 1aa08f927c7043a643e847c434399fc76d053df0 (diff) | |
download | stred-go-39f767aef901694eef14b1004b13756410f19f66.tar |
Add labels and branches with the : and b commands
Diffstat (limited to 'main/command.go')
-rw-r--r-- | main/command.go | 12 |
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 |