virtualization-lms-core
virtualization-lms-core copied to clipboard
Make mirroring less cumbersome
Add a default case for mirrorDef using reflection.
Evaluate whether mirror can be made a method on Def (or a subclass). This would allow writing:
case class MyNode(x: Exp[A]) extends MirrorDef {
def mirror(t: Transformer) => myop(t(x)))
}
def myop(x: Exp[A]) = MyNode(x)
Or:
case class MyNode(x: Exp[A]) extends MirrorDef(t => myop(t(x)))
def myop(x: Exp[A]) = MyNode(x)
Which may be simpler than the current mirror overrides.
Note: in the second version extends MirrorDef(t => myop(t(x))) we'd need to figure out how to pass the implicit SourceContext. Is there a better way than making it part of the Def instance?