2
0
Эх сурвалжийг харах

move more stuff around

- Common is now in src/context because it really isn't about typing
- Meta and MetaInfo are now unified in src/context/meta.ml
- Abstract now has its own file in src/typing/abstract.ml which allows it to access Error (which depends on Type where Abstract used to be)
- pos is now in Globals so not _everything_ has to pull in Ast
Simon Krajewski 9 жил өмнө
parent
commit
01f544e1ee
45 өөрчлөгдсөн 828 нэмэгдсэн , 800 устгасан
  1. 52 45
      Makefile
  2. 7 298
      src/context/common.ml
  3. 424 0
      src/context/meta.ml
  4. 5 4
      src/display/display.ml
  5. 13 13
      src/display/displayOutput.ml
  6. 1 1
      src/display/displayTypes.ml
  7. 3 2
      src/generators/codegen.ml
  8. 15 15
      src/generators/genas3.ml
  9. 8 7
      src/generators/gencommon.ml
  10. 3 2
      src/generators/gencpp.ml
  11. 18 17
      src/generators/gencs.ml
  12. 2 1
      src/generators/genhl.ml
  13. 19 17
      src/generators/genjava.ml
  14. 2 3
      src/generators/genjs.ml
  15. 3 3
      src/generators/genlua.ml
  16. 1 0
      src/generators/genneko.ml
  17. 3 3
      src/generators/genphp.ml
  18. 1 0
      src/generators/genpy.ml
  19. 3 2
      src/generators/genswf.ml
  20. 1 0
      src/generators/genswf9.ml
  21. 4 3
      src/generators/genxml.ml
  22. 53 1
      src/globals.ml
  23. 42 41
      src/macro/interp.ml
  24. 12 14
      src/main.ml
  25. 2 1
      src/optimization/analyzer.ml
  26. 1 0
      src/optimization/analyzerConfig.ml
  27. 1 0
      src/optimization/analyzerTexpr.ml
  28. 2 1
      src/optimization/analyzerTexprTransformer.ml
  29. 1 0
      src/optimization/analyzerTypes.ml
  30. 1 0
      src/optimization/dce.ml
  31. 1 0
      src/optimization/filters.ml
  32. 1 0
      src/optimization/optimizer.ml
  33. 1 0
      src/optimization/optimizerTexpr.ml
  34. 7 6
      src/server.ml
  35. 1 191
      src/syntax/ast.ml
  36. 1 0
      src/syntax/lexer.mll
  37. 6 5
      src/syntax/parser.ml
  38. 67 0
      src/typing/abstract.ml
  39. 3 3
      src/typing/error.ml
  40. 1 0
      src/typing/matcher.ml
  41. 0 1
      src/typing/overloads.ml
  42. 20 87
      src/typing/type.ml
  43. 2 1
      src/typing/typecore.ml
  44. 7 6
      src/typing/typeload.ml
  45. 7 6
      src/typing/typer.ml

+ 52 - 45
Makefile

@@ -27,7 +27,7 @@ LFLAGS=
 
 CFLAGS= -bin-annot
 ALL_CFLAGS= $(CFLAGS) -g -w -3 -I libs/extlib -I libs/extc -I libs/neko -I libs/javalib -I libs/ziplib -I libs/swflib -I libs/xml-light -I libs/ttflib -I libs/ilib -I libs/objsize \
-	-I src -I src/generators -I src/macro -I src/optimization -I src/syntax -I src/typing -I src/display
+	-I src -I src/context -I src/generators -I src/macro -I src/optimization -I src/syntax -I src/typing -I src/display
 
 LIBS=unix str libs/extlib/extLib libs/xml-light/xml-light libs/swflib/swflib \
 	libs/extc/extc libs/neko/neko libs/javalib/java libs/ziplib/zip \
@@ -54,8 +54,9 @@ CC_PARSER_CMD = $(COMPILER) -pp camlp4o $(ALL_CFLAGS) -c src/syntax/parser.ml
 
 RELDIR=../../..
 
-MODULES=json version globals path syntax/ast display/displayTypes typing/type typing/error syntax/lexer typing/common generators/genxml \
-	syntax/parser typing/typecore display/display optimization/optimizerTexpr \
+MODULES=json version globals path context/meta syntax/ast display/displayTypes typing/type typing/error \
+	syntax/lexer context/common generators/genxml \
+	syntax/parser typing/abstract typing/typecore display/display optimization/optimizerTexpr \
 	optimization/optimizer typing/overloads typing/typeload generators/codegen generators/gencommon generators/genas3 \
 	generators/gencpp generators/genjs generators/genneko generators/genphp generators/genswf9 \
 	generators/genswf generators/genjava generators/gencs generators/genpy macro/interp generators/hlcode generators/hlopt generators/hlinterp generators/hl2c generators/genhl \
@@ -134,112 +135,118 @@ uninstall:
 
 # Modules
 
+# context
+
+src/context/common.$(MODULE_EXT): src/globals.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/display/displayTypes.$(MODULE_EXT) libs/ilib/il.$(LIB_EXT)
+
+src/context/meta.$(MODULE_EXT): src/globals.$(MODULE_EXT)
+
 # display
 
-src/display/display.$(MODULE_EXT): src/path.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/typing/typecore.$(MODULE_EXT) src/syntax/parser.$(MODULE_EXT) src/display/displayTypes.$(MODULE_EXT)
+src/display/display.$(MODULE_EXT): src/globals.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/path.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/typing/typecore.$(MODULE_EXT) src/syntax/parser.$(MODULE_EXT) src/display/displayTypes.$(MODULE_EXT)
 
-src/display/displayTypes.$(MODULE_EXT) : src/syntax/ast.$(MODULE_EXT)
+src/display/displayTypes.$(MODULE_EXT) : src/globals.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
 
-src/display/displayOutput.$(MODULE_EXT): src/typing/error.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/typing/typer.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/display/display.$(MODULE_EXT)
+src/display/displayOutput.$(MODULE_EXT): src/globals.$(MODULE_EXT) src/typing/error.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/typing/typer.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/display/display.$(MODULE_EXT)
 
 # generators
 
-src/generators/codegen.$(MODULE_EXT): src/typing/type.$(MODULE_EXT) src/generators/genxml.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
+src/generators/codegen.$(MODULE_EXT): src/globals.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/generators/genxml.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
 
-src/generators/genas3.$(MODULE_EXT): src/typing/type.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
+src/generators/genas3.$(MODULE_EXT): src/typing/abstract.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
 
-src/generators/gencommon.$(MODULE_EXT):src/typing/error.$(MODULE_EXT) src/typing/overloads.$(MODULE_EXT) src/path.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) libs/ilib/il.$(LIB_EXT)
+src/generators/gencommon.$(MODULE_EXT): src/typing/abstract.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/typing/error.$(MODULE_EXT) src/typing/overloads.$(MODULE_EXT) src/path.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) libs/ilib/il.$(LIB_EXT)
 
-src/generators/gencpp.$(MODULE_EXT): src/path.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
+src/generators/gencpp.$(MODULE_EXT): src/typing/abstract.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/path.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
 
-src/generators/gencs.$(MODULE_EXT): src/path.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/generators/gencommon.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) libs/ilib/il.$(LIB_EXT)
+src/generators/gencs.$(MODULE_EXT): src/typing/abstract.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/path.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/generators/gencommon.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) libs/ilib/il.$(LIB_EXT)
 
-src/generators/genjava.$(MODULE_EXT): src/path.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/generators/gencommon.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
+src/generators/genjava.$(MODULE_EXT): src/typing/abstract.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/path.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/generators/gencommon.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
 
-src/generators/genjs.$(MODULE_EXT): src/path.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
+src/generators/genjs.$(MODULE_EXT): src/typing/abstract.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/path.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
 
-src/generators/genneko.$(MODULE_EXT): src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
+src/generators/genneko.$(MODULE_EXT): src/globals.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
 
-src/generators/genlua.$(MODULE_EXT): src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
+src/generators/genlua.$(MODULE_EXT): src/typing/abstract.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
 
-src/generators/genphp.$(MODULE_EXT): src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
+src/generators/genphp.$(MODULE_EXT): src/typing/abstract.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
 
-src/generators/genpy.$(MODULE_EXT): src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
+src/generators/genpy.$(MODULE_EXT): src/typing/abstract.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
 
-src/generators/genswf.$(MODULE_EXT): src/typing/type.$(MODULE_EXT) src/generators/genswf9.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
+src/generators/genswf.$(MODULE_EXT): src/globals.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/generators/genswf9.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
 
-src/generators/hlinterp.$(MODULE_EXT): src/typing/common.$(MODULE_EXT) src/generators/hlcode.$(MODULE_EXT) src/macro/interp.$(MODULE_EXT)
+src/generators/hlinterp.$(MODULE_EXT): src/context/common.$(MODULE_EXT) src/generators/hlcode.$(MODULE_EXT) src/macro/interp.$(MODULE_EXT)
 
 src/generators/hl2c.$(MODULE_EXT): src/generators/hlcode.$(MODULE_EXT)
 
 src/generators/hlopt.$(MODULE_EXT): src/generators/hlcode.$(MODULE_EXT)
 
-src/generators/genhl.$(MODULE_EXT): src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/generators/hlcode.$(MODULE_EXT) src/generators/hlinterp.$(MODULE_EXT) src/generators/hl2c.$(MODULE_EXT) src/generators/hlopt.$(MODULE_EXT)
+src/generators/genhl.$(MODULE_EXT): src/globals.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/generators/hlcode.$(MODULE_EXT) src/generators/hlinterp.$(MODULE_EXT) src/generators/hl2c.$(MODULE_EXT) src/generators/hlopt.$(MODULE_EXT)
 
-src/generators/genswf9.$(MODULE_EXT): src/path.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
+src/generators/genswf9.$(MODULE_EXT): src/typing/abstract.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/path.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
 
-src/generators/genxml.$(MODULE_EXT): src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
+src/generators/genxml.$(MODULE_EXT): src/globals.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
 
 # macro
 
-src/macro/interp.$(MODULE_EXT): src/typing/error.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/path.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/generators/genneko.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/generators/genswf.$(MODULE_EXT) src/generators/genjava.$(MODULE_EXT) src/generators/gencs.$(MODULE_EXT) src/syntax/parser.$(MODULE_EXT) libs/ilib/il.$(LIB_EXT)
+src/macro/interp.$(MODULE_EXT): src/typing/abstract.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/typing/error.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/path.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/generators/genneko.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/generators/genswf.$(MODULE_EXT) src/generators/genjava.$(MODULE_EXT) src/generators/gencs.$(MODULE_EXT) src/syntax/parser.$(MODULE_EXT) libs/ilib/il.$(LIB_EXT)
 
 # optimization
 
-src/optimization/analyzer.$(MODULE_EXT): src/optimization/optimizer.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/optimization/analyzerConfig.$(MODULE_EXT) src/optimization/analyzerTypes.$(MODULE_EXT) src/optimization/analyzerTexpr.$(MODULE_EXT) src/optimization/analyzerTexprTransformer.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT)
+src/optimization/analyzer.$(MODULE_EXT): src/context/meta.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/optimization/optimizer.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/optimization/analyzerConfig.$(MODULE_EXT) src/optimization/analyzerTypes.$(MODULE_EXT) src/optimization/analyzerTexpr.$(MODULE_EXT) src/optimization/analyzerTexprTransformer.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT)
 
-src/optimization/analyzerConfig.$(MODULE_EXT): src/syntax/ast.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/typing/common.$(MODULE_EXT)
+src/optimization/analyzerConfig.$(MODULE_EXT): src/context/meta.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/context/common.$(MODULE_EXT)
 
-src/optimization/analyzerTexpr.$(MODULE_EXT): src/typing/error.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/optimization/analyzerConfig.$(MODULE_EXT) src/optimization/optimizerTexpr.$(MODULE_EXT)
+src/optimization/analyzerTexpr.$(MODULE_EXT): src/typing/abstract.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/typing/error.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/optimization/analyzerConfig.$(MODULE_EXT) src/optimization/optimizerTexpr.$(MODULE_EXT)
 
-src/optimization/analyzerTexprTransformer.$(MODULE_EXT): src/typing/error.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/optimization/analyzerConfig.$(MODULE_EXT) src/optimization/analyzerTypes.$(MODULE_EXT) src/optimization/analyzerTexpr.$(MODULE_EXT)
+src/optimization/analyzerTexprTransformer.$(MODULE_EXT): src/context/meta.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/typing/error.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/optimization/analyzerConfig.$(MODULE_EXT) src/optimization/analyzerTypes.$(MODULE_EXT) src/optimization/analyzerTexpr.$(MODULE_EXT)
 
-src/optimization/analyzerTypes.$(MODULE_EXT): src/syntax/ast.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/optimization/analyzerConfig.$(MODULE_EXT)
+src/optimization/analyzerTypes.$(MODULE_EXT): src/globals.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/optimization/analyzerConfig.$(MODULE_EXT)
 
-src/optimization/dce.$(MODULE_EXT): src/typing/typecore.$(MODULE_EXT) src/typing/error.$(MODULE_EXT) src/path.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/typing/type.$(MODULE_EXT)
+src/optimization/dce.$(MODULE_EXT): src/typing/abstract.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/typing/typecore.$(MODULE_EXT) src/typing/error.$(MODULE_EXT) src/path.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/typing/type.$(MODULE_EXT)
 
-src/optimization/filters.$(MODULE_EXT): src/typing/error.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/optimization/analyzer.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/optimization/dce.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/typing/typecore.$(MODULE_EXT)
+src/optimization/filters.$(MODULE_EXT): src/context/meta.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/typing/error.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/optimization/analyzer.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/optimization/dce.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/typing/typecore.$(MODULE_EXT)
 
-src/optimization/optimizer.$(MODULE_EXT): src/optimization/optimizerTexpr.$(MODULE_EXT) src/display/display.$(MODULE_EXT) src/typing/typecore.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/parser.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
+src/optimization/optimizer.$(MODULE_EXT): src/context/meta.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/optimization/optimizerTexpr.$(MODULE_EXT) src/display/display.$(MODULE_EXT) src/typing/typecore.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/parser.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
 
-src/optimization/optimizerTexpr.$(MODULE_EXT): src/typing/common.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
+src/optimization/optimizerTexpr.$(MODULE_EXT): src/globals.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
 
 # syntax
 
-src/syntax/ast.$(MODULE_EXT):
+src/syntax/ast.$(MODULE_EXT): src/context/meta.$(MODULE_EXT) src/globals.$(MODULE_EXT)
 
-src/syntax/lexer.$(MODULE_EXT): src/syntax/lexer.ml src/syntax/ast.$(MODULE_EXT)
+src/syntax/lexer.$(MODULE_EXT): src/globals.$(MODULE_EXT) src/syntax/lexer.ml src/syntax/ast.$(MODULE_EXT)
 
-src/syntax/parser.$(MODULE_EXT): src/path.$(MODULE_EXT) src/syntax/parser.ml src/syntax/lexer.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
+src/syntax/parser.$(MODULE_EXT): src/globals.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/path.$(MODULE_EXT) src/syntax/parser.ml src/syntax/lexer.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
 	$(CC_PARSER_CMD)
 
 # typing
 
-src/typing/common.$(MODULE_EXT): src/typing/type.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/display/displayTypes.$(MODULE_EXT) libs/ilib/il.$(LIB_EXT)
+src/typing/abstract.$(MODULE_EXT): src/context/meta.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/typing/error.$(MODULE_EXT)
 
-src/typing/error.$(MODULE_EXT): src/typing/type.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
+src/typing/error.$(MODULE_EXT): src/globals.$(MODULE_EXT) src/typing/type.$(MODULE_EXT)
 
-src/typing/matcher.$(MODULE_EXT): src/typing/error.$(MODULE_EXT) src/optimization/optimizer.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/typing/typecore.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/typing/typer.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
+src/typing/matcher.$(MODULE_EXT): src/typing/abstract.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/typing/error.$(MODULE_EXT) src/optimization/optimizer.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/typing/typecore.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/typing/typer.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
 
-src/typing/overloads.$(MODULE_EXT): src/syntax/ast.$(MODULE_EXT) src/typing/type.$(MODULE_EXT)
+src/typing/overloads.$(MODULE_EXT): src/typing/abstract.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/typing/type.$(MODULE_EXT)
 
-src/typing/type.$(MODULE_EXT): src/syntax/ast.$(MODULE_EXT) src/json.$(MODULE_EXT)
+src/typing/type.$(MODULE_EXT): src/globals.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/json.$(MODULE_EXT)
 
-src/typing/typecore.$(MODULE_EXT): src/path.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
+src/typing/typecore.$(MODULE_EXT): src/typing/abstract.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/path.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
 
-src/typing/typeload.$(MODULE_EXT): src/optimization/optimizerTexpr.$(MODULE_EXT) src/typing/overloads.$(MODULE_EXT) src/path.$(MODULE_EXT) src/typing/typecore.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/parser.$(MODULE_EXT) src/optimization/optimizer.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/json.$(MODULE_EXT) src/display/display.$(MODULE_EXT)
+src/typing/typeload.$(MODULE_EXT): src/globals.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/optimization/optimizerTexpr.$(MODULE_EXT) src/typing/overloads.$(MODULE_EXT) src/path.$(MODULE_EXT) src/typing/typecore.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/parser.$(MODULE_EXT) src/optimization/optimizer.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/json.$(MODULE_EXT) src/display/display.$(MODULE_EXT)
 
-src/typing/typer.$(MODULE_EXT): src/typing/error.$(MODULE_EXT) src/optimization/optimizerTexpr.$(MODULE_EXT) src/typing/overloads.$(MODULE_EXT) src/path.$(MODULE_EXT) src/typing/typeload.$(MODULE_EXT) src/typing/typecore.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/parser.$(MODULE_EXT) src/optimization/optimizer.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/macro/interp.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/optimization/filters.$(MODULE_EXT) src/generators/genjs.$(MODULE_EXT) src/display/display.$(MODULE_EXT)
+src/typing/typer.$(MODULE_EXT): src/typing/abstract.$(MODULE_EXT) src/context/meta.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/typing/error.$(MODULE_EXT) src/optimization/optimizerTexpr.$(MODULE_EXT) src/typing/overloads.$(MODULE_EXT) src/path.$(MODULE_EXT) src/typing/typeload.$(MODULE_EXT) src/typing/typecore.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/parser.$(MODULE_EXT) src/optimization/optimizer.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/macro/interp.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/optimization/filters.$(MODULE_EXT) src/generators/genjs.$(MODULE_EXT) src/display/display.$(MODULE_EXT)
 
 # main
 
-src/main.$(MODULE_EXT): src/typing/error.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/path.$(MODULE_EXT) src/optimization/filters.$(MODULE_EXT) src/typing/matcher.$(MODULE_EXT) src/typing/typer.$(MODULE_EXT) src/typing/typeload.$(MODULE_EXT) src/typing/typecore.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/parser.$(MODULE_EXT) src/optimization/optimizer.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/macro/interp.$(MODULE_EXT) src/generators/genxml.$(MODULE_EXT) src/generators/genswf.$(MODULE_EXT) src/generators/genphp.$(MODULE_EXT) src/generators/genneko.$(MODULE_EXT) src/generators/genjs.$(MODULE_EXT) src/generators/genlua.$(MODULE_EXT) src/generators/gencpp.$(MODULE_EXT) src/generators/genas3.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/generators/genjava.$(MODULE_EXT) src/generators/gencs.$(MODULE_EXT) src/generators/genpy.$(MODULE_EXT) src/generators/genhl.$(MODULE_EXT) src/display/display.$(MODULE_EXT) src/server.$(MODULE_EXT) src/display/displayOutput.$(MODULE_EXT) libs/ilib/il.$(LIB_EXT)
+src/main.$(MODULE_EXT): src/context/meta.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/typing/error.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/path.$(MODULE_EXT) src/optimization/filters.$(MODULE_EXT) src/typing/matcher.$(MODULE_EXT) src/typing/typer.$(MODULE_EXT) src/typing/typeload.$(MODULE_EXT) src/typing/typecore.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/parser.$(MODULE_EXT) src/optimization/optimizer.$(MODULE_EXT) src/syntax/lexer.$(MODULE_EXT) src/macro/interp.$(MODULE_EXT) src/generators/genxml.$(MODULE_EXT) src/generators/genswf.$(MODULE_EXT) src/generators/genphp.$(MODULE_EXT) src/generators/genneko.$(MODULE_EXT) src/generators/genjs.$(MODULE_EXT) src/generators/genlua.$(MODULE_EXT) src/generators/gencpp.$(MODULE_EXT) src/generators/genas3.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/generators/codegen.$(MODULE_EXT) src/generators/genjava.$(MODULE_EXT) src/generators/gencs.$(MODULE_EXT) src/generators/genpy.$(MODULE_EXT) src/generators/genhl.$(MODULE_EXT) src/display/display.$(MODULE_EXT) src/server.$(MODULE_EXT) src/display/displayOutput.$(MODULE_EXT) libs/ilib/il.$(LIB_EXT)
 
 src/globals.$(MODULE_EXT): src/version.$(MODULE_EXT)
 
 src/path.$(MODULE_EXT): src/globals.$(MODULE_EXT)
 
