holmes 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +4 -0
  3. data/README.md +10 -0
  4. data/Rakefile +1 -0
  5. data/holmes.gemspec +24 -0
  6. data/lib/holmes.rb +38 -0
  7. data/lib/holmes/node_modules/detective/README.markdown +64 -0
  8. data/lib/holmes/node_modules/detective/example/strings.js +6 -0
  9. data/lib/holmes/node_modules/detective/example/strings_src.js +3 -0
  10. data/lib/holmes/node_modules/detective/index.js +65 -0
  11. data/lib/holmes/node_modules/detective/node_modules/burrito/.npmignore +1 -0
  12. data/lib/holmes/node_modules/detective/node_modules/burrito/README.markdown +185 -0
  13. data/lib/holmes/node_modules/detective/node_modules/burrito/browserify.js +4296 -0
  14. data/lib/holmes/node_modules/detective/node_modules/burrito/example/microwave.js +7 -0
  15. data/lib/holmes/node_modules/detective/node_modules/burrito/example/web/bs.js +4832 -0
  16. data/lib/holmes/node_modules/detective/node_modules/burrito/example/web/index.html +14 -0
  17. data/lib/holmes/node_modules/detective/node_modules/burrito/example/web/main.js +17 -0
  18. data/lib/holmes/node_modules/detective/node_modules/burrito/example/web/server.js +12 -0
  19. data/lib/holmes/node_modules/detective/node_modules/burrito/example/wrap.js +7 -0
  20. data/lib/holmes/node_modules/detective/node_modules/burrito/index.html +8 -0
  21. data/lib/holmes/node_modules/detective/node_modules/burrito/index.js +208 -0
  22. data/lib/holmes/node_modules/detective/node_modules/burrito/main.js +11 -0
  23. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/.bin/uglifyjs +317 -0
  24. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/.npmignore +1 -0
  25. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/LICENSE +24 -0
  26. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/README.markdown +237 -0
  27. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/examples/json.js +16 -0
  28. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/examples/leaves.js +15 -0
  29. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/examples/negative.js +8 -0
  30. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/examples/scrub.js +10 -0
  31. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/examples/stringify.js +38 -0
  32. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/index.js +267 -0
  33. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/main.js +10 -0
  34. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/package.json +18 -0
  35. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/circular.js +115 -0
  36. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/date.js +35 -0
  37. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/equal.js +220 -0
  38. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/instance.js +17 -0
  39. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/interface.js +42 -0
  40. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/json.js +47 -0
  41. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/keys.js +29 -0
  42. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/leaves.js +21 -0
  43. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/lib/deep_equal.js +92 -0
  44. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/mutability.js +252 -0
  45. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/negative.js +20 -0
  46. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/obj.js +15 -0
  47. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/siblings.js +35 -0
  48. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/stop.js +41 -0
  49. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/stringify.js +36 -0
  50. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/subexpr.js +34 -0
  51. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/traverse/test/super_deep.js +55 -0
  52. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/.npmignore +4 -0
  53. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/README.html +888 -0
  54. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/README.org +463 -0
  55. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/bin/uglifyjs +317 -0
  56. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/docstyle.css +75 -0
  57. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/lib/object-ast.js +75 -0
  58. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/lib/parse-js.js +1341 -0
  59. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/lib/process.js +1949 -0
  60. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/lib/squeeze-more.js +51 -0
  61. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/package.json +22 -0
  62. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/beautify.js +28 -0
  63. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/testparser.js +402 -0
  64. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/array1.js +1 -0
  65. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/array2.js +1 -0
  66. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/array3.js +1 -0
  67. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/array4.js +1 -0
  68. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/assignment.js +1 -0
  69. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/concatstring.js +1 -0
  70. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/const.js +1 -0
  71. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/empty-blocks.js +1 -0
  72. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/forstatement.js +1 -0
  73. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/if.js +1 -0
  74. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/ifreturn.js +1 -0
  75. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/ifreturn2.js +1 -0
  76. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue10.js +1 -0
  77. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue11.js +1 -0
  78. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue13.js +1 -0
  79. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue14.js +1 -0
  80. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue16.js +1 -0
  81. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue17.js +1 -0
  82. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue20.js +1 -0
  83. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue21.js +1 -0
  84. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue25.js +1 -0
  85. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue27.js +1 -0
  86. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue28.js +1 -0
  87. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue29.js +1 -0
  88. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue30.js +1 -0
  89. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue34.js +1 -0
  90. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue4.js +1 -0
  91. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue48.js +1 -0
  92. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue50.js +1 -0
  93. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue53.js +1 -0
  94. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue54.1.js +1 -0
  95. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue68.js +1 -0
  96. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue69.js +1 -0
  97. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue9.js +1 -0
  98. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/mangle.js +1 -0
  99. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/strict-equals.js +1 -0
  100. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/var.js +1 -0
  101. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/with.js +1 -0
  102. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/array1.js +3 -0
  103. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/array2.js +4 -0
  104. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/array3.js +4 -0
  105. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/array4.js +6 -0
  106. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/assignment.js +20 -0
  107. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/concatstring.js +3 -0
  108. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/const.js +5 -0
  109. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/empty-blocks.js +4 -0
  110. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/forstatement.js +10 -0
  111. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/if.js +6 -0
  112. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/ifreturn.js +9 -0
  113. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/ifreturn2.js +16 -0
  114. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue10.js +1 -0
  115. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue11.js +3 -0
  116. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue13.js +1 -0
  117. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue14.js +1 -0
  118. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue16.js +1 -0
  119. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue17.js +4 -0
  120. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue20.js +1 -0
  121. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue21.js +6 -0
  122. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue25.js +7 -0
  123. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue27.js +1 -0
  124. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue28.js +3 -0
  125. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue29.js +1 -0
  126. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue30.js +3 -0
  127. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue34.js +3 -0
  128. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue4.js +3 -0
  129. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue48.js +1 -0
  130. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue50.js +9 -0
  131. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue53.js +1 -0
  132. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue54.1.js +3 -0
  133. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue68.js +5 -0
  134. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue69.js +1 -0
  135. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue9.js +4 -0
  136. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/mangle.js +5 -0
  137. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/strict-equals.js +3 -0
  138. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/var.js +3 -0
  139. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/with.js +2 -0
  140. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/test/unit/scripts.js +55 -0
  141. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/tmp/hoist.js +33 -0
  142. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/tmp/instrument.js +97 -0
  143. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/tmp/instrument2.js +138 -0
  144. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/tmp/test.js +16 -0
  145. data/lib/holmes/node_modules/detective/node_modules/burrito/node_modules/uglify-js/uglify-js.js +17 -0
  146. data/lib/holmes/node_modules/detective/node_modules/burrito/package.json +43 -0
  147. data/lib/holmes/node_modules/detective/node_modules/burrito/server.js +4 -0
  148. data/lib/holmes/node_modules/detective/node_modules/burrito/test/ast.js +29 -0
  149. data/lib/holmes/node_modules/detective/node_modules/burrito/test/err.js +47 -0
  150. data/lib/holmes/node_modules/detective/node_modules/burrito/test/fail.js +8 -0
  151. data/lib/holmes/node_modules/detective/node_modules/burrito/test/fail/src.js +60 -0
  152. data/lib/holmes/node_modules/detective/node_modules/burrito/test/label.js +110 -0
  153. data/lib/holmes/node_modules/detective/node_modules/burrito/test/microwave.js +33 -0
  154. data/lib/holmes/node_modules/detective/node_modules/burrito/test/parent.js +26 -0
  155. data/lib/holmes/node_modules/detective/node_modules/burrito/test/wrap.js +157 -0
  156. data/lib/holmes/node_modules/detective/package.json +39 -0
  157. data/lib/holmes/node_modules/detective/test/both.js +10 -0
  158. data/lib/holmes/node_modules/detective/test/files/both.js +4 -0
  159. data/lib/holmes/node_modules/detective/test/files/nested.js +22 -0
  160. data/lib/holmes/node_modules/detective/test/files/strings.js +13 -0
  161. data/lib/holmes/node_modules/detective/test/files/word.js +13 -0
  162. data/lib/holmes/node_modules/detective/test/nested.js +8 -0
  163. data/lib/holmes/node_modules/detective/test/strings.js +8 -0
  164. data/lib/holmes/node_modules/detective/test/word.js +11 -0
  165. data/lib/holmes/require.js +5 -0
  166. data/lib/holmes/runner.js +20 -0
  167. data/lib/holmes/version.rb +3 -0
  168. metadata +223 -0
