CompilerTools.LambdaHandling
Exported
addEscapingVariable(s::Symbol, typ, desc::Int64, li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Adds a new escaping variable with the given Symbol "s", type "typ", descriptor "desc" in LambdaInfo "li". Returns true if the variable already existed and its type and descriptor were updated, false otherwise.
source: CompilerTools/src/lambda.jl:365
addEscapingVariable(vd::CompilerTools.LambdaHandling.VarDef, li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Adds a new escaping variable from a VarDef in parameter "vd" into LambdaInfo "li".
source: CompilerTools/src/lambda.jl:384
addGenSym(typ, li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Add a new GenSym to the LambdaInfo in "li" with the given type in "typ". Returns the new GenSym.
source: CompilerTools/src/lambda.jl:393
addLocalVariable(s::Symbol, typ, desc::Int64, li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Adds a new local variable with the given Symbol "s", type "typ", descriptor "desc" in LambdaInfo "li". Returns true if the variable already existed and its type and descriptor were updated, false otherwise.
source: CompilerTools/src/lambda.jl:345
addLocalVariable(vd::CompilerTools.LambdaHandling.VarDef, li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Adds a local variable from a VarDef to the given LambdaInfo.
source: CompilerTools/src/lambda.jl:323
getBody(lambda::Expr) ¶
Returns the body expression part of a lambda expression.
source: CompilerTools/src/lambda.jl:705
getDesc(x::Symbol, li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Returns the descriptor for a local variable or input parameter "x" from LambdaInfo in "li".
source: CompilerTools/src/lambda.jl:265
getRefParams(lambdaInfo::CompilerTools.LambdaHandling.LambdaInfo) ¶
Returns an array of Symbols corresponding to those parameters to the method that are going to be passed by reference. In short, isbits() types are passed by value and !isbits() types are passed by reference.
source: CompilerTools/src/lambda.jl:715
getReturnType(li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Returns the type of the lambda as stored in LambdaInfo "li" and as extracted during lambdaExprToLambdaInfo.
source: CompilerTools/src/lambda.jl:626
getType(x::Symbol, li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Returns the type of a Symbol or GenSym in "x" from LambdaInfo in "li".
source: CompilerTools/src/lambda.jl:235
getVarDef(s::Symbol, li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Returns the VarDef for a Symbol in LambdaInfo in "li"
source: CompilerTools/src/lambda.jl:272
isEscapingVariable(s::Symbol, li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Returns true if the Symbol in "s" is an escaping variable in LambdaInfo in "li".
source: CompilerTools/src/lambda.jl:300
isInputParameter(s::Symbol, li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Returns true if the Symbol in "s" is an input parameter in LambdaInfo in "li".
source: CompilerTools/src/lambda.jl:279
isLocalGenSym(s::GenSym, li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Returns true if the GenSym in "s" is a GenSym in LambdaInfo in "li".
source: CompilerTools/src/lambda.jl:307
isLocalVariable(s::Symbol, li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Returns true if the Symbol in "s" is a local variable in LambdaInfo in "li".
source: CompilerTools/src/lambda.jl:286
lambdaExprToLambdaInfo(lambda::Expr) ¶
Convert a lambda expression into our internal storage format, LambdaInfo. The input is asserted to be an expression whose head is :lambda.
source: CompilerTools/src/lambda.jl:586
lambdaInfoToLambdaExpr(lambdaInfo::CompilerTools.LambdaHandling.LambdaInfo, body) ¶
Convert our internal storage format, LambdaInfo, back into a lambda expression. This takes a LambdaInfo and a body as input parameters. This body can be a body expression or you can pass "nothing" if you want but then you will probably need to set the body in args[3] manually by yourself.
source: CompilerTools/src/lambda.jl:673
lambdaTypeinf(lambda::LambdaStaticData, typs::Tuple) ¶
Force type inference on a LambdaStaticData object. Return both the inferred AST that is to a "code_typed(Function, (type,...))" call, and the inferred return type of the input method.
source: CompilerTools/src/lambda.jl:637
replaceExprWithDict!(expr::ANY, dict::Dict{Union{GenSym, Symbol}, Any}) ¶
Replace the symbols in an expression "expr" with those defined in the dictionary "dict". Return the result expression, which may share part of the input expression, and the input "expr" may be modified inplace and shall not be used after this call. Note that unlike "replaceExprWithDict", the traversal here is done by ASTWalker, which has the ability to traverse non-Expr data.
source: CompilerTools/src/lambda.jl:511
replaceExprWithDict!(expr::ANY, dict::Dict{Union{GenSym, Symbol}, Any}, AstWalkFunc) ¶
Replace the symbols in an expression "expr" with those defined in the dictionary "dict". Return the result expression, which may share part of the input expression, and the input "expr" may be modified inplace and shall not be used after this call. Note that unlike "replaceExprWithDict", the traversal here is done by ASTWalker, which has the ability to traverse non-Expr data.
source: CompilerTools/src/lambda.jl:511
replaceExprWithDict(expr, dict::Dict{Union{GenSym, Symbol}, Any}) ¶
Replace the symbols in an expression "expr" with those defined in the dictionary "dict". Return the result expression, which may share part of the input expression, but the input "expr" remains intact and is not modified.
Note that unlike "replaceExprWithDict!", we do not recurse down nested lambda expressions (i.e., LambdaStaticData or DomainLambda or any other none Expr objects are left unchanged). If such lambdas have escaping names that are to be replaced, then the result will be wrong.
source: CompilerTools/src/lambda.jl:473
updateAssignedDesc(lambdaInfo::CompilerTools.LambdaHandling.LambdaInfo, symbol_assigns::Dict{Symbol, Int64}) ¶
Update the descriptor part of the VarDef dealing with whether the variable is assigned or not in the function. Takes the lambdaInfo and a dictionary that maps symbols names to the number of times they are statically assigned in the function.
source: CompilerTools/src/lambda.jl:682
CompilerTools.LambdaHandling.LambdaInfo ¶
An internal format for storing a lambda expression's args[1] and args[2]. The input parameters are stored as a Set since they must be unique and it makes for faster searching. The VarDefs are stored as a dictionary from symbol to VarDef since type lookups are reasonably frequent and need to be fast. The GenSym part (args[2][3]) is stored as an array since GenSym's are indexed. Captured_outer_vars and static_parameter_names are stored as arrays for now since we don't expect them to be changed much.
source: CompilerTools/src/lambda.jl:86
CompilerTools.LambdaHandling.VarDef ¶
Represents the triple stored in a lambda's args[2][1]. The triple is 1) the Symbol of an input parameter or local variable, 2) the type of that Symbol, and 3) a descriptor for that symbol. The descriptor can be 0 if the variable is an input parameter, 1 if it is captured, 2 if it is assigned within the function, 4 if it is assigned by an inner function, 8 if it is const, and 16 if it is assigned to statically only once by the function.
source: CompilerTools/src/lambda.jl:68
SymGen ¶
Type aliases for different unions of Symbol, SymbolNode, and GenSym.
source: CompilerTools/src/lambda.jl:54
Internal
addDescFlag(s::Symbol, desc_flag::Int64, li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Add one or more bitfields in "desc_flag" to the descriptor for a variable.
source: CompilerTools/src/lambda.jl:330
addInputParameter(vd::CompilerTools.LambdaHandling.VarDef, li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Add Symbol "s" as input parameter to LambdaInfo "li".
source: CompilerTools/src/lambda.jl:218
addInputParameters(collection, li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Add all variable in "collection" as input parameters to LambdaInfo "li".
source: CompilerTools/src/lambda.jl:226
addLocalVar(name::AbstractString, typ, desc::Int64, li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Add a local variable to the function corresponding to LambdaInfo in "li" with name (as String), type and descriptor. Returns true if variable already existed and was updated, false otherwise.
source: CompilerTools/src/lambda.jl:402
addLocalVar(name::Symbol, typ, desc::Int64, li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Add a local variable to the function corresponding to LambdaInfo in "li" with name (as Symbol), type and descriptor. Returns true if variable already existed and was updated, false otherwise.
source: CompilerTools/src/lambda.jl:410
addLocalVariables(collection, li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Add multiple local variables from some collection type.
source: CompilerTools/src/lambda.jl:314
count_symbols(x::Symbol, state::CompilerTools.LambdaHandling.CountSymbolState, top_level_number, is_top_level, read) ¶
Adds symbols and gensyms to their corresponding sets in CountSymbolState when they are seen in the AST.
source: CompilerTools/src/lambda.jl:141
createMeta(lambdaInfo::CompilerTools.LambdaHandling.LambdaInfo) ¶
Create the args[2] part of a lambda expression given an object of our internal storage format LambdaInfo.
source: CompilerTools/src/lambda.jl:655
createVarDict(x::Array{Any, 1}) ¶
Convert the lambda expression's args[2][1] from Array{Array{Any,1},1} to a Dict{Symbol,VarDef}. The internal triples are extracted and asserted that name and desc are of the appropriate type.
source: CompilerTools/src/lambda.jl:439
dictToArray(x::Dict{Symbol, CompilerTools.LambdaHandling.VarDef}) ¶
Convert the Dict{Symbol,VarDef} internal storage format from a dictionary back into an array of Any triples.
source: CompilerTools/src/lambda.jl:644
eliminateUnusedLocals!(li::CompilerTools.LambdaHandling.LambdaInfo, body::Expr) ¶
Eliminates unused symbols from the LambdaInfo var_defs. Takes a LambdaInfo to modify, the body to scan using AstWalk and an optional callback to AstWalk for custom AST types.
source: CompilerTools/src/lambda.jl:181
eliminateUnusedLocals!(li::CompilerTools.LambdaHandling.LambdaInfo, body::Expr, AstWalkFunc) ¶
Eliminates unused symbols from the LambdaInfo var_defs. Takes a LambdaInfo to modify, the body to scan using AstWalk and an optional callback to AstWalk for custom AST types.
source: CompilerTools/src/lambda.jl:181
getLocalVariables(li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Returns an array of Symbols for local variables.
source: CompilerTools/src/lambda.jl:293
mergeLambdaInfo(outer::CompilerTools.LambdaHandling.LambdaInfo, inner::CompilerTools.LambdaHandling.LambdaInfo) ¶
Merge "inner" lambdaInfo into "outer", and "outer" is changed as result. Note that the input_params, static_parameter_names, and escaping_defs of "outer" do not change, other fields are merged. The GenSyms in "inner" will need to adjust their indices as a result of this merge. We return a dictionary that maps from old GenSym to new GenSym for "inner", which can be used to adjust the body Expr of "inner" lambda using "replaceExprWithDict" or "replaceExprWithDict!".
source: CompilerTools/src/lambda.jl:557
removeLocalVar(name::Symbol, li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Remove a local variable from lambda "li" given the variable's "name". Returns true if the variable existed and it was removed, false otherwise.
source: CompilerTools/src/lambda.jl:426
show(io::IO, li::CompilerTools.LambdaHandling.LambdaInfo) ¶
Pretty print a LambdaInfo.
source: CompilerTools/src/lambda.jl:98
CompilerTools.LambdaHandling.CountSymbolState ¶
Holds symbols and gensyms that are seen in a given AST when using the specified callback to handle non-standard Julia AST types.
source: CompilerTools/src/lambda.jl:129