-src/server.$(MODULE_EXT): src/globals.$(MODULE_EXT) src/path.$(MODULE_EXT) src/typing/typer.$(MODULE_EXT) src/typing/typeload.$(MODULE_EXT) src/typing/typecore.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/parser.$(MODULE_EXT) src/typing/typecore.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/typing/common.$(MODULE_EXT) src/syntax/parser.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/display/displayOutput.$(MODULE_EXT)
+src/server.$(MODULE_EXT): src/context/meta.$(MODULE_EXT) src/globals.$(MODULE_EXT) src/path.$(MODULE_EXT) src/typing/typer.$(MODULE_EXT) src/typing/typeload.$(MODULE_EXT) src/typing/typecore.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/syntax/parser.$(MODULE_EXT) src/typing/typecore.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/syntax/parser.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT) src/display/displayOutput.$(MODULE_EXT)
 
 src/version.$(MODULE_EXT):
 	$(MAKE) -f Makefile.version_extra -s --no-print-directory ADD_REVISION=$(ADD_REVISION) BRANCH=$(BRANCH) COMMIT_SHA=$(COMMIT_SHA) COMMIT_DATE=$(COMMIT_DATE) > src/version.ml

+ 7 - 298
src/typing/common.ml → src/context/common.ml

@@ -19,12 +19,13 @@
 
 open Ast
 open Type
+open Globals
 
 type package_rule =
 	| Forbidden
 	| Remap of string
 
-type pos = Ast.pos
+type pos = Globals.pos
 
 type basic_types = {
 	mutable tvoid : t;
@@ -43,19 +44,6 @@ type stats = {
 	s_macros_called : int ref;
 }
 
-type platform =
-	| Cross
-	| Js
-	| Lua
-	| Neko
-	| Flash
-	| Php
-	| Cpp
-	| Cs
-	| Java
-	| Python
-	| Hl
-
 (**
 	The capture policy tells which handling we make of captured locals
 	(the locals which are referenced in local functions)
@@ -302,7 +290,7 @@ type context = {
 	memory_marker : float array;
 }
 
-exception Abort of string * Ast.pos
+exception Abort of string * pos
 
 let display_default = ref DisplayMode.DMNone
 
@@ -580,32 +568,6 @@ module Define = struct
 		| Last -> assert false
 end
 
-let platforms = [
-	Js;
-	Lua;
-	Neko;
-	Flash;
-	Php;
-	Cpp;
-	Cs;
-	Java;
-	Python;
-	Hl;
-]
-
-let platform_name = function
-	| Cross -> "cross"
-	| Js -> "js"
-	| Lua -> "lua"
-	| Neko -> "neko"
-	| Flash -> "flash"
-	| Php -> "php"
-	| Cpp -> "cpp"
-	| Cs -> "cs"
-	| Java -> "java"
-	| Python -> "python"
-	| Hl -> "hl"
-
 let short_platform_name = function
 	| Cross -> "x"
 	| Js -> "js"
@@ -619,258 +581,6 @@ let short_platform_name = function
 	| Python -> "py"
 	| Hl -> "hl"
 
-module MetaInfo = struct
-	open Meta
-	type meta_usage =
-		| TClass
-		| TClassField
-		| TAbstract
-		| TAbstractField
-		| TEnum
-		| TTypedef
-		| TAnyField
-		| TExpr
-		| TTypeParameter
-
-	type meta_parameter =
-		| HasParam of string
-		| Platform of platform
-		| Platforms of platform list
-		| UsedOn of meta_usage
-		| UsedOnEither of meta_usage list
-		| Internal
-
-	let to_string = function
-		| Abi -> ":abi",("Function ABI/calling convention",[Platforms [Cpp]])
-		| Abstract -> ":abstract",("Sets the underlying class implementation as 'abstract'",[Platforms [Java;Cs]])
-		| Access -> ":access",("Forces private access to package, type or field",[HasParam "Target path";UsedOnEither [TClass;TClassField]])
-		| Accessor -> ":accessor",("Used internally by DCE to mark property accessors",[UsedOn TClassField;Internal])
-		| Allow -> ":allow",("Allows private access from package, type or field",[HasParam "Target path";UsedOnEither [TClass;TClassField]])
-		| Analyzer -> ":analyzer",("Used to configure the static analyzer",[])
-		| Annotation -> ":annotation",("Annotation (@interface) definitions on -java-lib imports will be annotated with this metadata. Has no effect on types compiled by Haxe",[Platform Java; UsedOn TClass])
-		| ArrayAccess -> ":arrayAccess",("Allows [] access on an abstract",[UsedOnEither [TAbstract;TAbstractField]])
-		| Ast -> ":ast",("Internally used to pass the AST source into the typed AST",[Internal])
-		| AstSource -> ":astSource",("Filled by the compiler with the parsed expression of the field",[UsedOn TClassField])
-		| AutoBuild -> ":autoBuild",("Extends @:build metadata to all extending and implementing classes",[HasParam "Build macro call";UsedOn TClass])
-		| Bind -> ":bind",("Override Swf class declaration",[Platform Flash;UsedOn TClass])
-		| Bitmap -> ":bitmap",("Embeds given bitmap data into the class (must extend flash.display.BitmapData)",[HasParam "Bitmap file path";UsedOn TClass;Platform Flash])
-		| BridgeProperties -> ":bridgeProperties",("Creates native property bridges for all Haxe properties in this class",[UsedOn TClass;Platform Cs])
-		| Build -> ":build",("Builds a class or enum from a macro",[HasParam "Build macro call";UsedOnEither [TClass;TEnum]])
-		| BuildXml -> ":buildXml",("Specify xml data to be injected into Build.xml",[Platform Cpp])
-		| Callable -> ":callable",("Abstract forwards call to its underlying type",[UsedOn TAbstract])
-		| Class -> ":class",("Used internally to annotate an enum that will be generated as a class",[Platforms [Java;Cs]; UsedOn TEnum; Internal])
-		| ClassCode -> ":classCode",("Used to inject platform-native code into a class",[Platforms [Java;Cs]; UsedOn TClass])
-		| Commutative -> ":commutative",("Declares an abstract operator as commutative",[UsedOn TAbstractField])
-		| CompilerGenerated -> ":compilerGenerated",("Marks a field as generated by the compiler. Shouldn't be used by the end user",[Platforms [Java;Cs]])
-		| Const -> ":const",("Allows a type parameter to accept expression values",[UsedOn TTypeParameter])
-		| CoreApi -> ":coreApi",("Identifies this class as a core api class (forces Api check)",[UsedOnEither [TClass;TEnum;TTypedef;TAbstract]])
-		| CoreType -> ":coreType",("Identifies an abstract as core type so that it requires no implementation",[UsedOn TAbstract])
-		| CppFileCode -> ":cppFileCode",("Code to be injected into generated cpp file",[Platform Cpp])
-		| CppInclude -> ":cppInclude",("File to be included in generated cpp file",[Platform Cpp])
-		| CppNamespaceCode -> ":cppNamespaceCode",("",[Platform Cpp])
-		| CsNative -> ":csNative",("Automatically added by -net-lib on classes generated from .NET DLL files",[Platform Cs; UsedOnEither[TClass;TEnum]; Internal])
-		| Dce -> ":dce",("Forces dead code elimination even when -dce full is not specified",[UsedOnEither [TClass;TEnum]])
-		| Debug -> ":debug",("Forces debug information to be generated into the Swf even without -debug",[UsedOnEither [TClass;TClassField]; Platform Flash])
-		| Decl -> ":decl",("",[Platform Cpp])
-		| DefParam -> ":defParam",("Default function argument value loaded from the SWF and used for documentation in Genxml",[Platform Flash;Internal])
-		| Delegate -> ":delegate",("Automatically added by -net-lib on delegates",[Platform Cs; UsedOn TAbstract])
-		| Depend -> ":depend",("",[Platform Cpp])
-		| Deprecated -> ":deprecated",("Mark a type or field as deprecated",[])
-		| DirectlyUsed -> ":directlyUsed",("Marks types that are directly referenced by non-extern code",[Internal])
-		| DynamicObject -> ":dynamicObject",("Used internally to identify the Dynamic Object implementation",[Platforms [Java;Cs]; UsedOn TClass; Internal])
-		| Eager -> ":eager",("Forces typedefs to be followed early",[UsedOn TTypedef])
-		| Enum -> ":enum",("Defines finite value sets to abstract definitions",[UsedOn TAbstract])
-		| EnumConstructorParam -> ":enumConstructorParam",("Used internally to annotate GADT type parameters",[UsedOn TClass; Internal])
-		| Event -> ":event",("Automatically added by -net-lib on events. Has no effect on types compiled by Haxe",[Platform Cs; UsedOn TClassField])
-		| Exhaustive -> ":exhaustive",("",[Internal])
-		| Expose -> ":expose",("Makes the class available on the window object",[HasParam "?Name=Class path";UsedOn TClass;Platform Js])
-		| Extern -> ":extern",("Marks the field as extern so it is not generated",[UsedOn TClassField])
-		| FakeEnum -> ":fakeEnum",("Treat enum as collection of values of the specified type",[HasParam "Type name";UsedOn TEnum])
-		| File -> ":file",("Includes a given binary file into the target Swf and associates it with the class (must extend flash.utils.ByteArray)",[HasParam "File path";UsedOn TClass;Platform Flash])
-		| FileXml -> ":fileXml",("Include xml attribute snippet in Build.xml entry for file",[UsedOn TClass;Platform Cpp])
-		| Final -> ":final",("Prevents a class from being extended",[UsedOn TClass])
-		| Fixed -> ":fixed",("Delcares an anonymous object to have fixed fields",[ (*UsedOn TObjectDecl(_)*)])
-		| FlatEnum -> ":flatEnum",("Internally used to mark an enum as being flat, i.e. having no function constructors",[UsedOn TEnum; Internal])
-		| Font -> ":font",("Embeds the given TrueType font into the class (must extend flash.text.Font)",[HasParam "TTF path";HasParam "Range String";UsedOn TClass])
-		| Forward -> ":forward",("Forwards field access to underlying type",[HasParam "List of field names";UsedOn TAbstract])
-		| ForwardStatics -> ":forwardStatics",("Forwards static field access to underlying type",[HasParam "List of field names";UsedOn TAbstract])
-		| From -> ":from",("Specifies that the field of the abstract is a cast operation from the type identified in the function",[UsedOn TAbstractField])
-		| FunctionCode -> ":functionCode",("Used to inject platform-native code into a function",[Platforms [Cpp;Java;Cs]])
-		| FunctionTailCode -> ":functionTailCode",("",[Platform Cpp])
-		| Generic -> ":generic",("Marks a class or class field as generic so each type parameter combination generates its own type/field",[UsedOnEither [TClass;TClassField]])
-		| GenericBuild -> ":genericBuild",("Builds instances of a type using the specified macro",[UsedOn TClass])
-		| GenericInstance -> ":genericInstance",("Internally used to mark instances of @:generic methods",[UsedOn TClassField;Internal])
-		| Getter -> ":getter",("Generates a native getter function on the given field",[HasParam "Class field name";UsedOn TClassField;Platform Flash])
-		| Hack -> ":hack",("Allows extending classes marked as @:final",[UsedOn TClass])
-		| HasUntyped -> (":has_untyped",("Used by the typer to mark fields that have untyped expressions",[Internal]))
-		| HaxeGeneric -> ":haxeGeneric",("Used internally to annotate non-native generic classes",[Platform Cs; UsedOnEither[TClass;TEnum]; Internal])
-		| HeaderClassCode -> ":headerClassCode",("Code to be injected into the generated class, in the header",[Platform Cpp])
-		| HeaderCode -> ":headerCode",("Code to be injected into the generated header file",[Platform Cpp])
-		| HeaderInclude -> ":headerInclude",("File to be included in generated header file",[Platform Cpp])
-		| HeaderNamespaceCode -> ":headerNamespaceCode",("",[Platform Cpp])
-		| HxGen -> ":hxGen",("Annotates that an extern class was generated by Haxe",[Platforms [Java;Cs]; UsedOnEither [TClass;TEnum]])
-		| IfFeature -> ":ifFeature",("Causes a field to be kept by DCE if the given feature is part of the compilation",[HasParam "Feature name";UsedOn TClassField])
-		| Impl -> ":impl",("Used internally to mark abstract implementation fields",[UsedOn TAbstractField; Internal])
-		| PythonImport -> ":pythonImport",("Generates python import statement for extern classes",[Platforms [Python]; UsedOn TClass])
-		| ImplicitCast -> ":implicitCast",("Generated automatically on the AST when an implicit abstract cast happens",[Internal; UsedOn TExpr])
-		| Include -> ":include",("",[Platform Cpp])
-		| InitPackage -> ":initPackage",("Some weird thing for Genjs we want to remove someday",[Internal; Platform Js])
-		| InlineConstructorVariable -> ":inlineConstructorVariable",("Internally used to mark variables that come from inlined constructors",[Internal])
-		| Meta.Internal -> ":internal",("Generates the annotated field/class with 'internal' access",[Platforms [Java;Cs]; UsedOnEither[TClass;TEnum;TClassField]])
-		| IsVar -> ":isVar",("Forces a physical field to be generated for properties that otherwise would not require one",[UsedOn TClassField])
-		| JavaCanonical -> ":javaCanonical",("Used by the Java target to annotate the canonical path of the type",[HasParam "Output type package";HasParam "Output type name";UsedOnEither [TClass;TEnum]; Platform Java])
-		| JavaNative -> ":javaNative",("Automatically added by -java-lib on classes generated from JAR/class files",[Platform Java; UsedOnEither[TClass;TEnum]; Internal])
-		| JsRequire -> ":jsRequire",("Generate javascript module require expression for given extern",[Platform Js; UsedOn TClass])
-		| LuaRequire -> ":luaRequire",("Generate lua module require expression for given extern",[Platform Lua; UsedOn TClass])
-		| Keep -> ":keep",("Causes a field or type to be kept by DCE",[])
-		| KeepInit -> ":keepInit",("Causes a class to be kept by DCE even if all its field are removed",[UsedOn TClass])
-		| KeepSub -> ":keepSub",("Extends @:keep metadata to all implementing and extending classes",[UsedOn TClass])
-		| LibType -> ":libType",("Used by -net-lib and -java-lib to mark a class that shouldn't be checked (overrides, interfaces, etc) by the type loader",[Internal; UsedOn TClass; Platforms [Java;Cs]])
-		| Meta -> ":meta",("Internally used to mark a class field as being the metadata field",[])
-		| Macro -> ":macro",("(deprecated)",[])
-		| MaybeUsed -> ":maybeUsed",("Internally used by DCE to mark fields that might be kept",[Internal])
-		| MergeBlock -> ":mergeBlock",("Merge the annotated block into the current scope",[UsedOn TExpr])
-		| MultiReturn -> ":multiReturn",("Annotates an extern class as the result of multi-return function",[UsedOn TClass; Platform Lua])
-		| MultiType -> ":multiType",("Specifies that an abstract chooses its this-type from its @:to functions",[UsedOn TAbstract; HasParam "Relevant type parameters"])
-		| Native -> ":native",("Rewrites the path of a class or enum during generation",[HasParam "Output type path";UsedOnEither [TClass;TEnum]])
-		| NativeChildren -> ":nativeChildren",("Annotates that all children from a type should be treated as if it were an extern definition - platform native",[Platforms [Java;Cs]; UsedOn TClass])
-		| NativeGen -> ":nativeGen",("Annotates that a type should be treated as if it were an extern definition - platform native",[Platforms [Java;Cs;Python]; UsedOnEither[TClass;TEnum]])
-		| NativeGeneric -> ":nativeGeneric",("Used internally to annotate native generic classes",[Platform Cs; UsedOnEither[TClass;TEnum]; Internal])
-		| NativeProperty -> ":nativeProperty",("Use native properties which will execute even with dynamic usage",[Platform Cpp])
-		| NativeStaticExtension -> ":nativeStaticExtension",("Converts static function syntax into member call",[Platform Cpp])
-		| NoCompletion -> ":noCompletion",("Prevents the compiler from suggesting completion on this field",[UsedOn TClassField])
-		| NoDebug -> ":noDebug",("Does not generate debug information into the Swf even if -debug is set",[UsedOnEither [TClass;TClassField];Platform Flash])
-		| NoDoc -> ":noDoc",("Prevents a type from being included in documentation generation",[])
-		| NoExpr -> ":noExpr",("Internally used to mark abstract fields which have no expression by design",[Internal])
-		| NoImportGlobal -> ":noImportGlobal",("Prevents a static field from being imported with import Class.*",[UsedOn TAnyField])
-		| NonVirtual -> ":nonVirtual",("Declares function to be non-virtual in cpp",[Platform Cpp])
-		| NoPackageRestrict -> ":noPackageRestrict",("Allows a module to be accessed across all targets if found on its first type",[Internal])
-		| NoPrivateAccess -> ":noPrivateAccess",("Disallow private access to anything for the annotated expression",[UsedOn TExpr])
-		| NoStack -> ":noStack",("",[Platform Cpp])
-		| NotNull -> ":notNull",("Declares an abstract type as not accepting null values",[UsedOn TAbstract])
-		| NoUsing -> ":noUsing",("Prevents a field from being used with 'using'",[UsedOn TClassField])
-		| Ns -> ":ns",("Internally used by the Swf generator to handle namespaces",[Platform Flash])
-		| Objc -> ":objc",("Declares a class or interface that is used to interoperate with Objective-C code",[Platform Cpp;UsedOn TClass])
-		| ObjcProtocol -> ":objcProtocol",("Associates an interface with, or describes a function in, a native Objective-C protocol.",[Platform Cpp;UsedOnEither [TClass;TClassField] ])
-		| Op -> ":op",("Declares an abstract field as being an operator overload",[HasParam "The operation";UsedOn TAbstractField])
-		| Optional -> ":optional",("Marks the field of a structure as optional",[UsedOn TClassField])
-		| Overload -> ":overload",("Allows the field to be called with different argument types",[HasParam "Function specification (no expression)";UsedOn TClassField])
-		| PhpConstants -> ":phpConstants",("Marks the static fields of a class as PHP constants, without $",[Platform Php;UsedOn TClass])
-		| PhpGlobal -> ":phpGlobal",("Puts the static fields of a class in the global PHP namespace",[Platform Php;UsedOn TClass])
-		| Public -> ":public",("Marks a class field as being public",[UsedOn TClassField;Internal])
-		| PublicFields -> ":publicFields",("Forces all class fields of inheriting classes to be public",[UsedOn TClass])
-		| QuotedField -> ":quotedField",("Used internally to mark structure fields which are quoted in syntax",[Internal])
-		| PrivateAccess -> ":privateAccess",("Allow private access to anything for the annotated expression",[UsedOn TExpr])
-		| Protected -> ":protected",("Marks a class field as being protected",[UsedOn TClassField;Platforms [Cs;Java;Flash]])
-		| Property -> ":property",("Marks a property field to be compiled as a native C# property",[UsedOn TClassField;Platform Cs])
-		| Pure -> ":pure",("Marks a class field, class or expression as pure (side-effect free)",[UsedOnEither [TClass;TClassField;TExpr]])
-		| ReadOnly -> ":readOnly",("Generates a field with the 'readonly' native keyword",[Platform Cs; UsedOn TClassField])
-		| RealPath -> ":realPath",("Internally used on @:native types to retain original path information",[Internal])
-		| Remove -> ":remove",("Causes an interface to be removed from all implementing classes before generation",[UsedOn TClass])
-		| Require -> ":require",("Allows access to a field only if the specified compiler flag is set",[HasParam "Compiler flag to check";UsedOn TClassField])
-		| RequiresAssign -> ":requiresAssign",("Used internally to mark certain abstract operator overloads",[Internal])
-		| Resolve -> ":resolve",("Abstract fields marked with this metadata can be used to resolve unknown fields",[UsedOn TClassField])
-		| Rtti -> ":rtti",("Adds runtime type informations",[UsedOn TClass])
-		| Runtime -> ":runtime",("?",[])
-		| RuntimeValue -> ":runtimeValue",("Marks an abstract as being a runtime value",[UsedOn TAbstract])
-		| Scalar -> ":scalar",("Used by hxcpp to mark a custom coreType abstract",[UsedOn TAbstract; Platform Cpp])
-		| SelfCall -> ":selfCall",("Translates method calls into calling object directly",[UsedOn TClassField; Platform Js])
-		| Setter -> ":setter",("Generates a native setter function on the given field",[HasParam "Class field name";UsedOn TClassField;Platform Flash])
-		| StackOnly -> ":stackOnly",("Instances of this type can only appear on the stack",[Platform Cpp])
-		| StoredTypedExpr -> ":storedTypedExpr",("Used internally to reference a typed expression returned from a macro",[Internal])
-		| SkipCtor -> ":skipCtor",("Used internally to generate a constructor as if it were a native type (no __hx_ctor)",[Platforms [Java;Cs]; Internal])
-		| SkipReflection -> ":skipReflection",("Used internally to annotate a field that shouldn't have its reflection data generated",[Platforms [Java;Cs]; UsedOn TClassField; Internal])
-		| Sound -> ":sound",( "Includes a given .wav or .mp3 file into the target Swf and associates it with the class (must extend flash.media.Sound)",[HasParam "File path";UsedOn TClass;Platform Flash])
-		| SourceFile -> ":sourceFile",("Source code filename for external class",[Platform Cpp])
-		| Strict -> ":strict",("Used to declare a native C# attribute or a native Java metadata. Is type checked",[Platforms [Java;Cs]])
-		| Struct -> ":struct",("Marks a class definition as a struct",[Platform Cs; UsedOn TClass])
-		| StructAccess -> ":structAccess",("Marks an extern class as using struct access('.') not pointer('->')",[Platform Cpp; UsedOn TClass])
-		| StructInit -> ":structInit",("Allows to initialize the class with a structure that matches constructor parameters",[UsedOn TClass])
-		| SuppressWarnings -> ":suppressWarnings",("Adds a SuppressWarnings annotation for the generated Java class",[Platform Java; UsedOn TClass])
-		| TemplatedCall -> ":templatedCall",("Indicates that the first parameter of static call should be treated as a template arguement",[Platform Cpp; UsedOn TClassField])
-		| Throws -> ":throws",("Adds a 'throws' declaration to the generated function",[HasParam "Type as String"; Platform Java; UsedOn TClassField])
-		| This -> ":this",("Internally used to pass a 'this' expression to macros",[Internal; UsedOn TExpr])
-		| To -> ":to",("Specifies that the field of the abstract is a cast operation to the type identified in the function",[UsedOn TAbstractField])
-		| ToString -> ":toString",("Internally used",[Internal])
-		| Transient -> ":transient",("Adds the 'transient' flag to the class field",[Platform Java; UsedOn TClassField])
-		| ValueUsed -> ":valueUsed",("Internally used by DCE to mark an abstract value as used",[Internal])
-		| Volatile -> ":volatile",("",[Platforms [Java;Cs]])
-		| Unbound -> ":unbound", ("Compiler internal to denote unbounded global variable",[Internal])
-		| UnifyMinDynamic -> ":unifyMinDynamic",("Allows a collection of types to unify to Dynamic",[UsedOn TClassField])
-		| Unreflective -> ":unreflective",("",[Platform Cpp])
-		| Unsafe -> ":unsafe",("Declares a class, or a method with the C#'s 'unsafe' flag",[Platform Cs; UsedOnEither [TClass;TClassField]])
-		| Usage -> ":usage",("Internal metadata used to mark a symbol for which usage request was invoked",[Internal])
-		| Used -> ":used",("Internally used by DCE to mark a class or field as used",[Internal])
-		| UserVariable -> ":userVariable",("Internally used to mark variables that come from user code",[Internal])
-		| Value -> ":value",("Used to store default values for fields and function arguments",[UsedOn TClassField])
-		| Void -> ":void",("Use Cpp native 'void' return type",[Platform Cpp])
-		| Last -> assert false
-		(* do not put any custom metadata after Last *)
-		| Dollar s -> "$" ^ s,("",[])
-		| Custom s -> s,("",[])
-
-	let hmeta =
-		let h = Hashtbl.create 0 in
-		let rec loop i =
-			let m = Obj.magic i in
-			if m <> Last then begin
-				Hashtbl.add h (fst (to_string m)) m;
-				loop (i + 1);
-			end;
-		in
-		loop 0;
-		h
-
-	let parse s = try Hashtbl.find hmeta (":" ^ s) with Not_found -> Custom (":" ^ s)
-
-	let from_string s =
-		if s = "" then Custom "" else match s.[0] with
-		| ':' -> (try Hashtbl.find hmeta s with Not_found -> Custom s)
-		| '$' -> Dollar (String.sub s 1 (String.length s - 1))
-		| _ -> Custom s
-
-	let get_documentation d =
-		let t, (doc,flags) = to_string d in
-		if not (List.mem Internal flags) then begin
-			let params = ref [] and used = ref [] and pfs = ref [] in
-			List.iter (function
-				| HasParam s -> params := s :: !params
-				| Platform f -> pfs := f :: !pfs
-				| Platforms fl -> pfs := fl @ !pfs
-				| UsedOn u -> used := u :: !used
-				| UsedOnEither ul -> used := ul @ !used
-				| Internal -> assert false
-			) flags;
-			let params = (match List.rev !params with
-				| [] -> ""
-				| l -> "(" ^ String.concat "," l ^ ")"
-			) in
-			let pfs = (match List.rev !pfs with
-				| [] -> ""
-				| [p] -> " (" ^ platform_name p ^ " only)"
-				| pl -> " (for " ^ String.concat "," (List.map platform_name pl) ^ ")"
-			) in
-			let str = "@" ^ t in
-			Some (str,params ^ doc ^ pfs)
-		end else
-			None
-
-	let get_documentation_list () =
-		let m = ref 0 in
-		let rec loop i =
-			let d = Obj.magic i in
-			if d <> Meta.Last then begin match get_documentation d with
-				| None -> loop (i + 1)
-				| Some (str,desc) ->
-					if String.length str > !m then m := String.length str;
-						(str,desc) :: loop (i + 1)
-			end else
-				[]
-		in
-		let all = List.sort (fun (s1,_) (s2,_) -> String.compare s1 s2) (loop 0) in
-		all,!m
-end
-
 let stats =
 	{
 		s_files_parsed = ref 0;
@@ -1167,7 +877,7 @@ let has_dce com =
 	and we wouldn't need to generate unnecessary imports in dce=no, but that's good enough for now.
 *)
 let is_directly_used com meta =
-	not (has_dce com) || Ast.Meta.has Ast.Meta.DirectlyUsed meta
+	not (has_dce com) || Meta.has Meta.DirectlyUsed meta
 
 let rec has_feature com f =
 	try
@@ -1180,9 +890,9 @@ let rec has_feature com f =
 		| meth :: cl :: pack ->
 			let r = (try
 				let path = List.rev pack, cl in
-				(match List.find (fun t -> t_path t = path && not (Ast.Meta.has Ast.Meta.RealPath (t_infos t).mt_meta)) com.types with
-				| t when meth = "*" -> (match t with TAbstractDecl a -> Ast.Meta.has Ast.Meta.ValueUsed a.a_meta | _ ->
-					Ast.Meta.has Ast.Meta.Used (t_infos t).mt_meta)
+				(match List.find (fun t -> t_path t = path && not (Meta.has Meta.RealPath (t_infos t).mt_meta)) com.types with
+				| t when meth = "*" -> (match t with TAbstractDecl a -> Meta.has Meta.ValueUsed a.a_meta | _ ->
+					Meta.has Meta.Used (t_infos t).mt_meta)
 				| TClassDecl ({cl_extern = true} as c) when com.platform <> Js || cl <> "Array" && cl <> "Math" ->
 					Meta.has Meta.Used (try PMap.find meth c.cl_statics with Not_found -> PMap.find meth c.cl_fields).cf_meta
 				| TClassDecl c ->
@@ -1323,7 +1033,6 @@ let rec close_times() =
 	| t :: _ -> close t; close_times()
 
 ;;
-Ast.Meta.to_string_ref := fun m -> fst (MetaInfo.to_string m)
 
 (*  Taken from OCaml source typing/oprint.ml
 

+ 424 - 0
src/context/meta.ml

@@ -0,0 +1,424 @@
+open Globals
+
+type strict_meta =
+	| Abi
+	| Abstract
+	| Access
+	| Accessor
+	| Allow
+	| Analyzer
+	| Annotation
+	| ArrayAccess
+	| Ast
+	| AstSource
+	| AutoBuild
+	| Bind
+	| Bitmap
+	| BridgeProperties
+	| Build
+	| BuildXml
+	| Callable
+	| Class
+	| ClassCode
+	| Commutative
+	| CompilerGenerated
+	| Const
+	| CoreApi
+	| CoreType
+	| CppFileCode
+	| CppInclude
+	| CppNamespaceCode
+	| CsNative
+	| Dce
+	| Debug
+	| Decl
+	| DefParam
+	| Delegate
+	| Depend
+	| Deprecated
+	| DirectlyUsed
+	| DynamicObject
+	| Eager
+	| Enum
+	| EnumConstructorParam
+	| Event
+	| Exhaustive
+	| Expose
+	| Extern
+	| FakeEnum
+	| File
+	| FileXml
+	| Final
+	| Fixed
+	| FlatEnum
+	| Font
+	| Forward
+	| ForwardStatics
+	| From
+	| FunctionCode
+	| FunctionTailCode
+	| Generic
+	| GenericBuild
+	| GenericInstance
+	| Getter
+	| Hack
+	| HasUntyped
+	| HaxeGeneric
+	| HeaderClassCode
+	| HeaderCode
+	| HeaderInclude
+	| HeaderNamespaceCode
+	| HxGen
+	| IfFeature
+	| Impl
+	| PythonImport
+	| ImplicitCast
+	| Include
+	| InitPackage
+	| InlineConstructorVariable
+	| Internal
+	| IsVar
+	| JavaCanonical
+	| JavaNative
+	| JsRequire
+	| Keep
+	| KeepInit
+	| KeepSub
+	| LibType
+	| LuaRequire
+	| Meta
+	| Macro
+	| MaybeUsed
+	| MergeBlock
+	| MultiReturn
+	| MultiType
+	| Native
+	| NativeChildren
+	| NativeGen
+	| NativeGeneric
+	| NativeProperty
+	| NativeStaticExtension
+	| NoCompletion
+	| NoDebug
+	| NoDoc
+	| NoExpr
+	| NoImportGlobal
+	| NonVirtual
+	| NoPackageRestrict
+	| NoPrivateAccess
+	| NoStack
+	| NotNull
+	| NoUsing
+	| Ns
+	| Objc
+	| ObjcProtocol
+	| Op
+	| Optional
+	| Overload
+	| PhpConstants
+	| PhpGlobal
+	| PrivateAccess
+	| Property
+	| Protected
+	| Public
+	| PublicFields
+	| Pure
+	| QuotedField
+	| ReadOnly
+	| RealPath
+	| Remove
+	| Require
+	| RequiresAssign
+	| Resolve
+	| Rtti
+	| Runtime
+	| RuntimeValue
+	| Scalar
+	| SelfCall
+	| Setter
+	| SkipCtor
+	| SkipReflection
+	| Sound
+	| SourceFile
+	| StackOnly
+	| StoredTypedExpr
+	| Strict
+	| Struct
+	| StructAccess
+	| StructInit
+	| SuppressWarnings
+	| This
+	| Throws
+	| To
+	| ToString
+	| Transient
+	| TemplatedCall
+	| ValueUsed
+	| Volatile
+	| Unbound
+	| UnifyMinDynamic
+	| Unreflective
+	| Unsafe
+	| Usage
+	| Used
+	| UserVariable
+	| Value
+	| Void
+	| Last
+	(* do not put any custom metadata after Last *)
+	| Dollar of string
+	| Custom of string
+
+let has m ml = List.exists (fun (m2,_,_) -> m = m2) ml
+let get m ml = List.find (fun (m2,_,_) -> m = m2) ml
+
+type meta_usage =
+	| TClass
+	| TClassField
+	| TAbstract
+	| TAbstractField
+	| TEnum
+	| TTypedef
+	| TAnyField
+	| TExpr
+	| TTypeParameter
+
+type meta_parameter =
+	| HasParam of string
+	| Platform of platform
+	| Platforms of platform list
+	| UsedOn of meta_usage
+	| UsedOnEither of meta_usage list
+	| Internal
+
+let get_info = function
+	| Abi -> ":abi",("Function ABI/calling convention",[Platforms [Cpp]])
+	| Abstract -> ":abstract",("Sets the underlying class implementation as 'abstract'",[Platforms [Java;Cs]])
+	| Access -> ":access",("Forces private access to package, type or field",[HasParam "Target path";UsedOnEither [TClass;TClassField]])
+	| Accessor -> ":accessor",("Used internally by DCE to mark property accessors",[UsedOn TClassField;Internal])
+	| Allow -> ":allow",("Allows private access from package, type or field",[HasParam "Target path";UsedOnEither [TClass;TClassField]])
+	| Analyzer -> ":analyzer",("Used to configure the static analyzer",[])
+	| Annotation -> ":annotation",("Annotation (@interface) definitions on -java-lib imports will be annotated with this metadata. Has no effect on types compiled by Haxe",[Platform Java; UsedOn TClass])
+	| ArrayAccess -> ":arrayAccess",("Allows [] access on an abstract",[UsedOnEither [TAbstract;TAbstractField]])
+	| Ast -> ":ast",("Internally used to pass the AST source into the typed AST",[Internal])
+	| AstSource -> ":astSource",("Filled by the compiler with the parsed expression of the field",[UsedOn TClassField])
+	| AutoBuild -> ":autoBuild",("Extends @:build metadata to all extending and implementing classes",[HasParam "Build macro call";UsedOn TClass])
+	| Bind -> ":bind",("Override Swf class declaration",[Platform Flash;UsedOn TClass])
+	| Bitmap -> ":bitmap",("Embeds given bitmap data into the class (must extend flash.display.BitmapData)",[HasParam "Bitmap file path";UsedOn TClass;Platform Flash])
+	| BridgeProperties -> ":bridgeProperties",("Creates native property bridges for all Haxe properties in this class",[UsedOn TClass;Platform Cs])
+	| Build -> ":build",("Builds a class or enum from a macro",[HasParam "Build macro call";UsedOnEither [TClass;TEnum]])
+	| BuildXml -> ":buildXml",("Specify xml data to be injected into Build.xml",[Platform Cpp])
+	| Callable -> ":callable",("Abstract forwards call to its underlying type",[UsedOn TAbstract])
+	| Class -> ":class",("Used internally to annotate an enum that will be generated as a class",[Platforms [Java;Cs]; UsedOn TEnum; Internal])
+	| ClassCode -> ":classCode",("Used to inject platform-native code into a class",[Platforms [Java;Cs]; UsedOn TClass])
+	| Commutative -> ":commutative",("Declares an abstract operator as commutative",[UsedOn TAbstractField])
+	| CompilerGenerated -> ":compilerGenerated",("Marks a field as generated by the compiler. Shouldn't be used by the end user",[Platforms [Java;Cs]])
+	| Const -> ":const",("Allows a type parameter to accept expression values",[UsedOn TTypeParameter])
+	| CoreApi -> ":coreApi",("Identifies this class as a core api class (forces Api check)",[UsedOnEither [TClass;TEnum;TTypedef;TAbstract]])
+	| CoreType -> ":coreType",("Identifies an abstract as core type so that it requires no implementation",[UsedOn TAbstract])
+	| CppFileCode -> ":cppFileCode",("Code to be injected into generated cpp file",[Platform Cpp])
+	| CppInclude -> ":cppInclude",("File to be included in generated cpp file",[Platform Cpp])
+	| CppNamespaceCode -> ":cppNamespaceCode",("",[Platform Cpp])
+	| CsNative -> ":csNative",("Automatically added by -net-lib on classes generated from .NET DLL files",[Platform Cs; UsedOnEither[TClass;TEnum]; Internal])
+	| Dce -> ":dce",("Forces dead code elimination even when -dce full is not specified",[UsedOnEither [TClass;TEnum]])
+	| Debug -> ":debug",("Forces debug information to be generated into the Swf even without -debug",[UsedOnEither [TClass;TClassField]; Platform Flash])
+	| Decl -> ":decl",("",[Platform Cpp])
+	| DefParam -> ":defParam",("Default function argument value loaded from the SWF and used for documentation in Genxml",[Platform Flash;Internal])
+	| Delegate -> ":delegate",("Automatically added by -net-lib on delegates",[Platform Cs; UsedOn TAbstract])
+	| Depend -> ":depend",("",[Platform Cpp])
+	| Deprecated -> ":deprecated",("Mark a type or field as deprecated",[])
+	| DirectlyUsed -> ":directlyUsed",("Marks types that are directly referenced by non-extern code",[Internal])
+	| DynamicObject -> ":dynamicObject",("Used internally to identify the Dynamic Object implementation",[Platforms [Java;Cs]; UsedOn TClass; Internal])
+	| Eager -> ":eager",("Forces typedefs to be followed early",[UsedOn TTypedef])
+	| Enum -> ":enum",("Defines finite value sets to abstract definitions",[UsedOn TAbstract])
+	| EnumConstructorParam -> ":enumConstructorParam",("Used internally to annotate GADT type parameters",[UsedOn TClass; Internal])
+	| Event -> ":event",("Automatically added by -net-lib on events. Has no effect on types compiled by Haxe",[Platform Cs; UsedOn TClassField])
+	| Exhaustive -> ":exhaustive",("",[Internal])
+	| Expose -> ":expose",("Makes the class available on the window object",[HasParam "?Name=Class path";UsedOn TClass;Platform Js])
+	| Extern -> ":extern",("Marks the field as extern so it is not generated",[UsedOn TClassField])
+	| FakeEnum -> ":fakeEnum",("Treat enum as collection of values of the specified type",[HasParam "Type name";UsedOn TEnum])
+	| File -> ":file",("Includes a given binary file into the target Swf and associates it with the class (must extend flash.utils.ByteArray)",[HasParam "File path";UsedOn TClass;Platform Flash])
+	| FileXml -> ":fileXml",("Include xml attribute snippet in Build.xml entry for file",[UsedOn TClass;Platform Cpp])
+	| Final -> ":final",("Prevents a class from being extended",[UsedOn TClass])
+	| Fixed -> ":fixed",("Delcares an anonymous object to have fixed fields",[ (*UsedOn TObjectDecl(_)*)])
+	| FlatEnum -> ":flatEnum",("Internally used to mark an enum as being flat, i.e. having no function constructors",[UsedOn TEnum; Internal])
+	| Font -> ":font",("Embeds the given TrueType font into the class (must extend flash.text.Font)",[HasParam "TTF path";HasParam "Range String";UsedOn TClass])
+	| Forward -> ":forward",("Forwards field access to underlying type",[HasParam "List of field names";UsedOn TAbstract])
+	| ForwardStatics -> ":forwardStatics",("Forwards static field access to underlying type",[HasParam "List of field names";UsedOn TAbstract])
+	| From -> ":from",("Specifies that the field of the abstract is a cast operation from the type identified in the function",[UsedOn TAbstractField])
+	| FunctionCode -> ":functionCode",("Used to inject platform-native code into a function",[Platforms [Cpp;Java;Cs]])
+	| FunctionTailCode -> ":functionTailCode",("",[Platform Cpp])
+	| Generic -> ":generic",("Marks a class or class field as generic so each type parameter combination generates its own type/field",[UsedOnEither [TClass;TClassField]])
+	| GenericBuild -> ":genericBuild",("Builds instances of a type using the specified macro",[UsedOn TClass])
+	| GenericInstance -> ":genericInstance",("Internally used to mark instances of @:generic methods",[UsedOn TClassField;Internal])
+	| Getter -> ":getter",("Generates a native getter function on the given field",[HasParam "Class field name";UsedOn TClassField;Platform Flash])
+	| Hack -> ":hack",("Allows extending classes marked as @:final",[UsedOn TClass])
+	| HasUntyped -> (":has_untyped",("Used by the typer to mark fields that have untyped expressions",[Internal]))
+	| HaxeGeneric -> ":haxeGeneric",("Used internally to annotate non-native generic classes",[Platform Cs; UsedOnEither[TClass;TEnum]; Internal])
+	| HeaderClassCode -> ":headerClassCode",("Code to be injected into the generated class, in the header",[Platform Cpp])
+	| HeaderCode -> ":headerCode",("Code to be injected into the generated header file",[Platform Cpp])
+	| HeaderInclude -> ":headerInclude",("File to be included in generated header file",[Platform Cpp])
+	| HeaderNamespaceCode -> ":headerNamespaceCode",("",[Platform Cpp])
+	| HxGen -> ":hxGen",("Annotates that an extern class was generated by Haxe",[Platforms [Java;Cs]; UsedOnEither [TClass;TEnum]])
+	| IfFeature -> ":ifFeature",("Causes a field to be kept by DCE if the given feature is part of the compilation",[HasParam "Feature name";UsedOn TClassField])
+	| Impl -> ":impl",("Used internally to mark abstract implementation fields",[UsedOn TAbstractField; Internal])
+	| PythonImport -> ":pythonImport",("Generates python import statement for extern classes",[Platforms [Python]; UsedOn TClass])
+	| ImplicitCast -> ":implicitCast",("Generated automatically on the AST when an implicit abstract cast happens",[Internal; UsedOn TExpr])
+	| Include -> ":include",("",[Platform Cpp])
+	| InitPackage -> ":initPackage",("Some weird thing for Genjs we want to remove someday",[Internal; Platform Js])
+	| InlineConstructorVariable -> ":inlineConstructorVariable",("Internally used to mark variables that come from inlined constructors",[Internal])
+	| Internal -> ":internal",("Generates the annotated field/class with 'internal' access",[Platforms [Java;Cs]; UsedOnEither[TClass;TEnum;TClassField]])
+	| IsVar -> ":isVar",("Forces a physical field to be generated for properties that otherwise would not require one",[UsedOn TClassField])
+	| JavaCanonical -> ":javaCanonical",("Used by the Java target to annotate the canonical path of the type",[HasParam "Output type package";HasParam "Output type name";UsedOnEither [TClass;TEnum]; Platform Java])
+	| JavaNative -> ":javaNative",("Automatically added by -java-lib on classes generated from JAR/class files",[Platform Java; UsedOnEither[TClass;TEnum]; Internal])
+	| JsRequire -> ":jsRequire",("Generate javascript module require expression for given extern",[Platform Js; UsedOn TClass])
+	| LuaRequire -> ":luaRequire",("Generate lua module require expression for given extern",[Platform Lua; UsedOn TClass])
+	| Keep -> ":keep",("Causes a field or type to be kept by DCE",[])
+	| KeepInit -> ":keepInit",("Causes a class to be kept by DCE even if all its field are removed",[UsedOn TClass])
+	| KeepSub -> ":keepSub",("Extends @:keep metadata to all implementing and extending classes",[UsedOn TClass])
+	| LibType -> ":libType",("Used by -net-lib and -java-lib to mark a class that shouldn't be checked (overrides, interfaces, etc) by the type loader",[Internal; UsedOn TClass; Platforms [Java;Cs]])
+	| Meta -> ":meta",("Internally used to mark a class field as being the metadata field",[])
+	| Macro -> ":macro",("(deprecated)",[])
+	| MaybeUsed -> ":maybeUsed",("Internally used by DCE to mark fields that might be kept",[Internal])
+	| MergeBlock -> ":mergeBlock",("Merge the annotated block into the current scope",[UsedOn TExpr])
+	| MultiReturn -> ":multiReturn",("Annotates an extern class as the result of multi-return function",[UsedOn TClass; Platform Lua])
+	| MultiType -> ":multiType",("Specifies that an abstract chooses its this-type from its @:to functions",[UsedOn TAbstract; HasParam "Relevant type parameters"])
+	| Native -> ":native",("Rewrites the path of a class or enum during generation",[HasParam "Output type path";UsedOnEither [TClass;TEnum]])
+	| NativeChildren -> ":nativeChildren",("Annotates that all children from a type should be treated as if it were an extern definition - platform native",[Platforms [Java;Cs]; UsedOn TClass])
+	| NativeGen -> ":nativeGen",("Annotates that a type should be treated as if it were an extern definition - platform native",[Platforms [Java;Cs;Python]; UsedOnEither[TClass;TEnum]])
+	| NativeGeneric -> ":nativeGeneric",("Used internally to annotate native generic classes",[Platform Cs; UsedOnEither[TClass;TEnum]; Internal])
+	| NativeProperty -> ":nativeProperty",("Use native properties which will execute even with dynamic usage",[Platform Cpp])
+	| NativeStaticExtension -> ":nativeStaticExtension",("Converts static function syntax into member call",[Platform Cpp])
+	| NoCompletion -> ":noCompletion",("Prevents the compiler from suggesting completion on this field",[UsedOn TClassField])
+	| NoDebug -> ":noDebug",("Does not generate debug information into the Swf even if -debug is set",[UsedOnEither [TClass;TClassField];Platform Flash])
+	| NoDoc -> ":noDoc",("Prevents a type from being included in documentation generation",[])
+	| NoExpr -> ":noExpr",("Internally used to mark abstract fields which have no expression by design",[Internal])
+	| NoImportGlobal -> ":noImportGlobal",("Prevents a static field from being imported with import Class.*",[UsedOn TAnyField])
+	| NonVirtual -> ":nonVirtual",("Declares function to be non-virtual in cpp",[Platform Cpp])
+	| NoPackageRestrict -> ":noPackageRestrict",("Allows a module to be accessed across all targets if found on its first type",[Internal])
+	| NoPrivateAccess -> ":noPrivateAccess",("Disallow private access to anything for the annotated expression",[UsedOn TExpr])
+	| NoStack -> ":noStack",("",[Platform Cpp])
+	| NotNull -> ":notNull",("Declares an abstract type as not accepting null values",[UsedOn TAbstract])
+	| NoUsing -> ":noUsing",("Prevents a field from being used with 'using'",[UsedOn TClassField])
+	| Ns -> ":ns",("Internally used by the Swf generator to handle namespaces",[Platform Flash])
+	| Objc -> ":objc",("Declares a class or interface that is used to interoperate with Objective-C code",[Platform Cpp;UsedOn TClass])
+	| ObjcProtocol -> ":objcProtocol",("Associates an interface with, or describes a function in, a native Objective-C protocol.",[Platform Cpp;UsedOnEither [TClass;TClassField] ])
+	| Op -> ":op",("Declares an abstract field as being an operator overload",[HasParam "The operation";UsedOn TAbstractField])
+	| Optional -> ":optional",("Marks the field of a structure as optional",[UsedOn TClassField])
+	| Overload -> ":overload",("Allows the field to be called with different argument types",[HasParam "Function specification (no expression)";UsedOn TClassField])
+	| PhpConstants -> ":phpConstants",("Marks the static fields of a class as PHP constants, without $",[Platform Php;UsedOn TClass])
+	| PhpGlobal -> ":phpGlobal",("Puts the static fields of a class in the global PHP namespace",[Platform Php;UsedOn TClass])
+	| Public -> ":public",("Marks a class field as being public",[UsedOn TClassField;Internal])
+	| PublicFields -> ":publicFields",("Forces all class fields of inheriting classes to be public",[UsedOn TClass])
+	| QuotedField -> ":quotedField",("Used internally to mark structure fields which are quoted in syntax",[Internal])
+	| PrivateAccess -> ":privateAccess",("Allow private access to anything for the annotated expression",[UsedOn TExpr])
+	| Protected -> ":protected",("Marks a class field as being protected",[UsedOn TClassField;Platforms [Cs;Java;Flash]])
+	| Property -> ":property",("Marks a property field to be compiled as a native C# property",[UsedOn TClassField;Platform Cs])
+	| Pure -> ":pure",("Marks a class field, class or expression as pure (side-effect free)",[UsedOnEither [TClass;TClassField;TExpr]])
+	| ReadOnly -> ":readOnly",("Generates a field with the 'readonly' native keyword",[Platform Cs; UsedOn TClassField])
+	| RealPath -> ":realPath",("Internally used on @:native types to retain original path information",[Internal])
+	| Remove -> ":remove",("Causes an interface to be removed from all implementing classes before generation",[UsedOn TClass])
+	| Require -> ":require",("Allows access to a field only if the specified compiler flag is set",[HasParam "Compiler flag to check";UsedOn TClassField])
+	| RequiresAssign -> ":requiresAssign",("Used internally to mark certain abstract operator overloads",[Internal])
+	| Resolve -> ":resolve",("Abstract fields marked with this metadata can be used to resolve unknown fields",[UsedOn TClassField])
+	| Rtti -> ":rtti",("Adds runtime type informations",[UsedOn TClass])
+	| Runtime -> ":runtime",("?",[])
+	| RuntimeValue -> ":runtimeValue",("Marks an abstract as being a runtime value",[UsedOn TAbstract])
+	| Scalar -> ":scalar",("Used by hxcpp to mark a custom coreType abstract",[UsedOn TAbstract; Platform Cpp])
+	| SelfCall -> ":selfCall",("Translates method calls into calling object directly",[UsedOn TClassField; Platform Js])
+	| Setter -> ":setter",("Generates a native setter function on the given field",[HasParam "Class field name";UsedOn TClassField;Platform Flash])
+	| StackOnly -> ":stackOnly",("Instances of this type can only appear on the stack",[Platform Cpp])
+	| StoredTypedExpr -> ":storedTypedExpr",("Used internally to reference a typed expression returned from a macro",[Internal])
+	| SkipCtor -> ":skipCtor",("Used internally to generate a constructor as if it were a native type (no __hx_ctor)",[Platforms [Java;Cs]; Internal])
+	| SkipReflection -> ":skipReflection",("Used internally to annotate a field that shouldn't have its reflection data generated",[Platforms [Java;Cs]; UsedOn TClassField; Internal])
+	| Sound -> ":sound",( "Includes a given .wav or .mp3 file into the target Swf and associates it with the class (must extend flash.media.Sound)",[HasParam "File path";UsedOn TClass;Platform Flash])
+	| SourceFile -> ":sourceFile",("Source code filename for external class",[Platform Cpp])
+	| Strict -> ":strict",("Used to declare a native C# attribute or a native Java metadata. Is type checked",[Platforms [Java;Cs]])
+	| Struct -> ":struct",("Marks a class definition as a struct",[Platform Cs; UsedOn TClass])
+	| StructAccess -> ":structAccess",("Marks an extern class as using struct access('.') not pointer('->')",[Platform Cpp; UsedOn TClass])
+	| StructInit -> ":structInit",("Allows to initialize the class with a structure that matches constructor parameters",[UsedOn TClass])
+	| SuppressWarnings -> ":suppressWarnings",("Adds a SuppressWarnings annotation for the generated Java class",[Platform Java; UsedOn TClass])
+	| TemplatedCall -> ":templatedCall",("Indicates that the first parameter of static call should be treated as a template arguement",[Platform Cpp; UsedOn TClassField])
+	| Throws -> ":throws",("Adds a 'throws' declaration to the generated function",[HasParam "Type as String"; Platform Java; UsedOn TClassField])
+	| This -> ":this",("Internally used to pass a 'this' expression to macros",[Internal; UsedOn TExpr])
+	| To -> ":to",("Specifies that the field of the abstract is a cast operation to the type identified in the function",[UsedOn TAbstractField])
+	| ToString -> ":toString",("Internally used",[Internal])
+	| Transient -> ":transient",("Adds the 'transient' flag to the class field",[Platform Java; UsedOn TClassField])
+	| ValueUsed -> ":valueUsed",("Internally used by DCE to mark an abstract value as used",[Internal])
+	| Volatile -> ":volatile",("",[Platforms [Java;Cs]])
+	| Unbound -> ":unbound", ("Compiler internal to denote unbounded global variable",[Internal])
+	| UnifyMinDynamic -> ":unifyMinDynamic",("Allows a collection of types to unify to Dynamic",[UsedOn TClassField])
+	| Unreflective -> ":unreflective",("",[Platform Cpp])
+	| Unsafe -> ":unsafe",("Declares a class, or a method with the C#'s 'unsafe' flag",[Platform Cs; UsedOnEither [TClass;TClassField]])
+	| Usage -> ":usage",("Internal metadata used to mark a symbol for which usage request was invoked",[Internal])
+	| Used -> ":used",("Internally used by DCE to mark a class or field as used",[Internal])
+	| UserVariable -> ":userVariable",("Internally used to mark variables that come from user code",[Internal])
+	| Value -> ":value",("Used to store default values for fields and function arguments",[UsedOn TClassField])
+	| Void -> ":void",("Use Cpp native 'void' return type",[Platform Cpp])
+	| Last -> assert false
+	(* do not put any custom metadata after Last *)
+	| Dollar s -> "$" ^ s,("",[])
+	| Custom s -> s,("",[])
+
+let to_string m = fst (get_info m)
+
+let hmeta =
+	let h = Hashtbl.create 0 in
+	let rec loop i =
+		let m = Obj.magic i in
+		if m <> Last then begin
+			Hashtbl.add h (fst (get_info m)) m;
+			loop (i + 1);
+		end;
+	in
+	loop 0;
+	h
+
+let parse s = try Hashtbl.find hmeta (":" ^ s) with Not_found -> Custom (":" ^ s)
+
+let from_string s =
+	if s = "" then Custom "" else match s.[0] with
+	| ':' -> (try Hashtbl.find hmeta s with Not_found -> Custom s)
+	| '$' -> Dollar (String.sub s 1 (String.length s - 1))
+	| _ -> Custom s
+
+let get_documentation d =
+	let t, (doc,flags) = get_info d in
+	if not (List.mem Internal flags) then begin
+		let params = ref [] and used = ref [] and pfs = ref [] in
+		List.iter (function
+			| HasParam s -> params := s :: !params
+			| Platform f -> pfs := f :: !pfs
+			| Platforms fl -> pfs := fl @ !pfs
+			| UsedOn u -> used := u :: !used
+			| UsedOnEither ul -> used := ul @ !used
+			| Internal -> assert false
+		) flags;
+		let params = (match List.rev !params with
+			| [] -> ""
+			| l -> "(" ^ String.concat "," l ^ ")"
+		) in
+		let pfs = (match List.rev !pfs with
+			| [] -> ""
+			| [p] -> " (" ^ platform_name p ^ " only)"
+			| pl -> " (for " ^ String.concat "," (List.map platform_name pl) ^ ")"
+		) in
+		let str = "@" ^ t in
+		Some (str,params ^ doc ^ pfs)
+	end else
+		None
+
+let get_documentation_list () =
+	let m = ref 0 in
+	let rec loop i =
+		let d = Obj.magic i in
+		if d <> Last then begin match get_documentation d with
+			| None -> loop (i + 1)
+			| Some (str,desc) ->
+				if String.length str > !m then m := String.length str;
+					(str,desc) :: loop (i + 1)
+		end else
+			[]
+	in
+	let all = List.sort (fun (s1,_) (s2,_) -> String.compare s1 s2) (loop 0) in
+	all,!m

+ 5 - 4
src/display/display.ml

@@ -3,6 +3,7 @@ open Common
 open Common.DisplayMode
 open Type
 open Typecore
+open Globals
 
 type display_field_kind =
 	| FKVar of t
@@ -28,7 +29,7 @@ exception ModuleSymbols of string
 exception Metadata of string
 exception DisplaySignatures of (t * documentation) list * int
 exception DisplayType of t * pos * string option
-exception DisplayPosition of Ast.pos list
+exception DisplayPosition of pos list
 exception DisplayFields of (string * display_field_kind * documentation) list
 exception DisplayToplevel of IdentifierType.t list
 exception DisplayPackage of string list
@@ -184,14 +185,14 @@ module DisplayEmitter = struct
 		| DMType ->
 			begin match meta with
 			| Meta.Custom _ | Meta.Dollar _ -> ()
-			| _ -> match MetaInfo.get_documentation meta with
+			| _ -> match Meta.get_documentation meta with
 				| None -> ()
 				| Some (_,s) ->
 					(* TODO: hack until we support proper output for hover display mode *)
 					raise (Metadata ("<metadata>" ^ s ^ "</metadata>"));
 			end
 		| DMField ->
-			let all,_ = MetaInfo.get_documentation_list() in
+			let all,_ = Meta.get_documentation_list() in
 			let all = List.map (fun (s,doc) -> (s,FKMetadata,Some doc)) all in
 			raise (DisplayFields all)
 		| _ ->
@@ -754,7 +755,7 @@ let explore_class_paths ctx class_paths recusive f_pack f_module f_type =
 							try
 								let name = String.sub file 0 (l - 3) in
 								let path = (List.rev pack,name) in
-								let md = ctx.g.do_load_module ctx path Ast.null_pos in
+								let md = ctx.g.do_load_module ctx path null_pos in
 								f_module md;
 								List.iter (fun mt -> f_type mt) md.m_types
 							with _ ->

+ 13 - 13
src/display/displayOutput.ml

@@ -1,4 +1,4 @@
-open Ast
+open Globals
 open Common
 open Common.DisplayMode
 open Type
@@ -195,7 +195,7 @@ let display_memory com =
 			let sign md =
 				if md.m_extra.m_sign = key then "" else "(" ^ (try Digest.to_hex md.m_extra.m_sign with _ -> "???" ^ md.m_extra.m_sign) ^ ")"
 			in
-			print (Printf.sprintf "    %s : %s" (Ast.s_type_path m.m_path) (fmt_size size));
+			print (Printf.sprintf "    %s : %s" (s_type_path m.m_path) (fmt_size size));
 			(if reached then try
 				incr mcount;
 				let lcount = ref 0 in
@@ -210,14 +210,14 @@ let display_memory com =
 				in
 				if (Objsize.objsize m deps [Obj.repr Common.memory_marker]).Objsize.reached then leak "common";
 				PMap.iter (fun _ md ->
-					if (Objsize.objsize m deps [Obj.repr md]).Objsize.reached then leak (Ast.s_type_path md.m_path ^ sign md);
+					if (Objsize.objsize m deps [Obj.repr md]).Objsize.reached then leak (s_type_path md.m_path ^ sign md);
 				) out;
 			with Exit ->
 				());
 			if verbose then begin
 				print (Printf.sprintf "      %d total deps" (List.length deps));
 				PMap.iter (fun _ md ->
-					print (Printf.sprintf "      dep %s%s" (Ast.s_type_path md.m_path) (sign md));
+					print (Printf.sprintf "      dep %s%s" (s_type_path md.m_path) (sign md));
 				) m.m_extra.m_deps;
 			end;
 			flush stdout
@@ -317,7 +317,7 @@ module TypePathHandler = struct
 	let complete_type_path com p =
 		let packs, modules = read_type_path com p in
 		if packs = [] && modules = [] then
-			(error ("No classes found in " ^ String.concat "." p) Ast.null_pos)
+			(error ("No classes found in " ^ String.concat "." p) null_pos)
 		else
 			let packs = List.map (fun n -> n,Display.FKPackage,"") packs in
 			let modules = List.map (fun n -> n,Display.FKModule,"") modules in
@@ -333,7 +333,7 @@ module TypePathHandler = struct
 			let ctx = Typer.create com in
 			let rec lookup p =
 				try
-					Typeload.load_module ctx (p,s_module) Ast.null_pos
+					Typeload.load_module ctx (p,s_module) null_pos
 				with e ->
 					if cur_package then
 						match List.rev p with
@@ -375,7 +375,7 @@ module TypePathHandler = struct
 			in
 			Some fields
 		with _ ->
-			error ("Could not load module " ^ (Ast.s_type_path (p,c))) Ast.null_pos
+			error ("Could not load module " ^ (s_type_path (p,c))) null_pos
 end
 
 (* New JSON stuff *)
@@ -690,9 +690,9 @@ let handle_display_argument com file_pos pre_compilation did_something =
 		Common.define_value com Define.Display (if smode <> "" then smode else "1");
 		Parser.use_doc := true;
 		Parser.resume_display := {
-			Ast.pfile = Path.unique_full_path file;
-			Ast.pmin = pos;
-			Ast.pmax = pos;
+			pfile = Path.unique_full_path file;
+			pmin = pos;
+			pmax = pos;
 		}
 
 let process_display_file com classes =
@@ -708,7 +708,7 @@ let process_display_file com classes =
 					(try
 						let path = Path.parse_type_path path in
 						(match loop l with
-						| Some x as r when String.length (Ast.s_type_path x) < String.length (Ast.s_type_path path) -> r
+						| Some x as r when String.length (s_type_path x) < String.length (s_type_path path) -> r
 						| _ -> Some path)
 					with _ -> loop l)
 				end else
@@ -724,7 +724,7 @@ let process_display_file com classes =
 				classes := [];
 				com.main_class <- None;
 			end;
-			let real = Path.get_real_path (!Parser.resume_display).Ast.pfile in
+			let real = Path.get_real_path (!Parser.resume_display).pfile in
 			(match get_module_path_from_file_path com real with
 			| Some path ->
 				if com.display.dms_kind = DMPackage then raise (DisplayPackage (fst path));
@@ -737,7 +737,7 @@ let process_display_file com classes =
 				failwith "Display file was not found in class path"
 			);
 			Common.log com ("Display file : " ^ real);
-			Common.log com ("Classes found : ["  ^ (String.concat "," (List.map Ast.s_type_path !classes)) ^ "]")
+			Common.log com ("Classes found : ["  ^ (String.concat "," (List.map s_type_path !classes)) ^ "]")
 
 let process_global_display_mode com tctx = match com.display.dms_kind with
 	| DMUsage with_definition ->

+ 1 - 1
src/display/displayTypes.ml

@@ -32,7 +32,7 @@ module SymbolInformation = struct
 	type t = {
 		name : string;
 		kind : SymbolKind.t;
-		pos : pos;
+		pos : Globals.pos;
 		container_name : string option;
 	}
 

+ 3 - 2
src/generators/codegen.ml

@@ -21,6 +21,7 @@ open Ast
 open Type
 open Common
 open Error
+open Globals
 
 (* -------------------------------------------------------------------------- *)
 (* TOOLS *)
@@ -548,7 +549,7 @@ module Dump = struct
 			close_out ch)
 
 	let create_dumpfile_from_path com path =
-		let buf,close = create_dumpfile [] ("dump" :: (Common.platform_name com.platform) :: fst path @ [snd path]) in
+		let buf,close = create_dumpfile [] ("dump" :: (platform_name com.platform) :: fst path @ [snd path]) in
 		buf,close
 
 	let dump_types com s_expr =
@@ -670,7 +671,7 @@ module Dump = struct
 
 	let dump_dependencies ?(target_override=None) com =
 		let target_name = match target_override with
-			| None -> Common.platform_name com.platform
+			| None -> platform_name com.platform
 			| Some s -> s
 		in
 		let buf,close = create_dumpfile [] ["dump";target_name;".dependencies"] in

+ 15 - 15
src/generators/genas3.ml

@@ -109,7 +109,7 @@ let s_path ctx stat path p =
 		let name = protect name in
 		let packs = (try Hashtbl.find ctx.imports name with Not_found -> []) in
 		if not (List.mem pack packs) then Hashtbl.replace ctx.imports name (pack :: packs);
-		Ast.s_type_path (pack,name)
+		Globals.s_type_path (pack,name)
 
 let reserved =
 	let h = Hashtbl.create 0 in
@@ -190,7 +190,7 @@ let close ctx =
 	Hashtbl.iter (fun name paths ->
 		List.iter (fun pack ->
 			let path = pack, name in
-			if path <> ctx.path then output_string ctx.ch ("\timport " ^ Ast.s_type_path path ^ ";\n");
+			if path <> ctx.path then output_string ctx.ch ("\timport " ^ Globals.s_type_path path ^ ";\n");
 		) paths
 	) ctx.imports;
 	output_string ctx.ch (Buffer.contents ctx.buf);
@@ -247,7 +247,7 @@ let rec type_str ctx t p =
 	match t with
 	| TEnum _ | TInst _ when List.memq t ctx.local_types ->
 		"*"
-	| TAbstract (a,pl) when not (Ast.Meta.has Ast.Meta.CoreType a.a_meta) ->
+	| TAbstract (a,pl) when not (Meta.has Meta.CoreType a.a_meta) ->
 		type_str ctx (Abstract.get_underlying_type a pl) p
 	| TAbstract (a,_) ->
 		(match a.a_path with
@@ -264,7 +264,7 @@ let rec type_str ctx t p =
 			| _ ->
 				let rec loop = function
 					| [] -> "Object"
-					| (Ast.Meta.FakeEnum,[Ast.EConst (Ast.Ident n),_],_) :: _ ->
+					| (Meta.FakeEnum,[Ast.EConst (Ast.Ident n),_],_) :: _ ->
 						(match n with
 						| "Int" -> "int"
 						| "UInt" -> "uint"
@@ -397,8 +397,8 @@ let gen_function_header ctx name f params p =
 	print ctx "function%s(" (match name with None -> "" | Some (n,meta) ->
 		let rec loop = function
 			| [] -> n
-			| (Ast.Meta.Getter,[Ast.EConst (Ast.Ident i),_],_) :: _ -> "get " ^ i
-			| (Ast.Meta.Setter,[Ast.EConst (Ast.Ident i),_],_) :: _ -> "set " ^ i
+			| (Meta.Getter,[Ast.EConst (Ast.Ident i),_],_) :: _ -> "get " ^ i
+			| (Meta.Setter,[Ast.EConst (Ast.Ident i),_],_) :: _ -> "set " ^ i
 			| _ :: l -> loop l
 		in
 		" " ^ loop meta
@@ -964,7 +964,7 @@ and gen_value ctx e =
 		v()
 
 let final m =
-	if Ast.Meta.has Ast.Meta.Final m then " final " else ""
+	if Meta.has Meta.Final m then " final " else ""
 
 let generate_field ctx static f =
 	newline ctx;
@@ -972,7 +972,7 @@ let generate_field ctx static f =
 	ctx.gen_uid <- 0;
 	List.iter (fun(m,pl,_) ->
 		match m,pl with
-		| Ast.Meta.Meta, [Ast.ECall ((Ast.EConst (Ast.Ident n),_),args),_] ->
+		| Meta.Meta, [Ast.ECall ((Ast.EConst (Ast.Ident n),_),args),_] ->
 			let mk_arg (a,p) =
 				match a with
 				| Ast.EConst (Ast.String s) -> (None, s)
@@ -994,7 +994,7 @@ let generate_field ctx static f =
 		| _ -> ()
 	) f.cf_meta;
 	let public = f.cf_public || Hashtbl.mem ctx.get_sets (f.cf_name,static) || (f.cf_name = "main" && static)
-		|| f.cf_name = "resolve" || Ast.Meta.has Ast.Meta.Public f.cf_meta
+		|| f.cf_name = "resolve" || Meta.has Meta.Public f.cf_meta
 		(* consider all abstract methods public to avoid issues with inlined private access *)
 	    || (match ctx.curclass.cl_kind with KAbstractImpl _ -> true | _ -> false)
 	in
@@ -1024,8 +1024,8 @@ let generate_field ctx static f =
 			| TFun (args,r) when (match f.cf_kind with Method MethDynamic | Var _ -> false | _ -> true) ->
 				let rec loop = function
 					| [] -> f.cf_name
-					| (Ast.Meta.Getter,[Ast.EConst (Ast.String name),_],_) :: _ -> "get " ^ name
-					| (Ast.Meta.Setter,[Ast.EConst (Ast.String name),_],_) :: _ -> "set " ^ name
+					| (Meta.Getter,[Ast.EConst (Ast.String name),_],_) :: _ -> "get " ^ name
+					| (Meta.Setter,[Ast.EConst (Ast.String name),_],_) :: _ -> "set " ^ name
 					| _ :: l -> loop l
 				in
 				print ctx "function %s(" (loop f.cf_meta);
@@ -1137,13 +1137,13 @@ let generate_class ctx c =
 		newline ctx;
 		spr ctx "namespace static_init";
 		newline ctx;
-		print ctx "%s.static_init::init()" (s_path ctx true ctx.curclass.cl_path Ast.null_pos);
+		print ctx "%s.static_init::init()" (s_path ctx true ctx.curclass.cl_path Globals.null_pos);
 	end;
 	newline ctx;
-	if c.cl_interface && Ast.Meta.has (Ast.Meta.Custom ":hasMetadata") c.cl_meta then begin
+	if c.cl_interface && Meta.has (Meta.Custom ":hasMetadata") c.cl_meta then begin
 		(* we have to reference the metadata class in order for it to be compiled *)
 		let path = fst c.cl_path,snd c.cl_path ^ "_HxMeta" in
-		spr ctx (Ast.s_type_path path);
+		spr ctx (Globals.s_type_path path);
 		newline ctx
 	end
 
@@ -1152,7 +1152,7 @@ let generate_main ctx inits =
 	let pack = open_block ctx in
 	print ctx "\timport flash.Lib";
 	newline ctx;
-	print ctx "public class __main__ extends %s {" (s_path ctx true (["flash"],"Boot") Ast.null_pos);
+	print ctx "public class __main__ extends %s {" (s_path ctx true (["flash"],"Boot") Globals.null_pos);
 	let cl = open_block ctx in
 	newline ctx;
 	spr ctx "public function __main__() {";

+ 8 - 7
src/generators/gencommon.ml

@@ -56,6 +56,7 @@ open Unix
 open Ast
 open Type
 open Common
+open Globals
 open Option
 open Printf
 open ExtString
@@ -1153,7 +1154,7 @@ let mk_class_field name t public pos kind params =
 		cf_pos = pos;
 		cf_name_pos = null_pos;
 		cf_doc = None;
-		cf_meta = [ Meta.CompilerGenerated, [], Ast.null_pos ]; (* annotate that this class field was generated by the compiler *)
+		cf_meta = [ Meta.CompilerGenerated, [], null_pos ]; (* annotate that this class field was generated by the compiler *)
 		cf_kind = kind;
 		cf_params = params;
 		cf_expr = None;
@@ -1175,7 +1176,7 @@ let get_cl_t t =
 
 let mk_class m path pos =
 	let cl = Type.mk_class m path pos null_pos in
-	cl.cl_meta <- [ Meta.CompilerGenerated, [], Ast.null_pos ];
+	cl.cl_meta <- [ Meta.CompilerGenerated, [], null_pos ];
 	cl
 
 type tfield_access =
@@ -2959,10 +2960,10 @@ struct
 			let cur_line = Lexer.get_error_line fexpr.epos in
 			let path = (fst gen.gcurrent_path, Printf.sprintf "%s_%s_%d__Fun" (snd gen.gcurrent_path) cfield cur_line) in
 			let cls = mk_class (get gen.gcurrent_class).cl_module path tfunc.tf_expr.epos in
-			if in_unsafe then cls.cl_meta <- (Meta.Unsafe,[],Ast.null_pos) :: cls.cl_meta;
+			if in_unsafe then cls.cl_meta <- (Meta.Unsafe,[],null_pos) :: cls.cl_meta;
 
 			if Common.defined gen.gcon Define.EraseGenerics then begin
-				cls.cl_meta <- (Meta.HaxeGeneric,[],Ast.null_pos) :: cls.cl_meta
+				cls.cl_meta <- (Meta.HaxeGeneric,[],null_pos) :: cls.cl_meta
 			end;
 			cls.cl_module <- (get gen.gcurrent_class).cl_module;
 			cls.cl_params <- cltypes;
@@ -3232,7 +3233,7 @@ struct
 					(0, t_dynamic)
 			in
 
-			let args_real_to_func_call el (pos:Ast.pos) =
+			let args_real_to_func_call el (pos:pos) =
 				if List.length el >= max_arity then
 					[{ eexpr = TArrayDecl el; etype = basic.tarray t_dynamic; epos = pos }]
 				else begin
@@ -6192,7 +6193,7 @@ struct
 		in
 
 		let binop_type op main_expr e1 e2 =
-			let name = Common.platform_name gen.gcon.platform in
+			let name = platform_name gen.gcon.platform in
 			let basic = gen.gcon.basic in
 			(* If either operand is of type decimal, the other operand is converted to type decimal, or a compile-time error occurs if the other operand is of type float or double.
 			 * Otherwise, if either operand is of type double, the other operand is converted to type double.
@@ -9668,7 +9669,7 @@ struct
 				if vars <> [] then
 					List.iter (fun cf -> match cf.cf_kind with
 						| Var { v_read = AccCall } | Var { v_write = AccCall } when List.mem cf.cf_name vars ->
-							cf.cf_meta <- (Meta.Property, [], Ast.null_pos) :: cf.cf_meta
+							cf.cf_meta <- (Meta.Property, [], null_pos) :: cf.cf_meta
 						| _ -> ()
 					) cl.cl_ordered_fields
 			| _ ->

+ 3 - 2
src/generators/gencpp.ml

@@ -20,6 +20,7 @@
 open Ast
 open Type
 open Common
+open Globals
 
 (*
    Generators do not care about non-core-type abstracts, so let us follow them
@@ -471,7 +472,7 @@ let type_has_meta_key haxe_type key =
 
 (*
 let dump_meta meta =
-   List.iter (fun m -> match m with | (k,_,_) -> print_endline ((fst (MetaInfo.to_string k)) ^ "=" ^ (get_meta_string meta k) ) | _ -> () ) meta;;
+   List.iter (fun m -> match m with | (k,_,_) -> print_endline ((fst (Meta.to_string k)) ^ "=" ^ (get_meta_string meta k) ) | _ -> () ) meta;;
 *)
 
 let get_class_code class_def key = match class_def.cl_kind with
@@ -1369,7 +1370,7 @@ type tcpp =
 and tcppexpr = {
    cppexpr : tcpp_expr_expr;
    cpptype : tcpp;
-   cpppos : Ast.pos;
+   cpppos : pos;
 }
 
 

+ 18 - 17
src/generators/gencs.ml

@@ -17,6 +17,7 @@
 	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *)
 
+open Globals
 open Gencommon.ReflectionCFs
 open Ast
 open Common
@@ -1134,7 +1135,7 @@ let configure gen =
 		if skip_line_directives then
 			fun w p -> ()
 		else fun w p ->
-			if p.pfile <> Ast.null_pos.pfile then (* Compiler Error CS1560 https://msdn.microsoft.com/en-us/library/z3t5e5sw(v=vs.90).aspx *)
+			if p.pfile <> null_pos.pfile then (* Compiler Error CS1560 https://msdn.microsoft.com/en-us/library/z3t5e5sw(v=vs.90).aspx *)
 			let cur_line = Lexer.get_error_line p in
 			let file = Path.get_full_path p.pfile in
 			if cur_line <> ((!last_line)+1) then
@@ -2122,7 +2123,7 @@ let configure gen =
 						match meta with
 							| [] ->
 								let expr = match cf.cf_expr with
-									| None -> mk (TBlock([])) t_dynamic Ast.null_pos
+									| None -> mk (TBlock([])) t_dynamic null_pos
 									| Some s ->
 										match s.eexpr with
 											| TFunction tf ->
@@ -2402,7 +2403,7 @@ let configure gen =
 					write w "public static void Main() ";
 					begin_block w;
 					(if Hashtbl.mem gen.gtypes (["cs"], "Boot") then write w "global::cs.Boot.init();"; newline w);
-					expr_s w { eexpr = TTypeExpr(TClassDecl cl); etype = t_dynamic; epos = Ast.null_pos };
+					expr_s w { eexpr = TTypeExpr(TClassDecl cl); etype = t_dynamic; epos = null_pos };
 					write w ".main();";
 					end_block w;
 					end_block w;
@@ -2765,8 +2766,8 @@ let configure gen =
 	let empty_ctor_expr = mk (TField (empty_en_expr, FEnum(empty_en, PMap.find "EMPTY" empty_en.e_constrs))) empty_ctor_type null_pos in
 	OverloadingConstructor.configure ~empty_ctor_type:empty_ctor_type ~empty_ctor_expr:empty_ctor_expr gen;
 
-	let rcf_static_find = mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) "findHash" Ast.null_pos [] in
-	let rcf_static_lookup = mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) "lookupHash" Ast.null_pos [] in
+	let rcf_static_find = mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) "findHash" null_pos [] in
+	let rcf_static_lookup = mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) "lookupHash" null_pos [] in
 
 	let rcf_static_insert, rcf_static_remove =
 		if erase_generics then begin
@@ -2775,11 +2776,11 @@ let configure gen =
 				| TAnon _ | TDynamic _ -> "Dynamic"
 				| _ -> print_endline (debug_type t); assert false
 			in
-			(fun t -> mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) ("insert" ^ get_specialized_postfix t) Ast.null_pos []),
-			(fun t -> mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) ("remove" ^ get_specialized_postfix t) Ast.null_pos [])
+			(fun t -> mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) ("insert" ^ get_specialized_postfix t) null_pos []),
+			(fun t -> mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) ("remove" ^ get_specialized_postfix t) null_pos [])
 		end else
-			(fun t -> mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) "insert" Ast.null_pos [t]),
-			(fun t -> mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) "remove" Ast.null_pos [t])
+			(fun t -> mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) "insert" null_pos [t]),
+			(fun t -> mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) "remove" null_pos [t])
 	in
 
 	let can_be_float = like_float in
@@ -2893,7 +2894,7 @@ let configure gen =
 
 	ReflectionCFs.implement_varargs_cl rcf_ctx ( get_cl (get_type gen (["haxe";"lang"], "VarArgsBase")) );
 
-	let slow_invoke = mk_static_field_access_infer (runtime_cl) "slowCallField" Ast.null_pos [] in
+	let slow_invoke = mk_static_field_access_infer (runtime_cl) "slowCallField" null_pos [] in
 	ReflectionCFs.configure rcf_ctx ~slow_invoke:(fun ethis efield eargs -> {
 		eexpr = TCall(slow_invoke, [ethis; efield; eargs]);
 		etype = t_dynamic;
@@ -3172,9 +3173,9 @@ let configure gen =
 		let cf = PMap.find "content" res.cl_statics in
 		let res = ref [] in
 		Hashtbl.iter (fun name v ->
-			res := { eexpr = TConst(TString name); etype = gen.gcon.basic.tstring; epos = Ast.null_pos } :: !res;
+			res := { eexpr = TConst(TString name); etype = gen.gcon.basic.tstring; epos = null_pos } :: !res;
 		) gen.gcon.resources;
-		cf.cf_expr <- Some ({ eexpr = TArrayDecl(!res); etype = gen.gcon.basic.tarray gen.gcon.basic.tstring; epos = Ast.null_pos })
+		cf.cf_expr <- Some ({ eexpr = TArrayDecl(!res); etype = gen.gcon.basic.tarray gen.gcon.basic.tstring; epos = null_pos })
 	with | Not_found -> ());
 
 	run_filters gen;
@@ -3305,15 +3306,15 @@ let generate con =
 		let type_cl = get_cl ( get_type gen (["System"], "Type")) in
 		let basic_fns =
 		[
-			mk_class_field "Equals" (TFun(["obj",false,t_dynamic], basic.tbool)) true Ast.null_pos (Method MethNormal) [];
-			mk_class_field "ToString" (TFun([], basic.tstring)) true Ast.null_pos (Method MethNormal) [];
-			mk_class_field "GetHashCode" (TFun([], basic.tint)) true Ast.null_pos (Method MethNormal) [];
-			mk_class_field "GetType" (TFun([], TInst(type_cl, []))) true Ast.null_pos (Method MethNormal) [];
+			mk_class_field "Equals" (TFun(["obj",false,t_dynamic], basic.tbool)) true null_pos (Method MethNormal) [];
+			mk_class_field "ToString" (TFun([], basic.tstring)) true null_pos (Method MethNormal) [];
+			mk_class_field "GetHashCode" (TFun([], basic.tint)) true null_pos (Method MethNormal) [];
+			mk_class_field "GetType" (TFun([], TInst(type_cl, []))) true null_pos (Method MethNormal) [];
 		] in
 		List.iter (fun cf -> gen.gbase_class_fields <- PMap.add cf.cf_name cf gen.gbase_class_fields) basic_fns;
 		configure gen
 	with | TypeNotFound path ->
-		con.error ("Error. Module '" ^ (s_type_path path) ^ "' is required and was not included in build.")	Ast.null_pos);
+		con.error ("Error. Module '" ^ (s_type_path path) ^ "' is required and was not included in build.")	null_pos);
 	debug_mode := false
 
 (* -net-lib implementation *)