@@ -0,0 +1,317 @@
1
+ #! /usr/bin/env node
2
+ // -*- js -*-
3
+
4
+ global.sys = require(/^v0\.[012]/.test(process.version) ? "sys" : "util");
5
+ var fs = require("fs");
6
+ var uglify = require("uglify-js"), // symlink ~/.node_libraries/uglify-js.js to ../uglify-js.js
7
+ jsp = uglify.parser,
8
+ pro = uglify.uglify;
9
+
10
+ var options = {
11
+ ast: false,
12
+ mangle: true,
13
+ mangle_toplevel: false,
14
+ squeeze: true,
15
+ make_seqs: true,
16
+ dead_code: true,
17
+ verbose: false,
18
+ show_copyright: true,
19
+ out_same_file: false,
20
+ max_line_length: 32 * 1024,
21
+ unsafe: false,
22
+ reserved_names: null,
23
+ defines: { },
24
+ lift_vars: false,
25
+ codegen_options: {
26
+ ascii_only: false,
27
+ beautify: false,
28
+ indent_level: 4,
29
+ indent_start: 0,
30
+ quote_keys: false,
31
+ space_colon: false,
32
+ inline_script: false
33
+ },
34
+ make: false,
35
+ output: true // stdout
36
+ };
37
+
38
+ var args = jsp.slice(process.argv, 2);
39
+ var filename;
40
+
41
+ out: while (args.length > 0) {
42
+ var v = args.shift();
43
+ switch (v) {
44
+ case "-b":
45
+ case "--beautify":
46
+ options.codegen_options.beautify = true;
47
+ break;
48
+ case "-i":
49
+ case "--indent":
50
+ options.codegen_options.indent_level = args.shift();
51
+ break;
52
+ case "-q":
53
+ case "--quote-keys":
54
+ options.codegen_options.quote_keys = true;
55
+ break;
56
+ case "-mt":
57
+ case "--mangle-toplevel":
58
+ options.mangle_toplevel = true;
59
+ break;
60
+ case "--no-mangle":
61
+ case "-nm":
62
+ options.mangle = false;
63
+ break;
64
+ case "--no-squeeze":
65
+ case "-ns":
66
+ options.squeeze = false;
67
+ break;
68
+ case "--no-seqs":
69
+ options.make_seqs = false;
70
+ break;
71
+ case "--no-dead-code":
72
+ options.dead_code = false;
73
+ break;
74
+ case "--no-copyright":
75
+ case "-nc":
76
+ options.show_copyright = false;
77
+ break;
78
+ case "-o":
79
+ case "--output":
80
+ options.output = args.shift();
81
+ break;
82
+ case "--overwrite":
83
+ options.out_same_file = true;
84
+ break;
85
+ case "-v":
86
+ case "--verbose":
87
+ options.verbose = true;
88
+ break;
89
+ case "--ast":
90
+ options.ast = true;
91
+ break;
92
+ case "--unsafe":
93
+ options.unsafe = true;
94
+ break;
95
+ case "--max-line-len":
96
+ options.max_line_length = parseInt(args.shift(), 10);
97
+ break;
98
+ case "--reserved-names":
99
+ options.reserved_names = args.shift().split(",");
100
+ break;
101
+ case "--lift-vars":
102
+ options.lift_vars = true;
103
+ break;
104
+ case "-d":
105
+ case "--define":
106
+ var defarg = args.shift();
107
+ try {
108
+ var defsym = function(sym) {
109
+ // KEYWORDS_ATOM doesn't include NaN or Infinity - should we check
110
+ // for them too ?? We don't check reserved words and the like as the
111
+ // define values are only substituted AFTER parsing
112
+ if (jsp.KEYWORDS_ATOM.hasOwnProperty(sym)) {
113
+ throw "Don't define values for inbuilt constant '"+sym+"'";
114
+ }
115
+ return sym;
116
+ },
117
+ defval = function(v) {
118
+ if (v.match(/^"(.*)"$/) || v.match(/^'(.*)'$/)) {
119
+ return [ "string", RegExp.$1 ];
120
+ }
121
+ else if (!isNaN(parseFloat(v))) {
122
+ return [ "num", parseFloat(v) ];
123
+ }
124
+ else if (v.match(/^[a-z\$_][a-z\$_0-9]*$/i)) {
125
+ return [ "name", v ];
126
+ }
127
+ else if (!v.match(/"/)) {
128
+ return [ "string", v ];
129
+ }
130
+ else if (!v.match(/'/)) {
131
+ return [ "string", v ];
132
+ }
133
+ throw "Can't understand the specified value: "+v;
134
+ };
135
+ if (defarg.match(/^([a-z_\$][a-z_\$0-9]*)(=(.*))?$/i)) {
136
+ var sym = defsym(RegExp.$1),
137
+ val = RegExp.$2 ? defval(RegExp.$2.substr(1)) : [ 'name', 'true' ];
138
+ options.defines[sym] = val;
139
+ }
140
+ else {
141
+ throw "The --define option expects SYMBOL[=value]";
142
+ }
143
+ } catch(ex) {
144
+ sys.print("ERROR: In option --define "+defarg+"\n"+ex+"\n");
145
+ process.exit(1);
146
+ }
147
+ break;
148
+ case "--define-from-module":
149
+ var defmodarg = args.shift(),
150
+ defmodule = require(defmodarg),
151
+ sym,
152
+ val;
153
+ for (sym in defmodule) {
154
+ if (defmodule.hasOwnProperty(sym)) {
155
+ options.defines[sym] = function(val) {
156
+ if (typeof val == "string")
157
+ return [ "string", val ];
158
+ if (typeof val == "number")
159
+ return [ "num", val ];
160
+ if (val === true)
161
+ return [ 'name', 'true' ];
162
+ if (val === false)
163
+ return [ 'name', 'false' ];
164
+ if (val === null)
165
+ return [ 'name', 'null' ];
166
+ if (val === undefined)
167
+ return [ 'name', 'undefined' ];
168
+ sys.print("ERROR: In option --define-from-module "+defmodarg+"\n");
169
+ sys.print("ERROR: Unknown object type for: "+sym+"="+val+"\n");
170
+ process.exit(1);
171
+ return null;
172
+ }(defmodule[sym]);
173
+ }
174
+ }
175
+ break;
176
+ case "--ascii":
177
+ options.codegen_options.ascii_only = true;
178
+ break;
179
+ case "--make":
180
+ options.make = true;
181
+ break;
182
+ case "--inline-script":
183
+ options.codegen_options.inline_script = true;
184
+ break;
185
+ default:
186
+ filename = v;
187
+ break out;
188
+ }
189
+ }
190
+
191
+ if (options.verbose) {
192
+ pro.set_logger(function(msg){
193
+ sys.debug(msg);
194
+ });
195
+ }
196
+
197
+ jsp.set_logger(function(msg){
198
+ sys.debug(msg);
199
+ });
200
+
201
+ if (options.make) {
202
+ options.out_same_file = false; // doesn't make sense in this case
203
+ var makefile = JSON.parse(fs.readFileSync(filename || "Makefile.uglify.js").toString());
204
+ output(makefile.files.map(function(file){
205
+ var code = fs.readFileSync(file.name);
206
+ if (file.module) {
207
+ code = "!function(exports, global){global = this;\n" + code + "\n;this." + file.module + " = exports;}({})";
208
+ }
209
+ else if (file.hide) {
210
+ code = "(function(){" + code + "}());";
211
+ }
212
+ return squeeze_it(code);
213
+ }).join("\n"));
214
+ }
215
+ else if (filename) {
216
+ fs.readFile(filename, "utf8", function(err, text){
217
+ if (err) throw err;
218
+ output(squeeze_it(text));
219
+ });
220
+ }
221
+ else {
222
+ var stdin = process.openStdin();
223
+ stdin.setEncoding("utf8");
224
+ var text = "";
225
+ stdin.on("data", function(chunk){
226
+ text += chunk;
227
+ });
228
+ stdin.on("end", function() {
229
+ output(squeeze_it(text));
230
+ });
231
+ }
232
+
233
+ function output(text) {
234
+ var out;
235
+ if (options.out_same_file && filename)
236
+ options.output = filename;
237
+ if (options.output === true) {
238
+ out = process.stdout;
239
+ } else {
240
+ out = fs.createWriteStream(options.output, {
241
+ flags: "w",
242
+ encoding: "utf8",
243
+ mode: 0644
244
+ });
245
+ }
246
+ out.write(text);
247
+ if (options.output !== true) {
248
+ out.end();
249
+ }
250
+ };
251
+
252
+ // --------- main ends here.
253
+
254
+ function show_copyright(comments) {
255
+ var ret = "";
256
+ for (var i = 0; i < comments.length; ++i) {
257
+ var c = comments[i];
258
+ if (c.type == "comment1") {
259
+ ret += "//" + c.value + "\n";
260
+ } else {
261
+ ret += "/*" + c.value + "*/";
262
+ }
263
+ }
264
+ return ret;
265
+ };
266
+
267
+ function squeeze_it(code) {
268
+ var result = "";
269
+ if (options.show_copyright) {
270
+ var tok = jsp.tokenizer(code), c;
271
+ c = tok();
272
+ result += show_copyright(c.comments_before);
273
+ }
274
+ try {
275
+ var ast = time_it("parse", function(){ return jsp.parse(code); });
276
+ if (options.lift_vars) {
277
+ ast = time_it("lift", function(){ return pro.ast_lift_variables(ast); });
278
+ }
279
+ if (options.mangle) ast = time_it("mangle", function(){
280
+ return pro.ast_mangle(ast, {
281
+ toplevel: options.mangle_toplevel,
282
+ defines: options.defines,
283
+ except: options.reserved_names
284
+ });
285
+ });
286
+ if (options.squeeze) ast = time_it("squeeze", function(){
287
+ ast = pro.ast_squeeze(ast, {
288
+ make_seqs : options.make_seqs,
289
+ dead_code : options.dead_code,
290
+ keep_comps : !options.unsafe
291
+ });
292
+ if (options.unsafe)
293
+ ast = pro.ast_squeeze_more(ast);
294
+ return ast;
295
+ });
296
+ if (options.ast)
297
+ return sys.inspect(ast, null, null);
298
+ result += time_it("generate", function(){ return pro.gen_code(ast, options.codegen_options) });
299
+ if (!options.codegen_options.beautify && options.max_line_length) {
300
+ result = time_it("split", function(){ return pro.split_lines(result, options.max_line_length) });
301
+ }
302
+ return result;
303
+ } catch(ex) {
304
+ sys.debug(ex.stack);
305
+ sys.debug(sys.inspect(ex));
306
+ sys.debug(JSON.stringify(ex));
307
+ process.exit(1);
308
+ }
309
+ };
310
+
311
+ function time_it(name, cont) {
312
+ if (!options.verbose)
313
+ return cont();
314
+ var t1 = new Date().getTime();
315
+ try { return cont(); }
316
+ finally { sys.debug("// " + name + ": " + ((new Date().getTime() - t1) / 1000).toFixed(3) + " sec."); }
317
+ };
@@ -0,0 +1,75 @@
1
+ html { font-family: "Lucida Grande","Trebuchet MS",sans-serif; font-size: 12pt; }
2
+ body { max-width: 60em; }
3
+ .title { text-align: center; }
4
+ .todo { color: red; }
5
+ .done { color: green; }
6
+ .tag { background-color:lightblue; font-weight:normal }
7
+ .target { }
8
+ .timestamp { color: grey }
9
+ .timestamp-kwd { color: CadetBlue }
10
+ p.verse { margin-left: 3% }
11
+ pre {
12
+ border: 1pt solid #AEBDCC;
13
+ background-color: #F3F5F7;
14
+ padding: 5pt;
15
+ font-family: monospace;
16
+ font-size: 90%;
17
+ overflow:auto;
18
+ }
19
+ pre.src {
20
+ background-color: #eee; color: #112; border: 1px solid #000;
21
+ }
22
+ table { border-collapse: collapse; }
23
+ td, th { vertical-align: top; }
24
+ dt { font-weight: bold; }
25
+ div.figure { padding: 0.5em; }
26
+ div.figure p { text-align: center; }
27
+ .linenr { font-size:smaller }
28
+ .code-highlighted {background-color:#ffff00;}
29
+ .org-info-js_info-navigation { border-style:none; }
30
+ #org-info-js_console-label { font-size:10px; font-weight:bold;
31
+ white-space:nowrap; }
32
+ .org-info-js_search-highlight {background-color:#ffff00; color:#000000;
33
+ font-weight:bold; }
34
+
35
+ sup {
36
+ vertical-align: baseline;
37
+ position: relative;
38
+ top: -0.5em;
39
+ font-size: 80%;
40
+ }
41
+
42
+ sup a:link, sup a:visited {
43
+ text-decoration: none;
44
+ color: #c00;
45
+ }
46
+
47
+ sup a:before { content: "["; color: #999; }
48
+ sup a:after { content: "]"; color: #999; }
49
+
50
+ h1.title { border-bottom: 4px solid #000; padding-bottom: 5px; margin-bottom: 2em; }
51
+
52
+ #postamble {
53
+ color: #777;
54
+ font-size: 90%;
55
+ padding-top: 1em; padding-bottom: 1em; border-top: 1px solid #999;
56
+ margin-top: 2em;
57
+ padding-left: 2em;
58
+ padding-right: 2em;
59
+ text-align: right;
60
+ }
61
+
62
+ #postamble p { margin: 0; }
63
+
64
+ #footnotes { border-top: 1px solid #000; }
65
+
66
+ h1 { font-size: 200% }
67
+ h2 { font-size: 175% }
68
+ h3 { font-size: 150% }
69
+ h4 { font-size: 125% }
70
+
71
+ h1, h2, h3, h4 { font-family: "Bookman",Georgia,"Times New Roman",serif; font-weight: normal; }
72
+
73
+ @media print {
74
+ html { font-size: 11pt; }
75
+ }
@@ -0,0 +1,75 @@
1
+ var jsp = require("./parse-js"),
2
+ pro = require("./process");
3
+
4
+ var BY_TYPE = {};
5
+
6
+ function HOP(obj, prop) {
7
+ return Object.prototype.hasOwnProperty.call(obj, prop);
8
+ };
9
+
10
+ function AST_Node(parent) {
11
+ this.parent = parent;
12
+ };
13
+
14
+ AST_Node.prototype.init = function(){};
15
+
16
+ function DEFINE_NODE_CLASS(type, props, methods) {
17
+ var base = methods && methods.BASE || AST_Node;
18
+ if (!base) base = AST_Node;
19
+ function D(parent, data) {
20
+ base.apply(this, arguments);
21
+ if (props) props.forEach(function(name, i){
22
+ this["_" + name] = data[i];
23
+ });
24
+ this.init();
25
+ };
26
+ var P = D.prototype = new AST_Node;
27
+ P.node_type = function(){ return type };
28
+ if (props) props.forEach(function(name){
29
+ var propname = "_" + name;
30
+ P["set_" + name] = function(val) {
31
+ this[propname] = val;
32
+ return this;
33
+ };
34
+ P["get_" + name] = function() {
35
+ return this[propname];
36
+ };
37
+ });
38
+ if (type != null) BY_TYPE[type] = D;
39
+ if (methods) for (var i in methods) if (HOP(methods, i)) {
40
+ P[i] = methods[i];
41
+ }
42
+ return D;
43
+ };
44
+
45
+ var AST_String_Node = DEFINE_NODE_CLASS("string", ["value"]);
46
+ var AST_Number_Node = DEFINE_NODE_CLASS("num", ["value"]);
47
+ var AST_Name_Node = DEFINE_NODE_CLASS("name", ["value"]);
48
+
49
+ var AST_Statlist_Node = DEFINE_NODE_CLASS(null, ["body"]);
50
+ var AST_Root_Node = DEFINE_NODE_CLASS("toplevel", null, { BASE: AST_Statlist_Node });
51
+ var AST_Block_Node = DEFINE_NODE_CLASS("block", null, { BASE: AST_Statlist_Node });
52
+ var AST_Splice_Node = DEFINE_NODE_CLASS("splice", null, { BASE: AST_Statlist_Node });
53
+
54
+ var AST_Var_Node = DEFINE_NODE_CLASS("var", ["definitions"]);
55
+ var AST_Const_Node = DEFINE_NODE_CLASS("const", ["definitions"]);
56
+
57
+ var AST_Try_Node = DEFINE_NODE_CLASS("try", ["body", "catch", "finally"]);
58
+ var AST_Throw_Node = DEFINE_NODE_CLASS("throw", ["exception"]);
59
+
60
+ var AST_New_Node = DEFINE_NODE_CLASS("new", ["constructor", "arguments"]);
61
+
62
+ var AST_Switch_Node = DEFINE_NODE_CLASS("switch", ["expression", "branches"]);
63
+ var AST_Switch_Branch_Node = DEFINE_NODE_CLASS(null, ["expression", "body"]);
64
+
65
+ var AST_Break_Node = DEFINE_NODE_CLASS("break", ["label"]);
66
+ var AST_Continue_Node = DEFINE_NODE_CLASS("continue", ["label"]);
67
+ var AST_Assign_Node = DEFINE_NODE_CLASS("assign", ["operator", "lvalue", "rvalue"]);
68
+ var AST_Dot_Node = DEFINE_NODE_CLASS("dot", ["expression", "name"]);
69
+ var AST_Call_Node = DEFINE_NODE_CLASS("call", ["function", "arguments"]);
70
+
71
+ var AST_Lambda_Node = DEFINE_NODE_CLASS(null, ["name", "arguments", "body"])
72
+ var AST_Function_Node = DEFINE_NODE_CLASS("function", null, AST_Lambda_Node);
73
+ var AST_Defun_Node = DEFINE_NODE_CLASS("defun", null, AST_Lambda_Node);
74
+
75
+ var AST_If_Node = DEFINE_NODE_CLASS("if", ["condition", "then", "else"]);