optimizations
Some checks failed
Build / build (push) Successful in 10m29s
Publish Image / publish (push) Failing after 31s
Test / build (push) Failing after 6m34s

This commit is contained in:
Chuck Smith
2024-04-02 14:08:08 -04:00
parent 4c9ec5aaaa
commit 07fd82b261
23 changed files with 296 additions and 265 deletions

View File

@@ -99,6 +99,10 @@ func ExecFile(fn string, opts *Options) error {
err error
)
if opts == nil {
opts = &Options{}
}
ext := filepath.Ext(fn)
mc := fn[:len(fn)-len(ext)] + ".mc"
@@ -128,7 +132,7 @@ func ExecFile(fn string, opts *Options) error {
}
}
mvm := vm.New(fn, bytecode, vm.WithDebug(opts.Debug), vm.WithTrace(opts.Trace))
mvm := vm.New(fn, bytecode, opts.ToVMOptions()...)
if err := mvm.Run(); err != nil {
return err
}
@@ -138,6 +142,10 @@ func ExecFile(fn string, opts *Options) error {
// ExecString executes a Monkey program from a string.
func ExecString(input string, opts *Options) error {
if opts == nil {
opts = &Options{}
}
bytecode, err := compileString(input, opts.Debug)
if err != nil {
return err
@@ -157,6 +165,10 @@ func ExecString(input string, opts *Options) error {
// CompileFiles compiles multiple Monkey files and returns any errors encountered during compilation.
func CompileFiles(fns []string, opts *Options) error {
if opts == nil {
opts = &Options{}
}
for _, fn := range fns {
ext := filepath.Ext(fn)
mc := fn[:len(fn)-len(ext)] + ".mc"