-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hydroper
committed
Apr 28, 2024
1 parent
6d53ecc
commit 4ab1bc9
Showing
5 changed files
with
148 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Building a Compiler | ||
|
||
An ActionScript compiler does more than just parsing, including verification, and SWF and SWC processing. | ||
|
||
An ActionScript compiler handles three source file formats: ActionScript 3, MXML, and CSS. | ||
|
||
An ActionScript compiler outputs several problems, constructs a flow graph for every activation, and attaches meaning to tree nodes. | ||
|
||
This project itself is not a compiler, but it's designated to facilitate writing one, parsing the three file formats mentioned. | ||
|
||
## SWF | ||
|
||
The Ruffle player contains a [`swf` package](https://github.com/ruffle-rs/ruffle/tree/master/swf) that reads and writes SWF from or into structures. | ||
|
||
## Domain Memory Operations | ||
|
||
Detect [domain memory operations](https://obtw.wordpress.com/2013/04/03/making-bytearray-faster) to generate optimized AVM2 instructions. | ||
|
||
## Project Configuration | ||
|
||
It is interesting to consider allowing project configurations in a dependency managed manner. Something similiar to `asconfig.json` from the Visual Studio AS&MXML extension, but in a different way to allow dependencies that include their own ActionScript 3 configuration (including options such as `strict`, and `inferTypes`). | ||
|
||
## Special Cases | ||
|
||
Here is the [Special Cases](compilers/special-cases.md) document. | ||
|
||
Here is the [IDE](compilers/ide.md) document. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# IDE | ||
|
||
## Verification | ||
|
||
If the last verification fails due to any syntax errors, keep the semantic database and node tree from the last verification. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Special cases | ||
|
||
## Strict | ||
|
||
Strict mode (default) or ECMAScript mode. | ||
|
||
## Infer types | ||
|
||
Optional infer types option introduced by Apache Royale. | ||
|
||
Infers for initializers and method result types. | ||
|
||
## Reference lookups in source path list | ||
|
||
Similiar to `--source-path` in the MXML compiler, and optional main class file. | ||
|
||
This form of reference lookup does not allow zero or more than one package definition in a file, and the definition at the package must match exactly the source path in the source tree. | ||
|
||
## Reference lookups in included sources list | ||
|
||
Similiar to `--include-sources` (recursive directory or specific file) and `--doc-sources` in the MXML compiler. | ||
|
||
This form of reference lookup allows multiple package definitions within a file. | ||
|
||
## Embed meta-data | ||
|
||
HARMAN introduced additional forms of embedding data with encryption. | ||
|
||
## Vector Data Type | ||
|
||
[Information](https://github.com/hydroper/as3parser/blob/0.3/docs/verifier/vector.md) | ||
|
||
## Namespaces | ||
|
||
[Information](https://github.com/hydroper/as3parser/blob/0.3/docs/verifier/Type/kinds/namespace.md) | ||
|
||
Remember of `static protected`. | ||
|
||
## Event meta-data | ||
|
||
Used by MXML components for event handling. For example, consider the `creationComplete="someCall()"` attribute in a XML file, containing zero or more directives. | ||
|
||
## Data binding | ||
|
||
Certain property attributes in MXML components may have values containing at most one braces group, containing a single expression that locates a bindable property. | ||
|
||
Example from Apache Royale: | ||
|
||
```xml | ||
<j:TextInput id="databinding_ti"> | ||
<j:beads> | ||
<j:TextPrompt prompt="Using databinding"/> | ||
</j:beads> | ||
</j:TextInput> | ||
|
||
<j:Label text="The TextInput field text value is: {databinding_ti.text}"/> | ||
``` | ||
|
||
What about string literals, in case you want to escape the braces? Supporting them might not be an issue. | ||
|
||
## Royale meta-data | ||
|
||
[See all Royale meta-data here](https://apache.github.io/royale-docs/features/as3/metadata) | ||
|
||
## Inline constants | ||
|
||
Inline constants are replaced by their compile-time constant value. | ||
|
||
``` | ||
CONFIG::DEBUG | ||
``` | ||
|
||
## Scope | ||
|
||
```as3 | ||
package { | ||
import flash.display.Sprite; | ||
// Definitions may be nested in blocks. | ||
{ | ||
public class Main extends Sprite { | ||
{ | ||
protected var xy: * | ||
} | ||
} | ||
} | ||
} | ||
var x: Number | ||
{ | ||
class Example { | ||
function f(): void { | ||
// "x" is visible at this scope. | ||
x | ||
} | ||
} | ||
} | ||
// "Example" is visible at this scope. | ||
Example | ||
``` | ||
|
||
## Float class | ||
|
||
[Information](https://github.com/airsdk/Adobe-Runtime-Support/discussions/3081#discussioncomment-9091556) | ||
|
||
## Package Shadowing | ||
|
||
Properties from imported packages, when fully qualified, shadow variable names in scope. | ||
|
||
## Importing ActionScript 3 components in MXML | ||
|
||
* Use a `xmlns` prefix assigned to the full package name with a trailling `.*` sequence, as in `xmlns:fb="foo.bar.*"`. | ||
* Use the `import` directive in a `fx:Script` tag and refer lexically to a component in the MXML. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters