-
1. Re: ASC questions
pmd12345 May 17, 2009 12:03 PM (in response to joa__)General disclaimer:
We’re considering restructuring this code in the near future and can’t guarantee that your work will be compatible with future versions.
1. The Parser does not know about block statements. Is there a reason for that?
None that I'm aware of. I agree, a block node is a good idea. Even if the semantics of a statement-list are exactly the same, we can't recover the original source once this simplification occurs.
2. let statement.
I'm not sure about the future of the let statement given ECMA "Harmony".
3. Overriding Parser methods.
I disagree. It would be better for reusability and stability if the Parser/Scanner module's sole function was to verify syntax
and produce an AST. Given future requirements for compile performance, we may need several parsing solutions.
4. Multiple context classes and global scope confusion.
I agree. I'm looking at some of this code now. It's unnecessarily complex.
5. What is the general strategy one has to follow in order to compile?
Refer to CompilerAPI.java. There's a general workflow model defined there.
6. Is there another way to get to the AST?
If you're interested in a single AST (per file) I think your approach is reasonable. By invoking an instance of the Asc parser directly, you've simplified significantly. However, you could pick up the AST form at later compile stages, which might have completed some transformations and semantic analysis that would be of some use to you. Most code referring to the AST uses some derivation of the Evaluator pattern.
-
2. Re: ASC questions
joa__ May 18, 2009 2:24 AM (in response to pmd12345)Thank you for the quick answer.
If overriding methods of the Parser is not an option that is okay with me. I was just thinking about block statements and the possibility to insert that functionality for myself.
I have also another question. How are you going to handle this case in the near future?
var i: int = 0;
var n: int = 0xff;
for(;i<n;++i)
{
const x: Number = Math.random();
trace(x);
}
This will result in an RTE since x has been declared const and is changed inside the loop. Regarding the lack of scopes in ECMAScript this is of course correct since x is redefined for every iteration of i. But it is very confusing and should be checked at compile time.
Another question I have is about the package scope.
package
{
trace("static ctor0");
public class Foo()
{
trace("static ctor1");
public function Foo()
{
trace("instance ctor");
}
}
}
This will output for new Foo() "static ctor1", "static ctor0", "instance ctor". Why is the package level statement sitting inside the static initializer of the class and why is it executed after the "ctor1" trace?
Best,
Joa
-
3. Re: ASC questions
pmd12345 May 18, 2009 10:28 AM (in response to joa__)Having Asc parser internal methods private allows us to improve it more safely. The existing node form may be simplified as well, which is a major overhaul. If you're considering a feature of general usefulness we might be able to incorporate it as part of ongoing development, else your probably better off branching, since it'll break anyway.
Detection of const declarations within loop constructs:
I'd add the warning at a lint level, since without some dynamic programming (or known tripcount) even flow analysis wont tell you that the loop is intended to execute only once (which would be legal).
Class constructor invocation order:
I think the real question is, "When do package global statements get executed?".
--I'll get back to you on this one.
-
4. Re: ASC questions
pmd12345 May 18, 2009 11:21 AM (in response to pmd12345)According to Erik T.,
Loose global statements like the example get executed whenever the VM decides to run the script init code for that script block. This is usually when a type defined in that script is first referenced. So, if you have global statements in multiple files they could execute in different order based on which code path is taken.
Specifically, for the example below, class inits get hoisted to the top of the script init, so the code will init all the classes, and then run the rest of the script init. The class initialization will run the static initializer for the class, so it shows up first because it got hoisted to the top. -
5. Re: ASC questions
doughie Jun 23, 2009 8:16 AM (in response to joa__)I think i want to do the same thing. I was an AST in xml form.
I have a different approach though.
I am using the asdoc tool and am using the keep xml option. I am then adding methods to the *Node classes that return sensible structures. These are being called in the TopLevelGenerator class.
I am worried that i am adding code to classes that are likely to change with future versions. Is there anything else i can do? Is this a good approach?
TIA
Eamonn
-
6. Re: ASC questions
joa__ Jun 23, 2009 10:03 AM (in response to doughie)One Evaluator already outputs XML. I forgot the name and location but basically you can have a look at macromedia.asc.parser.NodePrinter to figure out how it works.
I think the XML evaluator was located somewhere in the compiler package (not asc) but maybe I am mistaken.
Best,
Joa
-
7. Re: ASC questions
pmd12345 Jun 23, 2009 1:58 PM (in response to doughie)One of the areas currently under development in the Asc Parser is the Node class and the shape of the AST built.
One of the existing Node visitor patterns is likely adaptable for your current purposes.
.
Again, the existing Node classes are subject to change in the very near future and I can almost guarantee that any work
based on the current intermediate representation will be incompatible with ongoing work
-
8. Re: ASC questions
doughie Jun 23, 2009 2:38 PM (in response to pmd12345)Thank you for your quick replies!
I know that the compiler was open sourced not long ago and was wondering if there was any plans to publish a roadmap for the compiler?
I was hoping for docs, future requirements or just a heads up of what is going on.
I think publishing these things would encourage more people to take part. I would love to get involved but feel like I need a little helping hand to get started and some idea of where the compiler is going? does this sound possible and in line with Adobe's plans?
-
9. Re: ASC questions
pmd12345 Jun 23, 2009 10:50 PM (in response to doughie)It'd be fun to have a lot of people working on the compiler. First we need to get some basic components down to simpler representations.
The Node class and the way ast's get built and used can be much improved, we're working on that now. It's so fundamental it's hard to start parallel efforts until that is complete. We're hoping to start defining a clearer roadmap within the next few weeks.
-
10. Re: ASC questions
Glenn Williams Jun 23, 2009 11:52 PM (in response to pmd12345)I quite agree.
More docs and a road map would be a very start start.

