for (int i = args.length; i > 0; i--) code.Emit(OpCodes.Starg_S, i); code.Emit(OpCodes.Br, l); willReturn = false;
for (int i = args.length - 1; i >= 0; i--) { Item ident = gen(ld.params[i], msilType(ld.params[i])); store(ident); } code.Emit(OpCodes.Br, ld.label);
    private Item genApply0(Tree fun, Tree[] args, MSILType resType) {	boolean tmpLastExpr = lastExpr; lastExpr = false;	Symbol sym = fun.symbol();	switch (fun) {	case Ident(_):	    Label l = (Label)sym2label.get(sym);	    if (l != null) {		lastExpr = false;		for (int i = 0; i < args.length; i++)		    genLoad(args[i], msilType(args[i].type));		for (int i = args.length; i > 0; i--)		    code.Emit(OpCodes.Starg_S, i);		code.Emit(OpCodes.Br, l);		willReturn = false;		MSILType retType = msilType(sym.info().resultType());		Item i = retType == MSILType.VOID ? items.VoidItem()		    : items.StackItem(retType);		return coerce(i, resType);	    }	    assert sym.isStatic() : Debug.show(sym);	    lastExpr = tmpLastExpr;	    Primitive p = primitives.getPrimitive(sym);	    switch (p) {	    case UNBOX:		assert args.length == 1;		MSILType t = msilType(args[0].type);		Item i = genLoad(args[0], t);		if (!i.type.isValueType()) {                    MethodInfo method = (MethodInfo)tc.getMethod(sym);		    code.Emit(OpCodes.Call, method);                    i = returnsVoid(method) ? items.VoidItem()                        : items.StackItem(msilType(method.ReturnType));                    return coerce(i, resType);                }                if (sym == primitives.UNBOX_UVALUE) {                    return items.VoidItem();                }		return i;	    }	    MSILType convTo = primitiveConvert(sym);	    if (convTo != null) {		assert args.length == 1;		genLoad(args[0], convTo);		return items.StackItem(convTo);	    }	    return check(invokeMethod(sym, args, resType, true));	case Select(Tree qualifier, _):	    // scala.Any.==	    if (sym == defs.ANY_EQEQ) {		return genEq(qualifier, args[0]);	    }	    // scala.Any.!=	    if (sym == defs.ANY_BANGEQ) {		return negate(genEq(qualifier, args[0]));	    }	    // java.lang.String.substring(int start, int end) needs conversion	    // to System.String.Substring(int start, int length)	    if (sym == tc.SYM_SUBSTRING_INT_INT) {		assert args.length == 2;		genLoad(qualifier, MSILType.STRING);		genLoad(args[0], MSILType.I4);		code.Emit(OpCodes.Dup);		code.Emit(OpCodes.Neg);		genLoad(args[1], MSILType.I4);		code.Emit(OpCodes.Add);		code.Emit(OpCodes.Call, tc.SUBSTRING_INT_INT);		return coerce(items.StackItem(MSILType.STRING), resType);	    }	    if (sym == tc.SYM_COMPARE_TO_IGNORE_CASE) {		assert args.length == 1;		genLoad(qualifier, MSILType.STRING);		genLoad(args[0], MSILType.STRING);		code.Emit(OpCodes.Ldc_I4_1);		code.Emit(OpCodes.Call, tc.COMPARE_TO_IGNORE_CASE);		return coerce(items.StackItem(MSILType.STRING), resType);	    }	    if (isPrimitiveArrayOp(sym)) {		Primitive prim = primitives.getPrimitive(sym);		loadArgs(args, tc.getMethod(sym).GetParameters());		Type elemType = getArrayElemType(prim);		switch (prim) {		case ZARRAY_LENGTH: case BARRAY_LENGTH: case SARRAY_LENGTH:		case CARRAY_LENGTH: case IARRAY_LENGTH: case LARRAY_LENGTH:		case FARRAY_LENGTH: case DARRAY_LENGTH: case OARRAY_LENGTH:		    code.Emit(OpCodes.Ldlen);		    return items.StackItem(MSILType.I4);		case NEW_ZARRAY:		case NEW_BARRAY:		case NEW_SARRAY:		case NEW_CARRAY:		case NEW_IARRAY:		case NEW_LARRAY:		case NEW_FARRAY:		case NEW_DARRAY:		    //case NEW_OARRAY:		    code.Emit(OpCodes.Newarr, elemType);		    return items.StackItem(MSILType.ARRAY(msilType(elemType)));		case ZARRAY_GET: case BARRAY_GET: case SARRAY_GET:		case CARRAY_GET: case IARRAY_GET: case LARRAY_GET:		case FARRAY_GET: case DARRAY_GET: case OARRAY_GET:		    MSILType mType = MSILArrayElemType(elemType);		    emitLdelem(mType);		    return items.StackItem(mType);		case ZARRAY_SET: case BARRAY_SET: case SARRAY_SET:		case CARRAY_SET: case IARRAY_SET: case LARRAY_SET:		case FARRAY_SET: case DARRAY_SET: case OARRAY_SET:		    emitStelem(MSILArrayElemType(elemType));		    return items.VoidItem();		}	    }  	    if (isPrimitiveOp(sym)) {		assert args.length <= 1;		Tree right = args.length > 0 ? args[0] : Tree.Empty;		return primitiveOp(primitives.getPrimitive(sym),				   qualifier, right, resType); 	    }	    Symbol owner = sym.owner();	    Type t = tc.getType(owner);	    assert t != null;	    if (t.IsEnum()) {		Primitive enumOp = null;		if (sym.name == Names.EQ) enumOp = Primitive.EQ;		else if (sym.name == Names.NE) enumOp = Primitive.NE;		else if (sym.name == Names.LT) enumOp = Primitive.LT;		else if (sym.name == Names.LE) enumOp = Primitive.LE;		else if (sym.name == Names.GT) enumOp = Primitive.GT;		else if (sym.name == Names.GE) enumOp = Primitive.GE;		else if (sym.name == Names.OR) enumOp = Primitive.OR;		else if (sym.name == Names.AND) enumOp = Primitive.AND;		else if (sym.name == Names.XOR) enumOp = Primitive.XOR;		if (enumOp != null) {		    assert args.length == 1;		    return primitiveOp(enumOp, qualifier, args[0], resType);		}	    }	    switch (qualifier.type) {	    case TypeRef(_, _, _):	    case SingleType(_, _):	    case ThisType(_):		MethodBase method = tc.getMethod(sym);		assert method != null : Debug.show(sym);		boolean virtualCall = false;		if (!method.IsStatic() || becomesStatic(sym)) {		    // FIXME: after the Super attribution is correct		    switch (qualifier) {		    case Super(_, _):			load(items.SelfItem(tc.getType(currentClass)));			break;		    default:			genAddr(qualifier, msilType(qualifier));			virtualCall = !msilType(qualifier).isValueType();		    }		}		lastExpr = tmpLastExpr;		return check(invokeMethod(sym, args, resType,                                          virtualCall || method.IsAbstract()));	    default:		throw Debug.abort(Debug.show(fun));	    } // switch(qualifier.type) 	case TypeApply(Tree tfun, Tree[] targs):	    final Symbol tsym = tfun.symbol();	    //System.out.println("gen.TypeApply: " + Debug.show(tsym) + " toType " + resType);	    if (primitives.isPrimitive(tsym)) {		return primitiveOp(primitives.getPrimitive(tsym),				   ((Select)tfun).qualifier,				   targs[0], resType);	    }	    throw Debug.abort(Debug.show(fun));	default:	    throw Debug.abort(Debug.show(fun));	} // switch (fun)    } //genApply()