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,
) -> StructAllocates 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
nameThe 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,
) -> StructAllocates 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
nameThe 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,
) -> StructReuses a local variable with the supplied name, if one exists in the
current scope. Otherwise, behaves identically to allocLocal.
Arguments
nameThe 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,
) -> StructCreates an accessor expression.
Arguments
collectionThe term containing the collection to access.
keyThe 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,
) -> StructEmits the instruction for a short-circuiting logical AND expression.
Arguments
eagerThe term which evaluates immediately.
lazyThe 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,
) -> StructEmits the instruction to create a new array literal.
Arguments
valuesThe 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,
) -> StructAttempts 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
typeThe assignment type to use.
lhsThe assignment target to use. Typically this is a local/global variable get expression.
rhsThe 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,
) -> StructCreates a binary operator.
Arguments
operatorThe operator type to use.
lhsThe left-hand side operand.
rhsThe 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,
) -> StructEmits the instruction to break from the current loop with a specified value.
Arguments
valueThe 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,
) -> StructEmits the instruction to call a function with a set of arguments.
Arguments
calleeThe instruction containing the function to call.
argsThe 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,
) -> StructEmits the instruction to call a constructor function with a set of arguments.
Arguments
calleeThe instruction containing the function to call.
argsThe the arguments to pass into the function call.
location(optional)The source location of this value term.
Returns Struct
ยง createContinuetop ^
GameMaker Language (.gml)Copystatic createContinue = function(
location? : Real,
) -> StructEmits 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,
) -> StructSearches a for a variable with the supplied name and emits a get instruction for it.
Arguments
nameThe 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,
) -> StructEmits the instruction for an if statement.
Arguments
conditionThe term which evaluates to the condition of the if statement.
ifTrueThe term which evaluates if the condition of the if statement is true.
ifFalseThe 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,
) -> StructEmits the instruction for a generic loop. GML style while,
for, and do loops can be implemented in terms of this function.
Arguments
preConditionThe term which evaluates to the condition of a
whileloop. Can beundefined.postConditionThe term which evaluates to the condition of a
doloop. Can beundefined.stepThe term which evaluates to the step of a
forloop. Can beundefined.bodyThe 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
valueThe term to evaluate and compare against.
armsA list of pairs where the first term is compared against
valueand 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,
) -> StructEmits the instruction for a short-circuiting logical OR expression.
Arguments
eagerThe term which evaluates immediately.
lazyThe term which evaluates if the first term is false.
location(optional)The source location of this value term.
Returns Struct
ยง createParamstop ^
GameMaker Language (.gml)Copystatic createParams = function(
property : Struct,
key : Struct,
location? : Real,
) -> StructCreates a params expression.
Arguments
propertyThe term containing the property to access.
keyThe 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,
) -> StructCreates a params expression.
Arguments
propertyThe 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,
) -> StructCreates a property expression.
Arguments
propertyThe 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,
) -> StructEmits the instruction to return a value from the current function.
Arguments
valueThe 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,
) -> StructCreates 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
termThe term to register to the current block.
ยง createStructtop ^
GameMaker Language (.gml)Copystatic createStruct = function(
values : Array,
location? : Real,
) -> StructEmits the instruction to create a new struct literal.
Arguments
valuesThe key-value pairs to populate the struct 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,
) -> StructCreates a binary operator.
Arguments
operatorThe operator type to use.
valueThe 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,
) -> StructEmits the instruction to return a new constant value.
Arguments
valueThe 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,
) -> StructEmits the instruction for a GML style with loop.
Arguments
scopeThe term which evaluates to the self scope of the
withloop.bodyThe body of the while loop.
location(optional)The source location of this value term.
Returns Struct
ยง gettop ^
GameMaker Language (.gml)Copystatic get = function()
-> StructReturns the underlying representation of this builder.
Returns Struct
ยง popBlocktop ^
GameMaker Language (.gml)Copystatic popBlock = function(
location? : Real,
) -> StructClears 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,
) -> StructFinalises 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
createLoopinstead.
Emits the instruction for a GML style while loop.
Arguments
conditionThe term which evaluates to the condition of the
whileloop.bodyThe body of the while loop.
location(optional)The source location of this value term.
Returns Struct