本文整理汇总了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);
}