This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: module constant values
On Dec 15, 2011, at 9:39 PM, Per Bothner wrote:
So I'm inclined to think the best fix is to not create the
BindingInitializer
in the first case (less work that way), perhaps changing SetExp
somewhat like:
else if ((decl.shouldEarlyInit() || decl.isAlias())
&& decl.context instanceof ModuleExp
&& isDefining() && ! decl.ignorable())
{
if (decl.shouldEarlyInit()
&& Attribute.get(decl.field, "ConstantValue") == null)
BindingInitializer.create(decl, new_value, comp);
if (needValue)
{
decl.load(this, 0, comp, Target.pushObject);
valuePushed = true;
}
}
Maybe it would be cleaner to add to ConstantValueAttr a method:
public static ConstantValueAttr get(AttrContainer container) {
return Attribute.get(container, "ConstantValue");
}
It's possible the above may not work - perhaps the ConstantValueAttr
is created too late. It seems like it should be ok, but perhaps you
can look into it?
Yup, that works.
Index: gnu/expr/SetExp.java
===================================================================
--- gnu/expr/SetExp.java (revision 7106)
+++ gnu/expr/SetExp.java (working copy)
@@ -174,7 +174,8 @@
&& decl.context instanceof ModuleExp
&& isDefining() && ! decl.ignorable())
{
- if (decl.shouldEarlyInit())
+ if (decl.shouldEarlyInit()
+ && Attribute.get(decl.field, "ConstantValue") == null)
BindingInitializer.create(decl, new_value, comp);
if (needValue)
{
Field#setConstantValue() is called during ModuleExp#allocFields()
in Compilation#process(COMPILE_SETUP), and SetExp#compile() doesn't
get called until Compilation#generateBytecode in process(COMPILED).
--
Jamison Hope
The PTR Group
www.theptrgroup.com