Flush code buffer on catch

This commit is contained in:
lash 2023-04-16 09:13:14 +01:00
parent ed9cd8d7b4
commit 57bb9af940
Signed by untrusted user who does not match committer: lash
GPG Key ID: 21D2E7BB88C2A746
4 changed files with 14 additions and 2 deletions

View File

@ -0,0 +1,3 @@
You are identified as:
Name: {{.myname}}
Email: {{.myemail}}

View File

@ -0,0 +1,2 @@
MAP myname
MAP myemail

View File

@ -191,7 +191,8 @@ func(vm *Vm) RunCatch(b []byte, ctx context.Context) ([]byte, error) {
if err != nil { if err != nil {
return b, err return b, err
} }
b = append(bh, b...) //b = append(bh, b...)
b = bh
vm.st.Down(sym) vm.st.Down(sym)
vm.ca.Push() vm.ca.Push()
vm.Reset() vm.Reset()

View File

@ -18,6 +18,7 @@ var dynVal = "three"
type TestResource struct { type TestResource struct {
resource.MenuResource resource.MenuResource
state *state.State state *state.State
RootCode []byte
} }
func getOne(sym string, input []byte, ctx context.Context) (resource.Result, error) { 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, MOUT, []string{"0", "repent"}, nil, nil)
b = NewLine(b, HALT, nil, nil, nil) b = NewLine(b, HALT, nil, nil, nil)
b = NewLine(b, MOVE, []string{"_"}, nil, nil) b = NewLine(b, MOVE, []string{"_"}, nil, nil)
case "root":
b = r.RootCode
} }
return b, nil return b, nil
@ -495,10 +498,13 @@ func TestInputBranch(t *testing.T) {
st.Down("root") st.Down("root")
b := NewLine(nil, LOAD, []string{"setFlagOne"}, []byte{0x00}, nil) 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, RELOAD, []string{"setFlagOne"}, nil, nil)
b = NewLine(b, CATCH, []string{"flagCatch"}, []byte{8}, []uint8{0}) b = NewLine(b, CATCH, []string{"flagCatch"}, []byte{8}, []uint8{0})
b = NewLine(b, CATCH, []string{"one"}, []byte{9}, []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() ctx := context.TODO()