new MetaScript(sourceOrProgram, filenameopt)
Constructs a new MetaScript instance.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
sourceOrProgram |
string | Source to compile or meta program to run |
|
filename |
string |
<optional> |
Source file name if known, defaults to |
- Source:
Members
-
(static, constant) VERSION :string
-
MetaScript version.
Type:
- string
- Source:
-
filename :string
-
Original source file name.
Type:
- string
- Source:
-
program :string
-
The compiled meta program's source.
Type:
- string
- Source:
-
(nullable) source :string
-
Original source.
Type:
- string
- Source:
Methods
-
(static) compile(source) → {string}
-
Compiles the specified source to a meta program and returns its source.
Parameters:
Name Type Description source
string Source
- Source:
Returns:
Meta program
- Type
- string
-
(static) transform(source, filenameopt, scopenon-null) → {string}
-
Compiles the source to a meta program and transforms it using the specified scope in a new VM context.
Parameters:
Name Type Attributes Description source
string Source
filename
string <optional>
Source file name
scope
Object Scope
- Source:
Returns:
Transformed source
- Type
- string
-
transform(scope) → {string}
-
Runs the meta program with the specified scope in the current context and returns the final document. This method should always be invoked in a fresh or otherwise safe context, so if you do not know exactly what you are doing, use MetaScript.transform instead, which always creates a fresh VM context before calling this method.
Parameters:
Name Type Description scope
Object Scope
- Source:
Returns:
Transformed source
- Type
- string