flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: Variable Renaming (was Re: [Falcon] Proposal for new ActionScript language feature: Optionally rename an import)
Date Wed, 05 Oct 2016 18:39:06 GMT

On 10/5/16, 11:13 AM, "Harbs" <harbs.lists@gmail.com> wrote:

>And what’s the reason we’re not just using Foo.someOtherStaticProperty?
>Is this a getter issue?

Getters/Setters need to be defined via Object.defineProperty.  It is the
only way to access a function via a property name (without using
parentheses).  IOW

  function Foo() {}  // defines the class

  Foo.someMethod = function() // defines a method.

  Foo.someVar; // defines a var or const.

But when you use them, you have to write:

  Foo.someMethod()  // note the parenthesis for function call


  Foo.someVar // but no function will be called.

We want getters and setters to be accessed like:

  Foo.someGetter; // calls a function

instead of:


So, we create an Object.defineProperties structure that looks like:

{ someGetter: { get: // the code that would run }}

Once you do that, when scanning Foo for vars and methods, GCC will not see
these getters and setters so it will not think that Foo has a someGetter
property.  GCC is only looking for the pattern of Foo.someMethod =
function and Foo.someVar = initialValue;

So then when you use someGetter as

  var value = Foo.someGetter;

GCC just renames it to a global like:

  var value = xx;

And thus, the someGetter code is never called.


View raw message