Type-Safe Tree Transformations for Precisely-Typed Compilers

dc.contributor.authorMagnan Cavalcante Oliveira, Pedro Jorge
dc.date.accessioned2025-01-23T19:23:14Z
dc.date.available2025-01-23T19:23:14Z
dc.date.issued2025-01-23
dc.date.submitted2025-01-14
dc.description.abstractCompilers translate programs from a source language to a target language. This can be done by translating into an intermediate tree representation, performing multiple partial transformations on the tree, and translating out. Compiler implementers must choose between encoding transformation invariants with multiple tree types at the cost of code boilerplate and duplication, or forgoing static correctness by using a broad and imprecise tree datatype. This thesis proposes a new approach to writing precisely-typed compilers and tree transformations without code boilerplate or duplication. The approach requires encoding the tree nodes using two type indices, one for the phase of the root node and another for the phase of all children nodes. This tree datatype can represent partially transformed nodes, and distinguish between trees of different phases. In order to make this approach possible it was necessary to modify the Scala type checker to better infer types in ‘match’-expressions. Precisely-typed tree transformations make use of the default case of a ‘match’-expression; this case must be elaborated to a type which is the type difference of the scrutinee expression and all previously matched patterns. We demonstrate the viability of this approach by implementing a case study for a precisely-typed compiler for the instructional language Lacs. This case study modifies the existing implementation of Lacs to track which subset of tree nodes may be present before and after any given tree transformation. We show that this approach can increase static correctness without the burden of additional code boilerplate or duplication.
dc.identifier.urihttps://hdl.handle.net/10012/21428
dc.language.isoen
dc.pendingfalse
dc.publisherUniversity of Waterlooen
dc.subjectprogramming languages
dc.subjectcompilers
dc.subjecttype theory
dc.titleType-Safe Tree Transformations for Precisely-Typed Compilers
dc.typeMaster Thesis
uws-etd.degreeMaster of Mathematics
uws-etd.degree.departmentDavid R. Cheriton School of Computer Science
uws-etd.degree.disciplineComputer Science
uws-etd.degree.grantorUniversity of Waterlooen
uws-etd.embargo.terms0
uws.contributor.advisorLhoták, Ondřej
uws.contributor.affiliation1Faculty of Mathematics
uws.peerReviewStatusUnrevieweden
uws.published.cityWaterlooen
uws.published.countryCanadaen
uws.published.provinceOntarioen
uws.scholarLevelGraduateen
uws.typeOfResourceTexten

Files

Original bundle

Now showing 1 - 1 of 1
No Thumbnail Available
Name:
Oliveira_Pedro.pdf
Size:
424.69 KB
Format:
Adobe Portable Document Format

License bundle

Now showing 1 - 1 of 1
No Thumbnail Available
Name:
license.txt
Size:
6.4 KB
Format:
Item-specific license agreed upon to submission
Description: