add Script.Run() method
This commit is contained in:
parent
2de0fa4efb
commit
8e56bd8218
1 changed files with 13 additions and 0 deletions
|
@ -74,6 +74,19 @@ func (s *Script) Compile() (*Compiled, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run compiles and runs the scripts.
|
||||||
|
// Use returned compiled object to access global variables.
|
||||||
|
func (s *Script) Run() (compiled *Compiled, err error) {
|
||||||
|
compiled, err = s.Compile()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = compiled.Run()
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Script) prepCompile() (symbolTable *compiler.SymbolTable, globals []*objects.Object) {
|
func (s *Script) prepCompile() (symbolTable *compiler.SymbolTable, globals []*objects.Object) {
|
||||||
var names []string
|
var names []string
|
||||||
for name := range s.variables {
|
for name := range s.variables {
|
||||||
|
|
Loading…
Reference in a new issue