<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/main/main.go
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2023-04-26 14:41:25 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2023-04-26 14:41:25 +0100
commit1aa08f927c7043a643e847c434399fc76d053df0 (patch)
tree3a6d5872a87395f44fced57d0aa0bf73564bf2f4 /main/main.go
parent58bbf68238e7711da1dda53d9656444ed6ccbd4d (diff)
downloadstred-go-1aa08f927c7043a643e847c434399fc76d053df0.tar
Store stred programs as a flat list of commands with no nesting, using a new jump command to simulate command blocks
Diffstat (limited to 'main/main.go')
-rw-r--r--main/main.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/main/main.go b/main/main.go
index 2067920..55ed5b5 100644
--- a/main/main.go
+++ b/main/main.go
@@ -13,6 +13,7 @@ type ProgramState struct {
in walk.JSONIn
out walk.JSONOut
program []Command
+ pc int
}
func main() {
@@ -55,8 +56,9 @@ func main() {
}
state.value = walkItem.Value
state.path = walkItem.Path
- for _, cmd := range state.program {
- cmd.exec(&state)
+ state.pc = 0
+ for state.pc < len(state.program) {
+ state.program[state.pc].exec(&state)
}
if !quiet {
pathValues, err := walk.Compound(state.path)