Esempio n. 1
0
// Loads and evaluates the specified Go script
func runScript(w *eval.World, scriptName string, optional bool) error {
	fileName := scriptName + ".go"

	path, err := spectrum.ScriptPath(fileName)
	if err != nil {
		return err
	}

	scriptData, err := ioutil.ReadFile(path)
	if err != nil {
		if !optional {
			return err
		} else {
			return nil
		}
	}

	err = intp.run(w, fileName, string(scriptData))
	return err
}
Esempio n. 2
0
// Signature: func script(scriptName string)
func wrapper_script(t *eval.Thread, in []eval.Value, out []eval.Value) {

	if app.TerminationInProgress() || app.Terminated() {
		return
	}

	path := in[0].(eval.StringValue).Get(t)

	var err error
	path, err = spectrum.ScriptPath(path)
	if err != nil {
		fmt.Fprintf(stdout, "%s\n", err)
		return
	}

	err = runScript(w, path, false /*optional*/)
	if err != nil {
		fmt.Fprintf(stdout, "%s\n", err)
		return
	}
}