InitMacro.hx 483 B

12345678910111213141516171819202122232425
  1. import haxe.macro.Compiler;
  2. import haxe.macro.Context;
  3. import haxe.macro.Type;
  4. class InitMacro {
  5. static function setup() {
  6. switch (Compiler.getConfiguration().platform) {
  7. case CustomTarget("mylang"): {}
  8. case _: throw "this shouldnt happen.";
  9. }
  10. Context.onAfterTyping(check);
  11. }
  12. static function check(types:Array<ModuleType>) {
  13. for (m in types) {
  14. switch (m) {
  15. case TClassDecl(_.get() => c):
  16. for (f in c.fields.get()) f.expr();
  17. case _:
  18. }
  19. }
  20. }
  21. }