-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1102 from hylo-lang/compile-for
Implement code generation for non-consuming non-modifying for loops
- Loading branch information
Showing
9 changed files
with
337 additions
and
95 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import Core | ||
|
||
/// The witness of a type's conformance to the `Collection` trait from the standard library. | ||
struct CollectionWitness { | ||
|
||
/// The implementation of the `Collection.Index`. | ||
let index: AnyType | ||
|
||
/// The implementation of the `Collection.Element`. | ||
let element: AnyType | ||
|
||
/// The implementation of `Collection.start_index`. | ||
let startIndex: Operand | ||
|
||
/// The implementation of `Collection.end_index`. | ||
let endIndex: Operand | ||
|
||
/// The implementation of `Collection.index_after(_:)`. | ||
let indexAfter: Operand | ||
|
||
/// The implementation of `Collection.[].let`. | ||
let accessLet: Function.ID | ||
|
||
/// Creates the witness of the conformance `c` for use in `module`. | ||
init(_ c: Core.Conformance, in module: inout Module) { | ||
self.index = module.program.associatedType("Index", for: c) | ||
self.element = module.program.associatedType("Element", for: c) | ||
|
||
self.startIndex = .constant( | ||
module.reference(toImplementationOf: Name(stem: "start_index"), for: c)) | ||
self.endIndex = .constant( | ||
module.reference(toImplementationOf: Name(stem: "end_index"), for: c)) | ||
self.indexAfter = .constant( | ||
module.reference(toImplementationOf: Name(stem: "index", labels: ["after"]), for: c)) | ||
|
||
self.accessLet = module.demandImplementation( | ||
of: Name(stem: "[]", labels: [nil], introducer: .let), for: c) | ||
} | ||
|
||
} |
Oops, something went wrong.