Skip to content

Building a compiler: special cases

Matheus Dias de Souza edited this page May 5, 2024 · 3 revisions

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

The Vector class is treated in a special way for compatibility. The program or an external library defines the __AS3__.vec.Vector class and the verifier automatically turns it into a generic class with a type parameter.

Code generation

An ActionScript 3 compiler should generate a multiname for a Vector type with type arguments as follows:

TypeName(QName(PackageNamespace("__AS3__.vec"),"Vector")<QName(PackageNamespace(""),"Number")>)

An ActionScript 3 compiler should generate a Class object for a Vector type with type arguments as follows:

getlex QName(PackageNamespace("__AS3__.vec"),"Vector")
getlex QName(PackageNamespace(""),"Number")
applytype (1)

Namespaces

Information

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:

<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

Inline constants

Inline constants are replaced by their compile-time constant value.

CONFIG::DEBUG

Scope

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

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 a xmlns prefix assigned to * to import the top-level package.
  • Use the import directive in a fx:Script tag and refer lexically to a component in the MXML.

Dynamic

  • The Object and * data types are fully dynamic, thus they may be mixed freely in operations, such as addition, property and query operators and iteration.
  • There are dynamic classes, which allow for dynamic property operations and iteration.

Proxy

In case it is necessary, the flash_proxy namespace is defined as:

public namespace flash_proxy = "http://www.adobe.com/2006/actionscript/flash/proxy";