Macro.hx 578 B

1234567891011121314151617181920212223242526
  1. import haxe.macro.Compiler;
  2. import haxe.macro.Context;
  3. function init() {
  4. if (Context.defined("haxe")) Context.warning("ok", (macro 0).pos);
  5. Context.onAfterInitMacros(() -> {
  6. Context.warning("after init 1", (macro 0).pos);
  7. var e = macro 42;
  8. Context.typeof(e);
  9. });
  10. Compiler.include("hax.ds", true, true);
  11. Context.onAfterInitMacros(() -> {
  12. Context.warning("after init 2", (macro 0).pos);
  13. });
  14. }
  15. function init_fail() {
  16. var e = macro 42;
  17. Context.typeof(e);
  18. Compiler.define("foo", "foo");
  19. Context.onAfterInitMacros(() -> {
  20. Compiler.define("bar", "bar");
  21. });
  22. }