void EmitArgsAndCall(int firstArgToEmit, RHC rhc, ObjExpr objx, CljILGen ilg) { for (int i = firstArgToEmit; i < Math.Min(Compiler.MaxPositionalArity, _args.count()); i++) { Expr e = (Expr)_args.nth(i); e.Emit(RHC.Expression, objx, ilg); } if (_args.count() > Compiler.MaxPositionalArity) { IPersistentVector restArgs = PersistentVector.EMPTY; for (int i = Compiler.MaxPositionalArity; i < _args.count(); i++) { restArgs = restArgs.cons(_args.nth(i)); } MethodExpr.EmitArgsAsArray(restArgs, objx, ilg); } //if ( rhc == RHC.Return ) //{ // ObjMethod2 method = (ObjMethod2)Compiler.MethodVar.deref(); // method.EmitClearLocals(context); //} MethodInfo mi = Compiler.Methods_IFn_invoke[Math.Min(Compiler.MaxPositionalArity + 1, _args.count())]; ilg.Emit(OpCodes.Callvirt, mi); }
public void EmitUnboxed(RHC rhc, ObjExpr objx, CljILGen ilg) { if (_variadic) { ParameterInfo[] pinfos = _method.GetParameters(); for (int i = 0; i < pinfos.Length - 1; i++) { Expr e = (Expr)_args.nth(i); if (Compiler.MaybePrimitiveType(e) == pinfos[i].ParameterType) { ((MaybePrimitiveExpr)e).EmitUnboxed(RHC.Expression, objx, ilg); } else { e.Emit(RHC.Expression, objx, ilg); HostExpr.EmitUnboxArg(objx, ilg, pinfos[i].ParameterType); } } IPersistentVector restArgs = RT.subvec(_args, pinfos.Length - 1, _args.count()); MethodExpr.EmitArgsAsArray(restArgs, objx, ilg); ilg.EmitCall(Compiler.Method_ArraySeq_create); } else { MethodExpr.EmitTypedArgs(objx, ilg, _method.GetParameters(), _args); } ilg.EmitCall(_method); }
public void Emit(RHC rhc, ObjExpr objx, CljILGen ilg) { MethodExpr.EmitArgsAsArray(_keys, objx, ilg); ilg.Emit(OpCodes.Call, Compiler.Method_RT_set); if (rhc == RHC.Statement) { ilg.Emit(OpCodes.Pop); } }
public void Emit(RHC rhc, ObjExpr objx, CljILGen ilg) { bool allKeysConstant = true; bool allConstantKeysUnique = true; IPersistentSet constantKeys = PersistentHashSet.EMPTY; for (int i = 0; i < _keyvals.count(); i += 2) { Expr k = (Expr)_keyvals.nth(i); if (k is LiteralExpr) { object kval = k.Eval(); if (constantKeys.contains(kval)) { allConstantKeysUnique = false; } else { constantKeys = (IPersistentSet)constantKeys.cons(kval); } } else { allKeysConstant = false; } } MethodExpr.EmitArgsAsArray(_keyvals, objx, ilg); if ((allKeysConstant && allConstantKeysUnique) || (_keyvals.count() <= 2)) { ilg.EmitCall(Compiler.Method_RT_mapUniqueKeys); } else { ilg.EmitCall(Compiler.Method_RT_map); } if (rhc == RHC.Statement) { ilg.Emit(OpCodes.Pop); } }
public void Emit(RHC rhc, ObjExpr objx, CljILGen ilg) { if (_args.count() <= Tuple.MAX_SIZE) { for (int i = 0; i < _args.count(); i++) { ((Expr)_args.nth(i)).Emit(RHC.Expression, objx, ilg); } ilg.Emit(OpCodes.Call, Compiler.Methods_CreateTuple[_args.count()]); } else { MethodExpr.EmitArgsAsArray(_args, objx, ilg); ilg.Emit(OpCodes.Call, Compiler.Method_RT_vector); } if (rhc == RHC.Statement) { ilg.Emit(OpCodes.Pop); } }