-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Textual] lowering closures into objects
Summary: We add a transformation that removes Closure/Apply expressions by classic OO encoding. `Closure`: An expression ``` n0 = fun (p1, p2, p3) -> C.foo(exp1, exp2, p1, p2, p3) ``` is turned into ``` n4 = __sil_allocate(<GENERATED_TYPE_NAME>) store n4.?.x <- exp1 store n4.?.y <- exp2 ``` where `C.foo` is a function *implemented* (not only declared) in the same file ``` define C.foo(x: T1, y: T2, z: T3, u: T4, v: T5) : T { ... } ``` We also add a type declaration and a virtual method: ``` type GENERATED_TYPE_NAME = {x: T1; y: T2} define __Closure_C_add_in_D_foo_4.call(this: *GENERATED_TYPE_NAME, p1: T3, p2: T4, p3: T5) : T { #entry: ret C.foo(this -> ?.x, this -> ?.y, p1, p2, p3) } ``` `Apply`: A call `exp(exp1, exp2, exp3)` is turned into a virtual call `exp.?.call(exp1, exp2, exp3)` Reviewed By: dulmarod Differential Revision: D49501165 fbshipit-source-id: 97e863e7c3ba53f5672f26503608744f146ffd0e
- Loading branch information
1 parent
db6e322
commit 0faa827
Showing
10 changed files
with
242 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.