Base class for most predefined operations.
Base class for most predefined operations.
Type descriptor for primitive types.
Type descriptor for primitive types.
There is implicit val
declaration for each primitive type.
Base class for virtualized instances of type companions.
Base class for virtualized instances of type companions. Each virtualized entity type (trait or class) may have virtualized companion class.
Default node type for embedding of literal values to graph IR.
Default node type for embedding of literal values to graph IR.
This can be used or those types T
when Elem[T]
is defined,
but Liftable[_,T]
is not, i.e. for non-liftable types.
literal value
type descriptor of IR type T
Descriptor of type constructor of * -> *
kind.
Descriptor of type constructor of * -> *
kind. Type constructor is not a type,
but rather a function from type to type.
It contains methods which abstract relationship between types T
, F[T]
etc.
Immutable data environment used to assign data values to graph nodes.
Base type for all graph nodes (aka computable value definitions).
Base type for all graph nodes (aka computable value definitions). Each graph node or definition represent one operation node of the data flow graph.
Type descriptor of staged types, which correspond to source (unstaged) RTypes defined outside of IR cake.
Type descriptor of staged types, which correspond to source (unstaged) RTypes defined outside of IR cake.
the type represented by this descriptor
Elements cache information for each Elem class.
Base class for all objects generated for virtualized types to support staged evaluation machinery.
Base class for all objects generated for virtualized types to support
staged evaluation machinery.
Each object contains definitions which can be imported when necessary.
All that objects are registered in entityObjects
hash map,
which is done while IR cake is constructed.
State monad for symbols computed in a data environment.
State monad for symbols computed in a data environment.
DataEnv
is used as the state of the state monad.
Type descriptor for A => B
type where descriptors for A
and B
are given as arguments.
Type descriptor which is computed lazily on demand.
Base class for all IR nodes/operations/definitions.
Base class for all IR nodes/operations/definitions.
Variants of owner
parameter of constructors of nested classes:
1) predefined node classes are owned by IR cake (ScalanOwner)
2) entity classes are owned by enclosing EntityObject
Variants of owner
parameter of constructors of nested classes:
1) predefined node classes are owned by IR cake (ScalanOwner)
2) entity classes are owned by enclosing EntityObject
Type descriptor for (A, B)
type where descriptors for A
and B
are given as arguments.
Symbols may temporary refer to this node until their target node is updated.
Symbols may temporary refer to this node until their target node is updated.
Abstract representation of a computable value.
Abstract representation of a computable value.
Default implementation is a simple lightweight reference to the corresponding definition.
Every Ref have direct access to its Def via node
property.
Every Ref is typed, and the type is avaliable via elem
property.
SingleRep
A Ref is a symbolic reference used internally to refer to graph nodes.
A Ref is a symbolic reference used internally to refer to graph nodes. Light weight stateless immutable reference to a graph node (Def[T]). Two symbols are equal if they refer to the nodes with the same id, which is due to Def unification means equal symbols refer to the same instance of Def.
Type descriptor for A | B
type where descriptors for A
and B
are given as arguments.
Untyped shortcut sinonim of Ref, which is used as untyped reference to graph nodes (definitions).
Untyped shortcut sinonim of Ref, which is used as untyped reference to graph nodes (definitions). Following a tradition in compiler engineering we call references to definitions as symbols.
Base class for Ref to Ref transformations.
Base class for Ref to Ref transformations. Each transformer keeps a mapping data between references to original nodes and references to the corresponding transformed nodes.
Node class for typed variables.
Node class for typed variables. In particular for lambda-bound variables.
is independent from nodeId, shouldn't be used as node id.
type descriptor of the variable type
Helper methods to throw errors
Helper methods to throw errors
Logical AND between two pattern matches of the save value x
.
Logical AND between two pattern matches of the save value x
.
Can be used to construct patterns like case P1 && P2 => ...
Type descriptor for Any
, cannot be used implicitly.
Type descriptor for AnyRef
, cannot be used implicitly.
Immutable empty array of symbols, can be used to avoid unnecessary allocations.
Immutable empty array of symbols, can be used to avoid unnecessary allocations.
Used internally in IR and should be used with care since it is mutable.
Used internally in IR and should be used with care since it is mutable. At the same time, it is used in the hotspot and allows to avoid roughly tens of thousands of allocations per second. WARNING: Mutations of this instance can lead to undefined behavior.
Immutable empty Seq, can be used to avoid unnecessary allocations.
Immutable empty Seq, can be used to avoid unnecessary allocations.
Since ListMap is immutable this empty map can be shared by all other maps created from it.
Zero literal node, which is lazily created and can be efficiently reused.
Zero literal node, which is lazily created and can be efficiently reused.
Much faster alternative to (0: Rep[Int])
or toRep(0)
.
Predefined Lazy value saved here to be used in hotspot code.
Data type ST
is liftable is there is Liftable[ST, T] instance for some type T
.
Data type ST
is liftable is there is Liftable[ST, T] instance for some type T
.
Liftable typeclass allows to define which types can have values embedded as literals
into graph IR.
Helper type case method.
Helper type case method.
Helper to type cast node references.
Helper to type cast node references.
Whether IR type descriptors should be cached.
Whether IR type descriptors should be cached.
Whether Tup instances should be cached.
Whether Tup instances should be cached.
Retrieve an instance of the given Elem class by either looking up in the cache or creating a new one.
Retrieve an instance of the given Elem class by either looking up in the cache or creating a new one. We assume that all Elem instances are uniquely defined by (clazz, args)
arguments of Elem class constructor
Elem class
Create new definition entry in either given Thunk or in the global hash table.
Create new definition entry in either given Thunk or in the global hash table.
optional thunk scope to put given definition
symbol refering to d
definition node to add to the scope of globally
reference to d
(which is s
)
Whether to perform extended checks of correctness, expected invariants and data consistency.
Whether to perform extended checks of correctness, expected invariants and data consistency.
NOTE: Since it may add substantial overhead, set it to false
before using in production.
Returns a number of definitions added to this IR context.
Returns a number of definitions added to this IR context.
Create a new empty buffer around pre-allocated empty array.
Create a new empty buffer around pre-allocated empty array. This method is preferred, rather that creating empty debox.Buffer directly because it allows to avoid allocation of the empty array.
Lookup definition in this IR context's hash table of definitions.
Lookup definition in this IR context's hash table of definitions.
node reference to an instance stored in hash table, which is equal to d
and null if there is no definition which is equal to d
Lookup d
in the heap of nodes.
Lookup d
in the heap of nodes. If the lookup is successfull, then
its reference is returned. If the node is not found in the heap, then it is added
and d.self
reference is returned.
node to be added to the head of nodes
producer of the reference to be used as the reference to d
node.
return a reference to d
node in the heap
Get next fresh node id
Get next fresh node id
Lookup of create reference to the given definition.
Lookup of create reference to the given definition.
To lookup d.nodeId
is used as the index in the _symbolTable
.
If Ref is not found in _symbolTable
, then new Ref instance is created
and stored in _symbolTable
at d.nodeId
index.
Returns OwnerKind for the given constructor, using its first parameter.
Returns OwnerKind for the given constructor, using its first parameter.
Lookup node reference by its id.
Lookup node reference by its id. This is simple array access by index O(1) operation.
Invoke source type method corresponding to the given MethodCall node.
Invoke source type method corresponding to the given MethodCall node. This method delegated the work to the given element instance.
type descriptor of receiver node
IR node representing method invocation
environment where each symbol of 'mc' has associated data value
data value returned from invoked method
Log warning message to the log.
Log warning message to the log. This is default and simple implementation, which can be overriden.
Called during resetContext() operation after the core context state has been reset.
Called during resetContext() operation after the core context state has been reset. Derived classes can override to define application specific initialization. Don't forget to call super method in the beginning of your overriding method.
Implicit injection of new definition (graph node) into universum of nodes with collapsing semantics.
Implicit injection of new definition (graph node) into universum of
nodes with collapsing semantics. If there exists node n
in this IR
such that obj equals n
, then the value of n.self
is returned, i.e.
the new node obj
is collapsed with already existing one.
This has an effect of Common Subexpression Elimination (CSE) when
an expression tree is transformed to the graph and identical subtrees
are collapsed.
After a reference to the node is obtained, global rewriting rules are
examined and the reference may be replaced with a new one.
Prettyprint exception message
Prettyprint exception message
Updates the universe of symbols and definitions, then rewrites until fix-point
Updates the universe of symbols and definitions, then rewrites until fix-point
A new graph node to add to the universe
A symbol that will be used if d doesn't exist in the universe
The symbol of the graph which is semantically(up to rewrites) equivalent to d
Lifting of data values to IR nodes.
Lifting of data values to IR nodes.
Transforms this object into new one by applying t
to every Ref inside
its structure.
Transforms this object into new one by applying t
to every Ref inside
its structure. The structure is build out of Seq, Array, Option and Def values.
Other structure items remain unchanged and copied to the new instance.
Create or find symbol (node Ref) which refers to the given node in the table of all created symbols.
Create or find symbol (node Ref) which refers to the given node in the table of all created symbols. The d.nodeId is the index in the _symbolTable which is DBuffer (backed by Array)
new of existing symbol
Extract data value from Const node or throw an exception.
Extract data value from Const node or throw an exception.