本文整理汇总了C#中clojure.lang.CljCompiler.Ast.Expr.Emit方法的典型用法代码示例。如果您正苦于以下问题:C# Expr.Emit方法的具体用法?C# Expr.Emit怎么用?C# Expr.Emit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clojure.lang.CljCompiler.Ast.Expr
的用法示例。
在下文中一共展示了Expr.Emit方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitAssign
public void EmitAssign(RHC rhc, ObjExpr objx, CljILGen ilg, Expr val)
{
objx.EmitVar(ilg, _var);
val.Emit(RHC.Expression, objx, ilg);
ilg.Emit(OpCodes.Call, Compiler.Method_Var_set);
if (rhc == RHC.Statement)
ilg.Emit(OpCodes.Pop);
}
示例2: EmitAssignLocal
internal void EmitAssignLocal(CljILGen ilg, LocalBinding lb, Expr val)
{
if (!IsMutable(lb))
throw new ArgumentException("Cannot assign to non-mutable: ", lb.Name);
FieldBuilder fb = null;
bool hasField = _closedOverFieldsMap.TryGetValue(lb, out fb);
ilg.Emit(OpCodes.Ldarg_0); // this
Type primt = lb.PrimitiveType;
if (primt != null)
{
MaybePrimitiveExpr mbe = val as MaybePrimitiveExpr;
if (!(mbe != null && mbe.CanEmitPrimitive))
throw new ArgumentException("Must assign primitive to primitive mutable", lb.Name);
mbe.EmitUnboxed(RHC.Expression, this, ilg);
}
else
{
val.Emit(RHC.Expression, this, ilg);
}
if (hasField)
{
ilg.MaybeEmitVolatileOp(IsVolatile(lb));
ilg.Emit(OpCodes.Stfld, fb);
}
else
ilg.Emit(OpCodes.Stloc, lb.LocalVar);
}
示例3: EmitTypedArg
public static void EmitTypedArg(ObjExpr objx, CljILGen ilg, Type paramType, Expr arg)
{
Type primt = Compiler.MaybePrimitiveType(arg);
MaybePrimitiveExpr mpe = arg as MaybePrimitiveExpr;
if (primt == paramType)
{
mpe.EmitUnboxed(RHC.Expression, objx, ilg);
}
else if (primt == typeof(int) && paramType == typeof(long))
{
mpe.EmitUnboxed(RHC.Expression, objx, ilg);
ilg.Emit(OpCodes.Conv_I8);
}
else if (primt == typeof(long) && paramType == typeof(int))
{
mpe.EmitUnboxed(RHC.Expression, objx, ilg);
if (RT.booleanCast(RT.UncheckedMathVar.deref()))
ilg.Emit(OpCodes.Call,Compiler.Method_RT_uncheckedIntCast_long);
else
ilg.Emit(OpCodes.Call,Compiler.Method_RT_intCast_long);
}
else if (primt == typeof(float) && paramType == typeof(double))
{
mpe.EmitUnboxed(RHC.Expression, objx, ilg);
ilg.Emit(OpCodes.Conv_R8);
}
else if (primt == typeof(double) && paramType == typeof(float))
{
mpe.EmitUnboxed(RHC.Expression, objx, ilg);
ilg.Emit(OpCodes.Conv_R4);
}
else
{
arg.Emit(RHC.Expression, objx, ilg);
HostExpr.EmitUnboxArg(objx, ilg, paramType);
}
}
示例4: EmitThenForInts
private void EmitThenForInts(ObjExpr objx, CljILGen ilg, Type exprType, Expr test, Expr then, Label defaultLabel, bool emitUnboxed)
{
if (exprType == null)
{
_expr.Emit(RHC.Expression, objx, ilg);
test.Emit(RHC.Expression, objx, ilg);
ilg.Emit(OpCodes.Call, Compiler.Method_Util_equiv);
ilg.Emit(OpCodes.Brfalse, defaultLabel);
EmitExpr(objx, ilg, then, emitUnboxed);
}
else if (exprType == typeof(long))
{
((NumberExpr)test).EmitUnboxed(RHC.Expression, objx, ilg);
_expr.EmitUnboxed(RHC.Expression, objx, ilg);
ilg.Emit(OpCodes.Ceq);
ilg.Emit(OpCodes.Brfalse, defaultLabel);
EmitExpr(objx, ilg, then, emitUnboxed);
}
else if (exprType == typeof(int)
|| exprType == typeof(short)
|| exprType == typeof(byte)
|| exprType == typeof(ulong)
|| exprType == typeof(uint)
|| exprType == typeof(ushort)
|| exprType == typeof(sbyte))
{
if (IsShiftMasked)
{
((NumberExpr)test).EmitUnboxed(RHC.Expression, objx, ilg);
_expr.EmitUnboxed(RHC.Expression, objx, ilg);
ilg.Emit(OpCodes.Conv_I8);
ilg.Emit(OpCodes.Ceq);
ilg.Emit(OpCodes.Brfalse, defaultLabel);
EmitExpr(objx, ilg, then, emitUnboxed);
}
// else direct match
EmitExpr(objx, ilg, then, emitUnboxed);
}
else
{
ilg.Emit(OpCodes.Br, defaultLabel);
}
}
示例5: EmitThenForHashes
void EmitThenForHashes(ObjExpr objx, CljILGen ilg, Expr test, Expr then, Label defaultLabel, bool emitUnboxed)
{
_expr.Emit(RHC.Expression, objx, ilg);
test.Emit(RHC.Expression, objx, ilg);
if (_testType == _hashIdentityKey)
{
ilg.Emit(OpCodes.Ceq);
ilg.Emit(OpCodes.Brfalse, defaultLabel);
}
else
{
ilg.Emit(OpCodes.Call, Compiler.Method_Util_equiv);
ilg.Emit(OpCodes.Brfalse, defaultLabel);
}
EmitExpr(objx, ilg, then, emitUnboxed);
}
示例6: EmitExpr
private static void EmitExpr(ObjExpr objx, CljILGen ilg, Expr expr, bool emitUnboxed)
{
MaybePrimitiveExpr mbe = expr as MaybePrimitiveExpr;
if (emitUnboxed && mbe != null)
mbe.EmitUnboxed(RHC.Expression, objx, ilg);
else
expr.Emit(RHC.Expression, objx, ilg);
}
示例7: EmitBody
protected static void EmitBody(ObjExpr objx, CljILGen ilg, Type retType, Expr body)
{
MaybePrimitiveExpr be = (MaybePrimitiveExpr)body;
if (Util.IsPrimitive(retType) && be.CanEmitPrimitive)
{
Type bt = Compiler.MaybePrimitiveType(be);
if (bt == retType)
be.EmitUnboxed(RHC.Return, objx, ilg);
else if (retType == typeof(long) && bt == typeof(int))
{
be.EmitUnboxed(RHC.Return, objx, ilg);
ilg.Emit(OpCodes.Conv_I8);
}
else if (retType == typeof(double) && bt == typeof(float))
{
be.EmitUnboxed(RHC.Return, objx, ilg);
ilg.Emit(OpCodes.Conv_R8);
}
else if (retType == typeof(int) && bt == typeof(long))
{
be.EmitUnboxed(RHC.Return, objx, ilg);
ilg.Emit(OpCodes.Call,Compiler.Method_RT_intCast_long);
}
else if (retType == typeof(float) && bt == typeof(double))
{
be.EmitUnboxed(RHC.Return, objx, ilg);
ilg.Emit(OpCodes.Conv_R4);
}
else
{
throw new ArgumentException(String.Format("Mismatched primitive return, expected: {0}, had: {1}", retType, be.ClrType));
}
}
else
{
body.Emit(RHC.Return, objx, ilg);
if (body.HasNormalExit())
{
if (retType == typeof(void))
ilg.Emit(OpCodes.Pop);
else
EmitUnboxArg(ilg, typeof(object), retType);
}
}
}