virtualization-lms-core icon indicating copy to clipboard operation
virtualization-lms-core copied to clipboard

Make mirroring less cumbersome

Open TiarkRompf opened this issue 13 years ago • 1 comments

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.

TiarkRompf avatar Sep 26 '12 16:09 TiarkRompf

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?

TiarkRompf avatar Dec 06 '12 17:12 TiarkRompf