This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: Package for define-simple-class
Chris Dean wrote:
Does:
(define-simple-class <happy.utils.Bar> () ...)
work?
Not really, or "sort of", depending on how you look at it. It generates
a complicated class name in the top level package: happy$Dtutils$DtBar
I checked into CVS the attached patch. That should fix the problem.
It also makes use of module-name and the -P option.
--
--Per Bothner
per at bothner dot com http://www.bothner.com/per/
Index: ClassExp.java
===================================================================
RCS file: /cvs/kawa/kawa/gnu/expr/ClassExp.java,v
retrieving revision 1.13
diff -u -r1.13 ClassExp.java
--- ClassExp.java 7 Aug 2002 05:23:37 -0000 1.13
+++ ClassExp.java 20 Feb 2003 07:01:15 -0000
@@ -121,7 +121,33 @@
if (! isSimple() || this instanceof ObjectExp)
name = comp.generateClassName(name);
else
- name = comp.mangleNameIfNeeded(name);
+ {
+ int start = 0;
+ StringBuffer nbuf = new StringBuffer(100);;
+ for (;;)
+ {
+ int dot = name.indexOf('.', start);
+ if (dot < 0)
+ break;
+ nbuf.append(comp.mangleNameIfNeeded(name.substring(start,
+ dot)));
+ nbuf.append('.');
+ start = dot + 1;
+ }
+ if (start == 0)
+ {
+ String mainName = comp.mainClass == null ? null
+ : comp.mainClass.getName();
+ int dot = mainName == null ? -1 : mainName.lastIndexOf('.');
+ if (dot > 0)
+ nbuf.append(mainName.substring(0, dot + 1));
+ else if (comp.classPrefix != null)
+ nbuf.append(comp.classPrefix);
+ }
+ if (start < name.length())
+ nbuf.append(comp.mangleNameIfNeeded(name.substring(start)));
+ name = nbuf.toString();
+ }
type.setName(name);
}
return type;
@@ -381,8 +407,7 @@
fld = instanceType.addField(fname, ftype, Access.PUBLIC);
Method impl = instanceType.addMethod(mname, Access.PUBLIC,
ptypes, rtype);
- impl.init_param_slots ();
- code = impl.getCode();
+ code = impl.startCode();
code.emitPushThis();
if (ch == 'g')
{
@@ -411,8 +436,7 @@
{
Method impl = instanceType.addMethod(mname, Access.PUBLIC,
ptypes, rtype);
- impl.init_param_slots ();
- code = impl.getCode();
+ code = impl.startCode();
for (Variable var = code.getCurrentScope().firstVar();
var != null; var = var.nextVar())
code.emitLoad(var);