+ 2 - 1
src/generators/genhl.ml

@@ -20,6 +20,7 @@
  * DEALINGS IN THE SOFTWARE.
  *)
 open Unix
+open Globals
 open Ast
 open Type
 open Common
@@ -3360,4 +3361,4 @@ let generate com =
 		close_out ch;
 	end;
 	t();
-	if Common.defined com Define.Interp then try ignore(Hlinterp.interp code) with Failure msg -> abort msg Ast.null_pos
+	if Common.defined com Define.Interp then try ignore(Hlinterp.interp code) with Failure msg -> abort msg null_pos

+ 19 - 17
src/generators/genjava.ml

@@ -17,6 +17,7 @@
 	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *)
 
+open Globals
 open JData
 open Unix
 open Ast
@@ -27,6 +28,7 @@ open Gencommon.SourceWriter
 open Printf
 open Option
 open ExtString
+
 module SS = Set.Make(String)
 
 let is_boxed_type t = match follow t with
@@ -1695,7 +1697,7 @@ let configure gen =
 								| [] -> acc
 								| _ -> acc) (* TODO
 								| _ -> (sprintf " where %s : %s" name (String.concat ", " (List.map (fun (cl,p) -> path_param_s (TClassDecl cl) cl.cl_path p) cl.cl_implements))) :: acc ) *)
-						| _ -> trace (t_s Ast.null_pos t); assert false (* FIXME it seems that a cl_params will never be anything other than cl.cl_params. I'll take the risk and fail if not, just to see if that confirms *)
+						| _ -> trace (t_s null_pos t); assert false (* FIXME it seems that a cl_params will never be anything other than cl.cl_params. I'll take the risk and fail if not, just to see if that confirms *)
 				) [] cl_params in
 				(params, String.concat " " params_extends)
 	in
@@ -1807,7 +1809,7 @@ let configure gen =
 						match meta with
 							| [] ->
 								let expr = match cf.cf_expr with
-									| None -> mk (TBlock([])) t_dynamic Ast.null_pos
+									| None -> mk (TBlock([])) t_dynamic null_pos
 									| Some s ->
 										match s.eexpr with
 											| TFunction tf ->
@@ -2097,16 +2099,16 @@ let configure gen =
 	let empty_ctor_expr = mk (TField (empty_en_expr, FEnum(empty_en, PMap.find "EMPTY" empty_en.e_constrs))) empty_ctor_type null_pos in
 	OverloadingConstructor.configure ~empty_ctor_type:empty_ctor_type ~empty_ctor_expr:empty_ctor_expr gen;
 
-	let rcf_static_find = mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) "findHash" Ast.null_pos [] in
-	(*let rcf_static_lookup = mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) "lookupHash" Ast.null_pos [] in*)
+	let rcf_static_find = mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) "findHash" null_pos [] in
+	(*let rcf_static_lookup = mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) "lookupHash" null_pos [] in*)
 	let get_specialized_postfix t = match t with
 		| TAbstract({a_path = [],"Float"}, _) -> "Float"
 		| TInst({cl_path = [],"String"},_) -> "String"
 		| TAnon _ | TDynamic _ -> "Dynamic"
 		| _ -> print_endline (debug_type t); assert false
 	in
-	let rcf_static_insert t = mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) ("insert" ^ get_specialized_postfix t) Ast.null_pos [] in
-	let rcf_static_remove t = mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) ("remove" ^ get_specialized_postfix t) Ast.null_pos [] in
+	let rcf_static_insert t = mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) ("insert" ^ get_specialized_postfix t) null_pos [] in
+	let rcf_static_remove t = mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) ("remove" ^ get_specialized_postfix t) null_pos [] in
 
 	let can_be_float t = like_float (real_type t) in
 
@@ -2191,7 +2193,7 @@ let configure gen =
 
 	ReflectionCFs.implement_varargs_cl rcf_ctx ( get_cl (get_type gen (["haxe";"lang"], "VarArgsBase")) );
 
