From 39f767aef901694eef14b1004b13756410f19f66 Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Wed, 26 Apr 2023 15:02:03 +0100 Subject: Add labels and branches with the : and b commands --- main/command.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'main/command.go') 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 -- cgit v1.2.3