本文整理汇总了C#中CodeBlock.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# CodeBlock.Execute方法的具体用法?C# CodeBlock.Execute怎么用?C# CodeBlock.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeBlock
的用法示例。
在下文中一共展示了CodeBlock.Execute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Else
public Value Else(Value previous, CodeBlock block)
{
if (previous.Type == ValueType.IfFalse)
{
return block.Execute(Interpreter);
}
return previous;
}
示例2: For
public Void For(CodeBlock init, CodeBlock condition, CodeBlock increment, CodeBlock block)
{
init.Execute(Interpreter);
while (true)
{
var b = condition.Execute(Interpreter) as Boolean;
if (b == null) throw new FunctionCallException("The conditional expression of the for loop didn't produce a Boolean value");
if (!b.Bool) break;
block.Execute(Interpreter);
increment.Execute(Interpreter);
}
return Void.Instance;
}
示例3: Function
public Function Function(List args, CodeBlock block)
{
var functionsScope = new ScopeTreeNode(Permanency.NonPermanent, Interpreter.CurrentScopeNode);
Func<List<Value>, Value> code = delegate(List<Value> list)
{
var tempScope = new ScopeTreeNode(Permanency.NonPermanent, functionsScope.Parent);
Interpreter.EnterScope(tempScope);
for (int i = 0; i < list.Count; ++i)
{
var name = args.InnerList[i].Var.OriginalName;
Interpreter.CurrentScopeNode.AddToScope(name, list[i]);
}
var ret = block.Execute(Interpreter);
if (ret.Type <= ValueType.ReturnValue) ret = (ret as ReturnValue).InnerValue;
Interpreter.ExitScope();
return ret;
};
var fun = new CSharpFunction(code, Fixity.Prefix, args.InnerList.Count) { FunctionScope = functionsScope };
fun.Signature.InputSignature.Clear();
args.Select(v => v.Type).ToList().ForEach(t => fun.Signature.InputSignature.Add(t == ValueType.BlankIdentifier ? ValueType.Uncertain : t));
return fun;
}
示例4: Exec
public Value Exec(CodeBlock block)
{
return block.Execute(Interpreter);
}
示例5: If
public Value If(Boolean condition, CodeBlock block)
{
if (condition.Bool)
{
return block.Execute(Interpreter);
}
return new TypedObject("IfFalse");
}