本文整理汇总了C#中CodeBlock.add方法的典型用法代码示例。如果您正苦于以下问题:C# CodeBlock.add方法的具体用法?C# CodeBlock.add怎么用?C# CodeBlock.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeBlock
的用法示例。
在下文中一共展示了CodeBlock.add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: evalPhrase
public ArgumentValue evalPhrase(Phrase matchedExpression, CodeBlock placeToWriteTo, bool useOutput)
{
//I store this all mods in a special block,
//because I can't predict failure
//and in case types arn't correct
//I need to not do anything and return
//so I store in tmpBlock, and add it
//to the main block on sucess
CodeBlock tmpBlock = new CodeBlock();
ArgumentValue returnValue;
if (matchedExpression.getReturnType()== null || !useOutput){
returnValue = ArgumentValue.Zero;
}
else
{
returnValue = ArgumentValue.getPull(matchedExpression.getReturnType());
}
Dictionary<string, string> args = matchedExpression.lastMatchArgs();
Stack<ArgumentValue> argValues = new Stack<ArgumentValue>();
foreach (Argument v in matchedExpression.arguments.Reverse())
{
ArgumentValue t = EvalExpression(args[v.name], tmpBlock);
if (!v.type.isParent(t.getKind()))
{
throw new Errors.TypeMismatchException("function requres a " + v.type.ToString() +
" but instead got incompatable type " + t.getKind().ToString()+"("
+args[v.name]+ ")");
}
if (v.isStackArgument())
{
if (t.getMode() != addressMode.stack)
{
tmpBlock.add(Phrase.push.toSubstituedPhrase(new ArgumentValue[] { t }, null));
}
}
else
{
argValues.Push(t);
}
}
tmpBlock.add(matchedExpression.toSubstituedPhrase(argValues, returnValue));
placeToWriteTo.add(tmpBlock);
return returnValue;
}