TiarkRompf / virtualization-lms-core

A Framework for Runtime Code Generation and Compiled DSLs
http://scala-lms.github.com
BSD 3-Clause "New" or "Revised" License
324 stars 91 forks source link

Scala class generation for records #23

Open julienrf opened 12 years ago

julienrf commented 12 years ago

Hi,

I faced another problem with Scala code generation of records: the current implementation registers that a record type should be mapped to a case class only if the program to generate creates such a record (by using new Record { … }). If a program only uses a record its type isn’t be remapped to the corresponding case class. Furthermore, as the code generator relies on a mutable state, the mapping to a case class works only if a record is used after a record of the same type has been created, in a program.

I solved this problem in this branch but my solution is not satisfying either. It still relies on a mutable state but registers record types both on usage and creation. It uses only the RefinedManifest of the type of the record to generate the corresponding case class (so it can’t be transformed by the mirror process, as it is the case in the delite-develop branch). Furthermore, the hashing function I use to generate case class names according to the record type is not deterministic, so tests fail.

TiarkRompf commented 12 years ago

yeah, i think we can't rely on uses happening after creation.