[Nice-commit] Nice/src/gnu/expr ThisExp.java,1.3,1.4 Compilation.java,1.21,1.22
Brought to you by:
bonniot
From: Daniel B. <bo...@us...> - 2004-03-20 15:59:24
|
Update of /cvsroot/nice/Nice/src/gnu/expr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv403/src/gnu/expr Modified Files: ThisExp.java Compilation.java Log Message: Compile dispatch methods as member methods whenever possible, to make integration with Java tools and code easier. Index: ThisExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/gnu/expr/ThisExp.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ThisExp.java 27 Nov 2003 21:02:13 -0000 1.3 --- ThisExp.java 20 Mar 2004 15:49:24 -0000 1.4 *************** *** 39,42 **** --- 39,43 ---- else comp.getCode().emitPushThis(); + target.compileFromStack(comp, comp.getCode().topType()); } Index: Compilation.java =================================================================== RCS file: /cvsroot/nice/Nice/src/gnu/expr/Compilation.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Compilation.java 17 Jan 2004 17:13:36 -0000 1.21 --- Compilation.java 20 Mar 2004 15:49:24 -0000 1.22 *************** *** 987,990 **** --- 987,993 ---- { LambdaExp source = (LambdaExp) lexp.applyMethods.elementAt(j); + int min_args = source.min_args; + if (source.isClassMethod()) + min_args++; // Select the subset of source.primMethods[*] that are suitable // for the current apply method. *************** *** 993,1002 **** boolean varArgs = source.max_args < 0 || Compilation.usingTailCalls ! || source.max_args >= source.min_args + numMethods; int methodIndex; boolean skipThisProc = false; if (i < 5) // Handling apply0 .. apply4 { ! methodIndex = i - source.min_args; if (methodIndex < 0 || methodIndex >= numMethods || (methodIndex == numMethods - 1 && varArgs)) --- 996,1005 ---- boolean varArgs = source.max_args < 0 || Compilation.usingTailCalls ! || source.max_args >= min_args + numMethods; int methodIndex; boolean skipThisProc = false; if (i < 5) // Handling apply0 .. apply4 { ! methodIndex = i - min_args; if (methodIndex < 0 || methodIndex >= numMethods || (methodIndex == numMethods - 1 && varArgs)) *************** *** 1007,1011 **** else // Handling applyN { ! methodIndex = 5 - source.min_args; if (methodIndex > 0 && numMethods <= methodIndex && ! varArgs) skipThisProc = true; --- 1010,1014 ---- else // Handling applyN { ! methodIndex = 5 - min_args; if (methodIndex > 0 && numMethods <= methodIndex && ! varArgs) skipThisProc = true; *************** *** 1066,1072 **** code.emitLoad(code.getArg(2)); code.emitArrayLength(); ! if (source.min_args != 0) { ! code.emitPushInt(source.min_args); code.emitSub(Type.int_type); } --- 1069,1075 ---- code.emitLoad(code.getArg(2)); code.emitArrayLength(); ! if (min_args != 0) { ! code.emitPushInt(min_args); code.emitSub(Type.int_type); } *************** *** 1074,1089 **** } ! int needsThis = primMethod.getStaticFlag() ? 0 : 1; ! if (needsThis > 0) code.emitPushThis(); Declaration var = source.firstDecl(); for (int k = 0; k < singleArgs; k++) { ! if (counter != null && k >= source.min_args) { code.emitLoad(counter); code.emitIfIntLEqZero(); ! code.emitInvoke(primMethods[k - source.min_args]); code.emitElse(); pendingIfEnds++; --- 1077,1100 ---- } ! int argumentStart = 2; ! ! if (source.getImportsLexVars()) code.emitPushThis(); + if (source.isClassMethod()) + { + code.emitLoad(code.getArg(argumentStart++)); + Type ptype = primMethod.getDeclaringClass(); + ptype.emitCoerceFromObject(code); + } + Declaration var = source.firstDecl(); for (int k = 0; k < singleArgs; k++) { ! if (counter != null && k >= min_args) { code.emitLoad(counter); code.emitIfIntLEqZero(); ! code.emitInvoke(primMethods[k - min_args]); code.emitElse(); pendingIfEnds++; *************** *** 1099,1103 **** } else // apply'i method ! code.emitLoad(code.getArg(k + 2)); Type ptype = var.getType(); if (ptype != Type.pointer_type) --- 1110,1114 ---- } else // apply'i method ! code.emitLoad(code.getArg(k + argumentStart)); Type ptype = var.getType(); if (ptype != Type.pointer_type) |