本文整理汇总了C#中Irony.Interpreter.ScriptThread.Bind方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptThread.Bind方法的具体用法?C# ScriptThread.Bind怎么用?C# ScriptThread.Bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Irony.Interpreter.ScriptThread
的用法示例。
在下文中一共展示了ScriptThread.Bind方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoEvaluate
protected override object DoEvaluate(ScriptThread thread)
{
// standard prolog
thread.CurrentNode = this;
var binding = thread.Bind(FunctionName, BindingRequestFlags.Read);
var result = binding.GetValueRef(thread);
if (result == null)
{
thread.ThrowScriptError("Unknown identifier: {0}", FunctionName);
return null;
}
CallTarget = result as ICallTarget;
if (CallTarget == null)
{
thread.ThrowScriptError("This identifier cannot be called: {0}", FunctionName);
return null;
}
// set Evaluate pointer
Evaluate = DoCall;
// standard epilog is done by DoCall
return DoCall(thread);
}
示例2: DoEvaluate
//Executed only once, on the first call
protected override object DoEvaluate(ScriptThread thread)
{
thread.CurrentNode = this; //standard prolog
_accessor = thread.Bind(Symbol, BindingRequestFlags.Read);
this.Evaluate = _accessor.GetValueRef; // Optimization - directly set method ref to accessor's method. EvaluateReader;
var result = this.Evaluate(thread);
thread.CurrentNode = Parent; //standard epilog
return result;
}
示例3: DoSetValue
public override void DoSetValue(ScriptThread thread, object value)
{
thread.CurrentNode = this; //standard prolog
if (_accessor == null) {
_accessor = thread.Bind(Symbol, BindingRequestFlags.Write | BindingRequestFlags.ExistingOrNew);
}
_accessor.SetValueRef(thread, value);
thread.CurrentNode = Parent; //standard epilog
}
示例4: DoEvaluate
public string Name { get; set; } // TODO: value.Replace("-", "__")
protected override object DoEvaluate(ScriptThread thread)
{
// standard prolog
thread.CurrentNode = this;
// define function: bind function name to the current instance
var binding = thread.Bind(Name, BindingRequestFlags.Write | BindingRequestFlags.NewOnly);
binding.SetValueRef(thread, this);
// set Evaluate method and return the current node
Evaluate = t => this;
// standard epilog
thread.CurrentNode = Parent;
return this;
}
示例5: DoEvaluate
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;
}