PatchSet 16 Date: 2003/09/28 19:06:50 Author: guilhem Branch: HEAD Tag: (none) Log: Last update was containing a class cast misbehaviour when using 'super'. That one should be right (hopefully ;-) ).
Members: patches/kjc-method-call.diff:1.2->1.3 Index: kaffe-extras/patches/kjc-method-call.diff diff -u kaffe-extras/patches/kjc-method-call.diff:1.2 kaffe-extras/patches/kjc-method-call.diff:1.3 --- kaffe-extras/patches/kjc-method-call.diff:1.2 Sun Sep 28 18:04:23 2003 +++ kaffe-extras/patches/kjc-method-call.diff Sun Sep 28 19:06:50 2003 @@ -1,5 +1,59 @@ ---- 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 +--- kjc-suite-2.1B/src/kjc/CMethod.java 2003-09-28 21:02:42.000000000 +0200 ++++ kjc-suite-2.1B.new/src/kjc/CMethod.java 2003-09-28 20:46:29.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 " + prefixClass + " doesn't descends from the owner " + owner + " of the method " + getIdent()); + + 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()); + } +--- kjc-suite-2.1B/src/kjc/JMethodCallExpression.java 2003-09-28 21:02:42.000000000 +0200 ++++ kjc-suite-2.1B.new/src/kjc/JMethodCallExpression.java 2003-09-28 20:58:09.000000000 +0200 @@ -40,7 +40,7 @@ */ public JMethodCallExpression(TokenReference where, @@ -18,7 +72,7 @@ CReferenceType[] exceptions = method.getThrowables(); for (int i = 0; i < exceptions.length; i++) { -@@ -281,6 +283,20 @@ +@@ -281,6 +283,21 @@ return this; } @@ -26,12 +80,13 @@ + { + prefixClass = null; + -+ if (prefix != null && !method.isStatic() && -+ !method.getOwner().getJavaName().equals("java.lang.Object")) -+ prefixClass = prefixType.getCClass(); ++ // Case already handled by findMethod. ++ if (method.getOwner().getJavaName().equals("java.lang.Object") || ++ prefix instanceof JSuperExpression) ++ return; + -+ if (prefix instanceof JSuperExpression) -+ prefixClass = prefixType.getCClass().getSuperClass(); ++ if (prefix != null && !method.isStatic()) ++ prefixClass = prefixType.getCClass(); + else if (prefix instanceof JTypeNameExpression) + prefixClass = ((JTypeNameExpression)prefix).getClassType().getCClass(); + } @@ -39,7 +94,7 @@ protected void findMethod(CExpressionContext context, CClass local, CType[] argTypes) throws PositionedError { TypeFactory factory = context.getTypeFactory(); -@@ -316,9 +332,20 @@ +@@ -316,9 +333,20 @@ try { if (! prefix.getType(factory).isTypeVariable()) { @@ -63,7 +118,7 @@ } else { // find method in a type of the bound; CReferenceType[] bound = ((CTypeVariable) prefix.getType(factory)).getBounds(); -@@ -364,7 +391,7 @@ +@@ -364,7 +392,7 @@ } throw new CMethodNotFoundError(getTokenReference(), this, prefixName + ident, argTypes); } @@ -72,7 +127,7 @@ // ---------------------------------------------------------------------- // CODE GENERATION // ---------------------------------------------------------------------- -@@ -403,7 +430,7 @@ +@@ -403,7 +431,7 @@ for (int i = 0; i < args.length; i++) { args[i].genCode(context, false); } @@ -81,63 +136,9 @@ if (discardValue) { code.plantPopInstruction(getType(factory)); -@@ -421,4 +448,5 @@ +@@ -421,4 +449,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()); - } _______________________________________________ kaffe mailing list [EMAIL PROTECTED] http://kaffe.org/cgi-bin/mailman/listinfo/kaffe