Comment by cromwellian:

  Joel,
   wouldn't this transformation work?

{{{
foo_Names = ["FOO_0", "FOO_1", "FOO_2"];
fooFuncs = { getMessage: [getMessage1, getMessage1, getMessage2] };
}}}
Enum's then become integer ordinals. `FooEnumType.name()` would return  
`foo_Names[ordinal()]`
`FooEnumType.func()` would invoke  
`fooFuncs[obfuscatedFuncName][ordinal](args)`.

The problem is, by the time you reach the JS AST, you've lost any idea that  
these are enums. So it would have to be done at the JDT->Java AST stage I  
think.

This is a special case of object inlining where you know that a given type  
can only be instantiated with N different permutations, all field values  
statically known at compile time. In which case, you can rip all of the  
object's fields out to global singleton and replace them with a pointer  
(integer or other reference)






For more information:
http://code.google.com/p/google-web-toolkit/wiki/EnumOptimizations

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to