In a transformation, how can I get the referrenced AST? For example:

foo : Import(m) -> ...body...
where
    Module(mname, imps, body) := <?> m

The binding rules for modules and imports:

Module(m, _, _):
	defines unique Module m
	
Import(m):
	refers to Module m
Asked by Sebastian Erdweg on 7 May 2014 at 13:12

Currently you can’t. You have to store the AST itself in the index with a property.

properties
  ast of Module : Term 

binding rules
  a@Module(m, _, _):
    defines unique Module m
      of ast a 

I’m however not sure what the performance implications of that are.

I would argue however that it is desirable to be able to get the ast, based on the parent-node of a name.
This would enable model -> target language AST transformations, instead of the source language AST -> target language AST transformations.

Answered by Daco Harkes on 7 May 2014 at 13:34