[kaffe] CVS kaffe-extras (guilhem): Updated KJC method call patch.

Kaffe CVS cvs-commits at kaffe.org
Sun Sep 28 11:05:03 PDT 2003


PatchSet 15 
Date: 2003/09/28 18:04:23
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Updated KJC method call patch.

To ensure compatibility we must follow JLS 13.1: java.lang.Object method
should be called directly, if a Typename is precised use it, if super is used
use super class type to call the method.

Members: 
	patches/kjc-method-call.diff:1.1->1.2 

Index: kaffe-extras/patches/kjc-method-call.diff
diff -u kaffe-extras/patches/kjc-method-call.diff:1.1 kaffe-extras/patches/kjc-method-call.diff:1.2
--- kaffe-extras/patches/kjc-method-call.diff:1.1	Sat Sep 27 12:26:40 2003
+++ kaffe-extras/patches/kjc-method-call.diff	Sun Sep 28 18:04:23 2003
@@ -1,61 +1,5 @@
-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
+--- kjc-suite-2.1B/src/kjc/JMethodCallExpression.java	2003-09-28 19:54:48.000000000 +0200
++++ kjc-suite-2.1B.new/src/kjc/JMethodCallExpression.java	2003-09-28 19:48:12.000000000 +0200
 @@ -40,7 +40,7 @@
     */
    public JMethodCallExpression(TokenReference where,
@@ -74,21 +18,28 @@
      CReferenceType[]	exceptions = method.getThrowables();
  
      for (int i = 0; i < exceptions.length; i++) {
-@@ -281,6 +283,13 @@
+@@ -281,6 +283,20 @@
      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 = null;
++
++    if (prefix != null && !method.isStatic() && 
++        !method.getOwner().getJavaName().equals("java.lang.Object"))
 +      prefixClass = prefixType.getCClass();
++
++    if (prefix instanceof JSuperExpression)
++      prefixClass = prefixType.getCClass().getSuperClass();
++    else if (prefix instanceof JTypeNameExpression)
++      prefixClass = ((JTypeNameExpression)prefix).getClassType().getCClass();
 +  }
 +
    protected void findMethod(CExpressionContext context, CClass local, CType[] argTypes)  throws PositionedError {
      TypeFactory         factory = context.getTypeFactory();
  
-@@ -316,9 +325,20 @@
+@@ -316,9 +332,20 @@
  
        try {
          if (! prefix.getType(factory).isTypeVariable()) {
@@ -112,7 +63,7 @@
          } else {
            // find method in a type of the bound;
            CReferenceType[]        bound =  ((CTypeVariable) prefix.getType(factory)).getBounds();
-@@ -364,7 +384,7 @@
+@@ -364,7 +391,7 @@
        }
        throw new CMethodNotFoundError(getTokenReference(), this, prefixName + ident, argTypes);
      }
@@ -121,7 +72,7 @@
    // ----------------------------------------------------------------------
    // CODE GENERATION
    // ----------------------------------------------------------------------
-@@ -403,7 +423,7 @@
+@@ -403,7 +430,7 @@
      for (int i = 0; i < args.length; i++) {
        args[i].genCode(context, false);
      }
@@ -130,9 +81,63 @@
  
      if (discardValue) {
        code.plantPopInstruction(getType(factory));
-@@ -421,4 +441,5 @@
+@@ -421,4 +448,5 @@
    protected CMethod		method;
    protected CType               type;
    protected CType               prefixType;
 +  protected CClass              prefixClass;
  }
+--- kjc-suite-2.1B/src/kjc/CMethod.java	2003-09-28 19:54: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());
+     }




More information about the kaffe mailing list