commit 39b8e4e6b7a6be892be740d3ede34d4d3ccc3b35
parent b2d2c5f18f387e01695805ab0aeb9b0809e44fd0
Author: lash <dev@holbrook.no>
Date: Fri, 20 Sep 2024 22:58:22 +0100
Reset terminate and dirty on reset
Diffstat:
2 files changed, 5 insertions(+), 17 deletions(-)
diff --git a/dev/interactive/main.go b/dev/interactive/main.go
@@ -19,11 +19,13 @@ func main() {
var size uint
var sessionId string
var persistDir string
+ var initial string
flag.StringVar(&dir, "d", ".", "resource dir to read from")
flag.UintVar(&size, "s", 0, "max size of output")
flag.StringVar(&root, "root", "root", "entry point symbol")
flag.StringVar(&sessionId, "session-id", "default", "session id")
flag.StringVar(&persistDir, "p", "", "state persistence directory")
+ flag.StringVar(&initial, "initial", "", "initial input to pass to engine initialization")
flag.Parse()
fmt.Fprintf(os.Stderr, "starting session at symbol '%s' using resource dir: %s\n", root, dir)
@@ -54,22 +56,7 @@ func main() {
en = en.WithPersister(pe)
}
- //cont, err := en.Init(ctx)
- cont, err := en.Exec(ctx, []byte{})
- if err != nil {
- fmt.Fprintf(os.Stderr, "engine init exited with error: %v\n", err)
- os.Exit(1)
- }
- if !cont {
- _, err = en.Flush(ctx, os.Stdout)
- if err != nil {
- fmt.Fprintf(os.Stderr, "dead init write error: %v\n", err)
- os.Exit(1)
- }
- os.Stdout.Write([]byte{0x0a})
- os.Exit(0)
- }
- err = engine.Loop(ctx, en, os.Stdin, os.Stdout)
+ err = engine.Loop(ctx, en, os.Stdin, os.Stdout, []byte(initial))
if err != nil {
fmt.Fprintf(os.Stderr, "loop exited with error: %v\n", err)
os.Exit(1)
diff --git a/engine/db.go b/engine/db.go
@@ -615,7 +615,8 @@ func(en *DefaultEngine) reset(ctx context.Context) (bool, error) {
en.ca.Pop()
}
en.st.Restart()
- en.initd = false
+ en.st.ResetFlag(state.FLAG_TERMINATE)
+ en.st.ResetFlag(state.FLAG_DIRTY)
return false, nil
}