-	let slow_invoke = mk_static_field_access_infer (runtime_cl) "slowCallField" Ast.null_pos [] in
+	let slow_invoke = mk_static_field_access_infer (runtime_cl) "slowCallField" null_pos [] in
 	ReflectionCFs.configure rcf_ctx ~slow_invoke:(fun ethis efield eargs -> {
 		eexpr = TCall(slow_invoke, [ethis; efield; eargs]);
 		etype = t_dynamic;
@@ -2420,7 +2422,7 @@ let configure gen =
 	(* add resources array *)
 	let res = ref [] in
 	Hashtbl.iter (fun name v ->
-		res := { eexpr = TConst(TString name); etype = gen.gcon.basic.tstring; epos = Ast.null_pos } :: !res;
+		res := { eexpr = TConst(TString name); etype = gen.gcon.basic.tstring; epos = null_pos } :: !res;
 		let name = Codegen.escape_res_name name true in
 		let full_path = gen.gcon.file ^ "/src/" ^ name in
 		mkdir_from_path full_path;
@@ -2434,7 +2436,7 @@ let configure gen =
 	(try
 		let c = get_cl (Hashtbl.find gen.gtypes (["haxe"], "Resource")) in
 		let cf = PMap.find "content" c.cl_statics in
-		cf.cf_expr <- Some ({ eexpr = TArrayDecl(!res); etype = gen.gcon.basic.tarray gen.gcon.basic.tstring; epos = Ast.null_pos })
+		cf.cf_expr <- Some ({ eexpr = TArrayDecl(!res); etype = gen.gcon.basic.tarray gen.gcon.basic.tstring; epos = null_pos })
 	with | Not_found -> ());
 
 	run_filters gen;
@@ -2503,19 +2505,19 @@ let generate con =
 	let cl_cl = get_cl (get_type gen (["java";"lang"],"Class")) in
 	let basic_fns =
 	[
-		mk_class_field "equals" (TFun(["obj",false,t_dynamic], basic.tbool)) true Ast.null_pos (Method MethNormal) [];
-		mk_class_field "toString" (TFun([], basic.tstring)) true Ast.null_pos (Method MethNormal) [];
-		mk_class_field "hashCode" (TFun([], basic.tint)) true Ast.null_pos (Method MethNormal) [];
-		mk_class_field "getClass" (TFun([], (TInst(cl_cl,[t_dynamic])))) true Ast.null_pos (Method MethNormal) [];
-		mk_class_field "wait" (TFun([], basic.tvoid)) true Ast.null_pos (Method MethNormal) [];
-		mk_class_field "notify" (TFun([], basic.tvoid)) true Ast.null_pos (Method MethNormal) [];
-		mk_class_field "notifyAll" (TFun([], basic.tvoid)) true Ast.null_pos (Method MethNormal) [];
+		mk_class_field "equals" (TFun(["obj",false,t_dynamic], basic.tbool)) true null_pos (Method MethNormal) [];
+		mk_class_field "toString" (TFun([], basic.tstring)) true null_pos (Method MethNormal) [];
+		mk_class_field "hashCode" (TFun([], basic.tint)) true null_pos (Method MethNormal) [];
+		mk_class_field "getClass" (TFun([], (TInst(cl_cl,[t_dynamic])))) true null_pos (Method MethNormal) [];
+		mk_class_field "wait" (TFun([], basic.tvoid)) true null_pos (Method MethNormal) [];
+		mk_class_field "notify" (TFun([], basic.tvoid)) true null_pos (Method MethNormal) [];
+		mk_class_field "notifyAll" (TFun([], basic.tvoid)) true null_pos (Method MethNormal) [];
 	] in
 	List.iter (fun cf -> gen.gbase_class_fields <- PMap.add cf.cf_name cf gen.gbase_class_fields) basic_fns;
 
 	(try
 		configure gen
-	with | TypeNotFound path -> con.error ("Error. Module '" ^ (s_type_path path) ^ "' is required and was not included in build.")	Ast.null_pos);
+	with | TypeNotFound path -> con.error ("Error. Module '" ^ (s_type_path path) ^ "' is required and was not included in build.")	null_pos);
 	debug_mode := false
 
 (** Java lib *)

+ 2 - 3
src/generators/genjs.ml

@@ -17,12 +17,11 @@
 	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *)
 
+open Globals
 open Ast
 open Type
 open Common
 
-type pos = Ast.pos
-
 type sourcemap = {
 	sources : (string) DynArray.t;
 	sources_hash : (string, int) Hashtbl.t;
@@ -74,7 +73,7 @@ let get_exposed ctx path meta =
 			| _ -> abort "Invalid @:expose parameters" pos)
 	with Not_found -> []
 
-let dot_path = Ast.s_type_path
+let dot_path = s_type_path
 
 let flat_path (p,s) =
 	(* Replace _ with _$ in paths to prevent name collisions. *)

+ 3 - 3
src/generators/genlua.ml

@@ -25,7 +25,7 @@ open Type
 open Common
 open ExtList
 
-type pos = Ast.pos
+type pos = Globals.pos
 
 type ctx = {
 	com : Common.context;
@@ -67,7 +67,7 @@ let get_exposed ctx path meta = try
 			| _ -> abort "Invalid @:expose parameters" pos)
 	with Not_found -> []
 
-let dot_path = Ast.s_type_path
+let dot_path = Globals.s_type_path
 
 let s_path ctx = dot_path
 
@@ -630,7 +630,7 @@ and gen_expr ?(local=true) ctx e = begin
 				| _ when Meta.has Meta.MultiReturn v.v_meta ->
 					(* multi-return var is generated as several vars for unpacking *)
 				    let id = temp ctx in
-				    let temp_expr = (EConst(String(id)), null_pos) in
+				    let temp_expr = (EConst(String(id)), Globals.null_pos) in
 				    v.v_meta <- (Meta.Custom ":lua_mr_id", [temp_expr], v.v_pos) :: v.v_meta;
 				    let name = ident v.v_name in
 				    let names =

+ 1 - 0
src/generators/genneko.ml

@@ -18,6 +18,7 @@
  *)
 
 open Ast
+open Globals
 open Type
 open Nast
 open Common

+ 3 - 3
src/generators/genphp.ml

@@ -344,7 +344,7 @@ let write_resource dir name data =
 	close_out ch
 
 let stack_init com use_add =
-	Codegen.stack_context_init com "GLOBALS['%s']" "GLOBALS['%e']" "__hx__spos" "tmp" use_add null_pos
+	Codegen.stack_context_init com "GLOBALS['%s']" "GLOBALS['%e']" "__hx__spos" "tmp" use_add Globals.null_pos
 
 let init com cwd path def_type =
 	let rec create acc = function
@@ -2262,9 +2262,9 @@ let generate com =
 							else
 								((n = (prefixed_name false)) || (n = (prefixed_name true)))
 						) !lc_names in
-						unsupported ("method '" ^ (s_type_path c.cl_path) ^ "." ^ cf.cf_name ^ "' already exists here '" ^ (fst lc) ^ "' (different case?)") c.cl_pos
+						unsupported ("method '" ^ (Globals.s_type_path c.cl_path) ^ "." ^ cf.cf_name ^ "' already exists here '" ^ (fst lc) ^ "' (different case?)") c.cl_pos
 					with Not_found ->
-						lc_names := ((s_type_path c.cl_path) ^ "." ^ cf.cf_name, prefixed_name static) :: !lc_names)
+						lc_names := ((Globals.s_type_path c.cl_path) ^ "." ^ cf.cf_name, prefixed_name static) :: !lc_names)
 				| _ ->
 					()
 			) lst

+ 1 - 0
src/generators/genpy.ml

@@ -17,6 +17,7 @@
 	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *)
 
+open Globals
 open Ast
 open Type
 open Common

+ 3 - 2
src/generators/genswf.ml

@@ -24,6 +24,7 @@ open Genswf9
 open Type
 open Common
 open Ast
+open Globals
 
 let rec make_tpath = function
 	| HMPath (pack,name) ->
@@ -109,7 +110,7 @@ let is_valid_path com pack name =
 		| [] ->
 			false
 		| load :: l ->
-			match load (pack,name) Ast.null_pos with
+			match load (pack,name) null_pos with
 			| None -> loop l
 			| Some (file,(_,a)) -> true
 	in
@@ -1140,7 +1141,7 @@ let generate swf_header com =
 	let fattr = if Common.defined com Define.AdvancedTelemetry then fattr @ [tag (TUnknown (0x5D,"\x00\x00"))] else fattr in
 	let swf_script_limits = try
 		let s = Common.defined_value com Define.SwfScriptTimeout in
-		let i = try int_of_string s with _ -> abort "Argument to swf_script_timeout must be an integer" Ast.null_pos in
+		let i = try int_of_string s with _ -> abort "Argument to swf_script_timeout must be an integer" null_pos in
 		[tag(TScriptLimits (256, if i < 0 then 0 else if i > 65535 then 65535 else i))]
 	with Not_found ->
 		[]

+ 1 - 0
src/generators/genswf9.ml

@@ -17,6 +17,7 @@
 	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *)
 
+open Globals
 open Ast
 open Type
 open As3

+ 4 - 3
src/generators/genxml.ml

@@ -17,6 +17,7 @@
 	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *)
 
+open Globals
 open Ast
 open Type
 open Common
@@ -85,7 +86,7 @@ let gen_meta meta =
 	| [] -> []
 	| _ ->
 		let nodes = List.map (fun (m,el,_) ->
-			node "m" ["n",fst (MetaInfo.to_string m)] (List.map (fun e -> node "e" [] [gen_string (Ast.s_expr e)]) el)
+			node "m" ["n",Meta.to_string m] (List.map (fun e -> node "e" [] [gen_string (Ast.s_expr e)]) el)
 		) meta in
 		[node "meta" [] nodes]
 
@@ -425,8 +426,8 @@ let generate_type com t =
 			| Meta.DefParam | Meta.CoreApi | Meta.Used | Meta.MaybeUsed | Meta.FlatEnum | Meta.Value | Meta.DirectlyUsed -> ()
 			| _ ->
 			match pl with
-			| [] -> p "@%s " (fst (MetaInfo.to_string m))
-			| l -> p "@%s(%s) " (fst (MetaInfo.to_string m)) (String.concat "," (List.map Ast.s_expr pl))
+			| [] -> p "@%s " (Meta.to_string m)
+			| l -> p "@%s(%s) " (Meta.to_string m) (String.concat "," (List.map Ast.s_expr pl))
 		) ml
 	in
 	let access is_read a = s_access is_read a in

+ 53 - 1
src/globals.ml

@@ -1,3 +1,25 @@
+type pos = {
+	pfile : string;
+	pmin : int;
+	pmax : int;
+}
+
+module IntMap = Map.Make(struct type t = int let compare a b = a - b end)
+module StringMap = Map.Make(struct type t = string let compare = String.compare end)
+
+type platform =
+	| Cross
+	| Js
+	| Lua
+	| Neko
+	| Flash
+	| Php
+	| Cpp
+	| Cs
+	| Java
+	| Python
+	| Hl
+
 let version = 3300
 let version_major = version / 1000
 let version_minor = (version mod 1000) / 100
@@ -7,4 +29,34 @@ let version_is_stable = version_minor land 1 = 0
 let is_windows = Sys.os_type = "Win32" || Sys.os_type = "Cygwin"
 
 let s_version =
-	Printf.sprintf "%d.%d.%d%s" version_major version_minor version_revision (match Version.version_extra with None -> "" | Some v -> " " ^ v)
+	Printf.sprintf "%d.%d.%d%s" version_major version_minor version_revision (match Version.version_extra with None -> "" | Some v -> " " ^ v)
+
+let platforms = [
+	Js;
+	Lua;
+	Neko;
+	Flash;
+	Php;
+	Cpp;
+	Cs;
+	Java;
+	Python;
+	Hl;
+]
+
+let platform_name = function
+	| Cross -> "cross"
+	| Js -> "js"
+	| Lua -> "lua"
+	| Neko -> "neko"
+	| Flash -> "flash"
+	| Php -> "php"
+	| Cpp -> "cpp"
+	| Cs -> "cs"
+	| Java -> "java"
+	| Python -> "python"
+	| Hl -> "hl"
+
+let null_pos = { pfile = "?"; pmin = -1; pmax = -1 }
+
+let s_type_path (p,s) = match p with [] -> s | _ -> String.concat "." p ^ "." ^ s

+ 42 - 41
src/macro/interp.ml

@@ -17,6 +17,7 @@
 	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *)
 
+open Globals
 open Common
 open Nast
 open Unix
@@ -49,7 +50,7 @@ and vabstract =
 	| AHash of (value, value) Hashtbl.t
 	| ARandom of Random.State.t ref
 	| ABuffer of Buffer.t
-	| APos of Ast.pos
+	| APos of Globals.pos
 	| AFRead of (in_channel * bool ref)
 	| AFWrite of out_channel
 	| AReg of regexp
