go-vise

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

commit 5a63b24ec1c59d83779daa3adf870de620e63f63
parent a0f7ad5c808ef678e081d75934994e43a16bd8e0
Author: lash <dev@holbrook.no>
Date:   Mon,  3 Apr 2023 07:34:09 +0100

Ignore load request on same level in state

Diffstat:
Mgo/engine/engine.go | 11-----------
Mgo/state/state.go | 4++++
Mgo/state/state_test.go | 5+++++
3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/go/engine/engine.go b/go/engine/engine.go @@ -38,17 +38,6 @@ func(en *Engine) Init(sym string, ctx context.Context) error { if err != nil { return err } -// location := en.st.Where() -// code, err := en.rs.GetCode(location) -// if err != nil { -// return err -// } -// if len(code) == 0 { -// return fmt.Errorf("no code found at resource %s", en.rs) -// } -// -// code, err = vm.Run(code, en.st, en.rs, ctx) -// en.st.SetCode(b) return nil } diff --git a/go/state/state.go b/go/state/state.go @@ -238,6 +238,10 @@ func(st *State) Add(key string, value string, sizeLimit uint16) error { } checkFrame := st.frameOf(key) if checkFrame > -1 { + if checkFrame == len(st.execPath) - 1 { + log.Printf("Ignoring load request on frame that has symbol already loaded") + return nil + } return fmt.Errorf("key %v already defined in frame %v", key, checkFrame) } sz := st.checkCapacity(value) diff --git a/go/state/state_test.go b/go/state/state_test.go @@ -227,6 +227,11 @@ func TestStateLoadDup(t *testing.T) { if err == nil { t.Errorf("expected fail on duplicate load") } + st.Up() + err = st.Add("foo", "xyzzy", 0) + if err != nil { + t.Error(err) + } } func TestStateCurrentSize(t *testing.T) {