You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Michael Schmalle <ap...@teotigraphix.com> on 2012/12/29 13:37:51 UTC

Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Quoting Roland Zwaga <ro...@stackandheap.com>:

> On 29 December 2012 01:31, Michael Schmalle <ap...@teotigraphix.com> wrote:
>
>> Wow, Roland you didn't even tell me you were up to no good with asblocks!
>>
>
> Well, it was Christmas time, so I didn't want to bother you :)
>
>
>> I'm glad that freakin year of messing around produced something worth
>> while!
>>
>
> True, at least ONE app has been made using your library, that definitely
> makes up for a year's worth of hard labour, doesn't it? :)
>
>
>> BTW, in my laboratory of parser/compiler madness I am dreaming up a way to
>> make Falcon have writable AST so it can act like jasblocks does and
>> read-write ActionScript. Linked tokens from the parser/tokenizer is the
>> first hurdle but, I could see some nice utility possibilities with a
>> framework extension like that.
>>
>
> A writeable AST would be absolutely a must if we would ever want to
> implement any kind of compile-time AOP functionality. So if that could be
> done eventually, I think this would GREATLY improve the possibilities of
> the compiler. (Not just from an AOP perspective, all sorts of compile-time
> code generation could be added, I'm pretty sure Michael Labriola has a few
> ideas for this :))
> If somehow the compiler can be used through a ANE (AIR Native Extension)
> than little apps like the one I made here with ASBlocks could become even
> easier to build, plus the parsing times would become unnoticable.
> I'll be happy to help out in these cases, so once you get around to it
> let's brainstorm :)

Why couldn't it? I was thinking about that yesterday. It would be the  
data exchange format that would have to be agreed upon, XML, binary?  
What do you think. It would have to be something that the framework in  
asblocks could easily decorate with it's existing API.

Honestly, it seems like I'm in Apache Flex camp for a while so its the  
JS compiler, ASDoc and code generation that I'm going to work on.

Like I said, when they designed Falcon they are not saving the token  
stream like my parsers did which makes this whole, read, write edit A  
LOT harder. Actually it's the edit that would be broken.

With AOP (I'm not to versed on it) but it seems to me that would be  
easy to add. Since altering AST during compile is just managing API  
addition and updating. You are not worried about producing end product  
code that had the exact same formatting as the original source code  
did. Which is when editing is out of the question right now with the  
Falcon compiler.

I'm going to do some experiments, I'll let you know.


>
>> Anyway Roland great job and I saw your pull request, I didn't get notified
>> for it.
>>
>
>  I might have some more pull requests in the future for ASBlocks (I think
> I'll add a addStatementAt(index:int, statement:IAStatement) method to the
> IASMethod implementations for instance). I'll send you an email when I do,
> if github refuses to notify you, I'll just do it manually :)
>

Right, I'm sure you won't break anything so I will just commit them.

Mike




-- 
Michael Schmalle - Teoti Graphix, LLC
http://www.teotigraphix.com
http://blog.teotigraphix.com


Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Michael Schmalle <ap...@teotigraphix.com>.
Quoting Roland Zwaga <ro...@stackandheap.com>:

> On 12/29/12 5:02 AM, "Roland Zwaga" <ro...@stackandheap.com> wrote:
>
>> > Well, I think the fastest communication protocol would actually be AMF. I
>> > see no reason why an ANE couldn't send AMF back and forth. And all of the
>> > serialization logic already exists for that, so implementing it should,
>> > theoratically, be quite straightforward...
>> Probably, but those are tied to Flash/AIR.
>>
>
> Yea, but we were talking about exposing Falcon to AIR using an ANE, so in
> that use-case
> we're tied to Flash/AIR anyways, right?
>

There might be confusion here Alex, Roland and I were talking about  
the asblocks library I have that reads, edits and writes ActionScript  
source code in actionscript, not java. I had made two libraries, one  
that was an AS3 implementation and one that was Java.

When creating a utility application in AIR like the locales he did, he  
is using the AS3 framework to do it inside AIR using AS3 to manipulate  
the AS3 DOM and rewrite the source code to disk from the AS3  
application, so AMF I would assume is completely relevant because the  
application is not ever going to be cross compiled.

Mike

-- 
Michael Schmalle - Teoti Graphix, LLC
http://www.teotigraphix.com
http://blog.teotigraphix.com


Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Roland Zwaga <ro...@stackandheap.com>.
On 12/29/12 5:02 AM, "Roland Zwaga" <ro...@stackandheap.com> wrote:

> > Well, I think the fastest communication protocol would actually be AMF. I
> > see no reason why an ANE couldn't send AMF back and forth. And all of the
> > serialization logic already exists for that, so implementing it should,
> > theoratically, be quite straightforward...
> Probably, but those are tied to Flash/AIR.
>

Yea, but we were talking about exposing Falcon to AIR using an ANE, so in
that use-case
we're tied to Flash/AIR anyways, right?

Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Roland Zwaga <ro...@stackandheap.com>.
> Questions: why isn't this more like injecting an include file into a
> class's
> source code?  Why rename the base class and add more classes to the mix?
>

In the case of a Mixin that would be entirely valid. When implementing
interceptors things
get more complicated though. Its true that all of the interceptor method
bodies could be
merged into the original method, it would just make the weaving more
complicated.
It is avenue worth exploring though.


>
> FWIW, my understanding of Falcon is that each class source file is a
> compilation unit and compilation units are parsed in separate threads.
> Therefore there is no actual point where all ASTs are sitting around.  I
> can
> see a callback when the ASTs for a individual compilation unit is ready to
> be reduced, but I don't know if you can or want to synchronize all AST
> generation across all compilation units.
>

Ok, that might throw a spanner in the works. But I'm not sure if we really
need an AST
for the entire code base, as long as we can resolve references it ought be
ok.
I think we can make it work on a per-compilation-unit basis to be honest.

Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Michael Schmalle <ap...@teotigraphix.com>.
Erik,

This is OT for the thread but maybe you will read this.

Did you accidentally commit unittest.properties in your last commit?  
It looks like you did?

Mike

Quoting Erik de Bruin <er...@ixsoftware.nl>:

>> > Yeah, yeah I know man, I wasn't saying add AOP into the framework, what
>> do
>> > you think I am a JavaScript dev!
>>
>>
>> Well, if you spend enough time in close promixity of Javascript, who knows
>> what happens to your brain :)
>>
>>
> Us JavaScripters don't need no brains, we got Google. Wait, what...?
>
> EdB
>
>
>
>
> --
> Ix Multimedia Software
>
> Jan Luykenstraat 27
> 3521 VB Utrecht
>
> T. 06-51952295
> I. www.ixsoftware.nl
>

-- 
Michael Schmalle - Teoti Graphix, LLC
http://www.teotigraphix.com
http://blog.teotigraphix.com


Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Erik de Bruin <er...@ixsoftware.nl>.
> > Yeah, yeah I know man, I wasn't saying add AOP into the framework, what
> do
> > you think I am a JavaScript dev!
>
>
> Well, if you spend enough time in close promixity of Javascript, who knows
> what happens to your brain :)
>
>
Us JavaScripters don't need no brains, we got Google. Wait, what...?

EdB




-- 
Ix Multimedia Software

Jan Luykenstraat 27
3521 VB Utrecht

T. 06-51952295
I. www.ixsoftware.nl

Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Roland Zwaga <ro...@stackandheap.com>.
> Yeah, yeah I know man, I wasn't saying add AOP into the framework, what do
> you think I am a JavaScript dev!


Well, if you spend enough time in close promixity of Javascript, who knows
what happens to your brain :)


>
> This is what I meant when I said easy. :)


THEN BE MORE CLEAR, I'M A DAFT GIT, REMEMBER! :) hahaha



> So... moral of the story is add a Jira ticket with explicit lowlevel specs
> you need to be implemented for your plugin
>

Yes sir :)

Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Michael Schmalle <ap...@teotigraphix.com>.
Quoting Roland Zwaga <ro...@stackandheap.com>:

>> If some one could give me a simple AOP project example with source code
>> and expected out come, I could get that rolling as well.
>>
>
> As I stated before, if you just provide the low-level API changes, I
> believe the AOP stuff ought to be handled through a plugin.

Yeah, yeah I know man, I wasn't saying add AOP into the framework,  
what do you think I am a JavaScript dev!

> Once the
> low-level API is available I can start work on an AOP implementation. That
> way you can spend your time better on the JS cross-compilation.
>
> Just the low-level bits for AOP are pretty straightforward,

This is what I meant when I said easy. :)

> implementing
> the entire solution is going to be a LOT of work. Especially the pointcut
> scanning logic is not something trivial.
>
> cheers,

So... moral of the story is add a Jira ticket with explicit lowlevel  
specs you need to be implemented for your plugin

Mike


> Roland
>

-- 
Michael Schmalle - Teoti Graphix, LLC
http://www.teotigraphix.com
http://blog.teotigraphix.com


Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Roland Zwaga <ro...@stackandheap.com>.
> If some one could give me a simple AOP project example with source code
> and expected out come, I could get that rolling as well.
>

As I stated before, if you just provide the low-level API changes, I
believe the AOP stuff ought to be handled through a plugin. Once the
low-level API is available I can start work on an AOP implementation. That
way you can spend your time better on the JS cross-compilation.

Just the low-level bits for AOP are pretty straightforward, implementing
the entire solution is going to be a LOT of work. Especially the pointcut
scanning logic is not something trivial.

cheers,

Roland

Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Michael Schmalle <ap...@teotigraphix.com>.
Hi Carlos,

 From all discussions between Roland and I this morning (yes we are  
friends), everything we have talked about I can do.

It's really just a matter of time and priorities. I'm looking at the  
Falcon code right now and I think I could get metadata a full class  
citizen sooner than later for devs to mess around with.

If some one could give me a simple AOP project example with source  
code and expected out come, I could get that rolling as well.

The great thing about working on the compiler is all these projects  
relate to each other.

So Carlos, AOP seems easy based on what we have discussed. This is  
something that needs to be defined in detail on the Wiki before I go  
trudging off in the wilderness to implement though.

For others wondering if I have a life... I work my ass off in the New  
Hampshire winter and take about 3 months off in the summer with my  
family. :)

Mike


Quoting Carlos Rovira <ca...@codeoscopic.com>:

> Hi Roland and Michael,
>
> I'm out in vacation mode, but I see the ticket Roland created and it's
> something about I want to comment since I would want to see in Flex. It's
> without doubt one of the points that makes the difference between Flex and
> other platforms. We have basic metadata annotations and if we turn it to
> make more robust it would be really great.
>
> AOP is as well something many of us would want to have available in Flex.
> AOP and metadata allows you to decouple code, add/remove functionality
> easily across all your application, and create behaviours that can be
> configured to modify the existing code at runtime...this and much more can
> be done with AOP. Swiz framework get a valid and usable AOP implementation
> for a framework, but it had the problem that was relying on some flash
> player debugger, so it was not ready for production.
>
> Without doubt something very powerful that would make the difference.
>
>
>
> 2012/12/29 Roland Zwaga <ro...@stackandheap.com>
>
>> >
>> > Roland, excuse my COMPLETE ignorance on the subject of AOP but what is
>> the
>> > goal of it, how would it help and how is it implemented in code?
>> >
>> > Mike
>>
>>
>> Hehe, ok, explaining AOP in a few paragraphs is kinda hard... Please let me
>> be lazy here and point you to a Wikipedia article:
>>
>> https://en.wikipedia.org/wiki/Aspect-oriented_programming
>>
>> In short, AOP helps you inject cross-cutting concerns into your code base.
>> By injecting these concerns at compile-time, its even possible
>> to automatically implement interfaces or support partial classes.
>>
>> We already tried implementing a runtime version of this using
>> as3commons-bytecode and as3commons-aop, but supporting this stuff @
>> compile-time
>> will make it a lot more powerful.
>>
>> cheers,
>>
>> Roland
>>
>
>
>
> --
> Carlos Rovira
> Director de TecnologĂ­a
> M: +34 607 22 60 05
> F:  +34 912 94 80 80
> http://www.codeoscopic.com
> http://www.directwriter.es
> http://www.avant2.es
>

-- 
Michael Schmalle - Teoti Graphix, LLC
http://www.teotigraphix.com
http://blog.teotigraphix.com


Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Roland Zwaga <ro...@stackandheap.com>.
> AOP is as well something many of us would want to have available in Flex.
> AOP and metadata allows you to decouple code, add/remove functionality
> easily across all your application, and create behaviours that can be
> configured to modify the existing code at runtime...this and much more can
> be done with AOP. Swiz framework get a valid and usable AOP implementation
> for a framework, but it had the problem that was relying on some flash
> player debugger, so it was not ready for production.
>

Hi Carlos,

Swiz was actually using as3commons-bytecode under the hood to generate its
proxy classes,
I'm not aware of any dependency on the debugger player. The only
disadvantage as3commons-bytecode
had was, in order to generate the proxy classes, it had to first parse the
loaded SWF file.
In debug mode this was indeed pretty slow, in release mode it was
acceptable, but I did recommend
people to split their code into modules, so that the AOP functionality
didn't have to parse a huge SWF
file just to generate 5 proxies. So, AOP @runtime was quite limited in its
possibilities at that time.

