I am trying to determine how to manage types and conversions between types within a compiler that I am writing. The compiler is being written in C#.
There are a number of different kinds of types.
- Classes (read only / not mutable)
- Mutable Types (Which contain another type. Think the opposite of C++ const.)
- Generic Types (With constraints referring to types)
- etc
The problem I am trying to solve is, given two types, how can I determine whether one can be converted to the other. (eg. Allow a mutable type to be assigned to the read only version of the type)
My first thought was to use a virtual method and a visitor. However, many of the types here are recursive which makes that more difficult to implement.
Aucun commentaire:
Enregistrer un commentaire