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" <joshtynj...@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 <aha...@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" <joshtynj...@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 <aha...@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" <joshtynj...@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 >><aha...@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" <joshtynj...@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 >> >><joshtynj...@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" <harbs.li...@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 <harbs.li...@gmail.com> >> >>wrote: >> >> >> >>> > >> >> >> >>> >> The compiler needs to be modified to support the debugger >> >> >>statement. >> >> >> >>> >> >> >> >>> >> >> >> >> >> >> >> >> >> >> >> >>