Mind you, the only reason why I had to parse the existing SWF was because
the Flash player doesn't provide
a complete set of reflection data for classes and methods. Had the
reflection data been complete, the
parsing wouldn't have been necessary and runtime proxy generation would
have been an enormous amount
faster. (Definitely usable for production)

cheers,

Roland

Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Carlos Rovira <ca...@codeoscopic.com>.
Hi Roland and Michael,

I'm out in vacation mode, but I see the ticket Roland created and it's
something about I want to comment since I would want to see in Flex. It's
without doubt one of the points that makes the difference between Flex and
other platforms. We have basic metadata annotations and if we turn it to
make more robust it would be really great.

AOP is as well something many of us would want to have available in Flex.
AOP and metadata allows you to decouple code, add/remove functionality
easily across all your application, and create behaviours that can be
configured to modify the existing code at runtime...this and much more can
be done with AOP. Swiz framework get a valid and usable AOP implementation
for a framework, but it had the problem that was relying on some flash
player debugger, so it was not ready for production.

Without doubt something very powerful that would make the difference.



2012/12/29 Roland Zwaga <ro...@stackandheap.com>

> >
> > Roland, excuse my COMPLETE ignorance on the subject of AOP but what is
> the
> > goal of it, how would it help and how is it implemented in code?
> >
> > Mike
>
>
> Hehe, ok, explaining AOP in a few paragraphs is kinda hard... Please let me
> be lazy here and point you to a Wikipedia article:
>
> https://en.wikipedia.org/wiki/Aspect-oriented_programming
>
> In short, AOP helps you inject cross-cutting concerns into your code base.
> By injecting these concerns at compile-time, its even possible
> to automatically implement interfaces or support partial classes.
>
> We already tried implementing a runtime version of this using
> as3commons-bytecode and as3commons-aop, but supporting this stuff @
> compile-time
> will make it a lot more powerful.
>
> cheers,
>
> Roland
>



-- 
Carlos Rovira
Director de TecnologĂ­a
M: +34 607 22 60 05
F:  +34 912 94 80 80
http://www.codeoscopic.com
http://www.directwriter.es
http://www.avant2.es

Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Roland Zwaga <ro...@stackandheap.com>.
Well, if right now all that is needed is the writeChanges() method, than
that's pretty much all.
Is there some kind of plugin SDK/API for Falcon? An AOP plugin would
typically be something
that runs after the AST has been created to modify that AST further.
It would be the cleanest to have this functionality contained within some
kind of plugin I suppose, would you agree?

On 29 December 2012 15:28, Michael Schmalle <ap...@teotigraphix.com> wrote:

> Ok, just realized I'm not acting as an application developer right now so
> I hit the back button. :)
>
> I get what you need to do it, I'm a tool developer so I will stick to devs
> like you to tell me what you need.
>
>
> Mike
>
> Quoting Roland Zwaga <ro...@stackandheap.com>:
>
>
>>> Roland, excuse my COMPLETE ignorance on the subject of AOP but what is
>>> the
>>> goal of it, how would it help and how is it implemented in code?
>>>
>>> Mike
>>>
>>
>>
>> Hehe, ok, explaining AOP in a few paragraphs is kinda hard... Please let
>> me
>> be lazy here and point you to a Wikipedia article:
>>
>> https://en.wikipedia.org/wiki/**Aspect-oriented_programming<https://en.wikipedia.org/wiki/Aspect-oriented_programming>
>>
>> In short, AOP helps you inject cross-cutting concerns into your code base.
>> By injecting these concerns at compile-time, its even possible
>> to automatically implement interfaces or support partial classes.
>>
>> We already tried implementing a runtime version of this using
>> as3commons-bytecode and as3commons-aop, but supporting this stuff @
>> compile-time
>> will make it a lot more powerful.
>>
>> cheers,
>>
>> Roland
>>
>>
> --
> Michael Schmalle - Teoti Graphix, LLC
> http://www.teotigraphix.com
> http://blog.teotigraphix.com
>
>


-- 
regards,
Roland

-- 
Roland Zwaga
Senior Consultant | Stack & Heap BVBA

+32 (0)486 16 12 62 | roland@stackandheap.com | http://www.stackandheap.com

http://zwaga.blogspot.com
http://www.springactionscript.org
http://www.as3commons.org

Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Michael Schmalle <ap...@teotigraphix.com>.
Ok, just realized I'm not acting as an application developer right now  
so I hit the back button. :)

I get what you need to do it, I'm a tool developer so I will stick to  
devs like you to tell me what you need.

Mike

Quoting Roland Zwaga <ro...@stackandheap.com>:

>>
>> Roland, excuse my COMPLETE ignorance on the subject of AOP but what is the
>> goal of it, how would it help and how is it implemented in code?
>>
>> Mike
>
>
> Hehe, ok, explaining AOP in a few paragraphs is kinda hard... Please let me
> be lazy here and point you to a Wikipedia article:
>
> https://en.wikipedia.org/wiki/Aspect-oriented_programming
>
> In short, AOP helps you inject cross-cutting concerns into your code base.
> By injecting these concerns at compile-time, its even possible
> to automatically implement interfaces or support partial classes.
>
> We already tried implementing a runtime version of this using
> as3commons-bytecode and as3commons-aop, but supporting this stuff @
> compile-time
> will make it a lot more powerful.
>
> cheers,
>
> Roland
>

-- 
Michael Schmalle - Teoti Graphix, LLC
http://www.teotigraphix.com
http://blog.teotigraphix.com


Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Roland Zwaga <ro...@stackandheap.com>.
>
> Roland, excuse my COMPLETE ignorance on the subject of AOP but what is the
> goal of it, how would it help and how is it implemented in code?
>
> Mike


Hehe, ok, explaining AOP in a few paragraphs is kinda hard... Please let me
be lazy here and point you to a Wikipedia article:

https://en.wikipedia.org/wiki/Aspect-oriented_programming

In short, AOP helps you inject cross-cutting concerns into your code base.
By injecting these concerns at compile-time, its even possible
to automatically implement interfaces or support partial classes.

We already tried implementing a runtime version of this using
as3commons-bytecode and as3commons-aop, but supporting this stuff @
compile-time
will make it a lot more powerful.

cheers,

Roland

Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Michael Schmalle <ap...@teotigraphix.com>.
Quoting Roland Zwaga <ro...@stackandheap.com>:

>
>>
>> Right, API to IClassNode.setName("**MyClassBase")
>>
>> There is a step here that doesn't exist which would be like
>> writeChanges(whatChanges), which is about the only aspect of this that
>> needs more than 10 minutes of thought, everything else is covered.
>>
>> Side note; The Falcon parser is so fast that to update offsets after code
>> is inserted is just a matter of reparsing the file with the new code, this
>> will give you updated AST without changing the source file yet.
>>
>
>
> Alright, so almost everything is in place for AOP, this is exciting :)
>

