To clarify, you're concerned about:
var myglobal = 7;
class devilish {
var myglobal = 666;
}
class myclass extends devilish {
function void bar() {
return myglobal;
}
}
where for whatever reason, we don't know about devilish. I agree with your
analysis. As a practical matter, the classes
we tend to not know about are in the LFC or components (since we have the
complete script for the user program (or can they
break it up into LZOs?)) Even though we hope the LFC would never alias its own
globals, the user could still create a global that
matches a name in the devilish class.
On Mar 9, 2011, at 1:42 PM, P T Withington wrote:
> I missed a glaring logic error in JavascriptGenerator in my previous review:
>
> JavascriptGenerator#1419:
>
> The global table is a red herring. It started out as an attempted solution
> to this problem, but it was an incorrect one. I'm sorry that it is still
> there, because I think it led you down the garden path...
>
> We _can't_ remove globals from possibleInstance if the classdesc is not
> complete. If it's not complete, we don't know that there might not be
> instance vars that alias globals. If the classdesc _is_ complete, we don't
> need possibleInstance, because we know the actual instance from the classdesc.
>
> In fact, the compiler's knowledge of globals is really useless for the
> purposes of computing if we need with(this) or not. The only use for globals
> would be to emit a warning when there are free references that the compiler
> cannot identify as a global.
>
> The real logic of this section should be:
>
> if classdesc complete OR if incomplete but all free references are in
> classdesc:
> rewrite all free references that are in classdesc
> otherwise:
> emit a warning and use with(this)
>
> As a bonus:
>
> if classdesc complete and there are free references _not_ in classdesc:
> compare those free references to known globals and emit a warning for any
> that cannot be identified
>
> Sorry that I missed this.
--
Don Anderson
Java/C/C++, Berkeley DB, systems consultant
voice: 617-306-2057
email: [email protected]
www: http://www.ddanderson.com
blog: http://libdb.wordpress.com