本文整理匯總了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;
}