Roland, excuse my COMPLETE ignorance on the subject of AOP but what is  
the goal of it, how would it help and how is it implemented in code?

Mike


-- 
Michael Schmalle - Teoti Graphix, LLC
http://www.teotigraphix.com
http://blog.teotigraphix.com


Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Roland Zwaga <ro...@stackandheap.com>.
> Heh, you know me, I will probably have something working sooner than
> later. If I don't waste to much time making trance music...


Yea, same problem here, I just bought one of these, so I'm slightly
distracted :)
http://1010.co.uk/org/blackdeath.html



> Generating extra classes etc shouldn't be a problem I suppose?
>
> We can already do this with ASEmitter.java in FalconJx, look at all the
> unit tests. :)


Yea, I gathered as much, but just checking :)


>
> Right, API to IClassNode.setName("**MyClassBase")
>
> There is a step here that doesn't exist which would be like
> writeChanges(whatChanges), which is about the only aspect of this that
> needs more than 10 minutes of thought, everything else is covered.
>
> Side note; The Falcon parser is so fast that to update offsets after code
> is inserted is just a matter of reparsing the file with the new code, this
> will give you updated AST without changing the source file yet.
>


Alright, so almost everything is in place for AOP, this is exciting :)

Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Michael Schmalle <ap...@teotigraphix.com>.
Quoting Roland Zwaga <ro...@stackandheap.com>:

>> I was thinking, maybe I'm not thinking in enough 5th dimensional thought
>> here.
>>
>> I'm not married to linked tokens, because other than Gordon helping out I
>> highly doubt I would even have time to implement that with the current
>> parser.
>>
>> The code when parsed has insane AST source offsets to everything in the
>> actual source file. If we were "injecting" AST into a class/method/etc., we
>> would just basically be substringing it with a replace. The code generation
>> could be done already with the AS emitter I have already made with FalconJx!
>>
>> Holy #$%@! I think that might actually work! :)
>>
>
> Hm, sounds pretty sweet. If its not too much work to create a small
> experiment to proof your theory than this could be a worthy approach :)

Heh, you know me, I will probably have something working sooner than  
later. If I don't waste to much time making trance music...


> Generating extra classes etc shouldn't be a problem I suppose?

We can already do this with ASEmitter.java in FalconJx, look at all  
the unit tests. :)


> What the AOP bits would do, in a nutshell, would basically be renaming an
> existing class, creating a new class with the old name of this class (and
> making it a subclass of the original) and then creating overridden methods
> in the new class.
> Come to think of, with this approach we wouldn't even need to inject
> subtrees into existing AST's... All I need to do is rename certain classes,
> I'm guessing that that wouldn't be too much of a hassle, right?

Right, API to IClassNode.setName("MyClassBase")

There is a step here that doesn't exist which would be like  
writeChanges(whatChanges), which is about the only aspect of this that  
needs more than 10 minutes of thought, everything else is covered.

Side note; The Falcon parser is so fast that to update offsets after  
code is inserted is just a matter of reparsing the file with the new  
code, this will give you updated AST without changing the source file  
yet.

Mike


> Roland
>

-- 
Michael Schmalle - Teoti Graphix, LLC
http://www.teotigraphix.com
http://blog.teotigraphix.com


Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Erik de Bruin <er...@ixsoftware.nl>.
I did. Mea culpa. I know it's not supposed to be there. I have a lot of
files not ready to be committed already in my working copy, guess I missed
one checkbox.

EdB



On Saturday, December 29, 2012, Michael Schmalle wrote:

> Erik,
>
> This is OT for the thread but maybe you will read this.
>
> Did you accidentally commit unittest.properties in your last commit? It
> looks like you did?
>
> Mike
>
> Quoting Erik de Bruin <er...@ixsoftware.nl>:
>
>  > Yeah, yeah I know man, I wasn't saying add AOP into the framework, what
>>> do
>>> > you think I am a JavaScript dev!
>>>
>>>
>>> Well, if you spend enough time in close promixity of Javascript, who
>>> knows
>>> what happens to your brain :)
>>>
>>>
>>>  Us JavaScripters don't need no brains, we got Google. Wait, what...?
>>
>> EdB
>>
>>
>>
>>
>> --
>> Ix Multimedia Software
>>
>> Jan Luykenstraat 27
>> 3521 VB Utrecht
>>
>> T. 06-51952295
>> I. www.ixsoftware.nl
>>
>>
> --
> Michael Schmalle - Teoti Graphix, LLC
> http://www.teotigraphix.com
> http://blog.teotigraphix.com
>
>

-- 
Ix Multimedia Software

Jan Luykenstraat 27
3521 VB Utrecht

T. 06-51952295
I. www.ixsoftware.nl

Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Michael Schmalle <ap...@teotigraphix.com>.
Quoting Alex Harui <ah...@adobe.com>:

>
>
>
> On 12/29/12 8:58 AM, "Michael Schmalle" <ap...@teotigraphix.com> wrote:
>
>> And one other thing;
>>
>> I thought this compiler was written for FlashBuilder, this means Adobe
>> has a huge API for saying files have changed, updating scopes ect.
> Probably true.
>>
>> In the IWorkspace API you can see evidence of this. Which means in a
>> code editor, you are updating source files all the time and
>> reconnecting definitions in the global symbol table which is the
>> workspace which holds projects which hold their compilation units. I
>> see the projects ass the ponds holding the compilation unit boats and
>> the workspace as the earth holding all the ponds, excuse the cheesy
>> analogy.
>>
>> I might be looking at this naively but I think my assumptions have  
>> some value.
> Could be.  I haven't run into any need to know about the workspace.  And I
> believe in the way I'm running FalconJS right now, only one ICompilerProject
> exists, but I don't know if that is supposed to map to FB projects or not.
> So far I haven't needed to know that either.


Well either I am going to know the whole system or walk away. I never  
was one for only know how to start a car and drive forward but not  
know how to backup and switch gears. :)

Mike

> --
> Alex Harui
> Flex SDK Team
> Adobe Systems, Inc.
> http://blogs.adobe.com/aharui
>
>

-- 
Michael Schmalle - Teoti Graphix, LLC
http://www.teotigraphix.com
http://blog.teotigraphix.com


Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Alex Harui <ah...@adobe.com>.


On 12/29/12 8:58 AM, "Michael Schmalle" <ap...@teotigraphix.com> wrote:

> And one other thing;
> 
> I thought this compiler was written for FlashBuilder, this means Adobe
> has a huge API for saying files have changed, updating scopes ect.
Probably true.
> 
> In the IWorkspace API you can see evidence of this. Which means in a
> code editor, you are updating source files all the time and
> reconnecting definitions in the global symbol table which is the
> workspace which holds projects which hold their compilation units. I
> see the projects ass the ponds holding the compilation unit boats and
> the workspace as the earth holding all the ponds, excuse the cheesy
> analogy.
> 
> I might be looking at this naively but I think my assumptions have some value.
Could be.  I haven't run into any need to know about the workspace.  And I
believe in the way I'm running FalconJS right now, only one ICompilerProject
exists, but I don't know if that is supposed to map to FB projects or not.
So far I haven't needed to know that either.

-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui


Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Michael Schmalle <ap...@teotigraphix.com>.
And one other thing;

I thought this compiler was written for FlashBuilder, this means Adobe  
has a huge API for saying files have changed, updating scopes ect.

In the IWorkspace API you can see evidence of this. Which means in a  
code editor, you are updating source files all the time and  
reconnecting definitions in the global symbol table which is the  
workspace which holds projects which hold their compilation units. I  
see the projects ass the ponds holding the compilation unit boats and  
the workspace as the earth holding all the ponds, excuse the cheesy  
analogy.

I might be looking at this naively but I think my assumptions have some value.

Mike


Quoting Michael Schmalle <ap...@teotigraphix.com>:

>
> Quoting Alex Harui <ah...@adobe.com>:
>
>>
>>
>>
>> On 12/29/12 8:26 AM, "Michael Schmalle" <ap...@teotigraphix.com> wrote:
>>
>>
>>>> FWIW, my understanding of Falcon is that each class source file is a
>>>> compilation unit and compilation units are parsed in separate threads.
>>>> Therefore there is no actual point where all ASTs are sitting  
>>>> around.  I can
>>>> see a callback when the ASTs for a individual compilation unit is ready to
>>>> be reduced, but I don't know if you can or want to synchronize all AST
>>>> generation across all compilation units.
>>>
>>> I think you're half correct. If you look at it from a parsing point
>>> your correct, but if you look at it from a definition compilation
>>> point it's incorrect.
>>>
>>> To create a SWF file, Falcon uses the Workspace and a step to
>>> reconnect all scopes which is syncornized after all compilation units
>>> have been parsed.
>> I hadn't noticed that.  I will look for it next time I'm wading through the
>> compiler.  What I thought I saw was that a unit would request abc from
>> another unit, which would result not only in its parsing but in its
>> reduction to byte code which I would think you would want to avoid if you
>> are trying to sync everything up.
>
>
> Well I'm not in the mood to stick my foot in my mouth so I am on a  
> mission to demystify the compiler's actions.
>
> I will post my result on the wiki. I have to many projects I want to  
> do now where not "konwing" this exactly is going to end up wasting  
> my time.
>
> I know when I wrote ASDoc, I was able to resolve everything but I  
> used the MXML compiler as a base. I just need to really understand  
> what is going on now. I takled the multithreading in FalconJx, but  
> when I debug, the multithreading is over after;
>
>
>                 final File outputFolder = new File(outputFile.getParent());
>                 List<ICompilationUnit> reachableCompilationUnits = project
>                         .getReachableCompilationUnitsInSWFOrder(ImmutableSet
>                                 .of(mainCU));
>
> Once this returns I swear it's synced back on 1 thread. After that  
> call I loop through all reachable units and produce .js files for  
> each.
>
> Mike
>
>
>
>
>>
>> --
>> Alex Harui
>> Flex SDK Team
>> Adobe Systems, Inc.
>> http://blogs.adobe.com/aharui
>>
>>
>
> -- 
> Michael Schmalle - Teoti Graphix, LLC
> http://www.teotigraphix.com
> http://blog.teotigraphix.com
>
>

-- 
Michael Schmalle - Teoti Graphix, LLC
http://www.teotigraphix.com
http://blog.teotigraphix.com


Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Michael Schmalle <ap...@teotigraphix.com>.
Quoting Alex Harui <ah...@adobe.com>:

>
>
>
> On 12/30/12 4:57 AM, "Michael Schmalle" <ap...@teotigraphix.com> wrote:
>
>>
>> Quoting Alex Harui <ah...@adobe.com>:
>>
>>>
>>>
>>>
>>> On 12/29/12 8:52 AM, "Michael Schmalle" <ap...@teotigraphix.com> wrote:
>>>
>>>> I know when I wrote ASDoc, I was able to resolve everything but I used
>>>> the MXML compiler as a base. I just need to really understand what is
>>>> going on now. I takled the multithreading in FalconJx, but when I
>>>> debug, the multithreading is over after;
>>>>
>>>>
>>>>                  final File outputFolder = new  
>>>> File(outputFile.getParent());
>>>>                  List<ICompilationUnit> reachableCompilationUnits  
>>>> = project
>>>>
>>>> .getReachableCompilationUnitsInSWFOrder(ImmutableSet
>>>>                                  .of(mainCU));
>>>>
>>>> Once this returns I swear it's synced back on 1 thread. After that
>>>> call I loop through all reachable units and produce .js files for each.
>>> Interesting.  I agree by the time you get here we're back on one thread.
>>> But I'm pretty sure the reducers and emitters have been called at least for
>>> some threads by then.
>>>
>>> I hadn't noticed that was when you were starting your tree walk for
>>> FalconJx.  I thought you were walking in response to the abcbytes request,
>>> but I'm pretty sure when I'm debugging FalconJS, that happens while many
>>> threads are spinning.
>>
>> Yes, this is true. I spent 2 hours on this now and have figured it out.
>>
>> Really, I think there are multiple ways you can implement things here.
>> With the current FalconJS they utilized the existing production
>> framework.
>>
>> Honestly, the way I first did it, I don't see a real problem with it
>> other than not using the multiple threads to create the actual
>> javascript source code (String) like I am doing.

> Yes, I agree you will get correct output by waiting until the threads are
> done, but then are you going to create degenerate reducers/emitters so you
> don't spend time creating ABC instruction lists which is what the threads
> seem to be doing?  Otherwise, you will be inefficient by whatever time is
> spent generating ABC.
>

> create degenerate reducers/emitters

What does this mean?

In FalconJx there is no ABC generation whatsoever. I use the AST and  
FileNode requests; nothing else. So I am parsing and creating the file  
scopes in multiple threads. After all compilation units have their  
file scopes created, I loop through them synchronously to create the  
.js code and save it to disk.

I see being able to alter AST right after this stage. I also see that  
it might just be possible to put the compiler back into multithreaded  
mode to do the below .js source code generation.

The walker is a top down traverse that visits each nod with an emitter  
that saves it's output to a buffer writer. Once walking the FileNode  
is complete, the buffer is flushed to the relevant .js file. Then the  
next compilation unit is processed in the same fashion.

