...
For every non-trivial language feature, we should introduce a dedicated child page.
Notation:
$0
,$1
, ... are auxiliary variables generated by the compiler, chosen to avoid name-clashes with any other identifiers in scope.- exp1, exp2, ... (italics) are arbitrary complex ActionScript expressions
Compilation Units
An ActionScript application consists of several compilation units, where one is selected as the application's entry point. A compilation unit is defined in one ActionScript source file, containing a primary declaration and optionally static code. Compilation units are organized in packages.
...
"this" is always in scope
TODO
Statements
TODO
...
Almost all statements can be mapped one-to-one from ActionScript to JavaScript.
There are only two exceptions: for each
and try
... catch
.
for each
Unlike the for
... in
loop, the for each
... in
loop has been introduced to JavaScript later, so to make sure the generated code runs in JavaScript 1.5 browsers, we have to simulate it.
Notation:
$0
,$1
are auxiliary variables generated by the compiler, chosen to avoid name-clashes with any other identifiers in scope.<lhs>
,<rhs>
are arbitrary complex ActionScript expressions<block>
is an ActionScript code block (the loop body)
Then,
Code Block |
---|
for each (<lhs> in <rhs>) {
<block>
}
|
becomes
Code Block |
---|
var $1;
for (var $0 in ($1 = <rhs>)) {
<lhs> = $1[$0];
<block>
}
|
Note that if <block>
is not enclosed by curly braces, these have to added, as we add a second statement to the loop body.
try... catch... finally
TODO
Operators
TODO
&&=
TODO
||=
...