Closed nhweston closed 3 years ago
Will need to do a rebase if you merge in the vectors branch first.
This one is tricky since I've got a major reworking of Primitives
on my prelude branch. I've switched from an object-oriented approach to a more functional one, mostly due to wanting to use a grammar specification to define the legal primitive forms. So, I think things are getting simpler anyway. Maybe we can wait until after the prelude is done and see if more is needed.
Closing as this was achieved in PR #41.
This PR simplifies the definitions of primitives.
The existing
Primitives.scala
requires every primitive class to have a type parameter 'I <: Backend
' and every method of these classes to have a parameter block '(interp: I)
', with fields ofinterp
(including types) frequently accessed.The key change proposed in this PR is to change
Primitives
from an object to a trait that is mixed in with aBackend
. This eliminates the type parameters, the extra parameter block, and all accesses oninterp
.The only complication I ran into is in
CoomaPrimitiveValue.java
for Truffle, which seems to arise from some Scala-to-Java weirdness with mixins and inner classes. I explored some possible type-safe fixes, but was unable to find one. I have resolved this using a type coercion.