You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Harbs <ha...@gmail.com> on 2017/07/16 09:07:22 UTC

[FlexJS] Debugging package

I just added a debugging package to FlexJS. There are two things I don’t know how to do:

1. The debugging functions should disappear in a release build of JS, but I’m not sure how to make the same thing happen in a release build of SWF. I don’t think a debug config is the solution, because the debug statements should be preserved in framework code and only be stripped out for application release builds. Does anyone have ideas on how to go about doing that?

2. I have conditionalBreak commented out of CoreClasses because the debugger statement is not recognized. Where do we need to add that? missing.js?

Harbs

Re: [FlexJS] Debugging package

Posted by Harbs <ha...@gmail.com>.
Because it’s not being imported by CoreClasses. What is making Maven import it?

> On Jul 16, 2017, at 6:25 PM, piotrz <pi...@gmail.com> wrote:
> 
> Let's create jira for that. I'm surprise that Ant build is not complaining
> about that. Why?
> 
> Piotr 
> 
> 
> 
> -----
> Apache Flex PMC
> piotrzarzycki21@gmail.com
> --
> View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-Debugging-package-tp63288p63306.html
> Sent from the Apache Flex Development mailing list archive at Nabble.com.


Re: [FlexJS] Debugging package

Posted by piotrz <pi...@gmail.com>.
Let's create jira for that. I'm surprise that Ant build is not complaining
about that. Why?

Piotr 



-----
Apache Flex PMC
piotrzarzycki21@gmail.com
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-Debugging-package-tp63288p63306.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.

Re: [FlexJS] Debugging package

Posted by Alex Harui <ah...@adobe.com.INVALID>.
It sounds like an interesting challenge, but I would not want to see
special cases like this in the compiler.  I don't understand the need to
extend AS with JS syntax.

In general, if there are different implementations on the various
runtimes, we should invent an API for everyone to use, such as

package org.apache.flex.debugger
{
  public function haltDebugger()

  {
     COMPILE::SWF
     {
        flash.system.System.pause();
     }
     COMPILE::JS
     {
        debugger;
     }
  }
}

There may be other runtimes/platforms we want to support someday.

-Alex

On 7/20/17, 9:41 AM, "Josh Tynjala" <jo...@gmail.com> wrote:

>> > I'm still confused.  If you can use flash.system.System.pause() what
>custom byte code is needed?
>
>I want to be able to write a "debugger" statement in ActionScript and have
>the compiler call flash.system.System.pause() in the generated SWF.
>Calling
>a function in a SWF requires some kind of instructions in bytecode, right?
>
>> Are there other JS statements we need to support some day?  Being able
>>to
>add them to js.swc might be a better plan than having to change the
>compiler for each statement.
>
>The debugger statement is kind of special because the keyword is the
>complete statement. We could certainly fake the debugger statement in
>js.swc because of that (it would only work on the JS side, though).
>
>However, imagine if "throw" didn't exist in ActionScript:
>
>throw new Error("Something went wrong");
>
>I don't think we can fake that one in js.swc.
>
>I appreciate that you're trying to find an easy workaround here. I am
>purposefully challenging myself to implement the debugger statement in the
>compiler, and to make it work in both SWF and JS.
>
>- Josh
>
>
>
>On Thu, Jul 20, 2017 at 9:15 AM, Alex Harui <ah...@adobe.com.invalid>
>wrote:
>
>> I'm still confused.  If you can use flash.system.System.pause() what
>> custom byte code is needed?
>>
>> Are there other JS statements we need to support some day?  Being able
>>to
>> add them to js.swc might be a better plan than having to change the
>> compiler for each statement.
>>
>> -Alex
>>
>> On 7/19/17, 7:37 PM, "Josh Tynjala" <jo...@gmail.com> wrote:
>>
>> >Well, as I said, I already have the compiler parsing the real debugger
>> >statement in AS, and emitting the right JS. I just need to generate
>>some
>> >custom bytecode for SWF and then it will work everywhere.
>> >
>> >- Josh
>> >
>> >On Wed, Jul 19, 2017 at 7:17 PM, Alex Harui <ah...@adobe.com.invalid>
>> >wrote:
>> >
>> >> I think we allow classes to be used as a "statement" for dependency
>> >> management.  CoreClasses.as, for example, has plenty of lines like:
>> >>
>> >>    import org.apache.flex.core.IUIBase; IUIBase;
>> >>
>> >>
>> >> HTH,
>> >> -Alex
>> >>
>> >> On 7/19/17, 6:57 PM, "Josh Tynjala" <jo...@gmail.com> wrote:
>> >>
>> >> >Yes, I'm changing the compiler. The debugger statement is not a
>> >>function.
>> >> >It works like this:
>> >> >
>> >> >debugger;
>> >> >
>> >> >I think that flash.system.System.pause() will work too, and it's
>> >> >documented:
>> >> >
>> >> >https://na01.safelinks.protection.outlook.com/?url=
>> >> http%3A%2F%2Fhelp.adobe
>> >> >.com%2Fen_US%2FFlashPlatform%2Freference%2Factionscript%
>> >> 2F3%2Fflash%2Fsyst
>> >> >em%2FSystem.html%23pause&data=02%7C01%7C%
>> 7C7bb64776e6eb48b8d61908d4cf12
>> >> d04
>> >> >e%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%
>> >> 7C636361127090455464&sdata=I2
>> >> >01iT7jr2mvseuvMIJdUVu1SpRLJimK7Tqdp3n%2B%2Bv8%3D&reserved=0()
>> >> >
>> >> >- Josh
>> >> >
>> >> >On Wed, Jul 19, 2017 at 6:44 PM, Alex Harui
>><ah...@adobe.com.invalid>
>> >> >wrote:
>> >> >
>> >> >> Are you changing the compiler?  I thought you could just add:
>> >> >>
>> >> >>   function debugger{};
>> >> >>
>> >> >> to missing.js so it results in:
>> >> >>
>> >> >>   public class debugger {};
>> >> >>
>> >> >> and
>> >> >>
>> >> >> package flash.debugger {
>> >> >>   native function enterDebugger():void;
>> >> >> }
>> >> >>
>> >> >> to one of our swcs?  Although I have to say I'm a bit
>>uncomfortable
>> >> >>about
>> >> >> adding undocumented Flash APIs to our code base.  We are not
>> >>supposed to
>> >> >> use APIs that are "reverse-engineered".  Do we have proof that
>>Adobe
>> >> >> documented it at one point in time?
>> >> >>
>> >> >> HTH,
>> >> >> -Alex
>> >> >>
>> >> >> On 7/18/17, 5:05 PM, "Josh Tynjala" <jo...@gmail.com> wrote:
>> >> >>
>> >> >> >I'm working on adding support for the debugger statement to the
>> >> >>compiler
>> >> >> >(FLEX-35343). I can successfully emit the debugger statement in
>>the
>> >> >> >generated JS so far.
>> >> >> >
>> >> >> >I'm not yet sure if I can make it work on the SWF side. I figured
>> >>out
>> >> >> >where
>> >> >> >I can generate bytecode instructions in ABCGeneratingReducer. If
>>I
>> >>can
>> >> >> >figure out how to generate bytecode to call enterDebugger() (or
>> >> >>whatever
>> >> >> >the function is called), the debugger statement will work in both
>> >>SWF
>> >> >>and
>> >> >> >JS.
>> >> >> >
>> >> >> >- Josh
>> >> >> >
>> >> >> >On Sun, Jul 16, 2017 at 9:22 AM, Josh Tynjala
>> >><jo...@gmail.com>
>> >> >> >wrote:
>> >> >> >
>> >> >> >> If it were a variable or function, it could be defined
>>somewhere
>> >>like
>> >> >> >> that. It's a statement, though, so it needs to be added to
>>where
>> >> >>Falcon
>> >> >> >> creates the AST from the ActionScript code. Then, it also
>>needs to
>> >> >>emit
>> >> >> >>the
>> >> >> >> statement as JS in FalconJX. On the SWF side, it should be
>> >> >>translated to
>> >> >> >> appropriate bytecode to call enterDebugger().
>> >> >> >>
>> >> >> >> - Josh
>> >> >> >>
>> >> >> >> On Jul 16, 2017 8:56 AM, "Harbs" <ha...@gmail.com> wrote:
>> >> >> >>
>> >> >> >>> What needs to be modified? Does it need to be added to
>> >>NativeJSType
>> >> >> >>> enums? Somewhere else?
>> >> >> >>>
>> >> >> >>> I’m really not clear on when things to be added to that and
>>when
>> >> >>they
>> >> >> >>> need to be in typedefs.
>> >> >> >>>
>> >> >> >>> > On Jul 16, 2017, at 6:51 PM, Harbs <ha...@gmail.com>
>> >>wrote:
>> >> >> >>> >
>> >> >> >>> >> The compiler needs to be modified to support the debugger
>> >> >>statement.
>> >> >> >>>
>> >> >> >>>
>> >> >>
>> >> >>
>> >>
>> >>
>>
>>


Re: [FlexJS] Debugging package

Posted by Josh Tynjala <jo...@gmail.com>.
> > I'm still confused.  If you can use flash.system.System.pause() what
custom byte code is needed?

I want to be able to write a "debugger" statement in ActionScript and have
the compiler call flash.system.System.pause() in the generated SWF. Calling
a function in a SWF requires some kind of instructions in bytecode, right?

> Are there other JS statements we need to support some day?  Being able to
add them to js.swc might be a better plan than having to change the
compiler for each statement.

The debugger statement is kind of special because the keyword is the
complete statement. We could certainly fake the debugger statement in
js.swc because of that (it would only work on the JS side, though).

However, imagine if "throw" didn't exist in ActionScript:

throw new Error("Something went wrong");

I don't think we can fake that one in js.swc.

I appreciate that you're trying to find an easy workaround here. I am
purposefully challenging myself to implement the debugger statement in the
compiler, and to make it work in both SWF and JS.

- Josh



On Thu, Jul 20, 2017 at 9:15 AM, Alex Harui <ah...@adobe.com.invalid>
wrote:

> I'm still confused.  If you can use flash.system.System.pause() what
> custom byte code is needed?
>
> Are there other JS statements we need to support some day?  Being able to
> add them to js.swc might be a better plan than having to change the
> compiler for each statement.
>
> -Alex
>
> On 7/19/17, 7:37 PM, "Josh Tynjala" <jo...@gmail.com> wrote:
>
> >Well, as I said, I already have the compiler parsing the real debugger
> >statement in AS, and emitting the right JS. I just need to generate some
> >custom bytecode for SWF and then it will work everywhere.
> >
> >- Josh
> >
> >On Wed, Jul 19, 2017 at 7:17 PM, Alex Harui <ah...@adobe.com.invalid>
> >wrote:
> >
> >> I think we allow classes to be used as a "statement" for dependency
> >> management.  CoreClasses.as, for example, has plenty of lines like:
> >>
> >>    import org.apache.flex.core.IUIBase; IUIBase;
> >>
> >>
> >> HTH,
> >> -Alex
> >>
> >> On 7/19/17, 6:57 PM, "Josh Tynjala" <jo...@gmail.com> wrote:
> >>
> >> >Yes, I'm changing the compiler. The debugger statement is not a
> >>function.
> >> >It works like this:
> >> >
> >> >debugger;
> >> >
> >> >I think that flash.system.System.pause() will work too, and it's
> >> >documented:
> >> >
> >> >https://na01.safelinks.protection.outlook.com/?url=
> >> http%3A%2F%2Fhelp.adobe
> >> >.com%2Fen_US%2FFlashPlatform%2Freference%2Factionscript%
> >> 2F3%2Fflash%2Fsyst
> >> >em%2FSystem.html%23pause&data=02%7C01%7C%
> 7C7bb64776e6eb48b8d61908d4cf12
> >> d04
> >> >e%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%
> >> 7C636361127090455464&sdata=I2
> >> >01iT7jr2mvseuvMIJdUVu1SpRLJimK7Tqdp3n%2B%2Bv8%3D&reserved=0()
> >> >
> >> >- Josh
> >> >
> >> >On Wed, Jul 19, 2017 at 6:44 PM, Alex Harui <ah...@adobe.com.invalid>
> >> >wrote:
> >> >
> >> >> Are you changing the compiler?  I thought you could just add:
> >> >>
> >> >>   function debugger{};
> >> >>
> >> >> to missing.js so it results in:
> >> >>
> >> >>   public class debugger {};
> >> >>
> >> >> and
> >> >>
> >> >> package flash.debugger {
> >> >>   native function enterDebugger():void;
> >> >> }
> >> >>
> >> >> to one of our swcs?  Although I have to say I'm a bit uncomfortable
> >> >>about
> >> >> adding undocumented Flash APIs to our code base.  We are not
> >>supposed to
> >> >> use APIs that are "reverse-engineered".  Do we have proof that Adobe
> >> >> documented it at one point in time?
> >> >>
> >> >> HTH,
> >> >> -Alex
> >> >>
> >> >> On 7/18/17, 5:05 PM, "Josh Tynjala" <jo...@gmail.com> wrote:
> >> >>
> >> >> >I'm working on adding support for the debugger statement to the
> >> >>compiler
> >> >> >(FLEX-35343). I can successfully emit the debugger statement in the
> >> >> >generated JS so far.
> >> >> >
> >> >> >I'm not yet sure if I can make it work on the SWF side. I figured
> >>out
> >> >> >where
> >> >> >I can generate bytecode instructions in ABCGeneratingReducer. If I
> >>can
> >> >> >figure out how to generate bytecode to call enterDebugger() (or
> >> >>whatever
> >> >> >the function is called), the debugger statement will work in both
> >>SWF
> >> >>and
> >> >> >JS.
> >> >> >
> >> >> >- Josh
> >> >> >
> >> >> >On Sun, Jul 16, 2017 at 9:22 AM, Josh Tynjala
> >><jo...@gmail.com>
> >> >> >wrote:
> >> >> >
> >> >> >> If it were a variable or function, it could be defined somewhere
> >>like
> >> >> >> that. It's a statement, though, so it needs to be added to where
> >> >>Falcon
> >> >> >> creates the AST from the ActionScript code. Then, it also needs to
> >> >>emit
> >> >> >>the
> >> >> >> statement as JS in FalconJX. On the SWF side, it should be
> >> >>translated to
> >> >> >> appropriate bytecode to call enterDebugger().
> >> >> >>
> >> >> >> - Josh
> >> >> >>
> >> >> >> On Jul 16, 2017 8:56 AM, "Harbs" <ha...@gmail.com> wrote:
> >> >> >>
> >> >> >>> What needs to be modified? Does it need to be added to
> >>NativeJSType
> >> >> >>> enums? Somewhere else?
> >> >> >>>
> >> >> >>> I’m really not clear on when things to be added to that and when
> >> >>they
> >> >> >>> need to be in typedefs.
> >> >> >>>
> >> >> >>> > On Jul 16, 2017, at 6:51 PM, Harbs <ha...@gmail.com>
> >>wrote:
> >> >> >>> >
> >> >> >>> >> The compiler needs to be modified to support the debugger
> >> >>statement.
> >> >> >>>
> >> >> >>>
> >> >>
> >> >>
> >>
> >>
>
>

Re: [FlexJS] Debugging package

Posted by Alex Harui <ah...@adobe.com.INVALID>.
I'm still confused.  If you can use flash.system.System.pause() what
custom byte code is needed?

Are there other JS statements we need to support some day?  Being able to
add them to js.swc might be a better plan than having to change the
compiler for each statement.

-Alex

On 7/19/17, 7:37 PM, "Josh Tynjala" <jo...@gmail.com> wrote:

>Well, as I said, I already have the compiler parsing the real debugger
>statement in AS, and emitting the right JS. I just need to generate some
>custom bytecode for SWF and then it will work everywhere.
>
>- Josh
>
>On Wed, Jul 19, 2017 at 7:17 PM, Alex Harui <ah...@adobe.com.invalid>
>wrote:
>
>> I think we allow classes to be used as a "statement" for dependency
>> management.  CoreClasses.as, for example, has plenty of lines like:
>>
>>    import org.apache.flex.core.IUIBase; IUIBase;
>>
>>
>> HTH,
>> -Alex
>>
>> On 7/19/17, 6:57 PM, "Josh Tynjala" <jo...@gmail.com> wrote:
>>
>> >Yes, I'm changing the compiler. The debugger statement is not a
>>function.
>> >It works like this:
>> >
>> >debugger;
>> >
>> >I think that flash.system.System.pause() will work too, and it's
>> >documented:
>> >
>> >https://na01.safelinks.protection.outlook.com/?url=
>> http%3A%2F%2Fhelp.adobe
>> >.com%2Fen_US%2FFlashPlatform%2Freference%2Factionscript%
>> 2F3%2Fflash%2Fsyst
>> >em%2FSystem.html%23pause&data=02%7C01%7C%7C7bb64776e6eb48b8d61908d4cf12
>> d04
>> >e%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%
>> 7C636361127090455464&sdata=I2
>> >01iT7jr2mvseuvMIJdUVu1SpRLJimK7Tqdp3n%2B%2Bv8%3D&reserved=0()
>> >
>> >- Josh
>> >
>> >On Wed, Jul 19, 2017 at 6:44 PM, Alex Harui <ah...@adobe.com.invalid>
>> >wrote:
>> >
>> >> Are you changing the compiler?  I thought you could just add:
>> >>
>> >>   function debugger{};
>> >>
>> >> to missing.js so it results in:
>> >>
>> >>   public class debugger {};
>> >>
>> >> and
>> >>
>> >> package flash.debugger {
>> >>   native function enterDebugger():void;
>> >> }
>> >>
>> >> to one of our swcs?  Although I have to say I'm a bit uncomfortable
>> >>about
>> >> adding undocumented Flash APIs to our code base.  We are not
>>supposed to
>> >> use APIs that are "reverse-engineered".  Do we have proof that Adobe
>> >> documented it at one point in time?
>> >>
>> >> HTH,
>> >> -Alex
>> >>
>> >> On 7/18/17, 5:05 PM, "Josh Tynjala" <jo...@gmail.com> wrote:
>> >>
>> >> >I'm working on adding support for the debugger statement to the
>> >>compiler
>> >> >(FLEX-35343). I can successfully emit the debugger statement in the
>> >> >generated JS so far.
>> >> >
>> >> >I'm not yet sure if I can make it work on the SWF side. I figured
>>out
>> >> >where
>> >> >I can generate bytecode instructions in ABCGeneratingReducer. If I
>>can
>> >> >figure out how to generate bytecode to call enterDebugger() (or
>> >>whatever
>> >> >the function is called), the debugger statement will work in both
>>SWF
>> >>and
>> >> >JS.
>> >> >
>> >> >- Josh
>> >> >
>> >> >On Sun, Jul 16, 2017 at 9:22 AM, Josh Tynjala
>><jo...@gmail.com>
>> >> >wrote:
>> >> >
>> >> >> If it were a variable or function, it could be defined somewhere
>>like
>> >> >> that. It's a statement, though, so it needs to be added to where
>> >>Falcon
>> >> >> creates the AST from the ActionScript code. Then, it also needs to
>> >>emit
>> >> >>the
>> >> >> statement as JS in FalconJX. On the SWF side, it should be
>> >>translated to
>> >> >> appropriate bytecode to call enterDebugger().
>> >> >>
>> >> >> - Josh
>> >> >>
>> >> >> On Jul 16, 2017 8:56 AM, "Harbs" <ha...@gmail.com> wrote:
>> >> >>
>> >> >>> What needs to be modified? Does it need to be added to
>>NativeJSType
>> >> >>> enums? Somewhere else?
>> >> >>>
>> >> >>> I’m really not clear on when things to be added to that and when
>> >>they
>> >> >>> need to be in typedefs.
>> >> >>>
>> >> >>> > On Jul 16, 2017, at 6:51 PM, Harbs <ha...@gmail.com>
>>wrote:
>> >> >>> >
>> >> >>> >> The compiler needs to be modified to support the debugger
>> >>statement.
>> >> >>>
>> >> >>>
>> >>
>> >>
>>
>>


Re: [FlexJS] Debugging package

Posted by Josh Tynjala <jo...@gmail.com>.
Well, as I said, I already have the compiler parsing the real debugger
statement in AS, and emitting the right JS. I just need to generate some
custom bytecode for SWF and then it will work everywhere.

- Josh

On Wed, Jul 19, 2017 at 7:17 PM, Alex Harui <ah...@adobe.com.invalid>
wrote:

> I think we allow classes to be used as a "statement" for dependency
> management.  CoreClasses.as, for example, has plenty of lines like:
>
>    import org.apache.flex.core.IUIBase; IUIBase;
>
>
> HTH,
> -Alex
>
> On 7/19/17, 6:57 PM, "Josh Tynjala" <jo...@gmail.com> wrote:
>
> >Yes, I'm changing the compiler. The debugger statement is not a function.
> >It works like this:
> >
> >debugger;
> >
> >I think that flash.system.System.pause() will work too, and it's
> >documented:
> >
> >https://na01.safelinks.protection.outlook.com/?url=
> http%3A%2F%2Fhelp.adobe
> >.com%2Fen_US%2FFlashPlatform%2Freference%2Factionscript%
> 2F3%2Fflash%2Fsyst
> >em%2FSystem.html%23pause&data=02%7C01%7C%7C7bb64776e6eb48b8d61908d4cf12
> d04
> >e%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%
> 7C636361127090455464&sdata=I2
> >01iT7jr2mvseuvMIJdUVu1SpRLJimK7Tqdp3n%2B%2Bv8%3D&reserved=0()
> >
> >- Josh
> >
> >On Wed, Jul 19, 2017 at 6:44 PM, Alex Harui <ah...@adobe.com.invalid>
> >wrote:
> >
> >> Are you changing the compiler?  I thought you could just add:
> >>
> >>   function debugger{};
> >>
> >> to missing.js so it results in:
> >>
> >>   public class debugger {};
> >>
> >> and
> >>
> >> package flash.debugger {
> >>   native function enterDebugger():void;
> >> }
> >>
> >> to one of our swcs?  Although I have to say I'm a bit uncomfortable
> >>about
> >> adding undocumented Flash APIs to our code base.  We are not supposed to
> >> use APIs that are "reverse-engineered".  Do we have proof that Adobe
> >> documented it at one point in time?
> >>
> >> HTH,
> >> -Alex
> >>
> >> On 7/18/17, 5:05 PM, "Josh Tynjala" <jo...@gmail.com> wrote:
> >>
> >> >I'm working on adding support for the debugger statement to the
> >>compiler
> >> >(FLEX-35343). I can successfully emit the debugger statement in the
> >> >generated JS so far.
> >> >
> >> >I'm not yet sure if I can make it work on the SWF side. I figured out
> >> >where
> >> >I can generate bytecode instructions in ABCGeneratingReducer. If I can
> >> >figure out how to generate bytecode to call enterDebugger() (or
> >>whatever
> >> >the function is called), the debugger statement will work in both SWF
> >>and
> >> >JS.
> >> >
> >> >- Josh
> >> >
> >> >On Sun, Jul 16, 2017 at 9:22 AM, Josh Tynjala <jo...@gmail.com>
> >> >wrote:
> >> >
> >> >> If it were a variable or function, it could be defined somewhere like
> >> >> that. It's a statement, though, so it needs to be added to where
> >>Falcon
> >> >> creates the AST from the ActionScript code. Then, it also needs to
> >>emit
> >> >>the
> >> >> statement as JS in FalconJX. On the SWF side, it should be
> >>translated to
> >> >> appropriate bytecode to call enterDebugger().
> >> >>
> >> >> - Josh
> >> >>
> >> >> On Jul 16, 2017 8:56 AM, "Harbs" <ha...@gmail.com> wrote:
> >> >>
> >> >>> What needs to be modified? Does it need to be added to NativeJSType
> >> >>> enums? Somewhere else?
> >> >>>
> >> >>> I’m really not clear on when things to be added to that and when
> >>they
> >> >>> need to be in typedefs.
> >> >>>
> >> >>> > On Jul 16, 2017, at 6:51 PM, Harbs <ha...@gmail.com> wrote:
> >> >>> >
> >> >>> >> The compiler needs to be modified to support the debugger
> >>statement.
> >> >>>
> >> >>>
> >>
> >>
>
>

Re: [FlexJS] Debugging package

Posted by Alex Harui <ah...@adobe.com.INVALID>.
I think we allow classes to be used as a "statement" for dependency
management.  CoreClasses.as, for example, has plenty of lines like:

   import org.apache.flex.core.IUIBase; IUIBase;


HTH,
-Alex

On 7/19/17, 6:57 PM, "Josh Tynjala" <jo...@gmail.com> wrote:

>Yes, I'm changing the compiler. The debugger statement is not a function.
>It works like this:
>
>debugger;
>
>I think that flash.system.System.pause() will work too, and it's
>documented:
>
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fhelp.adobe
>.com%2Fen_US%2FFlashPlatform%2Freference%2Factionscript%2F3%2Fflash%2Fsyst
>em%2FSystem.html%23pause&data=02%7C01%7C%7C7bb64776e6eb48b8d61908d4cf12d04
>e%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636361127090455464&sdata=I2
>01iT7jr2mvseuvMIJdUVu1SpRLJimK7Tqdp3n%2B%2Bv8%3D&reserved=0()
>
>- Josh
>
>On Wed, Jul 19, 2017 at 6:44 PM, Alex Harui <ah...@adobe.com.invalid>
>wrote:
>
>> Are you changing the compiler?  I thought you could just add:
>>
>>   function debugger{};
>>
>> to missing.js so it results in:
>>
>>   public class debugger {};
>>
>> and
>>
>> package flash.debugger {
>>   native function enterDebugger():void;
>> }
>>
>> to one of our swcs?  Although I have to say I'm a bit uncomfortable
>>about
>> adding undocumented Flash APIs to our code base.  We are not supposed to
>> use APIs that are "reverse-engineered".  Do we have proof that Adobe
>> documented it at one point in time?
>>
>> HTH,
>> -Alex
>>
>> On 7/18/17, 5:05 PM, "Josh Tynjala" <jo...@gmail.com> wrote:
>>
>> >I'm working on adding support for the debugger statement to the
>>compiler
>> >(FLEX-35343). I can successfully emit the debugger statement in the
>> >generated JS so far.
>> >
>> >I'm not yet sure if I can make it work on the SWF side. I figured out
>> >where
>> >I can generate bytecode instructions in ABCGeneratingReducer. If I can
>> >figure out how to generate bytecode to call enterDebugger() (or
>>whatever
>> >the function is called), the debugger statement will work in both SWF
>>and
>> >JS.
>> >
>> >- Josh
>> >
>> >On Sun, Jul 16, 2017 at 9:22 AM, Josh Tynjala <jo...@gmail.com>
>> >wrote:
>> >
>> >> If it were a variable or function, it could be defined somewhere like
>> >> that. It's a statement, though, so it needs to be added to where
>>Falcon
>> >> creates the AST from the ActionScript code. Then, it also needs to
>>emit
>> >>the
>> >> statement as JS in FalconJX. On the SWF side, it should be
>>translated to
>> >> appropriate bytecode to call enterDebugger().
>> >>
>> >> - Josh
>> >>
>> >> On Jul 16, 2017 8:56 AM, "Harbs" <ha...@gmail.com> wrote:
>> >>
>> >>> What needs to be modified? Does it need to be added to NativeJSType
>> >>> enums? Somewhere else?
>> >>>
>> >>> I’m really not clear on when things to be added to that and when
>>they
>> >>> need to be in typedefs.
>> >>>
>> >>> > On Jul 16, 2017, at 6:51 PM, Harbs <ha...@gmail.com> wrote:
>> >>> >
>> >>> >> The compiler needs to be modified to support the debugger
>>statement.
>> >>>
>> >>>
>>
>>


Re: [FlexJS] Debugging package

Posted by Josh Tynjala <jo...@gmail.com>.
Yes, I'm changing the compiler. The debugger statement is not a function.
It works like this:

debugger;

I think that flash.system.System.pause() will work too, and it's documented:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/System.html#pause()

- Josh

On Wed, Jul 19, 2017 at 6:44 PM, Alex Harui <ah...@adobe.com.invalid>
wrote:

> Are you changing the compiler?  I thought you could just add:
>
>   function debugger{};
>
> to missing.js so it results in:
>
>   public class debugger {};
>
> and
>
> package flash.debugger {
>   native function enterDebugger():void;
> }
>
> to one of our swcs?  Although I have to say I'm a bit uncomfortable about
> adding undocumented Flash APIs to our code base.  We are not supposed to
> use APIs that are "reverse-engineered".  Do we have proof that Adobe
> documented it at one point in time?
>
> HTH,
> -Alex
>
> On 7/18/17, 5:05 PM, "Josh Tynjala" <jo...@gmail.com> wrote:
>
> >I'm working on adding support for the debugger statement to the compiler
> >(FLEX-35343). I can successfully emit the debugger statement in the
> >generated JS so far.
> >
> >I'm not yet sure if I can make it work on the SWF side. I figured out
> >where
> >I can generate bytecode instructions in ABCGeneratingReducer. If I can
> >figure out how to generate bytecode to call enterDebugger() (or whatever
> >the function is called), the debugger statement will work in both SWF and
> >JS.
> >
> >- Josh
> >
> >On Sun, Jul 16, 2017 at 9:22 AM, Josh Tynjala <jo...@gmail.com>
> >wrote:
> >
> >> If it were a variable or function, it could be defined somewhere like
> >> that. It's a statement, though, so it needs to be added to where Falcon
> >> creates the AST from the ActionScript code. Then, it also needs to emit
> >>the
> >> statement as JS in FalconJX. On the SWF side, it should be translated to
> >> appropriate bytecode to call enterDebugger().
> >>
> >> - Josh
> >>
> >> On Jul 16, 2017 8:56 AM, "Harbs" <ha...@gmail.com> wrote:
> >>
> >>> What needs to be modified? Does it need to be added to NativeJSType
> >>> enums? Somewhere else?
> >>>
> >>> I’m really not clear on when things to be added to that and when they
> >>> need to be in typedefs.
> >>>
> >>> > On Jul 16, 2017, at 6:51 PM, Harbs <ha...@gmail.com> wrote:
> >>> >
> >>> >> The compiler needs to be modified to support the debugger statement.
> >>>
> >>>
>
>

Re: [FlexJS] Debugging package

Posted by Alex Harui <ah...@adobe.com.INVALID>.
Are you changing the compiler?  I thought you could just add:

  function debugger{};

to missing.js so it results in:

  public class debugger {};

and 

package flash.debugger {
  native function enterDebugger():void;
}

to one of our swcs?  Although I have to say I'm a bit uncomfortable about
adding undocumented Flash APIs to our code base.  We are not supposed to
use APIs that are "reverse-engineered".  Do we have proof that Adobe
documented it at one point in time?

HTH,
-Alex

On 7/18/17, 5:05 PM, "Josh Tynjala" <jo...@gmail.com> wrote:

>I'm working on adding support for the debugger statement to the compiler
>(FLEX-35343). I can successfully emit the debugger statement in the
>generated JS so far.
>
>I'm not yet sure if I can make it work on the SWF side. I figured out
>where
>I can generate bytecode instructions in ABCGeneratingReducer. If I can
>figure out how to generate bytecode to call enterDebugger() (or whatever
>the function is called), the debugger statement will work in both SWF and
>JS.
>
>- Josh
>
>On Sun, Jul 16, 2017 at 9:22 AM, Josh Tynjala <jo...@gmail.com>
>wrote:
>
>> If it were a variable or function, it could be defined somewhere like
>> that. It's a statement, though, so it needs to be added to where Falcon
>> creates the AST from the ActionScript code. Then, it also needs to emit
>>the
>> statement as JS in FalconJX. On the SWF side, it should be translated to
>> appropriate bytecode to call enterDebugger().
>>
>> - Josh
>>
>> On Jul 16, 2017 8:56 AM, "Harbs" <ha...@gmail.com> wrote:
>>
>>> What needs to be modified? Does it need to be added to NativeJSType
>>> enums? Somewhere else?
>>>
>>> I’m really not clear on when things to be added to that and when they
>>> need to be in typedefs.
>>>
>>> > On Jul 16, 2017, at 6:51 PM, Harbs <ha...@gmail.com> wrote:
>>> >
>>> >> The compiler needs to be modified to support the debugger statement.
>>>
>>>


Re: [FlexJS] Debugging package

Posted by yishayw <yi...@hotmail.com>.
This sounds like a very useful feature, provided not everyone is using source
map enabled tools. I agree with Alex it's worth implementing outside the
compiler for maintenance and future platforms.



--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-Debugging-package-tp63288p63541.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.

Re: [FlexJS] Debugging package

Posted by Josh Tynjala <jo...@gmail.com>.
I implemented a "debugger" statement in ActionScript that works similarly
to the JavaScript debugger statement:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger

In JavaScript, it translates directly. In SWF, the compiler generates
bytecode for a call to flash.debugger.enterDebugger(). This is not an
officially documented function in the Flash runtimes, but it's been around
since AS3 was introduced, as far as I can tell. I would say that it's
unlikely to be removed in the future. While I mentioned that I was
considering using flash.system.System.pause(), it did not behave in the way
that I originally hoped. In my tests, System.pause() seemed to pause
rendering only, and code kept running without triggering the debugger.

My changes are in the feature/debugger-statement branch of flex-falcon.
I'll be happy to merge them into develop, if there's interest.

- Josh



On Tue, Jul 18, 2017 at 5:05 PM, Josh Tynjala <jo...@gmail.com> wrote:

> I'm working on adding support for the debugger statement to the compiler
> (FLEX-35343). I can successfully emit the debugger statement in the
> generated JS so far.
>
> I'm not yet sure if I can make it work on the SWF side. I figured out
> where I can generate bytecode instructions in ABCGeneratingReducer. If I
> can figure out how to generate bytecode to call enterDebugger() (or
> whatever the function is called), the debugger statement will work in both
> SWF and JS.
>
> - Josh
>
> On Sun, Jul 16, 2017 at 9:22 AM, Josh Tynjala <jo...@gmail.com>
> wrote:
>
>> If it were a variable or function, it could be defined somewhere like
>> that. It's a statement, though, so it needs to be added to where Falcon
>> creates the AST from the ActionScript code. Then, it also needs to emit the
>> statement as JS in FalconJX. On the SWF side, it should be translated to
>> appropriate bytecode to call enterDebugger().
>>
>> - Josh
>>
>> On Jul 16, 2017 8:56 AM, "Harbs" <ha...@gmail.com> wrote:
>>
>>> What needs to be modified? Does it need to be added to NativeJSType
>>> enums? Somewhere else?
>>>
>>> I’m really not clear on when things to be added to that and when they
>>> need to be in typedefs.
>>>
>>> > On Jul 16, 2017, at 6:51 PM, Harbs <ha...@gmail.com> wrote:
>>> >
>>> >> The compiler needs to be modified to support the debugger statement.
>>>
>>>
>

Re: [FlexJS] Debugging package

Posted by Josh Tynjala <jo...@gmail.com>.
I'm working on adding support for the debugger statement to the compiler
(FLEX-35343). I can successfully emit the debugger statement in the
generated JS so far.

I'm not yet sure if I can make it work on the SWF side. I figured out where
I can generate bytecode instructions in ABCGeneratingReducer. If I can
figure out how to generate bytecode to call enterDebugger() (or whatever
the function is called), the debugger statement will work in both SWF and
JS.

- Josh

On Sun, Jul 16, 2017 at 9:22 AM, Josh Tynjala <jo...@gmail.com> wrote:

> If it were a variable or function, it could be defined somewhere like
> that. It's a statement, though, so it needs to be added to where Falcon
> creates the AST from the ActionScript code. Then, it also needs to emit the
> statement as JS in FalconJX. On the SWF side, it should be translated to
> appropriate bytecode to call enterDebugger().
>
> - Josh
>
> On Jul 16, 2017 8:56 AM, "Harbs" <ha...@gmail.com> wrote:
>
>> What needs to be modified? Does it need to be added to NativeJSType
>> enums? Somewhere else?
>>
>> I’m really not clear on when things to be added to that and when they
>> need to be in typedefs.
>>
>> > On Jul 16, 2017, at 6:51 PM, Harbs <ha...@gmail.com> wrote:
>> >
>> >> The compiler needs to be modified to support the debugger statement.
>>
>>

Re: [FlexJS] Debugging package

Posted by piotrz <pi...@gmail.com>.
I don't have free cycle right now, but I have some plan to look into compiler
and learn things. 
Jira need to be created to track this issue. Till it's failing we should
comment it out.

Piotr



-----
Apache Flex PMC
piotrzarzycki21@gmail.com
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-Debugging-package-tp63288p63313.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.

Re: [FlexJS] Debugging package

Posted by Harbs <ha...@gmail.com>.
That’s beyond me. One day maybe I’ll be up to fiddling with the compiler like that, but I’m not there yet…

I’d think nothing needs to be done on the SWF side (unless we need to support debugger; in client code unwrapped). Right now, here’s what I have:

        COMPILE::SWF
        {
            if(condition)
                enterDebugger();
        }
        COMPILE::JS
        {
            if(goog.DEBUG && condition)
                debugger;
        }

The COMPILE::SWF block should theoretically work as-is.

> On Jul 16, 2017, at 7:22 PM, Josh Tynjala <jo...@gmail.com> wrote:
> 
> If it were a variable or function, it could be defined somewhere like that.
> It's a statement, though, so it needs to be added to where Falcon creates
> the AST from the ActionScript code. Then, it also needs to emit the
> statement as JS in FalconJX. On the SWF side, it should be translated to
> appropriate bytecode to call enterDebugger().
> 
> - Josh
> 
> On Jul 16, 2017 8:56 AM, "Harbs" <ha...@gmail.com> wrote:
> 
>> What needs to be modified? Does it need to be added to NativeJSType enums?
>> Somewhere else?
>> 
>> I’m really not clear on when things to be added to that and when they need
>> to be in typedefs.
>> 
>>> On Jul 16, 2017, at 6:51 PM, Harbs <ha...@gmail.com> wrote:
>>> 
>>>> The compiler needs to be modified to support the debugger statement.
>> 
>> 


Re: [FlexJS] Debugging package

Posted by Josh Tynjala <jo...@gmail.com>.
If it were a variable or function, it could be defined somewhere like that.
It's a statement, though, so it needs to be added to where Falcon creates
the AST from the ActionScript code. Then, it also needs to emit the
statement as JS in FalconJX. On the SWF side, it should be translated to
appropriate bytecode to call enterDebugger().

- Josh

On Jul 16, 2017 8:56 AM, "Harbs" <ha...@gmail.com> wrote:

> What needs to be modified? Does it need to be added to NativeJSType enums?
> Somewhere else?
>
> I’m really not clear on when things to be added to that and when they need
> to be in typedefs.
>
> > On Jul 16, 2017, at 6:51 PM, Harbs <ha...@gmail.com> wrote:
> >
> >> The compiler needs to be modified to support the debugger statement.
>
>

Re: [FlexJS] Debugging package

Posted by Harbs <ha...@gmail.com>.
What needs to be modified? Does it need to be added to NativeJSType enums? Somewhere else?

I’m really not clear on when things to be added to that and when they need to be in typedefs.

> On Jul 16, 2017, at 6:51 PM, Harbs <ha...@gmail.com> wrote:
> 
>> The compiler needs to be modified to support the debugger statement.


Re: [FlexJS] Debugging package

Posted by Harbs <ha...@gmail.com>.
I added flash.debugger.enterDebugger(); on the SWF side. I have not yet tested it, but it’s *supposed* to work…

> On Jul 16, 2017, at 6:34 PM, Josh Tynjala <jo...@gmail.com> wrote:
> 
> The compiler needs to be modified to support the debugger statement.
> 
> Ideally, it would also force Flash to pause in the debugger.
> 
> - Josh
> 
> 
> On Jul 16, 2017 2:07 AM, "Harbs" <ha...@gmail.com> wrote:
> 
> I just added a debugging package to FlexJS. There are two things I don’t
> know how to do:
> 
> 1. The debugging functions should disappear in a release build of JS, but
> I’m not sure how to make the same thing happen in a release build of SWF. I
> don’t think a debug config is the solution, because the debug statements
> should be preserved in framework code and only be stripped out for
> application release builds. Does anyone have ideas on how to go about doing
> that?
> 
> 2. I have conditionalBreak commented out of CoreClasses because the
> debugger statement is not recognized. Where do we need to add that?
> missing.js?
> 
> Harbs


Re: [FlexJS] Debugging package

Posted by Josh Tynjala <jo...@gmail.com>.
The compiler needs to be modified to support the debugger statement.

Ideally, it would also force Flash to pause in the debugger.

- Josh


On Jul 16, 2017 2:07 AM, "Harbs" <ha...@gmail.com> wrote:

I just added a debugging package to FlexJS. There are two things I don’t
know how to do:

1. The debugging functions should disappear in a release build of JS, but
I’m not sure how to make the same thing happen in a release build of SWF. I
don’t think a debug config is the solution, because the debug statements
should be preserved in framework code and only be stripped out for
application release builds. Does anyone have ideas on how to go about doing
that?

2. I have conditionalBreak commented out of CoreClasses because the
debugger statement is not recognized. Where do we need to add that?
missing.js?

Harbs

Re: [FlexJS] Debugging package

Posted by piotrz <pi...@gmail.com>.
If that's the case we should not so freely use traces in framework itself.
Eventually pass in compilation require flag for each module.

Piotr



-----
Apache Flex PMC
piotrzarzycki21@gmail.com
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-Debugging-package-tp63288p63457.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.

