Exactly.  I want to be conservative and not make an optimization I can't prove, 
however obscure the possibility.

As to user lzo's, they output lzs (i.e., our class-ified version of 
javascript), so the class analysis tools can still be run over lzo's and do the 
right thing.  In fact, the test case that I compiled has a zillion independent 
lzo-compiled libraries, so I am confident that this works as expected.

Eventually, I would like warnWithThis to default to on.  And also have a 
warnUnknownGlobal that defaults to on.

On 2011-03-09, at 14:16, Donald Anderson wrote:

> 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
> 
> 
> 
> 
> 


Reply via email to