Main.hx 912 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package;
  2. #if macro
  3. import haxe.macro.Context;
  4. import haxe.macro.Type;
  5. #end
  6. function main() {
  7. }
  8. #if macro
  9. class MacroClass {
  10. public static function start() {
  11. printTypedExpr(Context.getMainExpr());
  12. Context.onAfterTyping(function(modules: Array<ModuleType>) {
  13. printTypedExpr(Context.getMainExpr());
  14. });
  15. Context.onGenerate(function(types: Array<Type>) {
  16. printTypedExpr(Context.getMainExpr());
  17. if(Context.getAllModuleTypes().length == types.length) {
  18. trace("Module type list length == types.length");
  19. } else {
  20. trace("Module types length != types.length");
  21. }
  22. });
  23. Context.onAfterGenerate(function() {
  24. printTypedExpr(Context.getMainExpr());
  25. });
  26. }
  27. static function printTypedExpr(te: Null<TypedExpr>, ?pos:haxe.PosInfos) {
  28. if(te == null) {
  29. haxe.Log.trace("null", pos);
  30. } else {
  31. haxe.Log.trace(haxe.macro.TypedExprTools.toString(te, true), pos);
  32. }
  33. }
  34. }
  35. #end