This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: define-simple-class in interactive session


Chris Dean wrote:
Here's a question for the list: When I'm running interactively I
sometimes don't have access to classes created with define-simple-class.
Does anyone know why?

unix% kawa -s
#|kawa:1|# (define-simple-class <MyClass> () (x))
#|kawa:2|# (make <MyClass>)                             ; works
MyClass at 79a2e7
#|kawa:3|# (let ((c (make <MyClass>))) c)               ; doesn't work

This ia a ClassLoader problem. I checked in the attached patch. -- --Per Bothner per at bothner dot com http://per.bothner.com/

Index: PrimProcedure.java
===================================================================
RCS file: /cvs/kawa/kawa/gnu/expr/PrimProcedure.java,v
retrieving revision 1.34
diff -u -r1.34 PrimProcedure.java
--- PrimProcedure.java	2 Jan 2003 05:16:13 -0000	1.34
+++ PrimProcedure.java	21 Apr 2003 07:28:52 -0000
@@ -333,6 +333,8 @@
 	    : is_static ? argTypes[i + skipArg]
             : i==0 ? thisType
             : argTypes[i-1];
+	if (comp.immediate && arg_type instanceof ClassType)
+	  comp.usedClass((ClassType) arg_type);
 	Target target =
 	  source == null ? CheckedTarget.getInstance(arg_type, name, i)
 	  : CheckedTarget.getInstance(arg_type, source, i);
@@ -347,12 +349,25 @@
   public void compile (ApplyExp exp, Compilation comp, Target target)
   {
     gnu.bytecode.CodeAttr code = comp.getCode();
+    ClassType mclass;
+    if (method == null)
+      mclass = null;
+    else
+      {
+	mclass = method.getDeclaringClass();
+	if (comp.immediate)
+	  {
+	    comp.usedClass(mclass);
+	    Type rtype = method.getReturnType();
+	    if (rtype instanceof ClassType)
+	      comp.usedClass((ClassType) rtype);
+	  }
+      }
 
     if (opcode() == 183) // invokespecial == primitive-constructor
       {
-	ClassType type = method.getDeclaringClass();
-	code.emitNew(type);
-	code.emitDup(type);
+	code.emitNew(mclass);
+	code.emitDup(mclass);
       }
 
     Expression[] args = exp.getArgs();
@@ -360,7 +375,7 @@
     if (arg_error != null)
       comp.error('e', arg_error);
 
-    compile(getStaticFlag() ? null : method.getDeclaringClass(), args, comp, target);
+    compile(getStaticFlag() ? null : mclass, args, comp, target);
   }
 
   public void compile (Type thisType, Expression[] args, Compilation comp, Target target)
Index: ChangeLog
===================================================================
RCS file: /cvs/kawa/kawa/gnu/expr/ChangeLog,v
retrieving revision 1.234
diff -u -r1.234 ChangeLog
--- ChangeLog	20 Apr 2003 01:57:52 -0000	1.234
+++ ChangeLog	21 Apr 2003 07:28:54 -0000
@@ -1,3 +1,8 @@
+2003-04-21  Per Bothner  <per at bothner dot com>
+
+	* PrimProcedure.java (compileArgs, compile):  Call usedClass on
+	classes declaring method and parameter and return types.
+
 2003-04-19  Per Bothner  <per at bothner dot com>
 
 	* ResolveNames.java:  New class, extends ExpWalker.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]