Create function engine #1821
Labels
big
this task is hard and will take a while
blocked
compiler: frontend
Everything to do with type checking, control flow analysis, and everything between parsing and IRgen
P: medium
In order to stop inlining function bodies and eliminate duplicated monomorphization during type checking, we will need to have the ability to refer to function bodies abstractly. Using a function engine during type checking would allow us to do this.
For example, given an untyped function declaration
add(a: u64, b: u64) -> u64
, we would create a typed function declaration and add it to the function engine. During calls toadd
instead of inlining the function body, we add a referenceBody(add, vec!(u64, u64))
, and that will serve as a pointer to the body ofadd
. The return type for the call toadd
would beReturnType(add, vec!(u64, u64))
.Given an untyped function declaration
sub<T>(a: T, b: T) -> T
, we would create a typed function declaration and add it to the function engine. During calls tosub(0u8, 1u8)
instead of inlining the function body, we add a referenceBody(sub, vec!(u8, u8))
. The return type for the call tosub
would beReturnType(sub, vec!(u8, u8))
. We do not perform monomorphization at this time.After type checking has completed, before IR. An additional pass (we will expand upon the pass added here #1820) will be used to resolve all types, monomorphize functions, and resolve all function bodies. During this pass, references like
Body(sub, vec!(u8, u8))
will be used to locate the definition ofsub
that takes typesu8, u8
(or monomorphizesub
and create one, if it does not already exist).The implementation of the function engine will eventually be expanded to a declaration engine (#1692), which will be used to implement #1819.
Blocked by:
Closes:
Unblocks:
where
clause for data structures. #1159where
clause for impl traits #1162where
clause for functions. #1163The text was updated successfully, but these errors were encountered: