go-vise

Constrained Size Output Virtual Machine
Info | Log | Files | Refs | README | LICENSE

commit 57bb9af9402b7eff0927edb166e4b4c043124eb0
parent ed9cd8d7b4eb3c2514bae671a40d2b568eeafe3f
Author: lash <dev@holbrook.no>
Date:   Sun, 16 Apr 2023 09:13:14 +0100

Flush code buffer on catch

Diffstat:
Aexamples/profile/identified | 3+++
Aexamples/profile/identified.vis | 2++
Mvm/runner.go | 3++-
Mvm/runner_test.go | 8+++++++-
4 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/examples/profile/identified b/examples/profile/identified @@ -0,0 +1,3 @@ +You are identified as: +Name: {{.myname}} +Email: {{.myemail}} diff --git a/examples/profile/identified.vis b/examples/profile/identified.vis @@ -0,0 +1,2 @@ +MAP myname +MAP myemail diff --git a/vm/runner.go b/vm/runner.go @@ -191,7 +191,8 @@ func(vm *Vm) RunCatch(b []byte, ctx context.Context) ([]byte, error) { if err != nil { return b, err } - b = append(bh, b...) + //b = append(bh, b...) + b = bh vm.st.Down(sym) vm.ca.Push() vm.Reset() diff --git a/vm/runner_test.go b/vm/runner_test.go @@ -18,6 +18,7 @@ var dynVal = "three" type TestResource struct { resource.MenuResource state *state.State + RootCode []byte } func getOne(sym string, input []byte, ctx context.Context) (resource.Result, error) { @@ -121,6 +122,8 @@ func(r TestResource) GetCode(sym string) ([]byte, error) { b = NewLine(b, MOUT, []string{"0", "repent"}, nil, nil) b = NewLine(b, HALT, nil, nil, nil) b = NewLine(b, MOVE, []string{"_"}, nil, nil) + case "root": + b = r.RootCode } return b, nil @@ -495,10 +498,13 @@ func TestInputBranch(t *testing.T) { st.Down("root") b := NewLine(nil, LOAD, []string{"setFlagOne"}, []byte{0x00}, nil) - b = NewLine(b, CATCH, []string{"flagCatch"}, []byte{8}, []uint8{0}) b = NewLine(b, RELOAD, []string{"setFlagOne"}, nil, nil) b = NewLine(b, CATCH, []string{"flagCatch"}, []byte{8}, []uint8{0}) b = NewLine(b, CATCH, []string{"one"}, []byte{9}, []uint8{0}) + rs.RootCode = b + + //b = NewLine(b, RELOAD, []string{"setFlagOne"}, nil, nil) + //b = NewLine(b, CATCH, []string{"flagCatch"}, []byte{8}, []uint8{0}) ctx := context.TODO()