本文整理汇总了C#中Executor.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# Executor.Clear方法的具体用法?C# Executor.Clear怎么用?C# Executor.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Executor
的用法示例。
在下文中一共展示了Executor.Clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Eval
public override void Eval(Executor exec)
{
exec.Clear();
}
示例2: PartialEval
/// <summary>
/// We attempt to execute an expression (list of functions) on an empty stack.
/// When no exception is raised we know that the subexpression can be replaced with anything
/// that generates the values.
/// </summary>
static CatExpr PartialEval(Executor exec, CatExpr fxns)
{
// Recursively partially evaluate all quotations
for (int i = 0; i < fxns.Count; ++i)
{
Function f = fxns[i];
if (f is PushFunction)
{
PushFunction q = f as PushFunction;
CatExpr tmp = PartialEval(new Executor(), q.GetSubFxns());
fxns[i] = new PushFunction(tmp);
}
}
CatExpr ret = new CatExpr();
object[] values = null;
int j = 0;
while (j < fxns.Count)
{
try
{
Function f = fxns[j];
if (f is DefinedFunction)
{
f.Eval(exec);
}
else
{
if (f.GetFxnType() == null)
throw new Exception("no type availables");
if (f.GetFxnType().HasSideEffects())
throw new Exception("can't perform partial execution when an expression has side-effects");
f.Eval(exec);
}
// at each step, we have to get the values stored so far
// since they could keep changing and any exception
// will obliterate the old values.
values = exec.GetStackAsArray();
}
catch
{
if (values != null)
{
// Copy all of the values from the previous good execution
for (int k = values.Length - 1; k >= 0; --k)
ret.Add(ValueToFunction(values[k]));
}
ret.Add(fxns[j]);
exec.Clear();
values = null;
}
j++;
}
if (values != null)
for (int l = values.Length - 1; l >= 0; --l)
ret.Add(ValueToFunction(values[l]));
return ret;
}