本文整理汇总了C#中clojure.lang.CljCompiler.Ast.Expr.GenCode方法的典型用法代码示例。如果您正苦于以下问题:C# Expr.GenCode方法的具体用法?C# Expr.GenCode怎么用?C# Expr.GenCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clojure.lang.CljCompiler.Ast.Expr
的用法示例。
在下文中一共展示了Expr.GenCode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenTestForInts
private Expression GenTestForInts(ObjExpr objx, GenContext context, Type primExprType, Expr test, bool genUnboxed)
{
Expression condCode;
if (primExprType == null)
{
Expression exprCode = _expr.GenCode(RHC.Expression, objx, context);
Expression testCode = test.GenCode(RHC.Expression, objx, context);
condCode = Expression.Call(null, Compiler.Method_Util_equiv, Compiler.MaybeBox(exprCode), Compiler.MaybeBox(testCode));
}
else if (primExprType == typeof(long) || primExprType == typeof(ulong))
{
Expression exprCode = _expr.GenCodeUnboxed(RHC.Expression, objx, context);
Expression testCode = ((NumberExpr)test).GenCodeUnboxed(RHC.Expression, objx, context);
condCode = Expression.Equal(exprCode, testCode);
}
else if (primExprType == typeof(int) || primExprType == typeof(short) || primExprType == typeof(byte)
|| primExprType == typeof(uint) || primExprType == typeof(ushort) || primExprType == typeof(sbyte))
{
if (IsShiftMasked)
{
Expression exprCode = Expression.Convert(_expr.GenCodeUnboxed(RHC.Expression, objx, context),typeof(long));
Expression testCode = ((NumberExpr)test).GenCodeUnboxed(RHC.Expression, objx, context);
condCode = Expression.Equal(exprCode, testCode);
}
else
condCode = Expression.Constant(true);
}
else
{
condCode = Expression.Constant(false);
}
return condCode;
}
示例2: GenTypedArg
internal static Expression GenTypedArg(ObjExpr objx, GenContext context, Type paramType, Expr arg)
{
Type primt = Compiler.MaybePrimitiveType(arg);
if ( primt == paramType )
{
Expression expr = ((MaybePrimitiveExpr)arg).GenCodeUnboxed(RHC.Expression, objx, context);
return expr;
}
else if ( primt == typeof(int) && paramType == typeof(long) )
{
Expression expr = ((MaybePrimitiveExpr)arg).GenCodeUnboxed(RHC.Expression, objx, context);
expr = Expression.Convert(expr,typeof(long));
return expr;
}
else if ( primt == typeof(long) && paramType == typeof(int) )
{
Expression expr = ((MaybePrimitiveExpr)arg).GenCodeUnboxed(RHC.Expression, objx, context);
if (RT.booleanCast(RT.UNCHECKED_MATH.deref()))
expr = Expression.Call(Compiler.Method_RT_uncheckedIntCast_long, expr);
else
expr = Expression.Call(Compiler.Method_RT_intCast_long, expr);
return expr;
}
else if ( primt == typeof(float) && paramType == typeof(double) )
{
Expression expr = ((MaybePrimitiveExpr)arg).GenCodeUnboxed(RHC.Expression, objx, context);
expr = Expression.Convert(expr,typeof(double));
return expr;
}
else if ( primt == typeof(double) && paramType == typeof(float) )
{
Expression expr = ((MaybePrimitiveExpr)arg).GenCodeUnboxed(RHC.Expression, objx, context);
expr = Expression.Convert(expr,typeof(float));
return expr;
}
else
{
Expression argExpr = arg.GenCode(RHC.Expression, objx, context);
return GenUnboxArg(argExpr, paramType);
}
}
示例3: GenTestForHashes
private Expression GenTestForHashes(ObjExpr objx, GenContext context, Expr test, bool genUnboxed)
{
Expression exprCode = _expr.GenCode(RHC.Expression, objx, context);
Expression testCode = test.GenCode(RHC.Expression, objx, context);
Expression condCode = _testType == _hashIdentityKey
? (Expression)Expression.Equal(exprCode, testCode)
: (Expression)Expression.Call(null, Compiler.Method_Util_equiv, Compiler.MaybeBox(exprCode), Compiler.MaybeBox(testCode));
return condCode;
}
示例4: GenResult
private static Expression GenResult(ObjExpr objx, GenContext context, Expr expr, bool genUnboxed, Type retType)
{
MaybePrimitiveExpr mbExpr = expr as MaybePrimitiveExpr;
Expression result = genUnboxed && mbExpr != null
? mbExpr.GenCodeUnboxed(RHC.Expression, objx, context)
: expr.GenCode(RHC.Expression, objx, context);
if (result.Type != retType)
{
if (expr is ThrowExpr)
{
// Fix type on the throw expression
UnaryExpression ur = (UnaryExpression)result;
result = Expression.Throw(ur.Operand, retType);
}
else result = Expression.Convert(result, retType);
}
return result;
}
示例5: GenAssignLocal
internal Expression GenAssignLocal(GenContext context, LocalBinding lb, Expr val)
{
if (!IsMutable(lb))
throw new ArgumentException("Cannot assign to non-mutable: " + lb.Name);
FieldBuilder fb;
if ( _closedOverFieldsMap.TryGetValue(lb,out fb) )
return Expression.Assign(Expression.Field(_thisParam,_closedOverFieldsMap[lb]), val.GenCode(RHC.Expression,this,context));
return Expression.Assign(lb.ParamExpression, val.GenCode(RHC.Expression,this,context));
}
示例6: GenTypedArg
internal static Expression GenTypedArg(ObjExpr objx, GenContext context, Type type, Expr arg)
{
if (Compiler.MaybePrimitiveType(arg) == type)
return ((MaybePrimitiveExpr)arg).GenCodeUnboxed(RHC.Expression, objx, context);
else
{
Expression argExpr = arg.GenCode(RHC.Expression, objx, context);
return GenMaybeUnboxedArg(type, argExpr);
}
}
示例7: GenAssign
public Expression GenAssign(RHC rhc, ObjExpr objx, GenContext context, Expr val)
{
Expression varExpr = objx.GenVar(context, _var);
Expression valExpr = val.GenCode(RHC.Expression,objx,context);
return Expression.Call(varExpr, Compiler.Method_Var_set, Compiler.MaybeBox(valExpr));
}