This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: define-namespace patch
Chris Dean wrote:
Per Bothner <per@bothner.com> wrote:
However, the implementation isn't right. You're doing the re-mapping
at reader-time, but it should be done later at name resolution time.
Aha - that makes sense. Can you point me at the right place to make the
change?
Actually, what I wrote isn't quite right. scanForDefinitions is called
just after "reading" in the case of top-level forms, but it's actually
"name definition time". And (unless we do some non-trivial redesign),
this is probably where we want to resolve namespace prefixes.
So I think the right thing to do is *just after* (rather than just
before) the call to rewrite_car, looking at the returned value.
* If value instanceof ReferenceExp *and* the ReferenceExp is not bound
to a Declaration, then take the ReferenceExp's getName() and try
classNameFromTypeString. If that returns returns non-null, do
value = new QuoteExp(new FString("class:"+className));
* If the value instanceof ReferenceExp *and* the it is bound to a
Declaration that is bound to a ClassExp, use the ClassExp's class.
* If the value instanceof QuoteExp and the constant is a Class or
ClassType, map that to new QuoteExp("class:NAME").
The getTypeFor(Expression) method in Interpreter does most of
what you need, but it may be a bit too permissive. However,
it's probably close enough, if the value is a ReferenceExp:
If (valus instanceof ReferenceExp)
{
Type t = interpreter.getTypeFor(value);
if (t instanceof ClassType)
value = new QuoteExp(new FString("class:"+t.getName());
// else warning? error? see what happens at runtime?
}
--
--Per Bothner
per@bothner.com http://per.bothner.com/