protected override object DoEvaluate(ScriptThread thread) { // standard prolog thread.CurrentNode = this; if (EntryPoint == null) { thread.ThrowScriptError("No entry point defined (entry point is a function named «Go»)"); return(null); } // define built-in runtime library functions var libraryFunctions = LibraryFunction.ExtractLibraryFunctions(thread, new RefalLibrary(thread)); foreach (var libFun in libraryFunctions) { var binding = thread.Bind(libFun.Name, BindingRequestFlags.Write | BindingRequestFlags.ExistingOrNew); binding.SetValueRef(thread, libFun); } // define functions declared in the compiled program foreach (var fun in FunctionList) { fun.Evaluate(thread); } // call entry point with an empty expression EntryPoint.Call(thread, new object[] { PassiveExpression.Build() }); // standard epilog thread.CurrentNode = Parent; return(null); }
public override void EvaluateNode(EvaluationContext context, AstMode mode) { if (EntryPoint == null) { context.ThrowError("No entry point defined (entry point is a function named «Go»)"); } // load standard run-time library functions var libraryFunctions = LibraryFunction.ExtractLibraryFunctions(context, new RefalLibrary(context)); foreach (LibraryFunction libFun in libraryFunctions) { context.SetValue(libFun.Name, libFun); } // define all functions foreach (Function fun in FunctionList) { fun.Evaluate(context, mode); } // call entry point with empty expression as an argument context.Data.Push(Runtime.PassiveExpression.Build()); EntryPoint.Call(context); // discard execution results context.Data.Pop(); context.ClearLastResult(); }