if (type2MSILType(qualifier.type). isType(TypeCreator.SYSTEM_STRING) || type2MSILType(args[0].type). isType(TypeCreator.SYSTEM_STRING) ) {  Item i1 = load(gen(qualifier)); Item i2 = load(gen(args[0])); code.Emit(OpCodes.Call, TypeCreator.CONCAT_OBJECT_OBJECT); return items.StackItem(MSILType.REF(TypeCreator.SYSTEM_STRING));
load(gen(qualifier)); load(gen(args[0])); code.Emit(OpCodes.Call, TypeCreator.CONCAT_OBJECT_OBJECT); return items.StackItem(MSILType.STRING_REF); }  if (isPrimitiveArrayOp(sym)) { Primitive prim = primitives.getPrimitive(sym); loadArgs(args, tc.getMethod(sym).GetParameters()); Type elemType = getArrayType(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:  code.Emit(OpCodes.Newarr, elemType); return items.StackItem(MSILType.ARRAY(type2MSILType(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: emitLdelem(MSILArrayElemType(elemType)); return items.StackItem(MSILType.BOOL);  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();
    Item genApply(Tree fun, Tree[] args, MSILType resType) {	boolean tmpLastStatement = lastStatement; lastStatement = false;	Symbol sym = fun.symbol();	switch (fun) {	case Ident(_):	    emitThis();	    lastStatement = tmpLastStatement;	    return check(invokeMethod(sym, args, resType));	case Select(Tree qualifier, Name selector)://  	    log("genApply.Select: " + dumpSym(sym));//  	    log("\tfun: " + Debug.show(fun));//  	    log("\tqualifier: " + Debug.show(qualifier));//  	    log("\tqualifier.symbol(): " + Debug.show(qualifier.symbol()));//  	    log("\tqualifier.type: " + Debug.show(qualifier.type));//  	    if (primitives.isPrimitive(sym)) {// 		log("genApply: TypeRef: " + primitives.getPrimitiveIndex(sym));// 		log("\t" + dumpSym(sym));// 	    }// 	    if (sym == global.primitives.AS_UVALUE) {// 		return coerce(gen(qualifier, MSILType.VOID), MSILType.VOID);// 	    }	    if (sym == global.primitives.BOX_UVALUE) {		return items.StaticItem(MSILType.REF(SCALA_UNIT), RUNTIME_UNIT_VAL);	    }	    if (selector == Names.PLUS) {	    //if (sym == defs.STRING_PLUS_ANY) {		assert args.length == 1;		if (type2MSILType(qualifier.type).		    isType(TypeCreator.SYSTEM_STRING) ||		    type2MSILType(args[0].type).		    isType(TypeCreator.SYSTEM_STRING) )		{		    //log("genApply: + -> " + dumpSym(sym));		    Item i1 = load(gen(qualifier));		    Item i2 = load(gen(args[0]));		    code.Emit(OpCodes.Call, TypeCreator.CONCAT_OBJECT_OBJECT);		    return items.StackItem(MSILType.REF(TypeCreator.SYSTEM_STRING));		}	    }	    switch (qualifier.type) {	    case TypeRef(_, _, _):	    case SingleType(_, _):// 		log("genApply.Select: " + dumpSym(sym));// 		log("\tfun: " + Debug.show(fun));// 		log("\tqualifier: " + Debug.show(qualifier));// 		log("\tqualifier.symbol(): " + Debug.show(qualifier.symbol()));// 		log("\tqualifier.type: " + Debug.show(qualifier.type));		//log("genApply: qualifier " + dumpSym(qualifier.symbol()) + "; selector = " + selector);		switch (qualifier) {		case Apply(Select(Tree qual, Name sel), Tree[] boxArgs):		    if (sel == Name.fromString("box")) {			if (args.length == 0) {			    if (selector == Names.MINUS) {				Item item = load(gen(boxArgs[0]));				code.Emit(OpCodes.Neg);				return check(item);			    }			    if (selector == Names.TILDE) {				Item item = load(gen(boxArgs[0]));				code.Emit(OpCodes.Not);				return check(item);			    }			    if (selector == Names.BANG) {				Item.CondItem cond = mkCond(gen(boxArgs[0]));				//return items.CondItem(cond.test, cond.failure, cond.success);				return items.CondItem(negate(cond.test),						      cond.success, cond.failure);			    }			} else 	if (args.length == 1) {			    assert sym.name == selector;			    return binaryOp(boxArgs[0], sym, args[0], resType);			}		    }		    break;		}		if (sym == defs.EQEQ) {		    load(gen(qualifier));		    load(gen(args[0]));		    code.Emit(OpCodes.Callvirt, TypeCreator.OBJECT_EQUALS);		    return items.StackItem(MSILType.BOOL);		} 		if (sym == defs.BANGEQ) { 		    log("genApply: != : " + dumpSym(sym)); 		    Item i1 = load(gen(qualifier)); 		    Item i2 = load(gen(args[0]));		     		    return items.CondItem(Test.Binary(Test.NE, i2.type),					  null, null); 		}		if (selector == Names.BANG) {		    Item.CondItem cond =  mkCond(gen(qualifier));		    // swap the failure and success chains		    return items.CondItem(cond.test, cond.failure, cond.success);		}		if (sym == defs.THROW) {		    load(gen(qualifier));		    code.Emit(OpCodes.Throw);		    code.Emit(OpCode.Ldnull);		    //return items.StackItem(MSILType.NULL_REF);		    return items.StackItem(MSILType.OBJECT);		}		if (sym == defs.STRING_PLUS_ANY || sym == STRING_CONCAT) {		    load(gen(qualifier));		    load(gen(args[0]));		    code.Emit(OpCodes.Call, TypeCreator.CONCAT_OBJECT_OBJECT);		    return items.StackItem(resType);		}		MethodBase method = tc.getMethod(sym);		if (!method.IsStatic || becomesStatic(sym)) {		    load(gen(qualifier));    		}		lastStatement = tmpLastStatement;		return check(invokeMethod(sym, args, resType));	    case UnboxedArrayType(_):		if (primitives.isPrimitive(sym)) {		    log("genApply: " + primitives.getPrimitive(sym));		} else {		    log("genApply: Array stuff is not primitive!");		}		// handle array.length		if (selector == Names.length) {		    assert args.length == 0;		    load(gen(qualifier));		    code.Emit(OpCodes.Ldlen);		    return items.StackItem(MSILType.I4);		}		// handle array indexing		else if (selector == Names.apply) {		    assert args.length == 1;		    Item i = load(gen(qualifier));		    MSILType elemtype = ((MSILType.ARRAY) i.type).t;		    load(gen(args[0]));		    switch (elemtype) {		    case I1: code.Emit(OpCodes.Ldelem_I1); break;		    case I2: code.Emit(OpCodes.Ldelem_I2); break;		    case I4: code.Emit(OpCodes.Ldelem_I4); break;		    case I8: code.Emit(OpCodes.Ldelem_I8); break;		    case R4: code.Emit(OpCodes.Ldelem_R4); break;		    case R8: code.Emit(OpCodes.Ldelem_R8); break;		    case BOOL: code.Emit(OpCodes.Ldelem_I1); break;		    case REF(_): code.Emit(OpCodes.Ldelem_Ref); break;		    case ARRAY(_): code.Emit(OpCodes.Ldelem_Ref); break;		    default:			throw new ApplicationError();		    }		    return items.StackItem(elemtype);		}		// hande array update		else if (selector == Names.update) {		    assert args.length == 2;		    Item i = load(gen(qualifier));		    MSILType elemtype = ((MSILType.ARRAY) i.type).t;		    load(gen(args[0]));		    load(gen(args[1]));		    switch (elemtype) {		    case I1: code.Emit(OpCodes.Stelem_I1); break;		    case I2: code.Emit(OpCodes.Stelem_I2); break;		    case I4: code.Emit(OpCodes.Stelem_I4); break;		    case I8: code.Emit(OpCodes.Stelem_I8); break;		    case R4: code.Emit(OpCodes.Stelem_R4); break;		    case R8: code.Emit(OpCodes.Stelem_R8); break;		    case BOOL: code.Emit(OpCodes.Stelem_I1); break;		    case REF(_): code.Emit(OpCodes.Stelem_Ref); break;		    case ARRAY(_): code.Emit(OpCodes.Stelem_Ref); break;		    default:			throw new ApplicationError();		    }		    return items.VoidItem();		}		throw new ApplicationError("Applying selector '" + selector + 					   "' to qualifier " +					   dumpSym(qualifier.symbol()));	    default:		throw new ApplicationError();	    } // switch(qualifier.type)// 	case TypeApply(Select(Tree qualifier,_), Tree[] targs): 	case TypeApply(Tree tfun, Tree[] targs):	    final Symbol tsym = tfun.symbol();	    switch (tfun) {	    case Select(Tree qualifier, _):		Item i = load(gen(qualifier));		final Type type = tc.getTypeFromType(targs[0].type);		if (tsym == defs.IS) {		    code.Emit(OpCodes.Isinst, type);		    return mkCond(items.StackItem(MSILType.REF(type)));		}		if (tsym == defs.AS) {		    if (!i.type.isType(type) && type != TypeCreator.SYSTEM_OBJECT) {			//log("genApply: casting item: " + i + " to type: " + type);			code.Emit(OpCodes.Castclass, type);		    }		    return items.StackItem(MSILType.REF(type));		}		log("genApply.TypeApply.Select: Dunno how to process TypeApply: "		    + Debug.show(fun));		log("\tTypeApply.fun: " + Debug.show(tfun));		log("\tTypeApply.fun.symbol(): " + tsym);		throw new ApplicationError();	    default:		log("default: genApply.TypeApply: Dunno how to process TypeApply: "		    + Debug.show(fun));		log("\tTypeApply.fun: " + Debug.show(tfun));		log("\tTypeApply.fun.symbol(): " + tsym);		throw new ApplicationError();	    }	default:	    throw new ApplicationError		("genApply: Unknown function node: " + Debug.show(fun));	} // switch (fun)    } //genApply()