2
0

Syntax.hx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package js;
  2. import haxe.extern.Rest;
  3. /**
  4. Generate JavaScript syntax not directly supported by Haxe.
  5. Use only at low-level when specific target-specific code-generation is required.
  6. **/
  7. extern class Syntax {
  8. /**
  9. Inject `code` directly into generated source.
  10. `code` must be a string constant.
  11. Additional `args` are supported to provide code interpolation, for example:
  12. ```
  13. Syntax.code("console.log({0}, {1})", "hi", 42);
  14. ```
  15. will generate
  16. ```
  17. console.log("hi", 42);
  18. ```
  19. **/
  20. static function code(code:String, args:Rest<Dynamic>):Dynamic;
  21. /**
  22. Generate `new cl(...args)` expression.
  23. **/
  24. @:overload(function(cl:String, args:Rest<Dynamic>):Dynamic {})
  25. static function new_<T>(cl:Class<T>, args:Rest<Dynamic>):T;
  26. /**
  27. Generate `v instanceof cl` expression.
  28. **/
  29. @:pure static function instanceof(v:Dynamic, cl:Class<Dynamic>):Bool;
  30. /**
  31. Generate `typeof o` expression.
  32. **/
  33. @:pure static function typeof(o:Dynamic):String;
  34. /**
  35. Genearte `a === b` expression.
  36. **/
  37. @:pure static function strictEq(a:Dynamic, b:Dynamic):Bool;
  38. /**
  39. Genearte `a !== b` expression.
  40. **/
  41. @:pure static function strictNeq(a:Dynamic, b:Dynamic):Bool;
  42. /**
  43. Generate `delete o[f]` expression.
  44. **/
  45. @:overload(function(o:Dynamic, f:Int):Bool {})
  46. static function delete(o:Dynamic, f:String):Bool;
  47. }