optimizations
Some checks failed
Build / build (push) Successful in 9m47s
Publish Image / publish (push) Failing after 49s
Test / build (push) Failing after 6m19s

This commit is contained in:
Chuck Smith
2024-04-02 14:32:03 -04:00
parent 07fd82b261
commit 88e3330856
18 changed files with 510 additions and 31 deletions

15
repl.go
View File

@@ -7,6 +7,7 @@ import (
"io"
"log"
"os"
"runtime/debug"
"strings"
"golang.org/x/term"
@@ -32,10 +33,11 @@ func REPL(opts *Options) error {
return fmt.Errorf("error opening terminal: %w", err)
}
defer func() {
if err := recover(); err != nil {
log.Printf("recovered from panic: %s", err)
}
term.Restore(0, initState)
if err := recover(); err != nil {
log.Printf("recovered from panic: %s\n", err)
log.Printf("stack trace:\n%s", debug.Stack())
}
}()
atexit.Register(func() {
term.Restore(0, initState)
@@ -83,7 +85,7 @@ func REPL(opts *Options) error {
log.Printf("Bytecode:\n%s\n", c.Bytecode())
}
mvm := vm.New("<stdin>", c.Bytecode(), opts.ToVMOptions()...)
mvm := vm.New("<stdin>", c.Bytecode(), append(opts.ToVMOptions(), vm.WithState(state))...)
if err := mvm.Run(); err != nil {
fmt.Fprintf(t, "runtime error: %v\n", err)
@@ -151,7 +153,8 @@ func SimpleREPL(opts *Options) {
defer func() {
if err := recover(); err != nil {
log.Printf("recovered from panic: %s", err)
log.Printf("recovered from panic: %s\n", err)
log.Printf("stack trace: %s\n", debug.Stack())
}
}()
@@ -196,7 +199,7 @@ func SimpleREPL(opts *Options) {
log.Printf("Bytecode:\n%s\n", c.Bytecode())
}
mvm := vm.New("<stdin>", c.Bytecode(), opts.ToVMOptions()...)
mvm := vm.New("<stdin>", c.Bytecode(), append(opts.ToVMOptions(), vm.WithState(state))...)
if err := mvm.Run(); err != nil {
fmt.Printf("runtime error: %v\n", err)