@@ -94,7 +95,7 @@ type cmp =
 	| CUndef
 
 type extern_api = {
-	pos : Ast.pos;
+	pos : Globals.pos;
 	get_com : unit -> Common.context;
 	get_type : string -> Type.t option;
 	get_module : string -> Type.t list;
@@ -102,9 +103,9 @@ type extern_api = {
 	on_generate : (Type.t list -> unit) -> unit;
 	after_generate : (unit -> unit) -> unit;
 	on_type_not_found : (string -> value) -> unit;
-	parse_string : string -> Ast.pos -> bool -> Ast.expr;
+	parse_string : string -> Globals.pos -> bool -> Ast.expr;
 	type_expr : Ast.expr -> Type.texpr;
-	resolve_type  : Ast.complex_type -> Ast.pos -> t;
+	resolve_type  : Ast.complex_type -> Globals.pos -> t;
 	type_macro_expr : Ast.expr -> Type.texpr;
 	store_typed_expr : Type.texpr -> Ast.expr;
 	allow_package : string -> unit;
@@ -119,16 +120,16 @@ type extern_api = {
 	get_local_using : unit -> tclass list;
 	get_local_vars : unit -> (string, Type.tvar) PMap.t;
 	get_build_fields : unit -> value;
-	get_pattern_locals : Ast.expr -> Type.t -> (string,Type.tvar * Ast.pos) PMap.t;
+	get_pattern_locals : Ast.expr -> Type.t -> (string,Type.tvar * Globals.pos) PMap.t;
 	define_type : value -> unit;
-	define_module : string -> value list -> ((string * Ast.pos) list * Ast.import_mode) list -> Ast.type_path list -> unit;
+	define_module : string -> value list -> ((string * Globals.pos) list * Ast.import_mode) list -> Ast.type_path list -> unit;
 	module_dependency : string -> string -> bool -> unit;
 	current_module : unit -> module_def;
 	mutable current_macro_module : unit -> module_def;
 	delayed_macro : int -> (unit -> (unit -> value));
 	use_cache : unit -> bool;
-	format_string : string -> Ast.pos -> Ast.expr;
-	cast_or_unify : Type.t -> texpr -> Ast.pos -> Type.texpr;
+	format_string : string -> Globals.pos -> Ast.expr;
+	cast_or_unify : Type.t -> texpr -> Globals.pos -> Type.texpr;
 	add_global_metadata : string -> string -> (bool * bool * bool) -> unit;
 }
 
@@ -183,7 +184,7 @@ type access =
 exception Runtime of value
 exception Builtin_error
 
-exception Error of string * Ast.pos list
+exception Error of string * Globals.pos list
 
 exception Abort
 exception Continue
@@ -222,7 +223,7 @@ let dec_array (l:value) : value list = (!dec_array_ref) l
 
 let decode_complex_type (v:value) : Ast.type_hint = (!decode_complex_type_ref) v
 let encode_complex_type (t:Ast.type_hint) : value = (!encode_complex_type_ref) t
-let decode_pos (v:value) : Ast.pos = (!decode_pos_ref) v
+let decode_pos (v:value) : Globals.pos = (!decode_pos_ref) v
 let encode_type (t:Type.t) : value = (!encode_type_ref) t
 let decode_type (v:value) : Type.t = (!decode_type_ref) v
 let encode_expr (e:Ast.expr) : value = (!encode_expr_ref) e
@@ -244,9 +245,9 @@ let best_int i = if need_32_bits i then VInt32 i else VInt (Int32.to_int i)
 let make_pos p =
 	let low = p.pline land 0xFFFFF in
 	{
-		Ast.pfile = p.psource;
-		Ast.pmin = low;
-		Ast.pmax = low + (p.pline lsr 20);
+		Globals.pfile = p.psource;
+		Globals.pmin = low;
+		Globals.pmax = low + (p.pline lsr 20);
 	}
 
 let warn ctx msg p =
@@ -801,7 +802,7 @@ let builtins =
 	let build_stack sl =
 		let make p =
 			let p = make_pos p in
-			VArray [|VString p.Ast.pfile;VInt (Lexer.get_error_line p)|]
+			VArray [|VString p.Globals.pfile;VInt (Lexer.get_error_line p)|]
 		in
 		VArray (Array.of_list (List.map make sl))
 	in
@@ -1717,7 +1718,7 @@ let std_lib =
 			VInt (((get_ctx()).curapi.get_com()).run_command (vstring cmd))
 		);
 		"sys_exit", Fun1 (fun code ->
-			if (get_ctx()).curapi.use_cache() then raise (Error.Fatal_error ("",Ast.null_pos));
+			if (get_ctx()).curapi.use_cache() then raise (Error.Fatal_error ("",Globals.null_pos));
 			raise (Sys_exit(vint code));
 		);
 		"sys_exists", Fun1 (fun file ->
@@ -1793,9 +1794,9 @@ let std_lib =
 			match com.main_class with
 			| None -> error()
 			| Some p ->
-				match ctx.curapi.get_type (Ast.s_type_path p) with
+				match ctx.curapi.get_type (s_type_path p) with
 				| Some(TInst (c, _)) ->
-					VString (Extc.get_full_path c.cl_pos.Ast.pfile)
+					VString (Extc.get_full_path c.cl_pos.Globals.pfile)
 				| _ -> error();
 		);
 		"sys_env", Fun0 (fun() ->
@@ -2338,7 +2339,7 @@ let macro_lib =
 					| VFloat f -> haxe_float f p
 					| VAbstract (APos p) ->
 						(Ast.EObjectDecl (
-							("fileName" , (Ast.EConst (Ast.String p.Ast.pfile) , p)) ::
+							("fileName" , (Ast.EConst (Ast.String p.Globals.pfile) , p)) ::
 							("lineNumber" , (Ast.EConst (Ast.Int (string_of_int (Lexer.get_error_line p))),p)) ::
 							("className" , (Ast.EConst (Ast.String ("")),p)) ::
 							[]
@@ -2436,7 +2437,7 @@ let macro_lib =
 					do_cache v v2;
 					rl := List.map loop vl;
 					v2
-				| VAbstract (APos p) -> VAbstract (APos { p with Ast.pfile = get_file p.Ast.pfile })
+				| VAbstract (APos p) -> VAbstract (APos { p with Globals.pfile = get_file p.Globals.pfile })
 				| VAbstract (ACacheRef v) -> v
 				| VAbstract (AHash h) ->
 					let h2 = Hashtbl.create 0 in
@@ -2462,8 +2463,8 @@ let macro_lib =
 			with Exit -> VNull
 		);
 		"unify", Fun2 (fun t1 t2 ->
-			let e1 = mk (TObjectDecl []) (decode_type t1) Ast.null_pos in
-			try ignore(((get_ctx()).curapi.cast_or_unify) (decode_type t2) e1 Ast.null_pos); VBool true
+			let e1 = mk (TObjectDecl []) (decode_type t1) Globals.null_pos in
+			try ignore(((get_ctx()).curapi.cast_or_unify) (decode_type t2) e1 Globals.null_pos); VBool true
 			with Error.Error (Error.Unify _,_) -> VBool false
 		);
 		"typeof", Fun1 (fun v ->
@@ -2534,12 +2535,12 @@ let macro_lib =
 		);
 		"get_pos_infos", Fun1 (fun p ->
 			match p with
-			| VAbstract (APos p) -> VObject (obj (hash_field (get_ctx())) ["min",VInt p.Ast.pmin;"max",VInt p.Ast.pmax;"file",VString p.Ast.pfile])
+			| VAbstract (APos p) -> VObject (obj (hash_field (get_ctx())) ["min",VInt p.Globals.pmin;"max",VInt p.Globals.pmax;"file",VString p.Globals.pfile])
 			| _ -> error()
 		);
 		"make_pos", Fun3 (fun min max file ->
 			match min, max, file with
-			| VInt min, VInt max, VString file -> VAbstract (APos { Ast.pmin = min; Ast.pmax = max; Ast.pfile = file })
+			| VInt min, VInt max, VString file -> VAbstract (APos { Globals.pmin = min; Globals.pmax = max; Globals.pfile = file })
 			| _ -> error()
 		);
 		"add_resource", Fun2 (fun name data ->
@@ -2560,7 +2561,7 @@ let macro_lib =
 		);
 		"local_module", Fun0 (fun() ->
 			let m = (get_ctx()).curapi.current_module() in
-			VString (Ast.s_type_path m.m_path);
+			VString (s_type_path m.m_path);
 		);
 		"local_type", Fun0 (fun() ->
 			match (get_ctx()).curapi.get_local_type() with
@@ -2608,7 +2609,7 @@ let macro_lib =
 					(match !r with
 					| None -> t
 					| Some t -> t)
-				| TAbstract (a,tl) when not (Ast.Meta.has Ast.Meta.CoreType a.a_meta) ->
+				| TAbstract (a,tl) when not (Meta.has Meta.CoreType a.a_meta) ->
 					Abstract.get_underlying_type a tl
 				| TAbstract _ | TEnum _ | TInst _ | TFun _ | TAnon _ | TDynamic _ ->
 					t
@@ -2732,10 +2733,10 @@ let macro_lib =
 		);
 		"get_display_pos", Fun0 (fun() ->
 			let p = !Parser.resume_display in
-			if p = Ast.null_pos then
+			if p = Globals.null_pos then
 				VNull
 			else
-				VObject (obj (hash_field (get_ctx())) ["file",VString p.Ast.pfile;"pos",VInt p.Ast.pmin])
+				VObject (obj (hash_field (get_ctx())) ["file",VString p.Globals.pfile;"pos",VInt p.Globals.pmin])
 		);
 		"pattern_locals", Fun2 (fun e t ->
 			let loc = (get_ctx()).curapi.get_pattern_locals (decode_expr e) (decode_type t) in
@@ -2890,7 +2891,7 @@ and eval ctx (e,p) =
 			| _ -> throw ctx p ("Invalid field access : " ^ f)
 		)
 	| ECall ((EConst (Builtin "mk_pos"),_),[(ECall (_,[EConst (String file),_]),_);(EConst (Int min),_);(EConst (Int max),_)]) ->
-		let pos = VAbstract (APos { Ast.pfile = file; Ast.pmin = min; Ast.pmax = max }) in
+		let pos = VAbstract (APos { Globals.pfile = file; Globals.pmin = min; Globals.pmax = max }) in
 		(fun() -> pos)
 	| ECall ((EConst (Builtin "typewrap"),_),[t]) ->
 		(fun() -> VAbstract (ATDecl (Obj.magic t)))
@@ -3738,7 +3739,7 @@ let can_reuse ctx types =
 
 let add_types ctx types ready =
 	let types = List.filter (fun t -> match t with
-		| TAbstractDecl a when not (Ast.Meta.has Ast.Meta.CoreType a.a_meta) ->
+		| TAbstractDecl a when not (Meta.has Meta.CoreType a.a_meta) ->
 			(* A @:native on an abstract causes the implementation class and the abstract
 			   to have the same path. Let's skip all abstracts so this doesn't matter. *)
 			false
@@ -3995,7 +3996,7 @@ and encode_access a =
 
 and encode_meta_entry (m,ml,p) =
 	enc_obj [
-		"name", enc_string (fst (MetaInfo.to_string m));
+		"name", enc_string (Meta.to_string m);
 		"params", enc_array (List.map encode_expr ml);
 		"pos", encode_pos p;
 	]
@@ -4022,7 +4023,7 @@ and encode_field (f:class_field) =
 and encode_ctype t =
 	let tag, pl = match fst t with
 	| CTPath p ->
-		0, [encode_path (p,null_pos)]
+		0, [encode_path (p,Globals.null_pos)]
 	| CTFunction (pl,r) ->
 		1, [enc_array (List.map encode_ctype pl);encode_ctype r]
 	| CTAnonymous fl ->
@@ -4199,7 +4200,7 @@ let decode_enum_with_pos v =
 	| VInt i, VArray a -> i, Array.to_list a
 	| _ -> raise Invalid_expr),(match field v "pos" with
 		| VAbstract(APos p) -> p
-		| _ -> Ast.null_pos) (* Can happen from reification and other sources. *)
+		| _ -> Globals.null_pos) (* Can happen from reification and other sources. *)
 
 let dec_bool = function
 	| VBool b -> b
@@ -4272,7 +4273,7 @@ let decode_import t = (List.map (fun o -> ((dec_string (field o "name")), (decod
 
 let maybe_decode_pos v = match v with
 	| VAbstract (APos p) -> p
-	| _ -> null_pos
+	| _ -> Globals.null_pos
 
 let decode_placed_name vp v =
 	dec_string v,maybe_decode_pos vp
@@ -4283,7 +4284,7 @@ let rec decode_path t =
 		tname = dec_string (field t "name");
 		tparams = (match field t "params" with VNull -> [] | a -> List.map decode_tparam (dec_array a));
 		tsub = opt dec_string (field t "sub");
-	},null_pos
+	},Globals.null_pos
 
 and decode_tparam v =
 	match decode_enum v with
@@ -4329,7 +4330,7 @@ and decode_access v =
 	| _ -> raise Invalid_expr
 
 and decode_meta_entry v =
-	MetaInfo.from_string (dec_string (field v "name")), (match field v "params" with VNull -> [] | a -> List.map decode_expr (dec_array a)), decode_pos (field v "pos")
+	Meta.from_string (dec_string (field v "name")), (match field v "params" with VNull -> [] | a -> List.map decode_expr (dec_array a)), decode_pos (field v "pos")
 
 and decode_meta_content = function
 	| VNull -> []
@@ -4421,7 +4422,7 @@ let rec decode_expr v =
 			let cases = List.map (fun c ->
 				(List.map loop (dec_array (field c "values")),opt loop (field c "guard"),opt loop (field c "expr"),maybe_decode_pos (field c "pos"))
 			) (dec_array cases) in
-			ESwitch (loop e,cases,opt (fun v -> decode_null_expr v,null_pos) eo)
+			ESwitch (loop e,cases,opt (fun v -> decode_null_expr v,Globals.null_pos) eo)
 		| 18, [e;catches] ->
 			let catches = List.map (fun c ->
 				((decode_placed_name (field c "name_pos") (field c "name")),(decode_ctype (field c "type")),loop (field c "expr"),maybe_decode_pos (field c "pos"))
@@ -4503,24 +4504,24 @@ let encode_meta m set =
 		"add", VFunction (Fun3 (fun k vl p ->
 			(try
 				let el = List.map decode_expr (dec_array vl) in
-				meta := (MetaInfo.from_string (dec_string k), el, decode_pos p) :: !meta;
+				meta := (Meta.from_string (dec_string k), el, decode_pos p) :: !meta;
 				set (!meta)
 			with Invalid_expr ->
 				failwith "Invalid expression");
 			VNull
 		));
 		"extract", VFunction (Fun1 (fun k ->
-			let k = MetaInfo.from_string (try dec_string k with Invalid_expr -> raise Builtin_error) in
+			let k = Meta.from_string (try dec_string k with Invalid_expr -> raise Builtin_error) in
 			encode_array encode_meta_entry (List.filter (fun (m,_,_) -> m = k) (!meta))
 		));
 		"remove", VFunction (Fun1 (fun k ->
-			let k = MetaInfo.from_string (try dec_string k with Invalid_expr -> raise Builtin_error) in
+			let k = Meta.from_string (try dec_string k with Invalid_expr -> raise Builtin_error) in
 			meta := List.filter (fun (m,_,_) -> m <> k) (!meta);
 			set (!meta);
 			VNull
 		));
 		"has", VFunction (Fun1 (fun k ->
-			let k = MetaInfo.from_string (try dec_string k with Invalid_expr -> raise Builtin_error) in
+			let k = Meta.from_string (try dec_string k with Invalid_expr -> raise Builtin_error) in
 			VBool (List.exists (fun (m,_,_) -> m = k) (!meta));
 		));
 	]
@@ -5084,7 +5085,7 @@ let decode_type_def v =
 		in
 		EEnum (mk (if isExtern then [EExtern] else []) (List.map conv fields))
 	| 1, [] ->
-		ETypedef (mk (if isExtern then [EExtern] else []) (CTAnonymous fields,null_pos))
+		ETypedef (mk (if isExtern then [EExtern] else []) (CTAnonymous fields,Globals.null_pos))
 	| 2, [ext;impl;interf] ->
 		let flags = if isExtern then [HExtern] else [] in
 		let flags = (match interf with VNull | VBool false -> flags | VBool true -> HInterface :: flags | _ -> raise Invalid_expr) in

+ 12 - 14
src/main.ml

@@ -43,12 +43,12 @@
 *)
 
 open Printf
-open Ast
 open Genswf
 open Common
 open Common.DisplayMode
 open Type
 open Server
+open Globals
 
 exception Abort
 
@@ -56,7 +56,7 @@ let executable_path() =
 	Extc.executable_path()
 
 let format msg p =
-	if p = Ast.null_pos then
+	if p = null_pos then
 		msg
 	else begin
 		let error_printer file line = sprintf "%s:%d:" file line in
@@ -330,7 +330,7 @@ let generate tctx ext xml_out interp swf_header =
 		| _ -> Common.mkdir_from_path com.file
 	end;
 	if interp then begin
-		let ctx = Interp.create com (Typer.make_macro_api tctx Ast.null_pos) in
+		let ctx = Interp.create com (Typer.make_macro_api tctx null_pos) in
 		Interp.add_types ctx com.types (fun t -> ());
 		(match com.main with
 		| None -> ()
@@ -726,7 +726,7 @@ try
 			assert false
 		),"<dir> : set current working directory");
 		("-version",Arg.Unit (fun() ->
-			message ctx Globals.s_version Ast.null_pos;
+			message ctx Globals.s_version null_pos;
 			did_something := true;
 		),": print version and exit");
 		("--help-defines", Arg.Unit (fun() ->
@@ -746,7 +746,7 @@ try
 			did_something := true
 		),": print help for all compiler specific defines");
 		("--help-metas", Arg.Unit (fun() ->
-			let all,max_length = MetaInfo.get_documentation_list() in
+			let all,max_length = Meta.get_documentation_list() in
 			let all = List.map (fun (n,doc) -> Printf.sprintf " %-*s: %s" max_length n (limit_string doc (max_length + 3))) all in
 			List.iter (fun msg -> ctx.com.print (msg ^ "\n")) all;
 			did_something := true
@@ -812,7 +812,7 @@ try
 		let tctx = Typer.create com in
 		List.iter (Typer.call_init_macro tctx) (List.rev !config_macros);
 		List.iter (Typer.eval tctx) !evals;
-		List.iter (fun cpath -> ignore(tctx.Typecore.g.Typecore.do_load_module tctx cpath Ast.null_pos)) (List.rev !classes);
+		List.iter (fun cpath -> ignore(tctx.Typecore.g.Typecore.do_load_module tctx cpath null_pos)) (List.rev !classes);
 		Typer.finalize tctx;
 		t();
 		if not ctx.com.display.dms_display && ctx.has_error then raise Abort;
@@ -852,8 +852,6 @@ try
 with
 	| Abort ->
 		()
-	| Ast.Error (m,p) ->
-		error ctx m p
 	| Error.Fatal_error (m,p) ->
 		error ctx m p
 	| Common.Abort (m,p) ->
@@ -867,7 +865,7 @@ with
 			ctx.has_error <- false;
 			ctx.messages <- [];
 		end else begin
-			error ctx (Printf.sprintf "You cannot access the %s package while %s (for %s)" pack (if pf = "macro" then "in a macro" else "targeting " ^ pf) (Ast.s_type_path m) ) p;
+			error ctx (Printf.sprintf "You cannot access the %s package while %s (for %s)" pack (if pf = "macro" then "in a macro" else "targeting " ^ pf) (s_type_path m) ) p;
 			List.iter (error ctx "    referenced here") (List.rev pl);
 		end
 	| Error.Error (m,p) ->
@@ -875,15 +873,15 @@ with
 	| Interp.Error (msg,p :: l) ->
 		message ctx msg p;
 		List.iter (message ctx "Called from") l;
-		error ctx "Aborted" Ast.null_pos;
+		error ctx "Aborted" null_pos;
 	| Typeload.Generic_Exception(m,p) ->
 		error ctx m p
 	| Arg.Bad msg ->
-		error ctx ("Error: " ^ msg) Ast.null_pos
+		error ctx ("Error: " ^ msg) null_pos
 	| Failure msg when not (is_debug_run()) ->
-		error ctx ("Error: " ^ msg) Ast.null_pos
+		error ctx ("Error: " ^ msg) null_pos
 	| Arg.Help msg ->
-		message ctx msg Ast.null_pos
+		message ctx msg null_pos
 	| Display.DisplayPackage pack ->
 		raise (DisplayOutput.Completion (String.concat "." pack))
 	| Display.DisplayFields fields ->
@@ -924,7 +922,7 @@ with
 		ctx.flush();
 		exit i
 	| e when (try Sys.getenv "OCAMLRUNPARAM" <> "b" || CompilationServer.runs() with _ -> true) && not (is_debug_run()) ->
-		error ctx (Printexc.to_string e) Ast.null_pos
+		error ctx (Printexc.to_string e) null_pos
 
 ;;
 let other = Common.timer ["other"] in

+ 2 - 1
src/optimization/analyzer.ml

@@ -23,6 +23,7 @@ open Common
 open AnalyzerTexpr
 open AnalyzerTypes
 open OptimizerTexpr
+open Globals
 
 (* File organization:
 	* analyzer.ml: The controlling file with all graph-based optimizations
@@ -1005,7 +1006,7 @@ module Debug = struct
 		) g.g_var_infos
 
 	let get_dump_path ctx c cf =
-		"dump" :: [Common.platform_name ctx.com.platform] @ (fst c.cl_path) @ [Printf.sprintf "%s.%s" (snd c.cl_path) cf.cf_name]
+		"dump" :: [platform_name ctx.com.platform] @ (fst c.cl_path) @ [Printf.sprintf "%s.%s" (snd c.cl_path) cf.cf_name]
 
 	let dot_debug ctx c cf =
 		let g = ctx.graph in

+ 1 - 0
src/optimization/analyzerConfig.ml

@@ -20,6 +20,7 @@
 open Ast
 open Type
 open Common
+open Globals
 
 type debug_kind =
 	| DebugNone

+ 1 - 0
src/optimization/analyzerTexpr.ml

@@ -21,6 +21,7 @@ open Ast
 open Type
 open Common
 open OptimizerTexpr
+open Globals
 
 let s_expr_pretty e = s_expr_pretty false "" false (s_type (print_context())) e
 

+ 2 - 1
src/optimization/analyzerTexprTransformer.ml

@@ -17,6 +17,7 @@
 	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *)
 
+open Globals
 open Ast
 open Type
 open Common
@@ -226,7 +227,7 @@ let rec func ctx bb tf t p =
 		let fl,e = loop [] e in
 		let v = alloc_var ctx.temp_var_name e.etype e.epos in
 		begin match ctx.com.platform with
-			| Cpp when sequential && not (Common.defined ctx.com Define.Cppia) -> ()
+			| Globals.Cpp when sequential && not (Common.defined ctx.com Define.Cppia) -> ()
 			| _ -> v.v_meta <- [Meta.CompilerGenerated,[],e.epos];
 		end;
 		let bb = declare_var_and_assign bb v e e.epos in

+ 1 - 0
src/optimization/analyzerTypes.ml

@@ -17,6 +17,7 @@
 	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *)
 
+open Globals
 open Ast
 open Type
 open Common

+ 1 - 0
src/optimization/dce.ml

@@ -20,6 +20,7 @@
 open Ast
 open Common
 open Type
+open Globals
 
 type dce = {
 	com : context;

+ 1 - 0
src/optimization/filters.ml

@@ -22,6 +22,7 @@ open Common
 open Type
 open Typecore
 open Error
+open Globals
 
 (* PASS 1 begin *)
 

+ 1 - 0
src/optimization/optimizer.ml

@@ -23,6 +23,7 @@ open Common
 open Typecore
 open OptimizerTexpr
 open Error
+open Globals
 
 (* ---------------------------------------------------------------------- *)
 (* API OPTIMIZATIONS *)

+ 1 - 0
src/optimization/optimizerTexpr.ml

@@ -1,6 +1,7 @@
 open Ast
 open Type
 open Error
+open Globals
 
 (*
 	PurityState represents whether or not something has a side-effect. Unless otherwise stated

+ 7 - 6
src/server.ml

@@ -1,4 +1,5 @@
 open Printf
+open Globals
 open Ast
 open Common
 open Common.DisplayMode
@@ -84,7 +85,7 @@ let default_flush ctx =
 
 let create_context params =
 	let ctx = {
-		com = Common.create Globals.version Globals.s_version params;
+		com = Common.create version s_version params;
 		flush = (fun()->());
 		setup = (fun()->());
 		messages = [];
@@ -149,7 +150,7 @@ let rec wait_loop process_params verbose accept =
 	let current_stdin = ref None in
 	Typeload.parse_hook := (fun com2 file p ->
 		let ffile = Path.unique_full_path file in
-		let is_display_file = ffile = (!Parser.resume_display).Ast.pfile in
+		let is_display_file = ffile = (!Parser.resume_display).pfile in
 
 		match is_display_file, !current_stdin with
 		| true, Some stdin when Common.defined com2 Define.DisplayStdin ->
@@ -262,14 +263,14 @@ let rec wait_loop process_params verbose accept =
 						| TEnumDecl e ->
 							let rec loop acc = function
 								| [] -> ()
-								| (Ast.Meta.RealPath,[Ast.EConst (Ast.String path),_],_) :: l ->
+								| (Meta.RealPath,[Ast.EConst (Ast.String path),_],_) :: l ->
 									e.e_path <- Ast.parse_path path;
 									e.e_meta <- (List.rev acc) @ l;
 								| x :: l -> loop (x::acc) l
 							in
 							loop [] e.e_meta
 						| TAbstractDecl a ->
-							a.a_meta <- List.filter (fun (m,_,_) -> m <> Ast.Meta.ValueUsed) a.a_meta
+							a.a_meta <- List.filter (fun (m,_,_) -> m <> Meta.ValueUsed) a.a_meta
 						| _ -> ()
 					) m.m_types;
 					if m.m_extra.m_kind <> MSub then Typeload.add_module ctx m p;
@@ -329,7 +330,7 @@ let rec wait_loop process_params verbose accept =
 				end;
 				Parser.display_error := (fun e p -> has_parse_error := true; ctx.com.error (Parser.error_msg e) p);
 				if ctx.com.display.dms_display then begin
-					let file = (!Parser.resume_display).Ast.pfile in
+					let file = (!Parser.resume_display).pfile in
 					let fkey = (file,get_signature ctx.com) in
 					(* force parsing again : if the completion point have been changed *)
 					CompilationServer.remove_file cs fkey;
@@ -355,7 +356,7 @@ let rec wait_loop process_params verbose accept =
 			if verbose then print_endline ("Processing Arguments [" ^ String.concat "," data ^ "]");
 			(try
 				Common.display_default := DMNone;
-				Parser.resume_display := Ast.null_pos;
+				Parser.resume_display := null_pos;
 				Typeload.return_partial_type := false;
 				measure_times := false;
 				close_times();

+ 1 - 191
src/syntax/ast.ml

@@ -17,191 +17,7 @@
 	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *)
 
-type pos = {
-	pfile : string;
-	pmin : int;
-	pmax : int;
-}
-
-module IntMap = Map.Make(struct type t = int let compare a b = a - b end)
-module StringMap = Map.Make(struct type t = string let compare = String.compare end)
-
-module Meta = struct
-	type strict_meta =
-		| Abi
-		| Abstract
-		| Access
-		| Accessor
-		| Allow
-		| Analyzer
-		| Annotation
-		| ArrayAccess
-		| Ast
-		| AstSource
-		| AutoBuild
-		| Bind
-		| Bitmap
-		| BridgeProperties
-		| Build
-		| BuildXml
-		| Callable
-		| Class
-		| ClassCode
-		| Commutative
-		| CompilerGenerated
-		| Const
-		| CoreApi
-		| CoreType
-		| CppFileCode
-		| CppInclude
-		| CppNamespaceCode
-		| CsNative
-		| Dce
-		| Debug
-		| Decl
-		| DefParam
-		| Delegate
-		| Depend
-		| Deprecated
-		| DirectlyUsed
-		| DynamicObject
-		| Eager
-		| Enum
-		| EnumConstructorParam
-		| Event
-		| Exhaustive
-		| Expose
-		| Extern
-		| FakeEnum
-		| File
-		| FileXml
-		| Final
-		| Fixed
-		| FlatEnum
-		| Font
-		| Forward
-		| ForwardStatics
-		| From
-		| FunctionCode
-		| FunctionTailCode
-		| Generic
-		| GenericBuild
-		| GenericInstance
-		| Getter
-		| Hack
-		| HasUntyped
-		| HaxeGeneric
-		| HeaderClassCode
-		| HeaderCode
-		| HeaderInclude
-		| HeaderNamespaceCode
-		| HxGen
-		| IfFeature
-		| Impl
-		| PythonImport
-		| ImplicitCast
-		| Include
-		| InitPackage
-		| InlineConstructorVariable
-		| Internal
-		| IsVar
-		| JavaCanonical
-		| JavaNative
-		| JsRequire
-		| Keep
-		| KeepInit
-		| KeepSub
-		| LibType
-		| LuaRequire
-		| Meta
-		| Macro
-		| MaybeUsed
-		| MergeBlock
-		| MultiReturn
-		| MultiType
-		| Native
-		| NativeChildren
-		| NativeGen
-		| NativeGeneric
-		| NativeProperty
-		| NativeStaticExtension
-		| NoCompletion
-		| NoDebug
-		| NoDoc
-		| NoExpr
-		| NoImportGlobal
-		| NonVirtual
-		| NoPackageRestrict
-		| NoPrivateAccess
-		| NoStack
-		| NotNull
-		| NoUsing
-		| Ns
-		| Objc
-		| ObjcProtocol
-		| Op
-		| Optional
-		| Overload
-		| PhpConstants
-		| PhpGlobal
-		| PrivateAccess
-		| Property
-		| Protected
-		| Public
-		| PublicFields
-		| Pure
-		| QuotedField
-		| ReadOnly
-		| RealPath
-		| Remove
-		| Require
-		| RequiresAssign
-		| Resolve
-		| Rtti
-		| Runtime
-		| RuntimeValue
-		| Scalar
-		| SelfCall
-		| Setter
-		| SkipCtor
-		| SkipReflection
-		| Sound
-		| SourceFile
-		| StackOnly
-		| StoredTypedExpr
-		| Strict
-		| Struct
-		| StructAccess
-		| StructInit
-		| SuppressWarnings
-		| This
-		| Throws
-		| To
-		| ToString
-		| Transient
-		| TemplatedCall
-		| ValueUsed
-		| Volatile
-		| Unbound
-		| UnifyMinDynamic
-		| Unreflective
-		| Unsafe
-		| Usage
-		| Used
-		| UserVariable
-		| Value
-		| Void
-		| Last
-		(* do not put any custom metadata after Last *)
-		| Dollar of string
-		| Custom of string
-
-	let has m ml = List.exists (fun (m2,_,_) -> m = m2) ml
-	let get m ml = List.find (fun (m2,_,_) -> m = m2) ml
-
-	let to_string_ref = ref (fun _ -> assert false)
-	let to_string (m : strict_meta) : string = !to_string_ref m
-end
+open Globals
 
 type keyword =
 	| Function
@@ -476,8 +292,6 @@ type type_decl = type_def * pos
 
 type package = string list * type_decl list
 
-exception Error of string * pos
-
 let is_lower_ident i =
 	let rec loop p =
 		match String.unsafe_get i p with
@@ -499,8 +313,6 @@ let is_prefix = function
 
 let base_class_name = snd
 
-let null_pos = { pfile = "?"; pmin = -1; pmax = -1 }
-
 let punion p p2 =
 	{
 		pfile = p.pfile;
@@ -516,8 +328,6 @@ let rec punion_el el = match el with
 	| (_,p) :: el ->
 		punion p (punion_el el)
 
-let s_type_path (p,s) = match p with [] -> s | _ -> String.concat "." p ^ "." ^ s
-
 let parse_path s =
 	match List.rev (ExtString.String.nsplit s ".") with
 	| [] -> failwith "Invalid empty path"

+ 1 - 0
src/syntax/lexer.mll

@@ -20,6 +20,7 @@
 {
 open Lexing
 open Ast
+open Globals
 
 type error_msg =
 	| Invalid_character of char

+ 6 - 5
src/syntax/parser.ml

@@ -18,6 +18,7 @@
  *)
 
 open Ast
+open Globals
 
 type error_msg =
 	| Unexpected of token
@@ -340,7 +341,7 @@ let reify in_macro =
 	and to_meta m p =
 		to_array (fun (m,el,p) _ ->
 			let fields = [
-				"name", to_string (fst (Common.MetaInfo.to_string m)) p;
+				"name", to_string (Meta.to_string m) p;
 				"params", to_expr_array el p;
 				"pos", to_pos p;
 			] in
@@ -490,7 +491,7 @@ let reify in_macro =
 				cur_pos := old;
 				e
 			| _ ->
-				expr "EMeta" [to_obj [("name",to_string (fst (Common.MetaInfo.to_string m)) p);("params",to_expr_array ml p);("pos",to_pos p)] p;loop e1]
+				expr "EMeta" [to_obj [("name",to_string (Meta.to_string m) p);("params",to_expr_array ml p);("pos",to_pos p)] p;loop e1]
 	and to_tparam_decl p t =
 		to_obj [
 			"name", to_placed_name t.tp_name;
@@ -876,8 +877,8 @@ and meta_name p1 = parser
 	| [< '(Const (Ident i),p) when p.pmin = p1.pmax >] -> (Meta.Custom i), p
 	| [< '(Kwd k,p) when p.pmin = p1.pmax >] -> (Meta.Custom (s_keyword k)),p
 	| [< '(DblDot,p) when p.pmin = p1.pmax; s >] -> match s with parser
-		| [< '(Const (Ident i),p) >] -> (Common.MetaInfo.parse i), p
-		| [< '(Kwd k,p) >] -> (Common.MetaInfo.parse (s_keyword k)),p
+		| [< '(Const (Ident i),p) >] -> (Meta.parse i), p
+		| [< '(Kwd k,p) >] -> (Meta.parse (s_keyword k)),p
 
 and parse_enum_flags = parser
 	| [< '(Kwd Enum,p) >] -> [] , p
@@ -1390,7 +1391,7 @@ and expr = parser
 and expr_next e1 = parser
 	| [< '(BrOpen,p1) when is_dollar_ident e1; eparam = expr; '(BrClose,p2); s >] ->
 		(match fst e1 with
-		| EConst(Ident n) -> expr_next (EMeta((Common.MetaInfo.from_string n,[],snd e1),eparam), punion p1 p2) s
+		| EConst(Ident n) -> expr_next (EMeta((Meta.from_string n,[],snd e1),eparam), punion p1 p2) s
 		| _ -> assert false)
 	| [< '(Dot,p); s >] ->
 		if is_resuming p then display (EDisplay (e1,false),p);

+ 67 - 0
src/typing/abstract.ml

@@ -0,0 +1,67 @@
+open Meta
+open Type
+open Error
+
+let find_to ab pl b =
+	if follow b == t_dynamic then
+		List.find (fun (t,_) -> follow t == t_dynamic) ab.a_to_field
+	else if List.exists (unify_to ab pl ~allow_transitive_cast:false b) ab.a_to then
+		raise Not_found (* legacy compatibility *)
+	else
+		List.find (unify_to_field ab pl b) ab.a_to_field
+
+let find_from ab pl a b =
+	if follow a == t_dynamic then
+		List.find (fun (t,_) -> follow t == t_dynamic) ab.a_from_field
+	else if List.exists (unify_from ab pl a ~allow_transitive_cast:false b) ab.a_from then
+		raise Not_found (* legacy compatibility *)
+	else
+		List.find (unify_from_field ab pl a b) ab.a_from_field
+
+let underlying_type_stack = ref []
+
+let rec get_underlying_type a pl =
+	let maybe_recurse t =
+		underlying_type_stack := (TAbstract(a,pl)) :: !underlying_type_stack;
+		let rec loop t = match t with
+			| TMono r ->
+				(match !r with
+				| Some t -> loop t
+				| _ -> t)
+			| TLazy f ->
+				loop (!f())
+			| TType({t_path=([],"Null")} as tn,[t1]) ->
+				TType(tn,[loop t1])
+			| TType (t,tl) ->
+				loop (apply_params t.t_params tl t.t_type)
+			| TAbstract(a,tl) when not (Meta.has Meta.CoreType a.a_meta) ->
+				if List.exists (fast_eq t) !underlying_type_stack then begin
+					let pctx = print_context() in
+					let s = String.concat " -> " (List.map (fun t -> s_type pctx t) (List.rev (t :: !underlying_type_stack))) in
+					underlying_type_stack := [];
+					error ("Abstract chain detected: " ^ s) a.a_pos
+				end;
+				get_underlying_type a tl
+			| _ ->
+				t
+		in
+		let t = loop t in
+		underlying_type_stack := List.tl !underlying_type_stack;
+		t
+	in
+	try
+		if not (Meta.has Meta.MultiType a.a_meta) then raise Not_found;
+		let m = mk_mono() in
+		let _ = find_to a pl m in
+		maybe_recurse (follow m)
+	with Not_found ->
+		if Meta.has Meta.CoreType a.a_meta then
+			t_dynamic
+		else
+			maybe_recurse (apply_params a.a_params pl a.a_this)
+
+let rec follow_with_abstracts t = match follow t with
+	| TAbstract(a,tl) when not (Meta.has Meta.CoreType a.a_meta) ->
+		follow_with_abstracts (get_underlying_type a tl)
+	| t ->
+		t

+ 3 - 3
src/typing/error.ml

@@ -1,4 +1,4 @@
-open Ast
+open Globals
 open Type
 
 type call_error =
@@ -17,8 +17,8 @@ and error_msg =
 	| Call_error of call_error
 	| No_constructor of module_type
 
-exception Fatal_error of string * pos
-exception Error of error_msg * pos
+exception Fatal_error of string * Globals.pos
+exception Error of error_msg * Globals.pos
 
 let string_source t = match follow t with
 	| TInst(c,_) -> List.map (fun cf -> cf.cf_name) c.cl_ordered_fields

+ 1 - 0
src/typing/matcher.ml

@@ -17,6 +17,7 @@
 	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *)
 
+open Globals
 open Ast
 open Type
 open Common

+ 0 - 1
src/typing/overloads.ml

@@ -1,4 +1,3 @@
-open Ast
 open Type
 
 let same_overload_args ?(get_vmtype) t1 t2 f1 f2 =

+ 20 - 87
src/typing/type.ml

@@ -18,6 +18,7 @@
  *)
 
 open Ast
+open Globals
 
 type path = string list * string
 
@@ -141,7 +142,7 @@ and tfield_access =
 and texpr = {
 	eexpr : texpr_expr;
 	etype : t;
-	epos : Ast.pos;
+	epos : pos;
 }
 
 and tclass_field = {
@@ -174,8 +175,8 @@ and metadata = Ast.metadata
 and tinfos = {
 	mt_path : path;
 	mt_module : module_def;
-	mt_pos : Ast.pos;
-	mt_name_pos : Ast.pos;
+	mt_pos : pos;
+	mt_name_pos : pos;
 	mt_private : bool;
 	mt_doc : Ast.documentation;
 	mutable mt_meta : metadata;
@@ -185,8 +186,8 @@ and tinfos = {
 and tclass = {
 	mutable cl_path : path;
 	mutable cl_module : module_def;
-	mutable cl_pos : Ast.pos;
-	mutable cl_name_pos : Ast.pos;
+	mutable cl_pos : pos;
+	mutable cl_name_pos : pos;
 	mutable cl_private : bool;
 	mutable cl_doc : Ast.documentation;
 	mutable cl_meta : metadata;
@@ -214,8 +215,8 @@ and tclass = {
 and tenum_field = {
 	ef_name : string;
 	ef_type : t;
-	ef_pos : Ast.pos;
-	ef_name_pos : Ast.pos;
+	ef_pos : pos;
+	ef_name_pos : pos;
 	ef_doc : Ast.documentation;
 	ef_index : int;
 	ef_params : type_params;
@@ -225,8 +226,8 @@ and tenum_field = {
 and tenum = {
 	mutable e_path : path;
 	e_module : module_def;
-	e_pos : Ast.pos;
-	e_name_pos : Ast.pos;
+	e_pos : pos;
+	e_name_pos : pos;
 	e_private : bool;
 	e_doc : Ast.documentation;
 	mutable e_meta : metadata;
@@ -241,8 +242,8 @@ and tenum = {
 and tdef = {
 	t_path : path;
 	t_module : module_def;
-	t_pos : Ast.pos;
-	t_name_pos : Ast.pos;
+	t_pos : pos;
+	t_name_pos : pos;
 	t_private : bool;
 	t_doc : Ast.documentation;
 	mutable t_meta : metadata;
@@ -254,8 +255,8 @@ and tdef = {
 and tabstract = {
 	mutable a_path : path;
 	a_module : module_def;
-	a_pos : Ast.pos;
-	a_name_pos : Ast.pos;
+	a_pos : pos;
+	a_name_pos : pos;
 	a_private : bool;
 	a_doc : Ast.documentation;
 	mutable a_meta : metadata;
@@ -430,11 +431,11 @@ let null_module = {
 	}
 
 let null_class =
-	let c = mk_class null_module ([],"") Ast.null_pos Ast.null_pos in
+	let c = mk_class null_module ([],"") null_pos null_pos in
 	c.cl_private <- true;
 	c
 
-let null_field = mk_field "" t_dynamic Ast.null_pos Ast.null_pos
+let null_field = mk_field "" t_dynamic null_pos null_pos
 
 let null_abstract = {
 	a_path = ([],"");
@@ -895,15 +896,15 @@ let rec s_type ctx t =
 		| None -> Printf.sprintf "Unknown<%d>" (try List.assq t (!ctx) with Not_found -> let n = List.length !ctx in ctx := (t,n) :: !ctx; n)
 		| Some t -> s_type ctx t)
 	| TEnum (e,tl) ->
-		Ast.s_type_path e.e_path ^ s_type_params ctx tl
+		s_type_path e.e_path ^ s_type_params ctx tl
 	| TInst (c,tl) ->
 		(match c.cl_kind with
 		| KExpr e -> Ast.s_expr e
-		| _ -> Ast.s_type_path c.cl_path ^ s_type_params ctx tl)
+		| _ -> s_type_path c.cl_path ^ s_type_params ctx tl)
 	| TType (t,tl) ->
-		Ast.s_type_path t.t_path ^ s_type_params ctx tl
+		s_type_path t.t_path ^ s_type_params ctx tl
 	| TAbstract (a,tl) ->
-		Ast.s_type_path a.a_path ^ s_type_params ctx tl
+		s_type_path a.a_path ^ s_type_params ctx tl
 	| TFun ([],t) ->
 		"Void -> " ^ s_fun ctx t false
 	| TFun (l,t) ->
@@ -2185,74 +2186,6 @@ and unify_with_access t1 f2 =
 	(* read/write *)
 	| _ -> with_variance (type_eq EqBothDynamic) t1 f2.cf_type
 
-module Abstract = struct
-	open Ast
-
-	let find_to ab pl b =
-		if follow b == t_dynamic then
-			List.find (fun (t,_) -> follow t == t_dynamic) ab.a_to_field
-		else if List.exists (unify_to ab pl ~allow_transitive_cast:false b) ab.a_to then
-			raise Not_found (* legacy compatibility *)
-		else
-			List.find (unify_to_field ab pl b) ab.a_to_field
-
-	let find_from ab pl a b =
-		if follow a == t_dynamic then
-			List.find (fun (t,_) -> follow t == t_dynamic) ab.a_from_field
-		else if List.exists (unify_from ab pl a ~allow_transitive_cast:false b) ab.a_from then
-			raise Not_found (* legacy compatibility *)
-		else
-			List.find (unify_from_field ab pl a b) ab.a_from_field
-
-	let underlying_type_stack = ref []
-
-	let rec get_underlying_type a pl =
-		let maybe_recurse t =
-			underlying_type_stack := (TAbstract(a,pl)) :: !underlying_type_stack;
-			let rec loop t = match t with
-				| TMono r ->
-					(match !r with
-					| Some t -> loop t
-					| _ -> t)
-				| TLazy f ->
-					loop (!f())
-				| TType({t_path=([],"Null")} as tn,[t1]) ->
-					TType(tn,[loop t1])
-				| TType (t,tl) ->
-					loop (apply_params t.t_params tl t.t_type)
-				| TAbstract(a,tl) when not (Meta.has Meta.CoreType a.a_meta) ->
-					if List.exists (fast_eq t) !underlying_type_stack then begin
-						let pctx = print_context() in
-						let s = String.concat " -> " (List.map (fun t -> s_type pctx t) (List.rev (t :: !underlying_type_stack))) in
-						underlying_type_stack := [];
-						raise (Error("Abstract chain detected: " ^ s,a.a_pos))
-					end;
-					get_underlying_type a tl
-				| _ ->
-					t
-			in
-			let t = loop t in
-			underlying_type_stack := List.tl !underlying_type_stack;
-			t
-		in
-		try
-			if not (Meta.has Meta.MultiType a.a_meta) then raise Not_found;
-			let m = mk_mono() in
-			let _ = find_to a pl m in
-			maybe_recurse (follow m)
-		with Not_found ->
-			if Meta.has Meta.CoreType a.a_meta then
-				t_dynamic
-			else
-				maybe_recurse (apply_params a.a_params pl a.a_this)
-
-	let rec follow_with_abstracts t = match follow t with
-		| TAbstract(a,tl) when not (Meta.has Meta.CoreType a.a_meta) ->
-			follow_with_abstracts (get_underlying_type a tl)
-		| t ->
-			t
-end
-
 (* ======= Mapping and iterating ======= *)
 
 let iter f e =

+ 2 - 1
src/typing/typecore.ml

@@ -17,6 +17,7 @@
 	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *)
 
+open Globals
 open Ast
 open Common
 open Type
@@ -476,7 +477,7 @@ module AbstractCast = struct
 						if not (has_mono t) then t
 						else t_dynamic
 				) a.a_params pl in
-				if com.platform = Js && a.a_path = ([],"Map") then begin match tl with
+				if com.platform = Globals.Js && a.a_path = ([],"Map") then begin match tl with
 					| t1 :: _ ->
 						let rec loop stack t =
 							if List.exists (fun t2 -> fast_eq t t2) stack then

+ 7 - 6
src/typing/typeload.ml

@@ -23,6 +23,7 @@ open Common.DisplayMode
 open Type
 open Typecore
 open Error
+open Globals
 
 exception Build_canceled of build_state
 
@@ -813,7 +814,7 @@ let valid_redefinition ctx f1 t1 f2 t2 = (* child, parent *)
 					| _ ->
 						raise (Unify_error [Unify_custom "Different number of constraints"]))
 				| _ -> ());
-				TInst (mk_class null_module ([],name) Ast.null_pos Ast.null_pos,[])
+				TInst (mk_class null_module ([],name) null_pos null_pos,[])
 			) l1 l2 in
 			List.iter (fun f -> f monos) !to_check;
 			apply_params l1 monos t1, apply_params l2 monos t2
@@ -877,7 +878,7 @@ let check_overriding ctx c =
 				if ctx.com.config.pf_overload && (Meta.has Meta.Overload f2.cf_meta && not (Meta.has Meta.Overload f.cf_meta)) then
 					display_error ctx ("Field " ^ i ^ " should be declared with @:overload since it was already declared as @:overload in superclass") p
 				else if not (List.memq f c.cl_overrides) then
-					display_error ctx ("Field " ^ i ^ " should be declared with 'override' since it is inherited from superclass " ^ Ast.s_type_path csup.cl_path) p
+					display_error ctx ("Field " ^ i ^ " should be declared with 'override' since it is inherited from superclass " ^ s_type_path csup.cl_path) p
 				else if not f.cf_public && f2.cf_public then
 					display_error ctx ("Field " ^ i ^ " has less visibility (public/private) than superclass one") p
 				else (match f.cf_kind, f2.cf_kind with
@@ -2162,7 +2163,7 @@ module ClassInitializer = struct
 				| Some (csup,_) ->
 					(* this can happen on -net-lib generated classes if a combination of explicit interfaces and variables with the same name happens *)
 					if not (csup.cl_interface && Meta.has Meta.CsNative c.cl_meta) then
-						error ("Redefinition of variable " ^ cf.cf_name ^ " in subclass is not allowed. Previously declared at " ^ (Ast.s_type_path csup.cl_path) ) p
+						error ("Redefinition of variable " ^ cf.cf_name ^ " in subclass is not allowed. Previously declared at " ^ (s_type_path csup.cl_path) ) p
 		end;
 		let t = cf.cf_type in
 
@@ -3554,7 +3555,7 @@ let parse_module ctx m p =
 	let pack, decls = (!parse_hook) ctx.com file p in
 	if pack <> !remap then begin
 		let spack m = if m = [] then "<empty>" else String.concat "." m in
-		if p == Ast.null_pos then
+		if p == null_pos then
 			display_error ctx ("Invalid commandline class : " ^ s_type_path m ^ " should be " ^ s_type_path (pack,snd m)) p
 		else
 			display_error ctx ("Invalid package : " ^ spack (fst m) ^ " should be " ^ spack pack) p
@@ -3617,7 +3618,7 @@ let load_module ctx m p =
 			let is_extern = !is_extern in
 			try
 				type_module ctx m file ~is_extern decls p
-			with Forbid_package (inf,pl,pf) when p <> Ast.null_pos ->
+			with Forbid_package (inf,pl,pf) when p <> null_pos ->
 				raise (Forbid_package (inf,p::pl,pf))
 	) in
 	add_dependency ctx.m.curmod m2;
@@ -3712,7 +3713,7 @@ let extend_remoting ctx c t p async prot =
 (* -------------------------------------------------------------------------- *)
 (* HAXE.RTTI.GENERIC *)
 
-exception Generic_Exception of string * Ast.pos
+exception Generic_Exception of string * pos
 
 type generic_context = {
 	ctx : typer;

+ 7 - 6
src/typing/typer.ml

@@ -23,6 +23,7 @@ open Common
 open Type
 open Typecore
 open Error
+open Globals
 
 (* ---------------------------------------------------------------------- *)
 (* TOOLS *)
@@ -4759,7 +4760,7 @@ let make_macro_api ctx p =
 				let _, tdef, pos = (try Interp.decode_type_def v with Interp.Invalid_expr -> Interp.exc (Interp.VString "Invalid type definition")) in
 				tdef, pos
 			) types in
-			let pos = (match types with [] -> Ast.null_pos | (_,p) :: _ -> p) in
+			let pos = (match types with [] -> null_pos | (_,p) :: _ -> p) in
 			let imports = List.map (fun (il,ik) -> EImport(il,ik),pos) imports in
 			let usings = List.map (fun tp ->
 				let sl = tp.tpackage @ [tp.tname] @ (match tp.tsub with None -> [] | Some s -> [s]) in
@@ -4816,7 +4817,7 @@ let make_macro_api ctx p =
 	}
 
 let rec init_macro_interp ctx mctx mint =
-	let p = Ast.null_pos in
+	let p = null_pos in
 	ignore(Typeload.load_module mctx (["haxe";"macro"],"Expr") p);
 	ignore(Typeload.load_module mctx (["haxe";"macro"],"Type") p);
 	flush_macro_context mint ctx;
@@ -4870,10 +4871,10 @@ let create_macro_interp ctx mctx =
 	let com2 = mctx.com in
 	let mint, init = (match !macro_interp_cache with
 		| None ->
-			let mint = Interp.create com2 (make_macro_api ctx Ast.null_pos) in
+			let mint = Interp.create com2 (make_macro_api ctx null_pos) in
 			mint, (fun() -> init_macro_interp ctx mctx mint)
 		| Some mint ->
-			Interp.do_reuse mint (make_macro_api ctx Ast.null_pos);
+			Interp.do_reuse mint (make_macro_api ctx null_pos);
 			mint, (fun() -> ())
 	) in
 	let on_error = com2.error in
@@ -4900,7 +4901,7 @@ let get_macro_context ctx p =
 		com2.package_rules <- PMap.empty;
 		com2.main_class <- None;
 		com2.display <- DisplayMode.create DMNone;
-		List.iter (fun p -> com2.defines <- PMap.remove (platform_name p) com2.defines) platforms;
+		List.iter (fun p -> com2.defines <- PMap.remove (Globals.platform_name p) com2.defines) Globals.platforms;
 		com2.defines_signature <- None;
 		com2.class_path <- List.filter (fun s -> not (ExtString.String.exists s "/_std/")) com2.class_path;
 		com2.class_path <- List.map (fun p -> p ^ "neko" ^ "/_std/") com2.std_path @ com2.class_path;
@@ -4915,7 +4916,7 @@ let get_macro_context ctx p =
 		api, mctx
 
 let load_macro ctx display cpath f p =
-	let t = macro_timer ctx ["typing";Ast.s_type_path cpath ^ "." ^ f] in
+	let t = macro_timer ctx ["typing";s_type_path cpath ^ "." ^ f] in
 	let api, mctx = get_macro_context ctx p in
 	let mint = Interp.get_ctx() in
 	let cpath, sub = (match List.rev (fst cpath) with