Re: [FlexJS] Debugging package

Posted by Alex Harui <ah...@adobe.com.INVALID>.
Hmm, after digging into it a bit more, it appears that optimization does
not remove trace calls.  I haven't dumped a release SWF to verify.  Maybe
trace() just doesn't do anything in the production player.

Optimization is a post-link process.  IOW, it processes ABC code instead
of source code, so no conditional compile directives are available.  There
are flags for doing various optimizations.  To remove debugging code, I
think you'd just add another flag and figure out how to manipulate the ABC
code.  There is a DeadCodeFilter that looks like it does serious rework of
the ABC that might be a good example to follow.

HTH,
-Alex

On 7/20/17, 6:21 AM, "Josh Tynjala" <jo...@gmail.com> wrote:

>We could consider something similar to COMPILE::JS and COMPILE::SWF where
>they default to a value of auto, which the compiler knows to turn into
>true
>or false. COMPILE::DEBUG could also default to a value of auto, and then
>the compiler makes it true for a debug build and false for a release
>build.
>
>- Josh
>
>On Thu, Jul 20, 2017 at 12:55 AM, Harbs <ha...@gmail.com> wrote:
>
>> Cool. So what would you recommend the convention to tell the compiler to
>> do so? A meta tag? a comment directive? (i.e. @debug)
>>
>> > On Jul 20, 2017, at 10:51 AM, Alex Harui <ah...@adobe.com.INVALID>
>> wrote:
>> >
>> > I believe there is code that becomes part of the optimizer.jar that
>> > removes the trace statements.  It might be possible extend that code
>>to
>> > remove other things.
>> >
>> > -Alex
>> >
>> > On 7/19/17, 11:47 PM, "Harbs" <ha...@gmail.com> wrote:
>> >
>> >> I don’t think there were any responses to this.
>> >>
>> >> As it stands, the debugging functions will exist in release versions
>>of
>> >> swfs.
>> >>
>> >> Harbs
>> >>
>> >>> On Jul 16, 2017, at 12:07 PM, Harbs <ha...@gmail.com> wrote:
>> >>>
>> >>> 1. The debugging functions should disappear in a release build of
>>JS,
>> >>> but I’m not sure how to make the same thing happen in a release
>>build
>> of
>> >>> SWF. I don’t think a debug config is the solution, because the debug
>> >>> statements should be preserved in framework code and only be
>>stripped
>> >>> out for application release builds. Does anyone have ideas on how
>>to go
>> >>> about doing that?
>> >>
>> >
>>
>>


Re: [FlexJS] Debugging package

Posted by Josh Tynjala <jo...@gmail.com>.
We could consider something similar to COMPILE::JS and COMPILE::SWF where
they default to a value of auto, which the compiler knows to turn into true
or false. COMPILE::DEBUG could also default to a value of auto, and then
the compiler makes it true for a debug build and false for a release build.

- Josh

On Thu, Jul 20, 2017 at 12:55 AM, Harbs <ha...@gmail.com> wrote:

> Cool. So what would you recommend the convention to tell the compiler to
> do so? A meta tag? a comment directive? (i.e. @debug)
>
> > On Jul 20, 2017, at 10:51 AM, Alex Harui <ah...@adobe.com.INVALID>
> wrote:
> >
> > I believe there is code that becomes part of the optimizer.jar that
> > removes the trace statements.  It might be possible extend that code to
> > remove other things.
> >
> > -Alex
> >
> > On 7/19/17, 11:47 PM, "Harbs" <ha...@gmail.com> wrote:
> >
> >> I don’t think there were any responses to this.
> >>
> >> As it stands, the debugging functions will exist in release versions of
> >> swfs.
> >>
> >> Harbs
> >>
> >>> On Jul 16, 2017, at 12:07 PM, Harbs <ha...@gmail.com> wrote:
> >>>
> >>> 1. The debugging functions should disappear in a release build of JS,
> >>> but I’m not sure how to make the same thing happen in a release build
> of
> >>> SWF. I don’t think a debug config is the solution, because the debug
> >>> statements should be preserved in framework code and only be stripped
> >>> out for application release builds. Does anyone have ideas on how to go
> >>> about doing that?
> >>
> >
>
>

Re: [FlexJS] Debugging package

Posted by piotrz <pi...@gmail.com>.
Harbs,

It would be great to have it summarized in jira!

Thanks, 
Piotr



-----
Apache Flex PMC
piotrzarzycki21@gmail.com
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-Debugging-package-tp63288p63453.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.

Re: [FlexJS] Debugging package

Posted by Harbs <ha...@gmail.com>.
We also need to modify the output for trace in JS to put the goog.DEBUG check at the very start of the function and to not output the @export tag.

The rest of the debugging functions need to lose the @export tag as well.

Should I put all this in a JIRA?

> On Jul 20, 2017, at 11:16 AM, Harbs <ha...@gmail.com> wrote:
> 
> Hard code what? For any function in the org.apache.flex.debugging package it would not output to release SWF?
> 
>> On Jul 20, 2017, at 11:00 AM, Alex Harui <ah...@adobe.com.INVALID> wrote:
>> 
>> For now, I would just hard code it.
>> 
>> On 7/20/17, 12:55 AM, "Harbs" <ha...@gmail.com> wrote:
>> 
>>> Cool. So what would you recommend the convention to tell the compiler to
>>> do so? A meta tag? a comment directive? (i.e. @debug)
>>> 
>>>> On Jul 20, 2017, at 10:51 AM, Alex Harui <ah...@adobe.com.INVALID>
>>>> wrote:
>>>> 
>>>> I believe there is code that becomes part of the optimizer.jar that
>>>> removes the trace statements.  It might be possible extend that code to
>>>> remove other things.
>>>> 
>>>> -Alex
>>>> 
>>>> On 7/19/17, 11:47 PM, "Harbs" <ha...@gmail.com> wrote:
>>>> 
>>>>> I don’t think there were any responses to this.
>>>>> 
>>>>> As it stands, the debugging functions will exist in release versions of
>>>>> swfs.
>>>>> 
>>>>> Harbs
>>>>> 
>>>>>> On Jul 16, 2017, at 12:07 PM, Harbs <ha...@gmail.com> wrote:
>>>>>> 
>>>>>> 1. The debugging functions should disappear in a release build of JS,
>>>>>> but I’m not sure how to make the same thing happen in a release build
>>>>>> of
>>>>>> SWF. I don’t think a debug config is the solution, because the debug
>>>>>> statements should be preserved in framework code and only be stripped
>>>>>> out for application release builds. Does anyone have ideas on how to
>>>>>> go
>>>>>> about doing that?
>>>>> 
>>>> 
>>> 
>> 
> 


Re: [FlexJS] Debugging package

Posted by Harbs <ha...@gmail.com>.
Hard code what? For any function in the org.apache.flex.debugging package it would not output to release SWF?

> On Jul 20, 2017, at 11:00 AM, Alex Harui <ah...@adobe.com.INVALID> wrote:
> 
> For now, I would just hard code it.
> 
> On 7/20/17, 12:55 AM, "Harbs" <ha...@gmail.com> wrote:
> 
>> Cool. So what would you recommend the convention to tell the compiler to
>> do so? A meta tag? a comment directive? (i.e. @debug)
>> 
>>> On Jul 20, 2017, at 10:51 AM, Alex Harui <ah...@adobe.com.INVALID>
>>> wrote:
>>> 
>>> I believe there is code that becomes part of the optimizer.jar that
>>> removes the trace statements.  It might be possible extend that code to
>>> remove other things.
>>> 
>>> -Alex
>>> 
>>> On 7/19/17, 11:47 PM, "Harbs" <ha...@gmail.com> wrote:
>>> 
>>>> I don’t think there were any responses to this.
>>>> 
>>>> As it stands, the debugging functions will exist in release versions of
>>>> swfs.
>>>> 
>>>> Harbs
>>>> 
>>>>> On Jul 16, 2017, at 12:07 PM, Harbs <ha...@gmail.com> wrote:
>>>>> 
>>>>> 1. The debugging functions should disappear in a release build of JS,
>>>>> but I’m not sure how to make the same thing happen in a release build
>>>>> of
>>>>> SWF. I don’t think a debug config is the solution, because the debug
>>>>> statements should be preserved in framework code and only be stripped
>>>>> out for application release builds. Does anyone have ideas on how to
>>>>> go
>>>>> about doing that?
>>>> 
>>> 
>> 
> 


Re: [FlexJS] Debugging package

Posted by Alex Harui <ah...@adobe.com.INVALID>.
For now, I would just hard code it.

On 7/20/17, 12:55 AM, "Harbs" <ha...@gmail.com> wrote:

>Cool. So what would you recommend the convention to tell the compiler to
>do so? A meta tag? a comment directive? (i.e. @debug)
>
>> On Jul 20, 2017, at 10:51 AM, Alex Harui <ah...@adobe.com.INVALID>
>>wrote:
>> 
>> I believe there is code that becomes part of the optimizer.jar that
>> removes the trace statements.  It might be possible extend that code to
>> remove other things.
>> 
>> -Alex
>> 
>> On 7/19/17, 11:47 PM, "Harbs" <ha...@gmail.com> wrote:
>> 
>>> I don’t think there were any responses to this.
>>> 
>>> As it stands, the debugging functions will exist in release versions of
>>> swfs.
>>> 
>>> Harbs
>>> 
>>>> On Jul 16, 2017, at 12:07 PM, Harbs <ha...@gmail.com> wrote:
>>>> 
>>>> 1. The debugging functions should disappear in a release build of JS,
>>>> but I’m not sure how to make the same thing happen in a release build
>>>>of
>>>> SWF. I don’t think a debug config is the solution, because the debug
>>>> statements should be preserved in framework code and only be stripped
>>>> out for application release builds. Does anyone have ideas on how to
>>>>go
>>>> about doing that?
>>> 
>> 
>


Re: [FlexJS] Debugging package

Posted by Harbs <ha...@gmail.com>.
Cool. So what would you recommend the convention to tell the compiler to do so? A meta tag? a comment directive? (i.e. @debug)

> On Jul 20, 2017, at 10:51 AM, Alex Harui <ah...@adobe.com.INVALID> wrote:
> 
> I believe there is code that becomes part of the optimizer.jar that
> removes the trace statements.  It might be possible extend that code to
> remove other things.
> 
> -Alex
> 
> On 7/19/17, 11:47 PM, "Harbs" <ha...@gmail.com> wrote:
> 
>> I don’t think there were any responses to this.
>> 
>> As it stands, the debugging functions will exist in release versions of
>> swfs.
>> 
>> Harbs
>> 
>>> On Jul 16, 2017, at 12:07 PM, Harbs <ha...@gmail.com> wrote:
>>> 
>>> 1. The debugging functions should disappear in a release build of JS,
>>> but I’m not sure how to make the same thing happen in a release build of
>>> SWF. I don’t think a debug config is the solution, because the debug
>>> statements should be preserved in framework code and only be stripped
>>> out for application release builds. Does anyone have ideas on how to go
>>> about doing that?
>> 
> 


Re: [FlexJS] Debugging package

Posted by Alex Harui <ah...@adobe.com.INVALID>.
I believe there is code that becomes part of the optimizer.jar that
removes the trace statements.  It might be possible extend that code to
remove other things.

-Alex

On 7/19/17, 11:47 PM, "Harbs" <ha...@gmail.com> wrote:

>I don’t think there were any responses to this.
>
>As it stands, the debugging functions will exist in release versions of
>swfs.
>
>Harbs
>
>> On Jul 16, 2017, at 12:07 PM, Harbs <ha...@gmail.com> wrote:
>> 
>> 1. The debugging functions should disappear in a release build of JS,
>>but I’m not sure how to make the same thing happen in a release build of
>>SWF. I don’t think a debug config is the solution, because the debug
>>statements should be preserved in framework code and only be stripped
>>out for application release builds. Does anyone have ideas on how to go
>>about doing that?
>


Re: [FlexJS] Debugging package

Posted by Harbs <ha...@gmail.com>.
I don’t think there were any responses to this.

As it stands, the debugging functions will exist in release versions of swfs.

Harbs

> On Jul 16, 2017, at 12:07 PM, Harbs <ha...@gmail.com> wrote:
> 
> 1. The debugging functions should disappear in a release build of JS, but I’m not sure how to make the same thing happen in a release build of SWF. I don’t think a debug config is the solution, because the debug statements should be preserved in framework code and only be stripped out for application release builds. Does anyone have ideas on how to go about doing that?


Re: [FlexJS] Avoiding Language.closure (was Re: [FlexJS] Debugging package)

Posted by Alex Harui <ah...@adobe.com.INVALID>.
"var self = this;” is added to every method that has inner/local
functions.  Use of "this" in local functions is changed to use "self" in
order to get AS scoping in JS.  I think we currently generate a self=this
even if the local functions don't need it.  Someday the compiler will be
smarter about that.


If the compiler is now generating self=this where there are no local
functions, that would be a bug.

-Alex

On 7/17/17, 2:23 PM, "Harbs" <ha...@gmail.com> wrote:

>The places that I checked look good.
>
>Side question: Despite the fact that “this” is no longer used in the
>callLater function, I noticed that the compiler is inserting "var self =
>this;” at the start of the function.
>
>I don’t think it causes any harm, but it does cause a Google compiler
>warning and I’m curious as to why it’s being output.
>
>> On Jul 17, 2017, at 10:36 PM, Harbs <ha...@gmail.com> wrote:
>> 
>> I’m not going to claim I understand what you just wrote. ;-)
>> 
>> I’ll see if I can understand the output…
>> 
>> Thanks.
>> 
>>> On Jul 17, 2017, at 10:33 PM, Alex Harui <ah...@adobe.com.INVALID>
>>>wrote:
>>> 
>>> Thinking about it more, I think a parameter of type Function never
>>>needs
>>> to be wrapped.  It would get wrapped on any assignment in the function
>>> body.  I just pushed changes to reflect that.
>>> 
>>> -Alex
>>> 
>>> On 7/16/17, 11:41 PM, "Alex Harui" <ah...@adobe.com.INVALID> wrote:
>>> 
>>>> Seems reasonable to add a check to see if the function body is for a
>>>> static method.
>>>> 
>>>> -Alex
>>>> 
>>>> On 7/16/17, 11:25 PM, "Harbs" <ha...@gmail.com> wrote:
>>>> 
>>>>> A directive could be a solution.
>>>>> 
>>>>> But I think this is an issue with any static method. If a closure is
>>>>>used
>>>>> inside a static method, or a function declared inside a static
>>>>>method, it
>>>>> should not use Language.closure.
>>>>> 
>>>>> FWIW, the Google compile complains about “this” being used in a
>>>>>static
>>>>> method as well:
>>>>> 
>>>>>  [mxmlc] Jul 16, 2017 7:26:08 PM
>>>>> com.google.javascript.jscomp.LoggerErrorManager println
>>>>>  [mxmlc] WARNING:
>>>>> 
>>>>>/Users/harbs/Documents/ApacheFlex/flex-asjs/examples/flexjs/DebuggingE
>>>>>xam
>>>>> p
>>>>> le/bin/js-debug/org/apache/flex/utils/callLater.js:35: WARNING -
>>>>> dangerous use of this in static method
>>>>>org.apache.flex.utils.callLater
>>>>>  [mxmlc]   
>>>>> setTimeout(org.apache.flex.utils.Language.closure(makeCalls, this,
>>>>> 'makeCalls'), 0);
>>>>> 
>>>>> Package level functions should be treated as static methods.
>>>>> 
>>>>> It might not be a bad idea to add a directive to allow developers to
>>>>> avoid Language.closure calls at will, but I think the “correct”
>>>>>general
>>>>> solution is to never output Language.closure in static and package
>>>>>level
>>>>> functions.
>>>>> 
>>>>>> On Jul 17, 2017, at 9:16 AM, Alex Harui <ah...@adobe.com.INVALID>
>>>>>> wrote:
>>>>>> 
>>>>>> I don't see any current way to suppress the Language.closure.
>>>>>>Without
>>>>>> flow-analysis, I'm not sure the compiler can tell.  It could guess
>>>>>>that
>>>>>> the identifier is a parameter, but the parameter variable could be
>>>>>> assigned within the function body.
>>>>>> 
>>>>>> We could add a new directive like @flexjsisclosure or something like
>>>>>> that.
>>>>>> 
>>>>>> Thoughts?
>>>>>> -Alex
>>>>>> 
>>>>>> On 7/16/17, 10:05 AM, "Harbs" <ha...@gmail.com> wrote:
>>>>>> 
>>>>>>> I figured out the problem.
>>>>>>> 
>>>>>>> org.apache.flex.utils.callLater has the following code:
>>>>>>> setTimeout(makeCalls, 0);
>>>>>>> 
>>>>>>> That compiles to:
>>>>>>> setTimeout(org.apache.flex.utils.Language.closure(makeCalls, this,
>>>>>>> 'makeCalls'), 0);
>>>>>>> 
>>>>>>> When Language.closure is called, it messes up the scope of the
>>>>>>>calls
>>>>>>> variable and subsequent calls to makeCalls step on each other. I
>>>>>>> believe
>>>>>>> this is because makeCalls is bound to the package object of the
>>>>>>> callLater
>>>>>>> function.
>>>>>>> 
>>>>>>> Is there any way to prevent rewriting of function calls to
>>>>>>> Language.closure?
>>>>>>> 
>>>>>>> If "setTimeout(makeCalls, 0);" is cross-compiled exactly to:
>>>>>>> "setTimeout(makeCalls, 0);", it works like I’d expect it to.
>>>>>>> 
>>>>>>> Thanks,
>>>>>>> Harbs
>>>>>>> 
>>>>>>>> On Jul 16, 2017, at 3:46 PM, Harbs <ha...@gmail.com> wrote:
>>>>>>>> 
>>>>>>>> Interesting to note:
>>>>>>>> 
>>>>>>>> Adding a number of callLater() calls resulted in only the first
>>>>>>>>one
>>>>>>>> being called in JS. I did not try as a SWF.
>>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
>


Re: [FlexJS] Avoiding Language.closure (was Re: [FlexJS] Debugging package)

Posted by Harbs <ha...@gmail.com>.
The places that I checked look good.

Side question: Despite the fact that “this” is no longer used in the callLater function, I noticed that the compiler is inserting "var self = this;” at the start of the function.

I don’t think it causes any harm, but it does cause a Google compiler warning and I’m curious as to why it’s being output.

> On Jul 17, 2017, at 10:36 PM, Harbs <ha...@gmail.com> wrote:
> 
> I’m not going to claim I understand what you just wrote. ;-)
> 
> I’ll see if I can understand the output…
> 
> Thanks.
> 
>> On Jul 17, 2017, at 10:33 PM, Alex Harui <ah...@adobe.com.INVALID> wrote:
>> 
>> Thinking about it more, I think a parameter of type Function never needs
>> to be wrapped.  It would get wrapped on any assignment in the function
>> body.  I just pushed changes to reflect that.
>> 
>> -Alex
>> 
>> On 7/16/17, 11:41 PM, "Alex Harui" <ah...@adobe.com.INVALID> wrote:
>> 
>>> Seems reasonable to add a check to see if the function body is for a
>>> static method.
>>> 
>>> -Alex
>>> 
>>> On 7/16/17, 11:25 PM, "Harbs" <ha...@gmail.com> wrote:
>>> 
>>>> A directive could be a solution.
>>>> 
>>>> But I think this is an issue with any static method. If a closure is used
>>>> inside a static method, or a function declared inside a static method, it
>>>> should not use Language.closure.
>>>> 
>>>> FWIW, the Google compile complains about “this” being used in a static
>>>> method as well:
>>>> 
>>>>  [mxmlc] Jul 16, 2017 7:26:08 PM
>>>> com.google.javascript.jscomp.LoggerErrorManager println
>>>>  [mxmlc] WARNING:
>>>> /Users/harbs/Documents/ApacheFlex/flex-asjs/examples/flexjs/DebuggingExam
>>>> p
>>>> le/bin/js-debug/org/apache/flex/utils/callLater.js:35: WARNING -
>>>> dangerous use of this in static method org.apache.flex.utils.callLater
>>>>  [mxmlc]   
>>>> setTimeout(org.apache.flex.utils.Language.closure(makeCalls, this,
>>>> 'makeCalls'), 0);
>>>> 
>>>> Package level functions should be treated as static methods.
>>>> 
>>>> It might not be a bad idea to add a directive to allow developers to
>>>> avoid Language.closure calls at will, but I think the “correct” general
>>>> solution is to never output Language.closure in static and package level
>>>> functions.
>>>> 
>>>>> On Jul 17, 2017, at 9:16 AM, Alex Harui <ah...@adobe.com.INVALID>
>>>>> wrote:
>>>>> 
>>>>> I don't see any current way to suppress the Language.closure.  Without
>>>>> flow-analysis, I'm not sure the compiler can tell.  It could guess that
>>>>> the identifier is a parameter, but the parameter variable could be
>>>>> assigned within the function body.
>>>>> 
>>>>> We could add a new directive like @flexjsisclosure or something like
>>>>> that.
>>>>> 
>>>>> Thoughts?
>>>>> -Alex
>>>>> 
>>>>> On 7/16/17, 10:05 AM, "Harbs" <ha...@gmail.com> wrote:
>>>>> 
>>>>>> I figured out the problem.
>>>>>> 
>>>>>> org.apache.flex.utils.callLater has the following code:
>>>>>> setTimeout(makeCalls, 0);
>>>>>> 
>>>>>> That compiles to:
>>>>>> setTimeout(org.apache.flex.utils.Language.closure(makeCalls, this,
>>>>>> 'makeCalls'), 0);
>>>>>> 
>>>>>> When Language.closure is called, it messes up the scope of the calls
>>>>>> variable and subsequent calls to makeCalls step on each other. I
>>>>>> believe
>>>>>> this is because makeCalls is bound to the package object of the
>>>>>> callLater
>>>>>> function.
>>>>>> 
>>>>>> Is there any way to prevent rewriting of function calls to
>>>>>> Language.closure?
>>>>>> 
>>>>>> If "setTimeout(makeCalls, 0);" is cross-compiled exactly to:
>>>>>> "setTimeout(makeCalls, 0);", it works like I’d expect it to.
>>>>>> 
>>>>>> Thanks,
>>>>>> Harbs
>>>>>> 
>>>>>>> On Jul 16, 2017, at 3:46 PM, Harbs <ha...@gmail.com> wrote:
>>>>>>> 
>>>>>>> Interesting to note:
>>>>>>> 
>>>>>>> Adding a number of callLater() calls resulted in only the first one
>>>>>>> being called in JS. I did not try as a SWF.
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 


Re: [FlexJS] Avoiding Language.closure (was Re: [FlexJS] Debugging package)

Posted by Harbs <ha...@gmail.com>.
I’m not going to claim I understand what you just wrote. ;-)

I’ll see if I can understand the output…

Thanks.

> On Jul 17, 2017, at 10:33 PM, Alex Harui <ah...@adobe.com.INVALID> wrote:
> 
> Thinking about it more, I think a parameter of type Function never needs
> to be wrapped.  It would get wrapped on any assignment in the function
> body.  I just pushed changes to reflect that.
> 
> -Alex
> 
> On 7/16/17, 11:41 PM, "Alex Harui" <ah...@adobe.com.INVALID> wrote:
> 
>> Seems reasonable to add a check to see if the function body is for a
>> static method.
>> 
>> -Alex
>> 
>> On 7/16/17, 11:25 PM, "Harbs" <ha...@gmail.com> wrote:
>> 
>>> A directive could be a solution.
>>> 
>>> But I think this is an issue with any static method. If a closure is used
>>> inside a static method, or a function declared inside a static method, it
>>> should not use Language.closure.
>>> 
>>> FWIW, the Google compile complains about “this” being used in a static
>>> method as well:
>>> 
>>>   [mxmlc] Jul 16, 2017 7:26:08 PM
>>> com.google.javascript.jscomp.LoggerErrorManager println
>>>   [mxmlc] WARNING:
>>> /Users/harbs/Documents/ApacheFlex/flex-asjs/examples/flexjs/DebuggingExam
>>> p
>>> le/bin/js-debug/org/apache/flex/utils/callLater.js:35: WARNING -
>>> dangerous use of this in static method org.apache.flex.utils.callLater
>>>   [mxmlc]   
>>> setTimeout(org.apache.flex.utils.Language.closure(makeCalls, this,
>>> 'makeCalls'), 0);
>>> 
>>> Package level functions should be treated as static methods.
>>> 
>>> It might not be a bad idea to add a directive to allow developers to
>>> avoid Language.closure calls at will, but I think the “correct” general
>>> solution is to never output Language.closure in static and package level
>>> functions.
>>> 
>>>> On Jul 17, 2017, at 9:16 AM, Alex Harui <ah...@adobe.com.INVALID>
>>>> wrote:
>>>> 
>>>> I don't see any current way to suppress the Language.closure.  Without
>>>> flow-analysis, I'm not sure the compiler can tell.  It could guess that
>>>> the identifier is a parameter, but the parameter variable could be
>>>> assigned within the function body.
>>>> 
>>>> We could add a new directive like @flexjsisclosure or something like
>>>> that.
>>>> 
>>>> Thoughts?
>>>> -Alex
>>>> 
>>>> On 7/16/17, 10:05 AM, "Harbs" <ha...@gmail.com> wrote:
>>>> 
>>>>> I figured out the problem.
>>>>> 
>>>>> org.apache.flex.utils.callLater has the following code:
>>>>> setTimeout(makeCalls, 0);
>>>>> 
>>>>> That compiles to:
>>>>> setTimeout(org.apache.flex.utils.Language.closure(makeCalls, this,
>>>>> 'makeCalls'), 0);
>>>>> 
>>>>> When Language.closure is called, it messes up the scope of the calls
>>>>> variable and subsequent calls to makeCalls step on each other. I
>>>>> believe
>>>>> this is because makeCalls is bound to the package object of the
>>>>> callLater
>>>>> function.
>>>>> 
>>>>> Is there any way to prevent rewriting of function calls to
>>>>> Language.closure?
>>>>> 
>>>>> If "setTimeout(makeCalls, 0);" is cross-compiled exactly to:
>>>>> "setTimeout(makeCalls, 0);", it works like I’d expect it to.
>>>>> 
>>>>> Thanks,
>>>>> Harbs
>>>>> 
>>>>>> On Jul 16, 2017, at 3:46 PM, Harbs <ha...@gmail.com> wrote:
>>>>>> 
>>>>>> Interesting to note:
>>>>>> 
>>>>>> Adding a number of callLater() calls resulted in only the first one
>>>>>> being called in JS. I did not try as a SWF.
>>>>> 
>>>> 
>>> 
>> 
> 


Re: [FlexJS] Avoiding Language.closure (was Re: [FlexJS] Debugging package)

Posted by Alex Harui <ah...@adobe.com.INVALID>.
Thinking about it more, I think a parameter of type Function never needs
to be wrapped.  It would get wrapped on any assignment in the function
body.  I just pushed changes to reflect that.

-Alex

On 7/16/17, 11:41 PM, "Alex Harui" <ah...@adobe.com.INVALID> wrote:

>Seems reasonable to add a check to see if the function body is for a
>static method.
>
>-Alex
>
>On 7/16/17, 11:25 PM, "Harbs" <ha...@gmail.com> wrote:
>
>>A directive could be a solution.
>>
>>But I think this is an issue with any static method. If a closure is used
>>inside a static method, or a function declared inside a static method, it
>>should not use Language.closure.
>>
>>FWIW, the Google compile complains about “this” being used in a static
>>method as well:
>>
>>    [mxmlc] Jul 16, 2017 7:26:08 PM
>>com.google.javascript.jscomp.LoggerErrorManager println
>>    [mxmlc] WARNING:
>>/Users/harbs/Documents/ApacheFlex/flex-asjs/examples/flexjs/DebuggingExam
>>p
>>le/bin/js-debug/org/apache/flex/utils/callLater.js:35: WARNING -
>>dangerous use of this in static method org.apache.flex.utils.callLater
>>    [mxmlc]   
>>setTimeout(org.apache.flex.utils.Language.closure(makeCalls, this,
>>'makeCalls'), 0);
>>
>>Package level functions should be treated as static methods.
>>
>>It might not be a bad idea to add a directive to allow developers to
>>avoid Language.closure calls at will, but I think the “correct” general
>>solution is to never output Language.closure in static and package level
>>functions.
>>
>>> On Jul 17, 2017, at 9:16 AM, Alex Harui <ah...@adobe.com.INVALID>
>>>wrote:
>>> 
>>> I don't see any current way to suppress the Language.closure.  Without
>>> flow-analysis, I'm not sure the compiler can tell.  It could guess that
>>> the identifier is a parameter, but the parameter variable could be
>>> assigned within the function body.
>>> 
>>> We could add a new directive like @flexjsisclosure or something like
>>>that.
>>> 
>>> Thoughts?
>>> -Alex
>>> 
>>> On 7/16/17, 10:05 AM, "Harbs" <ha...@gmail.com> wrote:
>>> 
>>>> I figured out the problem.
>>>> 
>>>> org.apache.flex.utils.callLater has the following code:
>>>> setTimeout(makeCalls, 0);
>>>> 
>>>> That compiles to:
>>>> setTimeout(org.apache.flex.utils.Language.closure(makeCalls, this,
>>>> 'makeCalls'), 0);
>>>> 
>>>> When Language.closure is called, it messes up the scope of the calls
>>>> variable and subsequent calls to makeCalls step on each other. I
>>>>believe
>>>> this is because makeCalls is bound to the package object of the
>>>>callLater
>>>> function.
>>>> 
>>>> Is there any way to prevent rewriting of function calls to
>>>> Language.closure?
>>>> 
>>>> If "setTimeout(makeCalls, 0);" is cross-compiled exactly to:
>>>> "setTimeout(makeCalls, 0);", it works like I’d expect it to.
>>>> 
>>>> Thanks,
>>>> Harbs
>>>> 
>>>>> On Jul 16, 2017, at 3:46 PM, Harbs <ha...@gmail.com> wrote:
>>>>> 
>>>>> Interesting to note:
>>>>> 
>>>>> Adding a number of callLater() calls resulted in only the first one
>>>>> being called in JS. I did not try as a SWF.
>>>> 
>>> 
>>
>


Re: [FlexJS] Avoiding Language.closure (was Re: [FlexJS] Debugging package)

Posted by Alex Harui <ah...@adobe.com.INVALID>.
Seems reasonable to add a check to see if the function body is for a
static method.

-Alex

On 7/16/17, 11:25 PM, "Harbs" <ha...@gmail.com> wrote:

