本文整理匯總了C#中CodeBlock.CreateTemporaryVariable方法的典型用法代碼示例。如果您正苦於以下問題:C# CodeBlock.CreateTemporaryVariable方法的具體用法?C# CodeBlock.CreateTemporaryVariable怎麽用?C# CodeBlock.CreateTemporaryVariable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CodeBlock
的用法示例。
在下文中一共展示了CodeBlock.CreateTemporaryVariable方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetAst
//.........這裏部分代碼省略.........
#endif
//if (!ScriptDomainManager.Options.DebugMode)
{
if (f == SymbolTable.StringToId("call-with-values"))
{
Expression[] ppp = GetAstListNoCast(c.cdr as Cons, cb);
if (ppp.Length == 2 && ppp[1] is MethodCallExpression)
{
MethodCallExpression consumer = ppp[1] as MethodCallExpression;
if (ppp[0] is MethodCallExpression)
{
MethodCallExpression producer = ppp[0] as MethodCallExpression;
if (consumer.Method == Closure_Make && producer.Method == Closure_Make)
{
CodeBlockExpression ccbe = consumer.Arguments[0] as CodeBlockExpression;
CodeBlockExpression pcbe = producer.Arguments[0] as CodeBlockExpression;
pcbe.Block.Bind();
ccbe.Block.Bind();
if (ccbe.Block.ParameterCount == 0)
{
return InlineCall(cb, ccbe);
}
else if (ccbe.Block.ParameterCount == 1)
{
return InlineCall(cb, ccbe, Ast.SimpleCallHelper(typeof(Helpers).GetMethod("UnwrapValue"), InlineCall(cb, pcbe)));
}
else
{
Variable values = cb.CreateTemporaryVariable((SymbolId)Builtins.GenSym("values"), typeof(object[]));
Expression valuesarr = Ast.Read(values);
Expression[] pppp = new Expression[ccbe.Block.ParameterCount];
for (int i = 0; i < pppp.Length; i++)
{
pppp[i] = Ast.ArrayIndex(valuesarr, Ast.Constant(i));
}
return Ast.Comma(
Ast.Void(
Ast.Write(
values,
Ast.ComplexCallHelper(
Ast.SimpleCallHelper(typeof(Helpers).GetMethod("WrapValue"), InlineCall(cb, pcbe)),
typeof(MultipleValues).GetMethod("ToArray", new Type[] { typeof(int) }),
Ast.Constant(pppp.Length)))),
InlineCall(cb, ccbe, pppp));
}
}
}
if (consumer.Method == Closure_Make)
{
CodeBlockExpression ccbe = consumer.Arguments[0] as CodeBlockExpression;
ccbe.Block.Bind();
Expression producer = ppp[0];
Expression exx = Ast.ConvertHelper(producer, typeof(Callable));
MethodInfo callx = GetCallable(0);
示例2: CoalesceInternal
private static Expression CoalesceInternal(CodeBlock currentBlock, Expression left, Expression right, MethodInfo isTrue, bool isReverse) {
Contract.RequiresNotNull(currentBlock, "currentBlock");
Contract.RequiresNotNull(left, "left");
Contract.RequiresNotNull(right, "right");
// A bit too strict, but on a safe side.
Contract.Requires(left.Type == right.Type, "Expression types must match");
Variable tmp = currentBlock.CreateTemporaryVariable(SymbolTable.StringToId("tmp_left"), left.Type);
Expression condition;
if (isTrue != null) {
Contract.Requires(isTrue.ReturnType == typeof(bool), "isTrue", "Predicate must return bool.");
ParameterInfo[] parameters = isTrue.GetParameters();
Contract.Requires(parameters.Length == 1, "isTrue", "Predicate must take one parameter.");
Contract.Requires(isTrue.IsStatic && isTrue.IsPublic, "isTrue", "Predicate must be public and static.");
Type pt = parameters[0].ParameterType;
Contract.Requires(TypeUtils.CanAssign(pt, left.Type), "left", "Incorrect left expression type");
condition = Call(isTrue, Assign(tmp, left));
} else {
Contract.Requires(TypeUtils.CanCompareToNull(left.Type), "left", "Incorrect left expression type");
condition = Equal(Assign(tmp, left), Null(left.Type));
}
Expression t, f;
if (isReverse) {
t = Read(tmp);
f = right;
} else {
t = right;
f = Read(tmp);
}
return Condition(condition, t, f);
}