samedi 24 janvier 2015

Managing types and conversions in a compiler


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.



  1. Classes (read only / not mutable)

  2. Mutable Types (Which contain another type. Think the opposite of C++ const.)

  3. Generic Types (With constraints referring to types)

  4. 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