Does this make sense?

PS I was only looking at FalconJS to see what algorithms they were  
using, like I said I ditched ABC for a straight top down traverse and  
emittion strategy.

> --
> Alex Harui
> Flex SDK Team
> Adobe Systems, Inc.
> http://blogs.adobe.com/aharui
>
>

-- 
Michael Schmalle - Teoti Graphix, LLC
http://www.teotigraphix.com
http://blog.teotigraphix.com


Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Alex Harui <ah...@adobe.com>.


On 12/30/12 4:57 AM, "Michael Schmalle" <ap...@teotigraphix.com> wrote:

> 
> Quoting Alex Harui <ah...@adobe.com>:
> 
>> 
>> 
>> 
>> On 12/29/12 8:52 AM, "Michael Schmalle" <ap...@teotigraphix.com> wrote:
>> 
>>> I know when I wrote ASDoc, I was able to resolve everything but I used
>>> the MXML compiler as a base. I just need to really understand what is
>>> going on now. I takled the multithreading in FalconJx, but when I
>>> debug, the multithreading is over after;
>>> 
>>> 
>>>                  final File outputFolder = new File(outputFile.getParent());
>>>                  List<ICompilationUnit> reachableCompilationUnits = project
>>>                
>>> .getReachableCompilationUnitsInSWFOrder(ImmutableSet
>>>                                  .of(mainCU));
>>> 
>>> Once this returns I swear it's synced back on 1 thread. After that
>>> call I loop through all reachable units and produce .js files for each.
>> Interesting.  I agree by the time you get here we're back on one thread.
>> But I'm pretty sure the reducers and emitters have been called at least for
>> some threads by then.
>> 
>> I hadn't noticed that was when you were starting your tree walk for
>> FalconJx.  I thought you were walking in response to the abcbytes request,
>> but I'm pretty sure when I'm debugging FalconJS, that happens while many
>> threads are spinning.
> 
> Yes, this is true. I spent 2 hours on this now and have figured it out.
> 
> Really, I think there are multiple ways you can implement things here.
> With the current FalconJS they utilized the existing production
> framework.
> 
> Honestly, the way I first did it, I don't see a real problem with it
> other than not using the multiple threads to create the actual
> javascript source code (String) like I am doing.
Yes, I agree you will get correct output by waiting until the threads are
done, but then are you going to create degenerate reducers/emitters so you
don't spend time creating ABC instruction lists which is what the threads
seem to be doing?  Otherwise, you will be inefficient by whatever time is
spent generating ABC.

-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui


Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Michael Schmalle <ap...@teotigraphix.com>.
Quoting Alex Harui <ah...@adobe.com>:

>
>
>
> On 12/29/12 8:52 AM, "Michael Schmalle" <ap...@teotigraphix.com> wrote:
>
>> I know when I wrote ASDoc, I was able to resolve everything but I used
>> the MXML compiler as a base. I just need to really understand what is
>> going on now. I takled the multithreading in FalconJx, but when I
>> debug, the multithreading is over after;
>>
>>
>>                  final File outputFolder = new File(outputFile.getParent());
>>                  List<ICompilationUnit> reachableCompilationUnits = project
>>                           
>> .getReachableCompilationUnitsInSWFOrder(ImmutableSet
>>                                  .of(mainCU));
>>
>> Once this returns I swear it's synced back on 1 thread. After that
>> call I loop through all reachable units and produce .js files for each.
> Interesting.  I agree by the time you get here we're back on one thread.
> But I'm pretty sure the reducers and emitters have been called at least for
> some threads by then.
>
> I hadn't noticed that was when you were starting your tree walk for
> FalconJx.  I thought you were walking in response to the abcbytes request,
> but I'm pretty sure when I'm debugging FalconJS, that happens while many
> threads are spinning.

Yes, this is true. I spent 2 hours on this now and have figured it out.

Really, I think there are multiple ways you can implement things here.  
With the current FalconJS they utilized the existing production  
framework.

Honestly, the way I first did it, I don't see a real problem with it  
other than not using the multiple threads to create the actual  
javascript source code (String) like I am doing.

So yeah, I can see where I could implement the same strategy now and  
get the string source production in the multple spawned threads.

What confused me in the beginning was the loop using the JSWriter,  
that is single threaded. What it's going is looping through each  
compilation unit, taking the ABC bytes which are ACTUALLY String bytes  
(created in the buildAndCollectProblems() of the JSTarget) and then  
writing them to disk synchronously.

There is obviously a need for tooling that requires access to the AST  
in the middle of a compile. We CAN do this since all requests are  
async, just because we want to compile async first, adjust AST or  
analyze, update compilation units or projects, dosn't mean we could  
then go and call handleABCRequest async after all that is done.

It's important to note that all the;

- handleABCBytesRequest()
- handleFileScopeRequest()
- handleOutgoingDependenciesRequest()
- handleSWFTagsRequest()
- handleSyntaxTreeRequest()

Can all be called at different times. That is why they abstract the  
the ITarget because different targets (SWC, SWF, JS etc.) need to  
execute these requests in different orders.

I'm not talking about messing around with how SWF production works  
either right now. Experiementing with this stuff in the JS cross  
compiler will show results and if people want to adjust the SWF  
compiler to allow the compiler hooks we will have positivly figured  
out where it's safe to add them.

Mike



> --
> Alex Harui
> Flex SDK Team
> Adobe Systems, Inc.
> http://blogs.adobe.com/aharui
>
>

-- 
Michael Schmalle - Teoti Graphix, LLC
http://www.teotigraphix.com
http://blog.teotigraphix.com


Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Alex Harui <ah...@adobe.com>.


On 12/29/12 8:52 AM, "Michael Schmalle" <ap...@teotigraphix.com> wrote:

> I know when I wrote ASDoc, I was able to resolve everything but I used
> the MXML compiler as a base. I just need to really understand what is
> going on now. I takled the multithreading in FalconJx, but when I
> debug, the multithreading is over after;
> 
> 
>                  final File outputFolder = new File(outputFile.getParent());
>                  List<ICompilationUnit> reachableCompilationUnits = project
>                          .getReachableCompilationUnitsInSWFOrder(ImmutableSet
>                                  .of(mainCU));
> 
> Once this returns I swear it's synced back on 1 thread. After that
> call I loop through all reachable units and produce .js files for each.
Interesting.  I agree by the time you get here we're back on one thread.
But I'm pretty sure the reducers and emitters have been called at least for
some threads by then.

I hadn't noticed that was when you were starting your tree walk for
FalconJx.  I thought you were walking in response to the abcbytes request,
but I'm pretty sure when I'm debugging FalconJS, that happens while many
threads are spinning.

