go-vise

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

commit a4ec4dd60e8bb426c32354a67e2a1c0c479f371a
parent 0ab6868ecafe185da5cd79dd606265b0eb217cee
Author: lash <dev@holbrook.no>
Date:   Sun, 16 Apr 2023 08:25:44 +0100

Add initialize entry state in compile script

Diffstat:
M.gitignore | 1+
Mexamples/compile.bash | 8++++++++
Dexamples/profile/entry_email.save.vis | 3---
Aexamples/profile/entry_email_save.vis | 3+++
Mexamples/profile/entry_name_save.vis | 1+
Mexamples/profile/main.go | 10+++++++++-
Dexamples/profile/myemail.txt | 2--
Aexamples/profile/myemail.txt.orig | 2++
Dexamples/profile/myname.txt | 2--
Aexamples/profile/myname.txt.orig | 2++
10 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1 +1,2 @@ examples/**/*.bin +examples/**/*.txt diff --git a/examples/compile.bash b/examples/compile.bash @@ -3,3 +3,11 @@ for f in $(ls $1/*.vis); do b=${b%.*} go run ./dev/asm $1/$b.vis > $1/$b.bin done + +for f in $(ls $1/*.txt.orig); do + b=$(basename $f) + b=${b%.*} + #go run ./dev/asm $1/$b.vis > $1/$b.bin + echo $b + cp -v $f $1/$b +done diff --git a/examples/profile/entry_email.save.vis b/examples/profile/entry_email.save.vis @@ -1,3 +0,0 @@ -LOAD entry_email_save 0 -RELOAD myemail -MOVE _ diff --git a/examples/profile/entry_email_save.vis b/examples/profile/entry_email_save.vis @@ -0,0 +1,3 @@ +LOAD do_email_save 1 +RELOAD myemail +MOVE _ diff --git a/examples/profile/entry_name_save.vis b/examples/profile/entry_name_save.vis @@ -1,2 +1,3 @@ +LOAD do_name_save 1 RELOAD myname MOVE _ diff --git a/examples/profile/main.go b/examples/profile/main.go @@ -29,6 +29,13 @@ func nameSave(sym string, input []byte, ctx context.Context) (resource.Result, e return resource.Result{}, err } +func emailSave(sym string, input []byte, ctx context.Context) (resource.Result, error) { + log.Printf("writing email to file") + fp := path.Join(scriptDir, "myemail.txt") + err := ioutil.WriteFile(fp, input, 0600) + return resource.Result{}, err +} + func main() { var dir string var root string @@ -42,7 +49,8 @@ func main() { st := state.NewState(0) rs := resource.NewFsResource(scriptDir) - rs.AddLocalFunc("entry_name_save", nameSave) + rs.AddLocalFunc("do_name_save", nameSave) + rs.AddLocalFunc("do_email_save", emailSave) ca := cache.NewCache() cfg := engine.Config{ Root: "root", diff --git a/examples/profile/myemail.txt b/examples/profile/myemail.txt @@ -1 +0,0 @@ -not set -\ No newline at end of file diff --git a/examples/profile/myemail.txt.orig b/examples/profile/myemail.txt.orig @@ -0,0 +1 @@ +(not set) +\ No newline at end of file diff --git a/examples/profile/myname.txt b/examples/profile/myname.txt @@ -1 +0,0 @@ -not set -\ No newline at end of file diff --git a/examples/profile/myname.txt.orig b/examples/profile/myname.txt.orig @@ -0,0 +1 @@ +(not set) +\ No newline at end of file