aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2018-01-15 00:34:27 +0100
committerDimitri Sokolyuk <demon@dim13.org>2018-01-15 00:34:27 +0100
commit331e5c36b4721b20a18156505be74e123e58bb55 (patch)
treeb16e555fd9666e2c72aa360de5703c74a8f7e884
parent3705ec154f2700d1b3c60ce56626cc520fb3e068 (diff)
expose context
-rw-r--r--cmd/eval/main.go8
-rw-r--r--cmd/j1e/main.go8
-rw-r--r--core.go4
3 files changed, 14 insertions, 6 deletions
diff --git a/cmd/eval/main.go b/cmd/eval/main.go
index b9518f3..a5fa686 100644
--- a/cmd/eval/main.go
+++ b/cmd/eval/main.go
@@ -1,11 +1,15 @@
package main
-import "dim13.org/j1"
+import (
+ "context"
+
+ "dim13.org/j1"
+)
func main() {
vm := j1.New()
if err := vm.LoadFile("testdata/j1e.bin"); err != nil {
panic(err)
}
- vm.Run()
+ vm.Run(context.Background())
}
diff --git a/cmd/j1e/main.go b/cmd/j1e/main.go
index 65cf626..057e106 100644
--- a/cmd/j1e/main.go
+++ b/cmd/j1e/main.go
@@ -2,10 +2,14 @@ package main
//go:generate file2go -in ../../testdata/j1e.bin
-import "dim13.org/j1"
+import (
+ "context"
+
+ "dim13.org/j1"
+)
func main() {
vm := j1.New()
vm.LoadBytes(J1eBin)
- vm.Run()
+ vm.Run(context.Background())
}
diff --git a/core.go b/core.go
index 5ffe7cb..32f37fb 100644
--- a/core.go
+++ b/core.go
@@ -54,8 +54,8 @@ func (c *Core) LoadFile(fname string) error {
}
// Run evaluates content of memory
-func (c *Core) Run() {
- ctx, cancel := context.WithCancel(context.Background())
+func (c *Core) Run(ctx context.Context) {
+ ctx, cancel := context.WithCancel(ctx)
c.tty = NewConsole(ctx)
c.stop = cancel
for {