[kaffe] CVS kaffe-extras (guilhem): New patch for KJC: methods with a target reference should use the class name
Kaffe CVS
Kaffe Mailing List <kaffe@kaffe.org>
Sat Sep 27 05:27:02 2003
PatchSet 14
Date: 2003/09/27 12:26:39
Author: guilhem
Branch: HEAD
Tag: (none)
Log:
New patch for KJC: methods with a target reference should use the class name
of the target reference as prefix and not the original solved method's class name.
Members:
build.xml:1.8->1.9
patches/kjc-method-call.diff:INITIAL->1.1
Index: kaffe-extras/build.xml
diff -u kaffe-extras/build.xml:1.8 kaffe-extras/build.xml:1.9
--- kaffe-extras/build.xml:1.8 Tue Sep 23 18:29:52 2003
+++ kaffe-extras/build.xml Sat Sep 27 12:26:39 2003
@@ -245,6 +245,9 @@
<patch patchfile="${patches_dir}/kjc-nested-class-loading.diff"
strip="1"
dir="${kjcsuite_dir}"/>
+ <patch patchfile="${patches_dir}/kjc-method-call.diff"
+ strip="1"
+ dir="${kjcsuite_dir}"/>
<touch file="${kjcsuite_unpacked_stamp}"/>
</target>
===================================================================
Checking out kaffe-extras/patches/kjc-method-call.diff
RCS: /home/cvs/kaffe/kaffe-extras/patches/kjc-method-call.diff,v
VERS: 1.1
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe-extras/patches/kjc-method-call.diff Sat Sep 27 12:26:41 2003
@@ -0,0 +1,138 @@
+diff -x KjcScanner.java -ur kopi-2.1B/src/kjc/CMethod.java kjc-suite-2.1B.new/src/kjc/CMethod.java
+--- kopi-2.1B/src/kjc/CMethod.java 2003-09-26 19:29:48.000000000 +0200
++++ kjc-suite-2.1B.new/src/kjc/CMethod.java 2003-09-25 17:48:51.000000000 +0200
+@@ -550,6 +550,7 @@
+ // ----------------------------------------------------------------------
+ // CODE GENERATION
+ // ----------------------------------------------------------------------
++ //
+
+ /**
+ * Generates a sequence of bytecode
+@@ -557,7 +558,25 @@
+ * @param nonVirtual force non-virtual dispatching
+ */
+ public void genCode(GenerationContext context, boolean nonVirtual) {
++ genCode(context, null, nonVirtual);
++ }
++
++ /**
++ * Generates a sequence of bytecode
++ * @param code the code sequence
++ * @param prefixClass the class that should be used as a prefix in the method call.
++ * @param nonVirtual force non-virtual dispatching
++ */
++ public void genCode(GenerationContext context, CClass prefixClass,
++ boolean nonVirtual) {
+ CodeSequence code = context.getCodeSequence();
++
++ if (prefixClass == null)
++ prefixClass = owner;
++
++ if (!prefixClass.descendsFrom(owner))
++ throw new IllegalArgumentException(
++ "prefixClass doesn't descends from the owner of the method");
+
+ if (getOwner().isInterface()) {
+ int size = 0;
+@@ -566,7 +585,7 @@
+ size += parameters[i].getSize();
+ }
+
+- code.plantInstruction(new InvokeinterfaceInstruction(getPrefixName(),
++ code.plantInstruction(new InvokeinterfaceInstruction(prefixClass.getQualifiedName(),
+ getIdent(),
+ getSignature(),
+ size + 1)); // this
+@@ -583,7 +602,7 @@
+ }
+
+ code.plantMethodRefInstruction(opcode,
+- getPrefixName(),
++ prefixClass.getQualifiedName(),
+ getIdent(),
+ getSignature());
+ }
+diff -x KjcScanner.java -ur kopi-2.1B/src/kjc/JMethodCallExpression.java kjc-suite-2.1B.new/src/kjc/JMethodCallExpression.java
+--- kopi-2.1B/src/kjc/JMethodCallExpression.java 2002-07-15 20:53:33.000000000 +0200
++++ kjc-suite-2.1B.new/src/kjc/JMethodCallExpression.java 2003-09-26 19:05:46.000000000 +0200
+@@ -40,7 +40,7 @@
+ */
+ public JMethodCallExpression(TokenReference where,
+ JExpression prefix,
+- String ident,
++ String ident,
+ JExpression[] args)
+ {
+ super(where);
+@@ -133,6 +133,8 @@
+
+ findMethod(context, local, argTypes);
+
++ adjustMethodCall(context, local);
++
+ CReferenceType[] exceptions = method.getThrowables();
+
+ for (int i = 0; i < exceptions.length; i++) {
+@@ -281,6 +283,13 @@
+ return this;
+ }
+
++ protected void adjustMethodCall(CExpressionContext context, CClass local)
++ {
++ // Make a stupid decision. Take the class in the prefix to build the call prefix.
++ if (prefix != null)
++ prefixClass = prefixType.getCClass();
++ }
++
+ protected void findMethod(CExpressionContext context, CClass local, CType[] argTypes) throws PositionedError {
+ TypeFactory factory = context.getTypeFactory();
+
+@@ -316,9 +325,20 @@
+
+ try {
+ if (! prefix.getType(factory).isTypeVariable()) {
+- // FIX it lackner 19.11.01 used for internalInitLoadDefinition of PPage : prefix instanceof JSuperExpression
+- method = prefix.getType(factory).getCClass().lookupMethod(context, local, (prefix instanceof JThisExpression || prefix instanceof JSuperExpression) ? null : prefix.getType(factory), ident, argTypes, prefix.getType(factory).getArguments());
+- prefixType = prefix.getType(factory);
++ // FIX it lackner 19.11.01 used for internalInitLoadDefinition of PPage : prefix instanceof JSuperExpression
++ if (prefix instanceof JThisExpression || prefix instanceof JSuperExpression)
++ prefixType = null;
++ else
++ prefixType = prefix.getType(factory);
++
++ method =
++ prefix.getType(factory).getCClass().
++ lookupMethod(context, local,
++ prefixType, ident, argTypes,
++ prefix.getType(factory).getArguments());
++
++ if (prefixType == null)
++ prefixType = prefix.getType(factory);
+ } else {
+ // find method in a type of the bound;
+ CReferenceType[] bound = ((CTypeVariable) prefix.getType(factory)).getBounds();
+@@ -364,7 +384,7 @@
+ }
+ throw new CMethodNotFoundError(getTokenReference(), this, prefixName + ident, argTypes);
+ }
+-}
++ }
+ // ----------------------------------------------------------------------
+ // CODE GENERATION
+ // ----------------------------------------------------------------------
+@@ -403,7 +423,7 @@
+ for (int i = 0; i < args.length; i++) {
+ args[i].genCode(context, false);
+ }
+- method.genCode(context, forceNonVirtual);
++ method.genCode(context, prefixClass, forceNonVirtual);
+
+ if (discardValue) {
+ code.plantPopInstruction(getType(factory));
+@@ -421,4 +441,5 @@
+ protected CMethod method;
+ protected CType type;
+ protected CType prefixType;
++ protected CClass prefixClass;
+ }