struct CatspeakIRBuilder
GameMaker Language (.gml)Copyfunction CatspeakIRBuilder() constructor {
// 5 fields omitted
}
๐ฌ This is an experimental feature. It may change at any moment.
Intended to be a stable inferface for generating code for Catspeak IR programs. The preferred method of creating correctly formed, and optimised Catspeak IR.
ยง allocArgtop ^
GameMaker Language (.gml)Copystatic allocArg = function(
name : String,
location? : Real,
) -> Struct
Allocates a new named function argument with the supplied name. Returns a term to get or set the value of this argument.
โ ๏ธ WarningAll parameter names must be allocated before allocating any local variables.
Arguments
name
The name of the local variable to allocate.
location
(optional)The source location of this local variable.
Returns Struct
ยง allocLocaltop ^
GameMaker Language (.gml)Copystatic allocLocal = function(
name : String,
location? : Real,
) -> Struct
Allocates a new local variable with the supplied name in the current scope. Returns a term to get or set the value of this local variable.
Arguments
name
The name of the local variable to allocate.
location
(optional)The source location of this local variable.
Returns Struct
ยง allocLocalOrReusetop ^
GameMaker Language (.gml)Copystatic allocLocalOrReuse = function(
name : String,
location? : Real,
) -> Struct
Reuses a local variable with the supplied name, if one exists in the
current scope. Otherwise, behaves identically to allocLocal
.
Arguments
name
The name of the local variable to allocate.
location
(optional)The source location of this local variable.
Returns Struct
ยง createAccessortop ^
GameMaker Language (.gml)Copystatic createAccessor = function(
collection : Struct,
key : Struct,
location? : Real,
) -> Struct
Creates an accessor expression.
Arguments
collection
The term containing the collection to access.
key
The term containing the key to access the collection with.
location
(optional)The source location of this term.
Returns Struct
ยง createAndtop ^
GameMaker Language (.gml)Copystatic createAnd = function(
eager : Struct,
lazy : Struct,
location? : Real,
) -> Struct
Emits the instruction for a short-circuiting logical AND expression.
Arguments
eager
The term which evaluates immediately.
lazy
The term which evaluates if the first term is true.
location
(optional)The source location of this value term.
Returns Struct
ยง createArraytop ^
GameMaker Language (.gml)Copystatic createArray = function(
values : Array,
location? : Real,
) -> Struct
Emits the instruction to create a new array literal.
Arguments
values
The values to populate the array with.
location
(optional)The source location of this value term.
Returns Struct
ยง createAssigntop ^
GameMaker Language (.gml)Copystatic createAssign = function(
type : Enum.CatspeakAssign,
lhs : Struct,
rhs : Struct,
location? : Real,
) -> Struct
Attempts to assign a right-hand-side value to a left-hand-side target.
๐ NoteEither terms A or B could be optimised or modified, therefore you should always treat both terms as being invalid after calling this method. Always use the result returned by this method as the new source of truth.
Arguments
type
The assignment type to use.
lhs
The assignment target to use. Typically this is a local/global variable get expression.
rhs
The assignment target to use. Typically this is a local/global variable get expression.
location
(optional)The source location of this assignment.
Returns Struct
ยง createBinarytop ^
GameMaker Language (.gml)Copystatic createBinary = function(
operator : Enum.CatspeakOperator,
lhs : String,
rhs : String,
location? : Real,
) -> Struct
Creates a binary operator.
Arguments
operator
The operator type to use.
lhs
The left-hand side operand.
rhs
The right-hand side operand.
location
(optional)The source location of this term.
Returns Struct
ยง createBreaktop ^
GameMaker Language (.gml)Copystatic createBreak = function(
value : Struct,
location? : Real,
) -> Struct
Emits the instruction to break from the current loop with a specified value.
Arguments
value
The instruction for the value to break with.
location
(optional)The source location of this value term.
Returns Struct
ยง createCalltop ^
GameMaker Language (.gml)Copystatic createCall = function(
callee : Struct,
args : Struct,
location? : Real,
) -> Struct
Emits the instruction to call a function with a set of arguments.
Arguments
callee
The instruction containing the function to call.
args
The the arguments to pass into the function call.
location
(optional)The source location of this value term.
Returns Struct
ยง createCallNewtop ^
GameMaker Language (.gml)Copystatic createCallNew = function(
callee : Struct,
args : Struct,
location? : Real,
) -> Struct
Emits the instruction to call a constructor function with a set of arguments.
Arguments
callee
The instruction containing the function to call.
args
The the arguments to pass into the function call.
location
(optional)The source location of this value term.
Returns Struct
ยง createCatchtop ^
GameMaker Language (.gml)Copystatic createCatch = function(
eager : Struct,
lazy : Struct,
localRef : Struct,
location? : Real,
) -> Struct
Creates an instruction for catching exceptions.
Arguments
eager
The term which evaluates immediately, maybe raising an exception.
lazy
The term which evaluates if the first term is exceptional.
localRef
The local variable to write the exception to. Can be
undefined
is no variable is needed/wanted.location
(optional)The source location of this term.
Returns Struct
ยง createContinuetop ^
GameMaker Language (.gml)Copystatic createContinue = function(
location? : Real,
) -> Struct
Emits the instruction to continue to the next iteration of the current loop.
Arguments
location
(optional)The source location of this value term.
Returns Struct
ยง createGettop ^
GameMaker Language (.gml)Copystatic createGet = function(
name : String,
location? : Real,
) -> Struct
Searches a for a variable with the supplied name and emits a get instruction for it.
Arguments
name
The name of the variable to search for.
location
(optional)The source location of this term.
Returns Struct
ยง createIftop ^
GameMaker Language (.gml)Copystatic createIf = function(
condition : Struct,
ifTrue : Struct,
ifFalse : Struct,
location? : Real,
) -> Struct
Emits the instruction for an if statement.
Arguments
condition
The term which evaluates to the condition of the if statement.
ifTrue
The term which evaluates if the condition of the if statement is true.
ifFalse
The term which evaluates if the condition of the if statement is false.
location
(optional)The source location of this value term.
Returns Struct
ยง createLooptop ^
GameMaker Language (.gml)Copystatic createLoop = function(
preCondition : Struct,
postCondition : Struct,
step : Struct,
body : Struct,
location? : Real,
) -> Struct
Emits the instruction for a generic loop. GML style while
,
for
, and do
loops can be implemented in terms of this function.
Arguments
preCondition
The term which evaluates to the condition of a
while
loop. Can beundefined
.postCondition
The term which evaluates to the condition of a
do
loop. Can beundefined
.step
The term which evaluates to the step of a
for
loop. Can beundefined
.body
The body of the while loop.
location
(optional)The source location of this value term.
Returns Struct
ยง createMatchtop ^
GameMaker Language (.gml)Copystatic createMatch = function(
value : Struct,
arms : Array,
location? : Real,
)
Emits the instruction for a match expression.
Arguments
value
The term to evaluate and compare against.
arms
A list of pairs where the first term is compared against
value
and the second term is returned if both match.location
(optional)The source location of this match term.
ยง createOrtop ^
GameMaker Language (.gml)Copystatic createOr = function(
eager : Struct,
lazy : Struct,
location? : Real,
) -> Struct
Emits the instruction for a short-circuiting logical OR expression.
Arguments
eager
The term which evaluates immediately.
lazy
The term which evaluates if the first term is false.
location
(optional)The source location of this value term.
Returns Struct
ยง createOthertop ^
GameMaker Language (.gml)Copystatic createOther = function(
location? : Real,
) -> Struct
Creates an instruction for accessing the caller other
.
Arguments
location
(optional)The source location of this term.
Returns Struct
ยง createParamstop ^
GameMaker Language (.gml)Copystatic createParams = function(
property : Struct,
key : Struct,
location? : Real,
) -> Struct
Creates a params expression.
Arguments
property
The term containing the property to access.
key
The term containing the key to access the collection with.
location
(optional)The source location of this term.
Returns Struct
ยง createParamsCounttop ^
GameMaker Language (.gml)Copystatic createParamsCount = function(
property : Struct,
location? : Real,
) -> Struct
Creates a params expression.
Arguments
property
The term containing the property to access.
location
(optional)The source location of this term.
Returns Struct
ยง createPropertytop ^
GameMaker Language (.gml)Copystatic createProperty = function(
property : Struct,
location? : Real,
) -> Struct
Creates a property expression.
Arguments
property
The term containing the property to access.
location
(optional)The source location of this term.
Returns Struct
ยง createReturntop ^
GameMaker Language (.gml)Copystatic createReturn = function(
value : Struct,
location? : Real,
) -> Struct
Emits the instruction to return a value from the current function.
Arguments
value
The instruction for the value to return.
location
(optional)The source location of this value term.
Returns Struct
ยง createSelftop ^
GameMaker Language (.gml)Copystatic createSelf = function(
location? : Real,
) -> Struct
Creates an instruction for accessing the caller self
.
Arguments
location
(optional)The source location of this term.
Returns Struct
ยง createStatementtop ^
GameMaker Language (.gml)Copystatic createStatement = function(
term : Struct,
)
Adds an existing node to the current block's statement list.
Arguments
term
The term to register to the current block.
ยง createStructtop ^
GameMaker Language (.gml)Copystatic createStruct = function(
values : Array,
location? : Real,
) -> Struct
Emits the instruction to create a new struct literal.
Arguments
values
The key-value pairs to populate the struct with.
location
(optional)The source location of this value term.
Returns Struct
ยง createThrowtop ^
GameMaker Language (.gml)Copystatic createThrow = function(
value : Struct,
location? : Real,
) -> Struct
Emits the instruction to raise an exception a specified value.
Arguments
value
The instruction for the value to break with.
location
(optional)The source location of this value term.
Returns Struct
ยง createUnarytop ^
GameMaker Language (.gml)Copystatic createUnary = function(
operator : Enum.CatspeakOperator,
value : String,
location? : Real,
) -> Struct
Creates a binary operator.
Arguments
operator
The operator type to use.
value
The value to apply the operator to.
location
(optional)The source location of this term.
Returns Struct
ยง createValuetop ^
GameMaker Language (.gml)Copystatic createValue = function(
value : Any,
location? : Real,
) -> Struct
Emits the instruction to return a new constant value.
Arguments
value
The value this term should resolve to.
location
(optional)The source location of this value term.
Returns Struct
ยง createWithtop ^
GameMaker Language (.gml)Copystatic createWith = function(
scope : Struct,
body : Struct,
location? : Real,
) -> Struct
Emits the instruction for a GML style with
loop.
Arguments
scope
The term which evaluates to the self scope of the
with
loop.body
The body of the while loop.
location
(optional)The source location of this value term.
Returns Struct
ยง gettop ^
GameMaker Language (.gml)Copystatic get = function()
-> Struct
Returns the underlying representation of this builder.
Returns Struct
ยง popBlocktop ^
GameMaker Language (.gml)Copystatic popBlock = function(
location? : Real,
) -> Struct
Clears the most recent local scope and frees any allocated local variables.
Arguments
location
(optional)The source location of this block.
Returns Struct
ยง popFunctiontop ^
GameMaker Language (.gml)Copystatic popFunction = function(
location? : Real,
) -> Struct
Finalises a Catspeak function and inserts it into the list of known functionScopes and returns its term.
Arguments
location
(optional)The source location of this function definition.
Returns Struct
ยง pushBlocktop ^
GameMaker Language (.gml)Copystatic pushBlock = function(
inherit? : Bool,
)
Starts a new local variable block scope. Any local variables allocated in this scope will be cleared after [popBlock] is called.
Arguments
inherit
(optional)Whether to write terms to the parent block or not. Defaults to
false
, which will always create a new block term per local scope.
ยง pushFunctiontop ^
GameMaker Language (.gml)Copystatic pushFunction = function()
Begins a new Catspeak function scope.
ยง createWhiletop ^
GameMaker Language (.gml)Copystatic createWhile = function(
condition : Struct,
body : Struct,
location? : Real,
) -> Struct
๐ DeprecatedUse
createLoop
instead.
Emits the instruction for a GML style while
loop.
Arguments
condition
The term which evaluates to the condition of the
while
loop.body
The body of the while loop.
location
(optional)The source location of this value term.
Returns Struct