-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui


Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Michael Schmalle <ap...@teotigraphix.com>.
Quoting Alex Harui <ah...@adobe.com>:

>
>
>
> On 12/29/12 8:26 AM, "Michael Schmalle" <ap...@teotigraphix.com> wrote:
>
>
>>> FWIW, my understanding of Falcon is that each class source file is a
>>> compilation unit and compilation units are parsed in separate threads.
>>> Therefore there is no actual point where all ASTs are sitting  
>>> around.  I can
>>> see a callback when the ASTs for a individual compilation unit is ready to
>>> be reduced, but I don't know if you can or want to synchronize all AST
>>> generation across all compilation units.
>>
>> I think you're half correct. If you look at it from a parsing point
>> your correct, but if you look at it from a definition compilation
>> point it's incorrect.
>>
>> To create a SWF file, Falcon uses the Workspace and a step to
>> reconnect all scopes which is syncornized after all compilation units
>> have been parsed.
> I hadn't noticed that.  I will look for it next time I'm wading through the
> compiler.  What I thought I saw was that a unit would request abc from
> another unit, which would result not only in its parsing but in its
> reduction to byte code which I would think you would want to avoid if you
> are trying to sync everything up.


Well I'm not in the mood to stick my foot in my mouth so I am on a  
mission to demystify the compiler's actions.

I will post my result on the wiki. I have to many projects I want to  
do now where not "konwing" this exactly is going to end up wasting my  
time.

I know when I wrote ASDoc, I was able to resolve everything but I used  
the MXML compiler as a base. I just need to really understand what is  
going on now. I takled the multithreading in FalconJx, but when I  
debug, the multithreading is over after;


                 final File outputFolder = new File(outputFile.getParent());
                 List<ICompilationUnit> reachableCompilationUnits = project
                         .getReachableCompilationUnitsInSWFOrder(ImmutableSet
                                 .of(mainCU));

Once this returns I swear it's synced back on 1 thread. After that  
call I loop through all reachable units and produce .js files for each.

Mike




>
> --
> Alex Harui
> Flex SDK Team
> Adobe Systems, Inc.
> http://blogs.adobe.com/aharui
>
>

-- 
Michael Schmalle - Teoti Graphix, LLC
http://www.teotigraphix.com
http://blog.teotigraphix.com


Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Alex Harui <ah...@adobe.com>.


On 12/29/12 8:26 AM, "Michael Schmalle" <ap...@teotigraphix.com> wrote:


>> FWIW, my understanding of Falcon is that each class source file is a
>> compilation unit and compilation units are parsed in separate threads.
>> Therefore there is no actual point where all ASTs are sitting around.  I can
>> see a callback when the ASTs for a individual compilation unit is ready to
>> be reduced, but I don't know if you can or want to synchronize all AST
>> generation across all compilation units.
> 
> I think you're half correct. If you look at it from a parsing point
> your correct, but if you look at it from a definition compilation
> point it's incorrect.
> 
> To create a SWF file, Falcon uses the Workspace and a step to
> reconnect all scopes which is syncornized after all compilation units
> have been parsed.
I hadn't noticed that.  I will look for it next time I'm wading through the
compiler.  What I thought I saw was that a unit would request abc from
another unit, which would result not only in its parsing but in its
reduction to byte code which I would think you would want to avoid if you
are trying to sync everything up.


-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui


Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Michael Schmalle <ap...@teotigraphix.com>.
Quoting Alex Harui <ah...@adobe.com>:

>
>
>
> On 12/29/12 5:19 AM, "Roland Zwaga" <ro...@stackandheap.com> wrote:
>
>
>> Hm, sounds pretty sweet. If its not too much work to create a small
>> experiment to proof your theory than this could be a worthy approach :)
>> Generating extra classes etc shouldn't be a problem I suppose?
>> What the AOP bits would do, in a nutshell, would basically be renaming an
>> existing class, creating a new class with the old name of this class (and
>> making it a subclass of the original) and then creating overridden methods
>> in the new class.
> Questions: why isn't this more like injecting an include file into a class's
> source code?  Why rename the base class and add more classes to the mix?

>> Come to think of, with this approach we wouldn't even need to inject
>> subtrees into existing AST's... All I need to do is rename certain classes,
>> I'm guessing that that wouldn't be too much of a hassle, right?
> FWIW, my understanding of Falcon is that each class source file is a
> compilation unit and compilation units are parsed in separate threads.
> Therefore there is no actual point where all ASTs are sitting around.  I can
> see a callback when the ASTs for a individual compilation unit is ready to
> be reduced, but I don't know if you can or want to synchronize all AST
> generation across all compilation units.

I think you're half correct. If you look at it from a parsing point  
your correct, but if you look at it from a definition compilation  
point it's incorrect.

To create a SWF file, Falcon uses the Workspace and a step to  
reconnect all scopes which is syncornized after all compilation units  
have been parsed.

The hook would be at the step of reconnection where all compilation  
units connect to their super classes etc.

Mind you, this is all speculation and things need to be ironed out.


Mike



> --
> Alex Harui
> Flex SDK Team
> Adobe Systems, Inc.
> http://blogs.adobe.com/aharui
>
>

-- 
Michael Schmalle - Teoti Graphix, LLC
http://www.teotigraphix.com
http://blog.teotigraphix.com


Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Alex Harui <ah...@adobe.com>.


On 12/29/12 5:19 AM, "Roland Zwaga" <ro...@stackandheap.com> wrote:


> Hm, sounds pretty sweet. If its not too much work to create a small
> experiment to proof your theory than this could be a worthy approach :)
> Generating extra classes etc shouldn't be a problem I suppose?
> What the AOP bits would do, in a nutshell, would basically be renaming an
> existing class, creating a new class with the old name of this class (and
> making it a subclass of the original) and then creating overridden methods
> in the new class.
Questions: why isn't this more like injecting an include file into a class's
source code?  Why rename the base class and add more classes to the mix?
> Come to think of, with this approach we wouldn't even need to inject
> subtrees into existing AST's... All I need to do is rename certain classes,
> I'm guessing that that wouldn't be too much of a hassle, right?
FWIW, my understanding of Falcon is that each class source file is a
compilation unit and compilation units are parsed in separate threads.
Therefore there is no actual point where all ASTs are sitting around.  I can
see a callback when the ASTs for a individual compilation unit is ready to
be reduced, but I don't know if you can or want to synchronize all AST
generation across all compilation units.

-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui


Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Roland Zwaga <ro...@stackandheap.com>.
> I was thinking, maybe I'm not thinking in enough 5th dimensional thought
> here.
>
> I'm not married to linked tokens, because other than Gordon helping out I
> highly doubt I would even have time to implement that with the current
> parser.
>
> The code when parsed has insane AST source offsets to everything in the
> actual source file. If we were "injecting" AST into a class/method/etc., we
> would just basically be substringing it with a replace. The code generation
> could be done already with the AS emitter I have already made with FalconJx!
>
> Holy #$%@! I think that might actually work! :)
>

Hm, sounds pretty sweet. If its not too much work to create a small
experiment to proof your theory than this could be a worthy approach :)
Generating extra classes etc shouldn't be a problem I suppose?
What the AOP bits would do, in a nutshell, would basically be renaming an
existing class, creating a new class with the old name of this class (and
making it a subclass of the original) and then creating overridden methods
in the new class.
Come to think of, with this approach we wouldn't even need to inject
subtrees into existing AST's... All I need to do is rename certain classes,
I'm guessing that that wouldn't be too much of a hassle, right?

Roland

Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Michael Schmalle <ap...@teotigraphix.com>.
I was thinking, maybe I'm not thinking in enough 5th dimensional thought here.

I'm not married to linked tokens, because other than Gordon helping  
out I highly doubt I would even have time to implement that with the  
current parser.

The code when parsed has insane AST source offsets to everything in  
the actual source file. If we were "injecting" AST into a  
class/method/etc., we would just basically be substringing it with a  
replace. The code generation could be done already with the AS emitter  
I have already made with FalconJx!

Holy #$%@! I think that might actually work! :)

Mike


Quoting Roland Zwaga <ro...@stackandheap.com>:

>> A writeable AST would be absolutely a must if we would ever want to
>>> implement any kind of compile-time AOP functionality. So if that could be
>>> done eventually, I think this would GREATLY improve the possibilities of
>>> the compiler. (Not just from an AOP perspective, all sorts of compile-time
>>> code generation could be added, I'm pretty sure Michael Labriola has a few
>>> ideas for this :))
>>> If somehow the compiler can be used through a ANE (AIR Native Extension)
>>> than little apps like the one I made here with ASBlocks could become even
>>> easier to build, plus the parsing times would become unnoticable.
>>> I'll be happy to help out in these cases, so once you get around to it
>>> let's brainstorm :)
>>>
>>
>> Why couldn't it? I was thinking about that yesterday. It would be the data
>> exchange format that would have to be agreed upon, XML, binary? What do you
>> think. It would have to be something that the framework in asblocks could
>> easily decorate with it's existing API.
>>
>
> Well, I think the fastest communication protocol would actually be AMF. I
> see no reason why an ANE couldn't send AMF back and forth. And all of the
> serialization logic already exists for that, so implementing it should,
> theoratically, be quite straightforward...
>
>
>> Like I said, when they designed Falcon they are not saving the token
>> stream like my parsers did which makes this whole, read, write edit A LOT
>> harder. Actually it's the edit that would be broken.
>>
>
> Hm, so getting Falcon to edit the locale file like my little app is doing
> right now would be kind of hard to implement if I understand correctly?
>
>
>> With AOP (I'm not to versed on it) but it seems to me that would be easy
>> to add. Since altering AST during compile is just managing API addition and
>> updating. You are not worried about producing end product code that had the
>> exact same formatting as the original source code did. Which is when
>> editing is out of the question right now with the Falcon compiler.
>>
>
> Aha, yes, this is true, AOP would be just about injecting AST subtrees, but
> also renaming stuff (methods, classes, etc). But indeed, there would be no
> concern about formatting or whatever. An AOP extension could detect custom
> metadata that identifies the pointcuts etc and performs the AST injections.
> But for now, just concentrate on the JS and ASDoc parts. :)
>
>
>> I'm going to do some experiments, I'll let you know.
>>
>
> Sure, maybe I can eventually take one of your experiments and start work on
> the AOP bits. Sounds like a plan :)
>
> cheers,
>
> Roland
>

-- 
Michael Schmalle - Teoti Graphix, LLC
http://www.teotigraphix.com
http://blog.teotigraphix.com


Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Alex Harui <ah...@adobe.com>.


On 12/29/12 5:02 AM, "Roland Zwaga" <ro...@stackandheap.com> wrote:
> Well, I think the fastest communication protocol would actually be AMF. I
> see no reason why an ANE couldn't send AMF back and forth. And all of the
> serialization logic already exists for that, so implementing it should,
> theoratically, be quite straightforward...
Probably, but those are tied to Flash/AIR.


-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui


Re: Writable AST and Code generation for Falcon was: [Re: [jira] [Commented] (FLEX-33330) ... )

Posted by Roland Zwaga <ro...@stackandheap.com>.
> A writeable AST would be absolutely a must if we would ever want to
>> implement any kind of compile-time AOP functionality. So if that could be
>> done eventually, I think this would GREATLY improve the possibilities of
>> the compiler. (Not just from an AOP perspective, all sorts of compile-time
>> code generation could be added, I'm pretty sure Michael Labriola has a few
>> ideas for this :))
>> If somehow the compiler can be used through a ANE (AIR Native Extension)
>> than little apps like the one I made here with ASBlocks could become even
>> easier to build, plus the parsing times would become unnoticable.
>> I'll be happy to help out in these cases, so once you get around to it
>> let's brainstorm :)
>>
>
> Why couldn't it? I was thinking about that yesterday. It would be the data
> exchange format that would have to be agreed upon, XML, binary? What do you
> think. It would have to be something that the framework in asblocks could
> easily decorate with it's existing API.
>

Well, I think the fastest communication protocol would actually be AMF. I
see no reason why an ANE couldn't send AMF back and forth. And all of the
serialization logic already exists for that, so implementing it should,
theoratically, be quite straightforward...


> Like I said, when they designed Falcon they are not saving the token
> stream like my parsers did which makes this whole, read, write edit A LOT
> harder. Actually it's the edit that would be broken.
>

Hm, so getting Falcon to edit the locale file like my little app is doing
right now would be kind of hard to implement if I understand correctly?


> With AOP (I'm not to versed on it) but it seems to me that would be easy
> to add. Since altering AST during compile is just managing API addition and
> updating. You are not worried about producing end product code that had the
> exact same formatting as the original source code did. Which is when
> editing is out of the question right now with the Falcon compiler.
>

Aha, yes, this is true, AOP would be just about injecting AST subtrees, but
also renaming stuff (methods, classes, etc). But indeed, there would be no
concern about formatting or whatever. An AOP extension could detect custom
metadata that identifies the pointcuts etc and performs the AST injections.
But for now, just concentrate on the JS and ASDoc parts. :)


> I'm going to do some experiments, I'll let you know.
>

Sure, maybe I can eventually take one of your experiments and start work on
the AOP bits. Sounds like a plan :)

cheers,

Roland