>A directive could be a solution.
>
>But I think this is an issue with any static method. If a closure is used
>inside a static method, or a function declared inside a static method, it
>should not use Language.closure.
>
>FWIW, the Google compile complains about “this” being used in a static
>method as well:
>
>    [mxmlc] Jul 16, 2017 7:26:08 PM
>com.google.javascript.jscomp.LoggerErrorManager println
>    [mxmlc] WARNING:
>/Users/harbs/Documents/ApacheFlex/flex-asjs/examples/flexjs/DebuggingExamp
>le/bin/js-debug/org/apache/flex/utils/callLater.js:35: WARNING -
>dangerous use of this in static method org.apache.flex.utils.callLater
>    [mxmlc]   
>setTimeout(org.apache.flex.utils.Language.closure(makeCalls, this,
>'makeCalls'), 0);
>
>Package level functions should be treated as static methods.
>
>It might not be a bad idea to add a directive to allow developers to
>avoid Language.closure calls at will, but I think the “correct” general
>solution is to never output Language.closure in static and package level
>functions.
>
>> On Jul 17, 2017, at 9:16 AM, Alex Harui <ah...@adobe.com.INVALID>
>>wrote:
>> 
>> I don't see any current way to suppress the Language.closure.  Without
>> flow-analysis, I'm not sure the compiler can tell.  It could guess that
>> the identifier is a parameter, but the parameter variable could be
>> assigned within the function body.
>> 
>> We could add a new directive like @flexjsisclosure or something like
>>that.
>> 
>> Thoughts?
>> -Alex
>> 
>> On 7/16/17, 10:05 AM, "Harbs" <ha...@gmail.com> wrote:
>> 
>>> I figured out the problem.
>>> 
>>> org.apache.flex.utils.callLater has the following code:
>>> setTimeout(makeCalls, 0);
>>> 
>>> That compiles to:
>>> setTimeout(org.apache.flex.utils.Language.closure(makeCalls, this,
>>> 'makeCalls'), 0);
>>> 
>>> When Language.closure is called, it messes up the scope of the calls
>>> variable and subsequent calls to makeCalls step on each other. I
>>>believe
>>> this is because makeCalls is bound to the package object of the
>>>callLater
>>> function.
>>> 
>>> Is there any way to prevent rewriting of function calls to
>>> Language.closure?
>>> 
>>> If "setTimeout(makeCalls, 0);" is cross-compiled exactly to:
>>> "setTimeout(makeCalls, 0);", it works like I’d expect it to.
>>> 
>>> Thanks,
>>> Harbs
>>> 
>>>> On Jul 16, 2017, at 3:46 PM, Harbs <ha...@gmail.com> wrote:
>>>> 
>>>> Interesting to note:
>>>> 
>>>> Adding a number of callLater() calls resulted in only the first one
>>>> being called in JS. I did not try as a SWF.
>>> 
>> 
>


Re: [FlexJS] Avoiding Language.closure (was Re: [FlexJS] Debugging package)

Posted by Harbs <ha...@gmail.com>.
A directive could be a solution.

But I think this is an issue with any static method. If a closure is used inside a static method, or a function declared inside a static method, it should not use Language.closure.

FWIW, the Google compile complains about “this” being used in a static method as well:

    [mxmlc] Jul 16, 2017 7:26:08 PM com.google.javascript.jscomp.LoggerErrorManager println
    [mxmlc] WARNING: /Users/harbs/Documents/ApacheFlex/flex-asjs/examples/flexjs/DebuggingExample/bin/js-debug/org/apache/flex/utils/callLater.js:35: WARNING - dangerous use of this in static method org.apache.flex.utils.callLater
    [mxmlc]   setTimeout(org.apache.flex.utils.Language.closure(makeCalls, this, 'makeCalls'), 0);

Package level functions should be treated as static methods.

It might not be a bad idea to add a directive to allow developers to avoid Language.closure calls at will, but I think the “correct” general solution is to never output Language.closure in static and package level functions.

> On Jul 17, 2017, at 9:16 AM, Alex Harui <ah...@adobe.com.INVALID> wrote:
> 
> I don't see any current way to suppress the Language.closure.  Without
> flow-analysis, I'm not sure the compiler can tell.  It could guess that
> the identifier is a parameter, but the parameter variable could be
> assigned within the function body.
> 
> We could add a new directive like @flexjsisclosure or something like that.
> 
> Thoughts?
> -Alex
> 
> On 7/16/17, 10:05 AM, "Harbs" <ha...@gmail.com> wrote:
> 
>> I figured out the problem.
>> 
>> org.apache.flex.utils.callLater has the following code:
>> setTimeout(makeCalls, 0);
>> 
>> That compiles to:
>> setTimeout(org.apache.flex.utils.Language.closure(makeCalls, this,
>> 'makeCalls'), 0);
>> 
>> When Language.closure is called, it messes up the scope of the calls
>> variable and subsequent calls to makeCalls step on each other. I believe
>> this is because makeCalls is bound to the package object of the callLater
>> function.
>> 
>> Is there any way to prevent rewriting of function calls to
>> Language.closure?
>> 
>> If "setTimeout(makeCalls, 0);" is cross-compiled exactly to:
>> "setTimeout(makeCalls, 0);", it works like I’d expect it to.
>> 
>> Thanks,
>> Harbs
>> 
>>> On Jul 16, 2017, at 3:46 PM, Harbs <ha...@gmail.com> wrote:
>>> 
>>> Interesting to note:
>>> 
>>> Adding a number of callLater() calls resulted in only the first one
>>> being called in JS. I did not try as a SWF.
>> 
> 


Re: [FlexJS] Avoiding Language.closure (was Re: [FlexJS] Debugging package)

Posted by Alex Harui <ah...@adobe.com.INVALID>.
I don't see any current way to suppress the Language.closure.  Without
flow-analysis, I'm not sure the compiler can tell.  It could guess that
the identifier is a parameter, but the parameter variable could be
assigned within the function body.

We could add a new directive like @flexjsisclosure or something like that.

Thoughts?
-Alex

On 7/16/17, 10:05 AM, "Harbs" <ha...@gmail.com> wrote:

>I figured out the problem.
>
>org.apache.flex.utils.callLater has the following code:
>setTimeout(makeCalls, 0);
>
>That compiles to:
>setTimeout(org.apache.flex.utils.Language.closure(makeCalls, this,
>'makeCalls'), 0);
>
>When Language.closure is called, it messes up the scope of the calls
>variable and subsequent calls to makeCalls step on each other. I believe
>this is because makeCalls is bound to the package object of the callLater
>function.
>
>Is there any way to prevent rewriting of function calls to
>Language.closure?
>
>If "setTimeout(makeCalls, 0);" is cross-compiled exactly to:
>"setTimeout(makeCalls, 0);", it works like I’d expect it to.
>
>Thanks,
>Harbs
>
>> On Jul 16, 2017, at 3:46 PM, Harbs <ha...@gmail.com> wrote:
>> 
>> Interesting to note:
>> 
>> Adding a number of callLater() calls resulted in only the first one
>>being called in JS. I did not try as a SWF.
>


[FlexJS] Avoiding Language.closure (was Re: [FlexJS] Debugging package)

Posted by Harbs <ha...@gmail.com>.
I figured out the problem.

org.apache.flex.utils.callLater has the following code:
setTimeout(makeCalls, 0);

That compiles to:
setTimeout(org.apache.flex.utils.Language.closure(makeCalls, this, 'makeCalls'), 0);

When Language.closure is called, it messes up the scope of the calls variable and subsequent calls to makeCalls step on each other. I believe this is because makeCalls is bound to the package object of the callLater function.

Is there any way to prevent rewriting of function calls to Language.closure?

If "setTimeout(makeCalls, 0);" is cross-compiled exactly to: "setTimeout(makeCalls, 0);", it works like I’d expect it to.

Thanks,
Harbs

> On Jul 16, 2017, at 3:46 PM, Harbs <ha...@gmail.com> wrote:
> 
> Interesting to note:
> 
> Adding a number of callLater() calls resulted in only the first one being called in JS. I did not try as a SWF.


Re: [FlexJS] Debugging package

Posted by Harbs <ha...@gmail.com>.
I just added an example project (maybe it should have gone into manual tests?).

Interesting to note:

Adding a number of callLater() calls resulted in only the first one being called in JS. I did not try as a SWF.

> On Jul 16, 2017, at 12:24 PM, piotrz <pi...@gmail.com> wrote:
> 
> Thank you! :) And I really like the idea :) 
> 
> Piotr
> 
> 
> 
> -----
> Apache Flex PMC
> piotrzarzycki21@gmail.com
> --
> View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-Debugging-package-tp63288p63292.html
> Sent from the Apache Flex Development mailing list archive at Nabble.com.


Re: [FlexJS] Debugging package

Posted by Harbs <ha...@gmail.com>.
That import should have been commented out in CoreClasses and it should not be compiled.

Does Maven work differently?

> On Jul 16, 2017, at 3:02 PM, piotrz <pi...@gmail.com> wrote:
> 
> Harbs,
> 
> I just tried compile FlexJS by Maven and got following error in core:
> 
> conditionalBreak.as(43): col: 17 Access of possibly undefined property
> debugger.
> 
>                debugger;
>                ^
> 
> Piotr
> 
> 
> 
> -----
> Apache Flex PMC
> piotrzarzycki21@gmail.com
> --
> View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-Debugging-package-tp63288p63298.html
> Sent from the Apache Flex Development mailing list archive at Nabble.com.


Re: [FlexJS] Debugging package

Posted by piotrz <pi...@gmail.com>.
Harbs,

I just tried compile FlexJS by Maven and got following error in core:

conditionalBreak.as(43): col: 17 Access of possibly undefined property
debugger.

                debugger;
                ^

Piotr



-----
Apache Flex PMC
piotrzarzycki21@gmail.com
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-Debugging-package-tp63288p63298.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.

Re: [FlexJS] Debugging package

Posted by piotrz <pi...@gmail.com>.
Thank you! :) And I really like the idea :) 

Piotr



-----
Apache Flex PMC
piotrzarzycki21@gmail.com
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-Debugging-package-tp63288p63292.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.

Re: [FlexJS] Debugging package

Posted by Harbs <ha...@gmail.com>.
Yes. Will do when I’m done.

> On Jul 16, 2017, at 12:18 PM, piotrz <pi...@gmail.com> wrote:
> 
> Harbs,
> 
> It would be great if you could creat Example project which demonstrate how
> to use those functions. 
> Maybe additionally confluence page. 
> 
> Thanks,
> Piotr
> 
> 
> 
> -----
> Apache Flex PMC
> piotrzarzycki21@gmail.com
> --
> View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-Debugging-package-tp63288p63290.html
> Sent from the Apache Flex Development mailing list archive at Nabble.com.


Re: [FlexJS] Debugging package

Posted by piotrz <pi...@gmail.com>.
Harbs,

It would be great if you could creat Example project which demonstrate how
to use those functions. 
Maybe additionally confluence page. 

Thanks,
Piotr



-----
Apache Flex PMC
piotrzarzycki21@gmail.com
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-Debugging-package-tp63288p63290.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.