Compare commits
537 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de180dc81a | ||
|
|
e2a3a5b993 | ||
|
|
8c81c4ad39 | ||
|
|
e620434a2e | ||
|
|
be0f1cb8db | ||
|
|
07d6eb6af5 | ||
|
|
81174187f5 | ||
|
|
aee27fbff0 | ||
|
|
28585439d1 | ||
|
|
7704cf571e | ||
|
|
26cfd19862 | ||
|
|
6a678f23a5 | ||
|
|
04961afa36 | ||
|
|
6fc9e338a5 | ||
|
|
df5dd7e383 | ||
|
|
8fbe095e94 | ||
|
|
a80d74a672 | ||
|
|
88f2bf9fa5 | ||
|
|
3ea0481bbe | ||
|
|
03eceeb615 | ||
|
|
81b9fe34ff | ||
|
|
fb0639fa38 | ||
|
|
b7dbee2402 | ||
|
|
2ca0f44cc8 | ||
|
|
c5121c8c4e | ||
|
|
2f72d0394f | ||
|
|
026d9d6ccd | ||
|
|
c9de5be966 | ||
|
|
d45d780869 | ||
|
|
d8abfae457 | ||
|
|
98bf335777 | ||
|
|
1a69493f87 | ||
|
|
abe746bf53 | ||
|
|
075e48df95 | ||
|
|
47c0a5cbef | ||
|
|
c48f5ce30f | ||
|
|
4efd27ed28 | ||
|
|
e6b1218ae1 | ||
|
|
68938cda30 | ||
|
|
7d6a3b5fa4 | ||
|
|
f187440bb8 | ||
|
|
d0d2ef9f77 | ||
|
|
a15bf3d336 | ||
|
|
6d507b46d3 | ||
|
|
5588658641 | ||
|
|
d99ae0e7ef | ||
|
|
cf3a27259a | ||
|
|
1ea753d19f | ||
|
|
831d3c9341 | ||
|
|
729fec2947 | ||
|
|
faab9330e9 | ||
|
|
8c8ebf874a | ||
|
|
06b3180223 | ||
|
|
6d29086519 | ||
|
|
a401f587c3 | ||
|
|
ac26360fdc | ||
|
|
ac20f6634a | ||
|
|
5c765f4cc7 | ||
|
|
02c5641b32 | ||
|
|
555e47dbb9 | ||
|
|
992eb49e92 | ||
|
|
8ea67ff3e9 | ||
|
|
56482a3166 | ||
|
|
6c759d49bd | ||
|
|
cc3be717a0 | ||
|
|
073e14746e | ||
|
|
78e1f43b24 | ||
|
|
a49c5c5150 | ||
|
|
24033eb11a | ||
|
|
f32740c032 | ||
|
|
bebc5812e5 | ||
|
|
4ab6fbca72 | ||
|
|
7bc5b73db1 | ||
|
|
a95d986055 | ||
|
|
846c0e4c51 | ||
|
|
3736b0fed1 | ||
|
|
eb46975d87 | ||
|
|
3739954de6 | ||
|
|
3b0b002f29 | ||
|
|
6f09d36ec8 | ||
|
|
b3896d08e8 | ||
|
|
aca72f9b91 | ||
|
|
c5afb4e2fd | ||
|
|
0d132318ce | ||
|
|
26ad6d4670 | ||
|
|
887052de07 | ||
|
|
6087c2c8fc | ||
|
|
0521c3582c | ||
|
|
3c42b400a1 | ||
|
|
be44ebd2cd | ||
|
|
4d3d7352f1 | ||
|
|
48e00d81a9 | ||
|
|
0853b412c6 | ||
|
|
a75fe280f2 | ||
|
|
e14946b3e6 | ||
|
|
88693e420d | ||
|
|
ce971b766f | ||
|
|
11561dddcf | ||
|
|
7c7bc8ee2f | ||
|
|
7b9fbf2c76 | ||
|
|
8623792bcd | ||
|
|
809634ba39 | ||
|
|
46841d916d | ||
|
|
0b2d852f67 | ||
|
|
964a588e29 | ||
|
|
568a0c7b4e | ||
|
|
57f5297714 | ||
|
|
32041806ae | ||
|
|
b0d8fca245 | ||
|
|
c3f5b8db86 | ||
|
|
2923e88207 | ||
|
|
66b5203689 | ||
|
|
e908fd4a91 | ||
|
|
ab97e2224e | ||
|
|
f6bc4b4c32 | ||
|
|
a8b77fb4e7 | ||
|
|
7667cb2370 | ||
|
|
51f24e0641 | ||
|
|
9ae377b481 | ||
|
|
0e0e8f87e1 | ||
|
|
ec9c4d8594 | ||
|
|
66ac8af678 | ||
|
|
feb42e5128 | ||
|
|
bd0024a9c2 | ||
|
|
133fadd36a | ||
|
|
a5980247dc | ||
|
|
ec333a061b | ||
|
|
0247b135f8 | ||
|
|
d7e752bc5d | ||
|
|
7c2f348a63 | ||
|
|
88192c197a | ||
|
|
d7385ece46 | ||
|
|
e318469cb0 | ||
|
|
6291b53492 | ||
|
|
841b3cd2ad | ||
|
|
9a0babf5b1 | ||
|
|
cbc72a29bf | ||
|
|
e42fc47747 | ||
|
|
5b7ac32905 | ||
|
|
4d8cd03298 | ||
|
|
585932cf5b | ||
|
|
8afb7cc95b | ||
|
|
021d2e4376 | ||
|
|
87216ea5b6 | ||
|
|
f80a8a5120 | ||
|
|
9590ad7622 | ||
|
|
402133a50e | ||
|
|
34b4311544 | ||
|
|
65c35e05a1 | ||
|
|
f7277c9de5 | ||
|
|
08129d0f1f | ||
|
|
347a625525 | ||
|
|
2df011f378 | ||
|
|
97882b8e49 | ||
|
|
67b0f95d4d | ||
|
|
ce84924101 | ||
|
|
ae72dbb379 | ||
|
|
b8403bfa97 | ||
|
|
f179b20e6e | ||
|
|
0995ba361c | ||
|
|
89921c0667 | ||
|
|
87a854afb4 | ||
|
|
1dd5795960 | ||
|
|
968f94f782 | ||
|
|
4b4675de30 | ||
|
|
36e80d7f5c | ||
|
|
2536bfd75c | ||
|
|
4acafad07b | ||
|
|
73b05a55b6 | ||
|
|
de2db48474 | ||
|
|
4ceb6a6818 | ||
|
|
d6ff91a454 | ||
|
|
da23a2f702 | ||
|
|
d1c6db476b | ||
|
|
b1ef5a9996 | ||
|
|
c1a9cfa044 | ||
|
|
d3cff9082f | ||
|
|
1739c9d720 | ||
|
|
75a4c01e17 | ||
|
|
8711da03a2 | ||
|
|
eb6baf2d9b | ||
|
|
d742a7dd1f | ||
|
|
ae65875c8b | ||
|
|
fcf5924dae | ||
|
|
f26d33d418 | ||
|
|
cea773ec81 | ||
|
|
6c6c8d48bf | ||
|
|
98dd1bf8e8 | ||
|
|
56d75baac7 | ||
|
|
0872c3d13d | ||
|
|
5095e02b62 | ||
|
|
874628b1d0 | ||
|
|
ff9d5117f9 | ||
|
|
10aca2a38e | ||
|
|
2c4d437e98 | ||
|
|
c0c13c1977 | ||
|
|
6d9553a016 | ||
|
|
66716cd730 | ||
|
|
f588ecb288 | ||
|
|
dc3e177811 | ||
|
|
2eef667916 | ||
|
|
617a932e89 | ||
|
|
beac56d4d5 | ||
|
|
cc98e99070 | ||
|
|
93e4eeafed | ||
|
|
efdc67241a | ||
|
|
24e8f1c98f | ||
|
|
2d1a6fa6ec | ||
|
|
3d7d68a766 | ||
|
|
342b395b0a | ||
|
|
75ae45e2bb | ||
|
|
1f197fcc1b | ||
|
|
e339f5f2da | ||
|
|
c37f284771 | ||
|
|
585298dc17 | ||
|
|
2087923163 | ||
|
|
b58772e8a7 | ||
|
|
769f02ec05 | ||
|
|
52b1749d57 | ||
|
|
ba85a38cb0 | ||
|
|
c0d44b1abd | ||
|
|
0262322400 | ||
|
|
8e8f6d13bd | ||
|
|
b6667f0735 | ||
|
|
99ea1c7a39 | ||
|
|
27fd65390a | ||
|
|
79a6d89849 | ||
|
|
6fb5833843 | ||
|
|
5494ac13ee | ||
|
|
300faf401c | ||
|
|
f2c6066103 | ||
|
|
2a5320fd2b | ||
|
|
36695540fc | ||
|
|
fc0c4fdd5f | ||
|
|
ebc172d1ee | ||
|
|
4e6b6678f7 | ||
|
|
378a04e48c | ||
|
|
1e62781759 | ||
|
|
234adef20c | ||
|
|
8b463cd3ad | ||
|
|
ce10a463f3 | ||
|
|
140a73dca7 | ||
|
|
46d16b5c49 | ||
|
|
d16cf19c15 | ||
|
|
edbb9a77e7 | ||
|
|
cc4c3b2606 | ||
|
|
3a2888f97a | ||
|
|
bd17cc9b3c | ||
|
|
0a3e3639dc | ||
|
|
008bacf5d5 | ||
|
|
cc1b056b03 | ||
|
|
3548b4883e | ||
|
|
37a376497c | ||
|
|
83744917b0 | ||
|
|
a548b70e8c | ||
|
|
c8147c046a | ||
|
|
4a7497b451 | ||
|
|
06aa329596 | ||
|
|
9becb0e937 | ||
|
|
7f7765546f | ||
|
|
c7a365b6f1 | ||
|
|
84c125a71b | ||
|
|
06b74591e7 | ||
|
|
6645fbb895 | ||
|
|
c2758da9eb | ||
|
|
7a1c8fef0a | ||
|
|
71c59dddcc | ||
|
|
ef6f90753a | ||
|
|
50fff63252 | ||
|
|
8f5c77c3ce | ||
|
|
88529bc339 | ||
|
|
f37f9d1eda | ||
|
|
836175baab | ||
|
|
7395ac1d4f | ||
|
|
61988fe361 | ||
|
|
533ad8afe9 | ||
|
|
1961f06e08 | ||
|
|
4503e2716e | ||
|
|
e4d81005be | ||
|
|
b6012c4617 | ||
|
|
feee6954a6 | ||
|
|
fea058c53a | ||
|
|
25d97aa136 | ||
|
|
7c8849cc21 | ||
|
|
b362bd672c | ||
|
|
a4f510501c | ||
|
|
e3f6e19950 | ||
|
|
b49b41320e | ||
|
|
6bc3157793 | ||
|
|
dc8a2b17d0 | ||
|
|
c3ae2328af | ||
|
|
57846ea5c0 | ||
|
|
3da88b9b3f | ||
|
|
8130e63e43 | ||
|
|
dc44ebbdaa | ||
|
|
88ad059d54 | ||
|
|
76c076db55 | ||
|
|
5698e6c72a | ||
|
|
e0e4967ad8 | ||
|
|
53c7891599 | ||
|
|
94a17cb74a | ||
|
|
5d139596f8 | ||
|
|
213225418a | ||
|
|
3b3e52097a | ||
|
|
72ceec5680 | ||
|
|
5a220d4e13 | ||
|
|
92e5ab2857 | ||
|
|
64632e3332 | ||
|
|
c0e1f23f23 | ||
|
|
ee8f889cbd | ||
|
|
ffa25aae77 | ||
|
|
04b30a6cc4 | ||
|
|
996a171a4e | ||
|
|
17a271af06 | ||
|
|
f8c366c479 | ||
|
|
934bd2acc7 | ||
|
|
dd0ec84ebe | ||
|
|
e9a372dff5 | ||
|
|
4d7a0d2470 | ||
|
|
c2abe253a1 | ||
|
|
3ddd3115eb | ||
|
|
a3096eab91 | ||
|
|
3fd004b852 | ||
|
|
0a9c7a3257 | ||
|
|
f7692c92ce | ||
|
|
cdf69eb5bc | ||
|
|
9aeecf582b | ||
|
|
e0ec8a51e4 | ||
|
|
a62e49311e | ||
|
|
9a38486d08 | ||
|
|
06e8be5d94 | ||
|
|
90a1cbac49 | ||
|
|
3d58b4cda1 | ||
|
|
2f0724f0ad | ||
|
|
f288d20409 | ||
|
|
dca915af60 | ||
|
|
54a4560340 | ||
|
|
518d7c16b7 | ||
|
|
8ed691e266 | ||
|
|
74fc7128ab | ||
|
|
68c0e2dc0f | ||
|
|
42dde38842 | ||
|
|
7d6f6174d5 | ||
|
|
05b3707506 | ||
|
|
5d1d1b7999 | ||
|
|
3db029f2c1 | ||
|
|
67aaa8b57f | ||
|
|
28c07d30cb | ||
|
|
fce502ac98 | ||
|
|
669e7fed10 | ||
|
|
4bf45ff894 | ||
|
|
4c2c472e07 | ||
|
|
22f19522ff | ||
|
|
9fa77af576 | ||
|
|
efd7ebb066 | ||
|
|
62712060c0 | ||
|
|
a46978640b | ||
|
|
8ab15d7372 | ||
|
|
23a691ae87 | ||
|
|
bec8f27e8a | ||
|
|
ac2e540e1b | ||
|
|
e0ad0d795d | ||
|
|
a63009fccb | ||
|
|
8fd6258a46 | ||
|
|
24398774fc | ||
|
|
e769423d52 | ||
|
|
9ec427ba80 | ||
|
|
c478f283f4 | ||
|
|
8e299b09cc | ||
|
|
b70f6571bd | ||
|
|
ae6df88c5c | ||
|
|
0dcff507fb | ||
|
|
8e4fb1b937 | ||
|
|
931b74e449 | ||
|
|
4199f4f325 | ||
|
|
5950d6328d | ||
|
|
a9fbf14adf | ||
|
|
485aa8efcf | ||
|
|
a563e8f8fe | ||
|
|
4035e7caab | ||
|
|
2c6e6ca870 | ||
|
|
f2a3f7507e | ||
|
|
4f82e5912e | ||
|
|
dd5da7f5f2 | ||
|
|
ec44aba71a | ||
|
|
e8a4e93a72 | ||
|
|
1301390087 | ||
|
|
158ca0d869 | ||
|
|
a78cbe78a1 | ||
|
|
77d5b95260 | ||
|
|
55e3b6b3c3 | ||
|
|
efca2861a6 | ||
|
|
781ea22d57 | ||
|
|
437b9ed65c | ||
|
|
c72556619f | ||
|
|
565d78f00b | ||
|
|
75900660fd | ||
|
|
b407a59baf | ||
|
|
9dfd71b0e4 | ||
|
|
872092f6de | ||
|
|
8b066f125d | ||
|
|
94c467b520 | ||
|
|
53aa50f785 | ||
|
|
81047d45ee | ||
|
|
9177676979 | ||
|
|
7cfba37f7c | ||
|
|
ee8d105194 | ||
|
|
6929441cb7 | ||
|
|
b5734028d9 | ||
|
|
ab6f69c741 | ||
|
|
2ec6e7e944 | ||
|
|
e8c96de269 | ||
|
|
fbbda3f85f | ||
|
|
f96ab11feb | ||
|
|
5c1daf966a | ||
|
|
df8529fbfb | ||
|
|
3465e7554d | ||
|
|
f7b36054fc | ||
|
|
3ec10df4a1 | ||
|
|
deead4bfad | ||
|
|
302aa6a457 | ||
|
|
5920939e23 | ||
|
|
2bab1b6aa1 | ||
|
|
2b539ebea8 | ||
|
|
159d562230 | ||
|
|
eb030a2c73 | ||
|
|
1157b32413 | ||
|
|
ba4157b5e2 | ||
|
|
5a54d8ba6d | ||
|
|
f619416492 | ||
|
|
2dd1ec3314 | ||
|
|
4ad625a265 | ||
|
|
df2b79fa56 | ||
|
|
c4f9c3abf5 | ||
|
|
9410216b02 | ||
|
|
233055a7ab | ||
|
|
edf3c12fcc | ||
|
|
1bb3c843e1 | ||
|
|
48f2c2d0d2 | ||
|
|
7e01672479 | ||
|
|
ddc023b28b | ||
|
|
c65f584112 | ||
|
|
70a9a341ac | ||
|
|
c608901d5a | ||
|
|
a5a1ea9157 | ||
|
|
1cd48a9f5d | ||
|
|
d8b7a55eb9 | ||
|
|
6ae21ae461 | ||
|
|
f0764096e9 | ||
|
|
ade9620351 | ||
|
|
3fdc3a4758 | ||
|
|
03705c674f | ||
|
|
576fe44ef8 | ||
|
|
e02c8abb1a | ||
|
|
2723f1afe9 | ||
|
|
6114751d21 | ||
|
|
15b64addbf | ||
|
|
4547612e50 | ||
|
|
9c15b13a96 | ||
|
|
63acf6a5ff | ||
|
|
3339c2f228 | ||
|
|
c2db81d892 | ||
|
|
8b15d8218d | ||
|
|
bfc9d4d594 | ||
|
|
ab5728c030 | ||
|
|
dcf1556ffc | ||
|
|
53c53bd3e6 | ||
|
|
c2e1ab589c | ||
|
|
75207a08ad | ||
|
|
a2dbfdc2f4 | ||
|
|
0a82ac7d69 | ||
|
|
a489006afb | ||
|
|
af08cfd37f | ||
|
|
9dc3a3df13 | ||
|
|
a82aecc008 | ||
|
|
36a3e03048 | ||
|
|
fc8e9fd92a | ||
|
|
c9e87f3044 | ||
|
|
bb319e2add | ||
|
|
81e2253a55 | ||
|
|
c41a14f447 | ||
|
|
a323160d14 | ||
|
|
a216f93b54 | ||
|
|
551cf56ceb | ||
|
|
09446ad515 | ||
|
|
b31951980e | ||
|
|
e7ba29514d | ||
|
|
a2c0106b3f | ||
|
|
4dfc75dede | ||
|
|
0ad30e9b3f | ||
|
|
46f55d1bb4 | ||
|
|
27f1976159 | ||
|
|
816241d9a1 | ||
|
|
4bbd63c883 | ||
|
|
e9a0512663 | ||
|
|
8980647f32 | ||
|
|
eda4f0c55b | ||
|
|
ed928928f6 | ||
|
|
5f28319cb1 | ||
|
|
6b0ee127da | ||
|
|
5e31672793 | ||
|
|
4ab8503e5a | ||
|
|
cc4cc8e652 | ||
|
|
52b89d5b03 | ||
|
|
094a0cbe95 | ||
|
|
f8eca2e822 | ||
|
|
114eccb459 | ||
|
|
38bd879a9a | ||
|
|
a73a6e24a6 | ||
|
|
b4d35f13a4 | ||
|
|
3fcaebb007 | ||
|
|
3357b6cf2c | ||
|
|
6df8d92499 | ||
|
|
e543eb5101 | ||
|
|
7c4f842501 | ||
|
|
a5fef52751 | ||
|
|
ef7b3a75e0 | ||
|
|
734fcedc06 | ||
|
|
e4c8bcf8f6 | ||
|
|
f375394381 | ||
|
|
1e377ed59b | ||
|
|
64e78a2bec | ||
|
|
25b1eee293 | ||
|
|
dab4ae9416 | ||
|
|
56b04a58dc | ||
|
|
e1000205fd | ||
|
|
c02a403f2e | ||
|
|
f4b850d59c | ||
|
|
85c7fffd1a | ||
|
|
9d29a830df | ||
|
|
74a92db173 | ||
|
|
d712a6c0f4 | ||
|
|
7906a2b6c1 | ||
|
|
f11ca9888f | ||
|
|
9941050120 | ||
|
|
dafc7bdea5 | ||
|
|
f51cbd7117 |
4
.gitignore
vendored
@@ -3,8 +3,6 @@ presentation
|
||||
test.coffee
|
||||
test.litcoffee
|
||||
parser.output
|
||||
test/fixtures/underscore
|
||||
test/*.js
|
||||
examples/beautiful_code/parse.coffee
|
||||
*.gem
|
||||
/node_modules
|
||||
npm-debug.log
|
||||
|
||||
11
.npmignore
@@ -1,11 +0,0 @@
|
||||
*.coffee
|
||||
*.html
|
||||
.DS_Store
|
||||
.git*
|
||||
Cakefile
|
||||
documentation/
|
||||
examples/
|
||||
extras/coffee-script.js
|
||||
raw/
|
||||
src/
|
||||
test/
|
||||
@@ -1,9 +1,9 @@
|
||||
## How to contribute to CoffeeScript
|
||||
|
||||
* Before you open a ticket or send a pull request, [search](https://github.com/jashkenas/coffee-script/issues) for previous discussions about the same feature or issue. Add to the earlier ticket if you find one.
|
||||
* Before you open a ticket or send a pull request, [search](https://github.com/jashkenas/coffeescript/issues) for previous discussions about the same feature or issue. Add to the earlier ticket if you find one.
|
||||
|
||||
* Before sending a pull request for a feature, be sure to have [tests](https://github.com/jashkenas/coffee-script/tree/master/test).
|
||||
* Before sending a pull request for a feature, be sure to have [tests](https://github.com/jashkenas/coffeescript/tree/master/test).
|
||||
|
||||
* Use the same coding style as the rest of the [codebase](https://github.com/jashkenas/coffee-script/tree/master/src). If you're just getting started with CoffeeScript, there's a nice [style guide](https://github.com/polarmobile/coffeescript-style-guide).
|
||||
* Use the same coding style as the rest of the [codebase](https://github.com/jashkenas/coffeescript/tree/master/src). If you're just getting started with CoffeeScript, there's a nice [style guide](https://github.com/polarmobile/coffeescript-style-guide).
|
||||
|
||||
* In your pull request, do not add documentation to `index.html` or re-build the minified `coffee-script.js` file. We'll do those things before cutting a new release.
|
||||
* In your pull request, do not add documentation to `index.html` or re-build the minified `coffee-script.js` file. We'll do those things before cutting a new release.
|
||||
|
||||
220
Cakefile
@@ -1,9 +1,9 @@
|
||||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
_ = require 'underscore'
|
||||
CoffeeScript = require './lib/coffee-script'
|
||||
{spawn, exec} = require 'child_process'
|
||||
helpers = require './lib/coffee-script/helpers'
|
||||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
_ = require 'underscore'
|
||||
{ spawn, exec, execSync } = require 'child_process'
|
||||
CoffeeScript = require './lib/coffee-script'
|
||||
helpers = require './lib/coffee-script/helpers'
|
||||
|
||||
# ANSI Terminal Colors.
|
||||
bold = red = green = reset = ''
|
||||
@@ -24,6 +24,9 @@ header = """
|
||||
*/
|
||||
"""
|
||||
|
||||
# Used in folder names like docs/v1
|
||||
majorVersion = parseInt CoffeeScript.VERSION.split('.')[0], 10
|
||||
|
||||
# Build the CoffeeScript language from source.
|
||||
build = (cb) ->
|
||||
files = fs.readdirSync 'src'
|
||||
@@ -35,36 +38,13 @@ run = (args, cb) ->
|
||||
proc = spawn 'node', ['bin/coffee'].concat(args)
|
||||
proc.stderr.on 'data', (buffer) -> console.log buffer.toString()
|
||||
proc.on 'exit', (status) ->
|
||||
process.exit(1) if status != 0
|
||||
process.exit(1) if status isnt 0
|
||||
cb() if typeof cb is 'function'
|
||||
|
||||
# Log a message with a color.
|
||||
log = (message, color, explanation) ->
|
||||
console.log color + message + reset + ' ' + (explanation or '')
|
||||
|
||||
codeFor = ->
|
||||
counter = 0
|
||||
hljs = require 'highlight.js'
|
||||
hljs.configure classPrefix: ''
|
||||
(file, executable = false, showLoad = true) ->
|
||||
counter++
|
||||
return unless fs.existsSync "documentation/js/#{file}.js"
|
||||
cs = fs.readFileSync "documentation/coffee/#{file}.coffee", 'utf-8'
|
||||
js = fs.readFileSync "documentation/js/#{file}.js", 'utf-8'
|
||||
js = js.replace /^\/\/ generated.*?\n/i, ''
|
||||
|
||||
cshtml = "<pre><code>#{hljs.highlight('coffeescript', cs).value}</code></pre>"
|
||||
jshtml = "<pre><code>#{hljs.highlight('javascript', js).value}</code></pre>"
|
||||
append = if executable is yes then '' else "alert(#{executable});"
|
||||
if executable and executable != yes
|
||||
cs.replace /(\S)\s*\Z/m, "$1\n\nalert #{executable}"
|
||||
run = if executable is true then 'run' else "run: #{executable}"
|
||||
name = "example#{counter}"
|
||||
script = "<script>window.#{name} = #{JSON.stringify cs}</script>"
|
||||
load = if showLoad then "<div class='minibutton load' onclick='javascript: loadConsole(#{name});'>load</div>" else ''
|
||||
button = if executable then "<div class='minibutton ok' onclick='javascript: #{js};#{append}'>#{run}</div>" else ''
|
||||
"<div class='code'>#{cshtml}#{jshtml}#{script}#{load}#{button}<br class='clear' /></div>"
|
||||
|
||||
option '-p', '--prefix [DIR]', 'set the installation prefix for `cake install`'
|
||||
|
||||
task 'install', 'install CoffeeScript into /usr/local (or --prefix)', (options) ->
|
||||
@@ -72,12 +52,12 @@ task 'install', 'install CoffeeScript into /usr/local (or --prefix)', (options)
|
||||
lib = "#{base}/lib/coffee-script"
|
||||
bin = "#{base}/bin"
|
||||
node = "~/.node_libraries/coffee-script"
|
||||
console.log "Installing CoffeeScript to #{lib}"
|
||||
console.log "Linking to #{node}"
|
||||
console.log "Linking 'coffee' to #{bin}/coffee"
|
||||
console.log "Installing CoffeeScript to #{lib}"
|
||||
console.log "Linking to #{node}"
|
||||
console.log "Linking 'coffee' to #{bin}/coffee"
|
||||
exec([
|
||||
"mkdir -p #{lib} #{bin}"
|
||||
"cp -rf bin lib LICENSE README package.json src #{lib}"
|
||||
"cp -rf bin lib LICENSE README.md package.json src #{lib}"
|
||||
"ln -sfn #{lib}/bin/coffee #{bin}/coffee"
|
||||
"ln -sfn #{lib}/bin/cake #{bin}/cake"
|
||||
"mkdir -p ~/.node_libraries"
|
||||
@@ -103,13 +83,18 @@ task 'build:full', 'rebuild the source twice, and run the tests', ->
|
||||
|
||||
|
||||
task 'build:parser', 'rebuild the Jison parser (run build first)', ->
|
||||
helpers.extend global, require('util')
|
||||
helpers.extend global, require 'util'
|
||||
require 'jison'
|
||||
parser = require('./lib/coffee-script/grammar').parser
|
||||
fs.writeFile 'lib/coffee-script/parser.js', parser.generate()
|
||||
fs.writeFileSync 'lib/coffee-script/parser.js', parser.generate()
|
||||
|
||||
|
||||
task 'build:browser', 'rebuild the merged script for inclusion in the browser', ->
|
||||
code = ''
|
||||
code = """
|
||||
require['../../package.json'] = (function() {
|
||||
return #{fs.readFileSync "./package.json"};
|
||||
})();
|
||||
"""
|
||||
for name in ['helpers', 'rewriter', 'lexer', 'parser', 'scope', 'nodes', 'sourcemap', 'coffee-script', 'browser']
|
||||
code += """
|
||||
require['./#{name}'] = (function() {
|
||||
@@ -134,34 +119,142 @@ task 'build:browser', 'rebuild the merged script for inclusion in the browser',
|
||||
}(this));
|
||||
"""
|
||||
unless process.env.MINIFY is 'false'
|
||||
{code} = require('uglify-js').minify code, fromString: true
|
||||
fs.writeFileSync 'extras/coffee-script.js', header + '\n' + code
|
||||
{compiledCode: code} = require('google-closure-compiler-js').compile
|
||||
jsCode: [
|
||||
src: code
|
||||
languageOut: if majorVersion is 1 then 'ES5' else 'ES6'
|
||||
]
|
||||
outputFolder = "docs/v#{majorVersion}/browser-compiler"
|
||||
fs.mkdirSync outputFolder unless fs.existsSync outputFolder
|
||||
fs.writeFileSync "#{outputFolder}/coffee-script.js", header + '\n' + code
|
||||
console.log "built ... running browser tests:"
|
||||
invoke 'test:browser'
|
||||
|
||||
|
||||
task 'doc:site', 'watch and continually rebuild the documentation for the website', ->
|
||||
source = 'documentation/index.html.js'
|
||||
exec 'bin/coffee -bc -o documentation/js documentation/coffee/*.coffee'
|
||||
# Constants
|
||||
indexFile = 'documentation/index.html'
|
||||
versionedSourceFolder = "documentation/v#{majorVersion}"
|
||||
sectionsSourceFolder = 'documentation/sections'
|
||||
examplesSourceFolder = 'documentation/examples'
|
||||
outputFolder = "docs/v#{majorVersion}"
|
||||
|
||||
# Helpers
|
||||
releaseHeader = (date, version, prevVersion) ->
|
||||
monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
|
||||
|
||||
formatDate = (date) ->
|
||||
date.replace /^(\d\d\d\d)-(\d\d)-(\d\d)$/, (match, $1, $2, $3) ->
|
||||
"#{monthNames[$2 - 1]} #{+$3}, #{$1}"
|
||||
|
||||
"""
|
||||
<div class="anchor" id="#{version}"></div>
|
||||
<h2 class="header">
|
||||
#{prevVersion and "<a href=\"https://github.com/jashkenas/coffeescript/compare/#{prevVersion}...#{version}\">#{version}</a>" or version}
|
||||
<span class="timestamp"> — <time datetime="#{date}">#{formatDate date}</time></span>
|
||||
</h2>
|
||||
"""
|
||||
|
||||
codeFor = require "./documentation/v#{majorVersion}/code.coffee"
|
||||
|
||||
htmlFor = ->
|
||||
marked = require 'marked'
|
||||
markdownRenderer = new marked.Renderer()
|
||||
markdownRenderer.heading = (text, level) ->
|
||||
"<h#{level}>#{text}</h#{level}>" # Don’t let marked add an id
|
||||
markdownRenderer.code = (code) ->
|
||||
if code.indexOf('codeFor(') is 0 or code.indexOf('releaseHeader(') is 0
|
||||
"<%= #{code} %>"
|
||||
else
|
||||
"<pre><code>#{code}</code></pre>" # Default
|
||||
|
||||
(file, bookmark) ->
|
||||
md = fs.readFileSync "#{sectionsSourceFolder}/#{file}.md", 'utf-8'
|
||||
md = md.replace /<%= releaseHeader %>/g, releaseHeader
|
||||
md = md.replace /<%= majorVersion %>/g, majorVersion
|
||||
md = md.replace /<%= fullVersion %>/g, CoffeeScript.VERSION
|
||||
html = marked md, renderer: markdownRenderer
|
||||
html = _.template(html)
|
||||
codeFor: codeFor()
|
||||
releaseHeader: releaseHeader
|
||||
|
||||
include = ->
|
||||
(file) ->
|
||||
file = "#{versionedSourceFolder}/#{file}" if file.indexOf('/') is -1
|
||||
output = fs.readFileSync file, 'utf-8'
|
||||
if /\.html$/.test(file)
|
||||
render = _.template output
|
||||
output = render
|
||||
releaseHeader: releaseHeader
|
||||
majorVersion: majorVersion
|
||||
fullVersion: CoffeeScript.VERSION
|
||||
htmlFor: htmlFor()
|
||||
codeFor: codeFor()
|
||||
include: include()
|
||||
output
|
||||
|
||||
# Task
|
||||
do renderIndex = ->
|
||||
codeSnippetCounter = 0
|
||||
rendered = _.template fs.readFileSync(source, 'utf-8'), codeFor: codeFor()
|
||||
fs.writeFileSync 'index.html', rendered
|
||||
log "compiled", green, "#{source}"
|
||||
render = _.template fs.readFileSync(indexFile, 'utf-8')
|
||||
output = render
|
||||
include: include()
|
||||
fs.writeFileSync "#{outputFolder}/index.html", output
|
||||
log 'compiled', green, "#{indexFile} → #{outputFolder}/index.html"
|
||||
try
|
||||
fs.symlinkSync "v#{majorVersion}/index.html", 'docs/index.html'
|
||||
catch exception
|
||||
|
||||
fs.watchFile source, internal: 200, renderIndex
|
||||
log "watching..." , green
|
||||
for target in [indexFile, versionedSourceFolder, examplesSourceFolder, sectionsSourceFolder]
|
||||
fs.watch target, interval: 200, renderIndex
|
||||
log 'watching...' , green
|
||||
|
||||
|
||||
task 'doc:source', 'rebuild the internal documentation', ->
|
||||
exec 'docco src/*.*coffee && cp -rf docs documentation && rm -r docs', (err) ->
|
||||
throw err if err
|
||||
task 'doc:test', 'watch and continually rebuild the browser-based tests', ->
|
||||
# Constants
|
||||
testFile = 'documentation/test.html'
|
||||
testsSourceFolder = 'test'
|
||||
outputFolder = "docs/v#{majorVersion}"
|
||||
|
||||
# Included in test.html
|
||||
testHelpers = fs.readFileSync('test/support/helpers.coffee', 'utf-8').replace /exports\./g, '@'
|
||||
|
||||
# Helpers
|
||||
testsInScriptBlocks = ->
|
||||
output = ''
|
||||
for filename in fs.readdirSync testsSourceFolder
|
||||
if filename.indexOf('.coffee') isnt -1
|
||||
type = 'coffeescript'
|
||||
else if filename.indexOf('.litcoffee') isnt -1
|
||||
type = 'literate-coffeescript'
|
||||
else
|
||||
continue
|
||||
|
||||
# Set the type to text/x-coffeescript or text/x-literate-coffeescript
|
||||
# to prevent the browser compiler from automatically running the script
|
||||
output += """
|
||||
<script type="text/x-#{type}" class="test" id="#{filename.split('.')[0]}">
|
||||
#{fs.readFileSync "test/#{filename}", 'utf-8'}
|
||||
</script>\n
|
||||
"""
|
||||
output
|
||||
|
||||
# Task
|
||||
do renderTest = ->
|
||||
render = _.template fs.readFileSync(testFile, 'utf-8')
|
||||
output = render
|
||||
testHelpers: testHelpers
|
||||
tests: testsInScriptBlocks()
|
||||
fs.writeFileSync "#{outputFolder}/test.html", output
|
||||
log 'compiled', green, "#{testFile} → #{outputFolder}/test.html"
|
||||
|
||||
for target in [testFile, testsSourceFolder]
|
||||
fs.watch target, interval: 200, renderTest
|
||||
log 'watching...' , green
|
||||
|
||||
|
||||
task 'doc:underscore', 'rebuild the Underscore.coffee documentation page', ->
|
||||
exec 'docco examples/underscore.coffee && cp -rf docs documentation && rm -r docs', (err) ->
|
||||
throw err if err
|
||||
task 'doc:source', 'rebuild the annotated source documentation', ->
|
||||
exec "node_modules/docco/bin/docco src/*.*coffee --output docs/v#{majorVersion}/annotated-source", (err) -> throw err if err
|
||||
|
||||
|
||||
task 'bench', 'quick benchmark of compilation time', ->
|
||||
{Rewriter} = require './lib/coffee-script/rewriter'
|
||||
@@ -212,23 +305,7 @@ runTests = (CoffeeScript) ->
|
||||
description: description if description?
|
||||
source: fn.toString() if fn.toString?
|
||||
|
||||
# See http://wiki.ecmascript.org/doku.php?id=harmony:egal
|
||||
egal = (a, b) ->
|
||||
if a is b
|
||||
a isnt 0 or 1/a is 1/b
|
||||
else
|
||||
a isnt a and b isnt b
|
||||
|
||||
# A recursive functional equivalence helper; uses egal for testing equivalence.
|
||||
arrayEgal = (a, b) ->
|
||||
if egal a, b then yes
|
||||
else if a instanceof Array and b instanceof Array
|
||||
return no unless a.length is b.length
|
||||
return no for el, idx in a when not arrayEgal el, b[idx]
|
||||
yes
|
||||
|
||||
global.eq = (a, b, msg) -> ok egal(a, b), msg ? "Expected #{a} to equal #{b}"
|
||||
global.arrayEq = (a, b, msg) -> ok arrayEgal(a,b), msg ? "Expected #{a} to deep equal #{b}"
|
||||
helpers.extend global, require './test/support/helpers'
|
||||
|
||||
# When all the tests have run, collect and print errors.
|
||||
# If a stacktrace is available, output the compiled function source.
|
||||
@@ -247,6 +324,7 @@ runTests = (CoffeeScript) ->
|
||||
|
||||
# Run every test in the `test` folder, recording failures.
|
||||
files = fs.readdirSync 'test'
|
||||
|
||||
for file in files when helpers.isCoffee file
|
||||
literate = helpers.isLiterate file
|
||||
currentFile = filename = path.join 'test', file
|
||||
@@ -263,7 +341,7 @@ task 'test', 'run the CoffeeScript language test suite', ->
|
||||
|
||||
|
||||
task 'test:browser', 'run the test suite against the merged browser script', ->
|
||||
source = fs.readFileSync 'extras/coffee-script.js', 'utf-8'
|
||||
source = fs.readFileSync "docs/v#{majorVersion}/browser-compiler/coffee-script.js", 'utf-8'
|
||||
result = {}
|
||||
global.testingBrowser = yes
|
||||
(-> eval source).call result
|
||||
|
||||
2
LICENSE
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2009-2014 Jeremy Ashkenas
|
||||
Copyright (c) 2009-2015 Jeremy Ashkenas
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
|
||||
@@ -18,33 +18,45 @@
|
||||
`-.._________..-' | |
|
||||
|_|
|
||||
|
||||
CoffeeScript is a little language that compiles into JavaScript.
|
||||
|
||||
CoffeeScript is a little language that compiles into JavaScript.
|
||||
## Installation
|
||||
|
||||
If you have the Node Package Manager installed:
|
||||
npm install -g coffee-script
|
||||
(Leave off the -g if you don't wish to install globally.)
|
||||
If you have the node package manager, npm, installed:
|
||||
|
||||
Or, if you don't wish to use npm:
|
||||
sudo bin/cake install
|
||||
```shell
|
||||
npm install -g coffee-script
|
||||
```
|
||||
|
||||
Execute a script:
|
||||
coffee /path/to/script.coffee
|
||||
Leave off the `-g` if you don't wish to install globally. If you don't wish to use npm:
|
||||
|
||||
Compile a script:
|
||||
coffee -c /path/to/script.coffee
|
||||
```shell
|
||||
git clone https://github.com/jashkenas/coffeescript.git
|
||||
sudo coffeescript/bin/cake install
|
||||
```
|
||||
|
||||
For documentation, usage, and examples, see:
|
||||
http://coffeescript.org/
|
||||
## Getting Started
|
||||
|
||||
To suggest a feature, report a bug, or general discussion:
|
||||
http://github.com/jashkenas/coffee-script/issues/
|
||||
Execute a script:
|
||||
|
||||
If you'd like to chat, drop by #coffeescript on Freenode IRC,
|
||||
or on webchat.freenode.net.
|
||||
```shell
|
||||
coffee /path/to/script.coffee
|
||||
```
|
||||
|
||||
The source repository:
|
||||
git://github.com/jashkenas/coffee-script.git
|
||||
Compile a script:
|
||||
|
||||
Top 100 contributors are listed here:
|
||||
http://github.com/jashkenas/coffee-script/contributors
|
||||
```shell
|
||||
coffee -c /path/to/script.coffee
|
||||
```
|
||||
|
||||
For documentation, usage, and examples, see: http://coffeescript.org/
|
||||
|
||||
To suggest a feature or report a bug: http://github.com/jashkenas/coffeescript/issues
|
||||
|
||||
If you'd like to chat, drop by #coffeescript on Freenode IRC.
|
||||
|
||||
The source repository: https://github.com/jashkenas/coffeescript.git
|
||||
|
||||
Changelog: http://coffeescript.org/#changelog
|
||||
|
||||
Our lovely and talented contributors are listed here: http://github.com/jashkenas/coffeescript/contributors
|
||||
19
bower.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "coffee-script",
|
||||
"main": [
|
||||
"lib/coffee-script/coffee-script.js"
|
||||
],
|
||||
"description": "Unfancy JavaScript",
|
||||
"keywords": [
|
||||
"javascript",
|
||||
"language",
|
||||
"coffeescript",
|
||||
"compiler"
|
||||
],
|
||||
"author": {
|
||||
"name": "Jeremy Ashkenas"
|
||||
},
|
||||
"ignore": [
|
||||
"test"
|
||||
]
|
||||
}
|
||||
1
docs/CNAME
Normal file
@@ -0,0 +1 @@
|
||||
coffeescript.org
|
||||
BIN
docs/android-chrome-192x192.png
Normal file
|
After Width: | Height: | Size: 7.8 KiB |
BIN
docs/android-chrome-512x512.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
docs/apple-touch-icon.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
9
docs/browserconfig.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<browserconfig>
|
||||
<msapplication>
|
||||
<tile>
|
||||
<square150x150logo src="/mstile-150x150.png"/>
|
||||
<TileColor>#da532c</TileColor>
|
||||
</tile>
|
||||
</msapplication>
|
||||
</browserconfig>
|
||||
BIN
docs/favicon-16x16.png
Normal file
|
After Width: | Height: | Size: 987 B |
BIN
docs/favicon-32x32.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
docs/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
1
docs/index.html
Symbolic link
@@ -0,0 +1 @@
|
||||
v1/index.html
|
||||
17
docs/manifest.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "",
|
||||
"icons": [
|
||||
{
|
||||
"src": "\/android-chrome-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image\/png"
|
||||
},
|
||||
{
|
||||
"src": "\/android-chrome-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image\/png"
|
||||
}
|
||||
],
|
||||
"theme_color": "#ffffff",
|
||||
"display": "standalone"
|
||||
}
|
||||
BIN
docs/mstile-150x150.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
44
docs/safari-pinned-tab.svg
Normal file
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
||||
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
||||
width="916.000000pt" height="916.000000pt" viewBox="0 0 916.000000 916.000000"
|
||||
preserveAspectRatio="xMidYMid meet">
|
||||
<metadata>
|
||||
Created by potrace 1.11, written by Peter Selinger 2001-2013
|
||||
</metadata>
|
||||
<g transform="translate(0.000000,916.000000) scale(0.100000,-0.100000)"
|
||||
fill="#000000" stroke="none">
|
||||
<path d="M5555 8253 c-199 -8 -487 -49 -670 -94 -283 -70 -464 -155 -829 -387
|
||||
-307 -196 -461 -259 -721 -297 -134 -20 -345 -19 -442 1 -160 33 -243 104
|
||||
-243 208 0 59 38 103 118 139 159 72 516 78 707 11 l70 -24 40 28 c94 66 62
|
||||
162 -73 213 -90 34 -196 48 -352 48 -404 1 -684 -104 -767 -286 -22 -48 -25
|
||||
-65 -21 -138 8 -147 86 -267 241 -368 192 -125 402 -184 702 -194 248 -9 474
|
||||
23 699 99 148 50 244 94 565 262 375 197 551 266 806 319 207 43 297 52 535
|
||||
51 194 0 238 -3 319 -22 199 -46 311 -131 311 -235 0 -125 -160 -221 -435
|
||||
-262 -333 -50 -606 26 -685 191 -25 50 -31 52 -128 29 -258 -61 -317 -257
|
||||
-117 -390 157 -104 371 -149 700 -149 539 1 944 133 1084 352 108 171 68 386
|
||||
-105 557 -195 192 -518 305 -959 335 -143 9 -193 10 -350 3z"/>
|
||||
<path d="M1095 7556 c-323 -132 -512 -261 -576 -391 -35 -73 -33 -161 5 -235
|
||||
139 -267 715 -511 1644 -696 1114 -222 2726 -285 4162 -163 584 49 1082 129
|
||||
1590 255 590 146 1001 330 1155 518 135 165 92 351 -120 513 -68 52 -250 153
|
||||
-276 153 -7 0 1 -15 18 -32 74 -77 93 -189 48 -286 -88 -189 -401 -351 -950
|
||||
-491 -589 -149 -1176 -233 -2060 -293 -302 -21 -1490 -17 -1815 5 -988 68
|
||||
-1692 183 -2240 366 -363 122 -575 252 -646 397 -58 118 -25 250 88 357 34 31
|
||||
59 57 57 57 -2 -1 -40 -16 -84 -34z"/>
|
||||
<path d="M554 6215 c42 -244 59 -335 76 -415 53 -243 141 -560 215 -779 19
|
||||
-58 35 -108 35 -112 0 -4 -43 -38 -97 -75 -176 -126 -380 -340 -500 -527 -113
|
||||
-176 -202 -394 -245 -602 -20 -96 -23 -139 -23 -330 0 -198 3 -229 24 -315 47
|
||||
-189 122 -347 237 -500 235 -313 529 -501 879 -560 109 -19 341 -14 475 9 106
|
||||
18 460 129 484 152 6 5 -15 9 -50 9 -158 0 -384 62 -556 152 -224 117 -495
|
||||
354 -622 546 -119 178 -177 338 -216 592 -62 402 38 761 288 1030 l60 65 22
|
||||
-50 c175 -407 322 -695 457 -894 59 -86 238 -340 398 -566 414 -584 421 -593
|
||||
471 -701 97 -210 179 -432 220 -599 19 -80 58 -137 172 -252 180 -182 363
|
||||
-282 727 -398 303 -96 462 -132 770 -177 128 -18 1029 -18 1175 0 304 39 499
|
||||
81 780 169 266 83 422 160 600 294 77 58 207 185 257 251 15 20 35 38 43 41
|
||||
10 2 21 34 33 93 37 180 111 402 199 595 23 50 146 230 360 530 518 724 597
|
||||
846 743 1142 270 549 475 1133 614 1752 45 203 92 447 88 452 -2 2 -22 -19
|
||||
-45 -46 -153 -181 -518 -355 -1007 -479 -1503 -383 -3714 -462 -5485 -196
|
||||
-390 58 -751 129 -988 195 -511 141 -861 305 -1025 482 -46 50 -48 51 -43 22z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
299
docs/v1/annotated-source/browser.html
Normal file
@@ -0,0 +1,299 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>browser.coffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="register.html">
|
||||
register.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>browser.coffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
<p>This <strong>Browser</strong> compatibility layer extends core CoffeeScript functions
|
||||
to make things work smoothly when compiling code directly in the browser.
|
||||
We add support for loading remote Coffee scripts via <strong>XHR</strong>, and
|
||||
<code>text/coffeescript</code> script tags, source maps via data-URLs, and so on.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffee-script'</span>
|
||||
CoffeeScript.<span class="hljs-built_in">require</span> = <span class="hljs-built_in">require</span>
|
||||
compile = CoffeeScript.compile</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-2">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-2">¶</a>
|
||||
</div>
|
||||
<p>Use standard JavaScript <code>eval</code> to eval code.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>CoffeeScript.eval = <span class="hljs-function"><span class="hljs-params">(code, options = {})</span> -></span>
|
||||
options.bare ?= <span class="hljs-literal">on</span>
|
||||
eval compile code, options</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-3">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-3">¶</a>
|
||||
</div>
|
||||
<p>Running code does not provide access to this scope.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>CoffeeScript.run = <span class="hljs-function"><span class="hljs-params">(code, options = {})</span> -></span>
|
||||
options.bare = <span class="hljs-literal">on</span>
|
||||
options.shiftLine = <span class="hljs-literal">on</span>
|
||||
Function(compile code, options)()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-4">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-4">¶</a>
|
||||
</div>
|
||||
<p>If we’re not in a browser environment, we’re finished with the public API.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> <span class="hljs-built_in">window</span>?</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-5">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-5">¶</a>
|
||||
</div>
|
||||
<p>Include source maps where possible. If we’ve got a base64 encoder, a
|
||||
JSON serializer, and tools for escaping unicode characters, we’re good to go.
|
||||
Ported from <a href="https://developer.mozilla.org/en-US/docs/DOM/window.btoa">https://developer.mozilla.org/en-US/docs/DOM/window.btoa</a></p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> btoa? <span class="hljs-keyword">and</span> JSON?
|
||||
<span class="hljs-function"> <span class="hljs-title">compile</span> = <span class="hljs-params">(code, options = {})</span> -></span>
|
||||
options.inlineMap = <span class="hljs-literal">true</span>
|
||||
CoffeeScript.compile code, options</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-6">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-6">¶</a>
|
||||
</div>
|
||||
<p>Load a remote script from the current domain via XHR.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>CoffeeScript.load = <span class="hljs-function"><span class="hljs-params">(url, callback, options = {}, hold = <span class="hljs-literal">false</span>)</span> -></span>
|
||||
options.sourceFiles = [url]
|
||||
xhr = <span class="hljs-keyword">if</span> <span class="hljs-built_in">window</span>.ActiveXObject
|
||||
<span class="hljs-keyword">new</span> <span class="hljs-built_in">window</span>.ActiveXObject(<span class="hljs-string">'Microsoft.XMLHTTP'</span>)
|
||||
<span class="hljs-keyword">else</span>
|
||||
<span class="hljs-keyword">new</span> <span class="hljs-built_in">window</span>.XMLHttpRequest()
|
||||
xhr.open <span class="hljs-string">'GET'</span>, url, <span class="hljs-literal">true</span>
|
||||
xhr.overrideMimeType <span class="hljs-string">'text/plain'</span> <span class="hljs-keyword">if</span> <span class="hljs-string">'overrideMimeType'</span> <span class="hljs-keyword">of</span> xhr
|
||||
xhr.onreadystatechange = <span class="hljs-function">-></span>
|
||||
<span class="hljs-keyword">if</span> xhr.readyState <span class="hljs-keyword">is</span> <span class="hljs-number">4</span>
|
||||
<span class="hljs-keyword">if</span> xhr.status <span class="hljs-keyword">in</span> [<span class="hljs-number">0</span>, <span class="hljs-number">200</span>]
|
||||
param = [xhr.responseText, options]
|
||||
CoffeeScript.run param... <span class="hljs-keyword">unless</span> hold
|
||||
<span class="hljs-keyword">else</span>
|
||||
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"Could not load <span class="hljs-subst">#{url}</span>"</span>
|
||||
callback param <span class="hljs-keyword">if</span> callback
|
||||
xhr.send <span class="hljs-literal">null</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-7">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-7">¶</a>
|
||||
</div>
|
||||
<p>Activate CoffeeScript in the browser by having it compile and evaluate
|
||||
all script tags with a content-type of <code>text/coffeescript</code>.
|
||||
This happens on page load.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">runScripts</span> = -></span>
|
||||
scripts = <span class="hljs-built_in">window</span>.<span class="hljs-built_in">document</span>.getElementsByTagName <span class="hljs-string">'script'</span>
|
||||
coffeetypes = [<span class="hljs-string">'text/coffeescript'</span>, <span class="hljs-string">'text/literate-coffeescript'</span>]
|
||||
coffees = (s <span class="hljs-keyword">for</span> s <span class="hljs-keyword">in</span> scripts <span class="hljs-keyword">when</span> s.type <span class="hljs-keyword">in</span> coffeetypes)
|
||||
index = <span class="hljs-number">0</span>
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">execute</span> = -></span>
|
||||
param = coffees[index]
|
||||
<span class="hljs-keyword">if</span> param <span class="hljs-keyword">instanceof</span> Array
|
||||
CoffeeScript.run param...
|
||||
index++
|
||||
execute()
|
||||
|
||||
<span class="hljs-keyword">for</span> script, i <span class="hljs-keyword">in</span> coffees
|
||||
<span class="hljs-keyword">do</span> (script, i) ->
|
||||
options = literate: script.type <span class="hljs-keyword">is</span> coffeetypes[<span class="hljs-number">1</span>]
|
||||
source = script.src <span class="hljs-keyword">or</span> script.getAttribute(<span class="hljs-string">'data-src'</span>)
|
||||
<span class="hljs-keyword">if</span> source
|
||||
CoffeeScript.load source,
|
||||
<span class="hljs-function"><span class="hljs-params">(param)</span> -></span>
|
||||
coffees[i] = param
|
||||
execute()
|
||||
options
|
||||
<span class="hljs-literal">true</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
options.sourceFiles = [<span class="hljs-string">'embedded'</span>]
|
||||
coffees[i] = [script.innerHTML, options]
|
||||
|
||||
execute()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
<p>Listen for window load, both in decent browsers and in IE.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> <span class="hljs-built_in">window</span>.addEventListener
|
||||
<span class="hljs-built_in">window</span>.addEventListener <span class="hljs-string">'DOMContentLoaded'</span>, runScripts, <span class="hljs-literal">no</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
<span class="hljs-built_in">window</span>.attachEvent <span class="hljs-string">'onload'</span>, runScripts</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
345
docs/v1/annotated-source/cake.html
Normal file
@@ -0,0 +1,345 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>cake.coffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="register.html">
|
||||
register.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>cake.coffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
<p><code>cake</code> is a simplified version of <a href="http://www.gnu.org/software/make/">Make</a>
|
||||
(<a href="http://rake.rubyforge.org/">Rake</a>, <a href="http://github.com/280north/jake">Jake</a>)
|
||||
for CoffeeScript. You define tasks with names and descriptions in a Cakefile,
|
||||
and can call them from the command line, or invoke them from other tasks.</p>
|
||||
<p>Running <code>cake</code> with no arguments will print out a list of all the tasks in the
|
||||
current directory’s Cakefile.</p>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-2">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-2">¶</a>
|
||||
</div>
|
||||
<p>External dependencies.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>fs = <span class="hljs-built_in">require</span> <span class="hljs-string">'fs'</span>
|
||||
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span>
|
||||
helpers = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span>
|
||||
optparse = <span class="hljs-built_in">require</span> <span class="hljs-string">'./optparse'</span>
|
||||
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffee-script'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-3">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-3">¶</a>
|
||||
</div>
|
||||
<p>Register .coffee extension</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>CoffeeScript.register()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-4">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-4">¶</a>
|
||||
</div>
|
||||
<p>Keep track of the list of defined tasks, the accepted options, and so on.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>tasks = {}
|
||||
options = {}
|
||||
switches = []
|
||||
oparse = <span class="hljs-literal">null</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-5">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-5">¶</a>
|
||||
</div>
|
||||
<p>Mixin the top-level Cake functions for Cakefiles to use directly.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>helpers.extend <span class="hljs-built_in">global</span>,</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-6">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-6">¶</a>
|
||||
</div>
|
||||
<p>Define a Cake task with a short name, an optional sentence description,
|
||||
and the function to run as the action itself.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> task: <span class="hljs-function"><span class="hljs-params">(name, description, action)</span> -></span>
|
||||
[action, description] = [description, action] <span class="hljs-keyword">unless</span> action
|
||||
tasks[name] = {name, description, action}</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-7">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-7">¶</a>
|
||||
</div>
|
||||
<p>Define an option that the Cakefile accepts. The parsed options hash,
|
||||
containing all of the command-line options passed, will be made available
|
||||
as the first argument to the action.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> option: <span class="hljs-function"><span class="hljs-params">(letter, flag, description)</span> -></span>
|
||||
switches.push [letter, flag, description]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
<p>Invoke another task in the current Cakefile.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> invoke: <span class="hljs-function"><span class="hljs-params">(name)</span> -></span>
|
||||
missingTask name <span class="hljs-keyword">unless</span> tasks[name]
|
||||
tasks[name].action options</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-9">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
</div>
|
||||
<p>Run <code>cake</code>. Executes all of the tasks you pass, in order. Note that Node’s
|
||||
asynchrony may cause tasks to execute in a different order than you’d expect.
|
||||
If no tasks are passed, print the help screen. Keep a reference to the
|
||||
original directory name, when running Cake tasks from subdirectories.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.run = <span class="hljs-function">-></span>
|
||||
<span class="hljs-built_in">global</span>.__originalDirname = fs.realpathSync <span class="hljs-string">'.'</span>
|
||||
process.chdir cakefileDirectory __originalDirname
|
||||
args = process.argv[<span class="hljs-number">2.</span>.]
|
||||
CoffeeScript.run fs.readFileSync(<span class="hljs-string">'Cakefile'</span>).toString(), filename: <span class="hljs-string">'Cakefile'</span>
|
||||
oparse = <span class="hljs-keyword">new</span> optparse.OptionParser switches
|
||||
<span class="hljs-keyword">return</span> printTasks() <span class="hljs-keyword">unless</span> args.length
|
||||
<span class="hljs-keyword">try</span>
|
||||
options = oparse.parse(args)
|
||||
<span class="hljs-keyword">catch</span> e
|
||||
<span class="hljs-keyword">return</span> fatalError <span class="hljs-string">"<span class="hljs-subst">#{e}</span>"</span>
|
||||
invoke arg <span class="hljs-keyword">for</span> arg <span class="hljs-keyword">in</span> options.arguments</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-10">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
</div>
|
||||
<p>Display the list of Cake tasks in a format similar to <code>rake -T</code></p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">printTasks</span> = -></span>
|
||||
relative = path.relative <span class="hljs-keyword">or</span> path.resolve
|
||||
cakefilePath = path.join relative(__originalDirname, process.cwd()), <span class="hljs-string">'Cakefile'</span>
|
||||
<span class="hljs-built_in">console</span>.log <span class="hljs-string">"<span class="hljs-subst">#{cakefilePath}</span> defines the following tasks:\n"</span>
|
||||
<span class="hljs-keyword">for</span> name, task <span class="hljs-keyword">of</span> tasks
|
||||
spaces = <span class="hljs-number">20</span> - name.length
|
||||
spaces = <span class="hljs-keyword">if</span> spaces > <span class="hljs-number">0</span> <span class="hljs-keyword">then</span> Array(spaces + <span class="hljs-number">1</span>).join(<span class="hljs-string">' '</span>) <span class="hljs-keyword">else</span> <span class="hljs-string">''</span>
|
||||
desc = <span class="hljs-keyword">if</span> task.description <span class="hljs-keyword">then</span> <span class="hljs-string">"# <span class="hljs-subst">#{task.description}</span>"</span> <span class="hljs-keyword">else</span> <span class="hljs-string">''</span>
|
||||
<span class="hljs-built_in">console</span>.log <span class="hljs-string">"cake <span class="hljs-subst">#{name}</span><span class="hljs-subst">#{spaces}</span> <span class="hljs-subst">#{desc}</span>"</span>
|
||||
<span class="hljs-built_in">console</span>.log oparse.help() <span class="hljs-keyword">if</span> switches.length</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-11">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
</div>
|
||||
<p>Print an error and exit when attempting to use an invalid task/option.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">fatalError</span> = <span class="hljs-params">(message)</span> -></span>
|
||||
<span class="hljs-built_in">console</span>.error message + <span class="hljs-string">'\n'</span>
|
||||
<span class="hljs-built_in">console</span>.log <span class="hljs-string">'To see a list of all tasks/options, run "cake"'</span>
|
||||
process.exit <span class="hljs-number">1</span>
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">missingTask</span> = <span class="hljs-params">(task)</span> -></span> fatalError <span class="hljs-string">"No such task: <span class="hljs-subst">#{task}</span>"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-12">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
</div>
|
||||
<p>When <code>cake</code> is invoked, search in the current and all parent directories
|
||||
to find the relevant Cakefile.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">cakefileDirectory</span> = <span class="hljs-params">(dir)</span> -></span>
|
||||
<span class="hljs-keyword">return</span> dir <span class="hljs-keyword">if</span> fs.existsSync path.join dir, <span class="hljs-string">'Cakefile'</span>
|
||||
parent = path.normalize path.join dir, <span class="hljs-string">'..'</span>
|
||||
<span class="hljs-keyword">return</span> cakefileDirectory parent <span class="hljs-keyword">unless</span> parent <span class="hljs-keyword">is</span> dir
|
||||
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"Cakefile not found in <span class="hljs-subst">#{process.cwd()}</span>"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
778
docs/v1/annotated-source/coffee-script.html
Normal file
@@ -0,0 +1,778 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>coffee-script.coffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="register.html">
|
||||
register.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>coffee-script.coffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
<p>CoffeeScript can be used both on the server, as a command-line compiler based
|
||||
on Node.js/V8, or to run CoffeeScript directly in the browser. This module
|
||||
contains the main entry functions for tokenizing, parsing, and compiling
|
||||
source CoffeeScript into JavaScript.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
fs = <span class="hljs-built_in">require</span> <span class="hljs-string">'fs'</span>
|
||||
vm = <span class="hljs-built_in">require</span> <span class="hljs-string">'vm'</span>
|
||||
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span>
|
||||
{Lexer} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./lexer'</span>
|
||||
{parser} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./parser'</span>
|
||||
helpers = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span>
|
||||
SourceMap = <span class="hljs-built_in">require</span> <span class="hljs-string">'./sourcemap'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-2">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-2">¶</a>
|
||||
</div>
|
||||
<p>Require <code>package.json</code>, which is two levels above this file, as this file is
|
||||
evaluated from <code>lib/coffee-script</code>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>packageJson = <span class="hljs-built_in">require</span> <span class="hljs-string">'../../package.json'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-3">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-3">¶</a>
|
||||
</div>
|
||||
<p>The current CoffeeScript version number.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.VERSION = packageJson.version
|
||||
|
||||
exports.FILE_EXTENSIONS = [<span class="hljs-string">'.coffee'</span>, <span class="hljs-string">'.litcoffee'</span>, <span class="hljs-string">'.coffee.md'</span>]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-4">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-4">¶</a>
|
||||
</div>
|
||||
<p>Expose helpers for testing.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.helpers = helpers</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-5">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-5">¶</a>
|
||||
</div>
|
||||
<p>Function that allows for btoa in both nodejs and the browser.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">base64encode</span> = <span class="hljs-params">(src)</span> -></span> <span class="hljs-keyword">switch</span>
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-keyword">typeof</span> Buffer <span class="hljs-keyword">is</span> <span class="hljs-string">'function'</span>
|
||||
<span class="hljs-keyword">new</span> Buffer(src).toString(<span class="hljs-string">'base64'</span>)
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-keyword">typeof</span> btoa <span class="hljs-keyword">is</span> <span class="hljs-string">'function'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-6">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-6">¶</a>
|
||||
</div>
|
||||
<p>The contents of a <code><script></code> block are encoded via UTF-16, so if any extended
|
||||
characters are used in the block, btoa will fail as it maxes out at UTF-8.
|
||||
See <a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem">https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem</a>
|
||||
for the gory details, and for the solution implemented here.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> btoa encodeURIComponent(src).replace <span class="hljs-regexp">/%([0-9A-F]{2})/g</span>, <span class="hljs-function"><span class="hljs-params">(match, p1)</span> -></span>
|
||||
String.fromCharCode <span class="hljs-string">'0x'</span> + p1
|
||||
<span class="hljs-keyword">else</span>
|
||||
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error(<span class="hljs-string">'Unable to base64 encode inline sourcemap.'</span>)</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-7">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-7">¶</a>
|
||||
</div>
|
||||
<p>Function wrapper to add source file information to SyntaxErrors thrown by the
|
||||
lexer/parser/compiler.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">withPrettyErrors</span> = <span class="hljs-params">(fn)</span> -></span>
|
||||
(code, options = {}) ->
|
||||
<span class="hljs-keyword">try</span>
|
||||
fn.call @, code, options
|
||||
<span class="hljs-keyword">catch</span> err
|
||||
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">if</span> <span class="hljs-keyword">typeof</span> code <span class="hljs-keyword">isnt</span> <span class="hljs-string">'string'</span> <span class="hljs-comment"># Support `CoffeeScript.nodes(tokens)`.</span>
|
||||
<span class="hljs-keyword">throw</span> helpers.updateSyntaxError err, code, options.filename</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
<p>Compile CoffeeScript code to JavaScript, using the Coffee/Jison compiler.</p>
|
||||
<p>If <code>options.sourceMap</code> is specified, then <code>options.filename</code> must also be specified. All
|
||||
options that can be passed to <code>SourceMap#generate</code> may also be passed here.</p>
|
||||
<p>This returns a javascript string, unless <code>options.sourceMap</code> is passed,
|
||||
in which case this returns a <code>{js, v3SourceMap, sourceMap}</code>
|
||||
object, where sourceMap is a sourcemap.coffee#SourceMap object, handy for doing programatic
|
||||
lookups.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.compile = compile = withPrettyErrors (code, options) ->
|
||||
{merge, extend} = helpers
|
||||
options = extend {}, options
|
||||
generateSourceMap = options.sourceMap <span class="hljs-keyword">or</span> options.inlineMap
|
||||
|
||||
<span class="hljs-keyword">if</span> generateSourceMap
|
||||
map = <span class="hljs-keyword">new</span> SourceMap
|
||||
|
||||
tokens = lexer.tokenize code, options</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-9">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
</div>
|
||||
<p>Pass a list of referenced variables, so that generated variables won’t get
|
||||
the same name.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> options.referencedVars = (
|
||||
token[<span class="hljs-number">1</span>] <span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> tokens <span class="hljs-keyword">when</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'IDENTIFIER'</span>
|
||||
)</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-10">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
</div>
|
||||
<p>Check for import or export; if found, force bare mode</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">unless</span> options.bare? <span class="hljs-keyword">and</span> options.bare <span class="hljs-keyword">is</span> <span class="hljs-literal">yes</span>
|
||||
<span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> tokens
|
||||
<span class="hljs-keyword">if</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> [<span class="hljs-string">'IMPORT'</span>, <span class="hljs-string">'EXPORT'</span>]
|
||||
options.bare = <span class="hljs-literal">yes</span>
|
||||
<span class="hljs-keyword">break</span>
|
||||
|
||||
fragments = parser.parse(tokens).compileToFragments options
|
||||
|
||||
currentLine = <span class="hljs-number">0</span>
|
||||
currentLine += <span class="hljs-number">1</span> <span class="hljs-keyword">if</span> options.header
|
||||
currentLine += <span class="hljs-number">1</span> <span class="hljs-keyword">if</span> options.shiftLine
|
||||
currentColumn = <span class="hljs-number">0</span>
|
||||
js = <span class="hljs-string">""</span>
|
||||
<span class="hljs-keyword">for</span> fragment <span class="hljs-keyword">in</span> fragments</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-11">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
</div>
|
||||
<p>Update the sourcemap with data from each fragment</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> generateSourceMap</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-12">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
</div>
|
||||
<p>Do not include empty, whitespace, or semicolon-only fragments.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> fragment.locationData <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> <span class="hljs-regexp">/^[;\s]*$/</span>.test fragment.code
|
||||
map.add(
|
||||
[fragment.locationData.first_line, fragment.locationData.first_column]
|
||||
[currentLine, currentColumn]
|
||||
{noReplace: <span class="hljs-literal">true</span>})
|
||||
newLines = helpers.count fragment.code, <span class="hljs-string">"\n"</span>
|
||||
currentLine += newLines
|
||||
<span class="hljs-keyword">if</span> newLines
|
||||
currentColumn = fragment.code.length - (fragment.code.lastIndexOf(<span class="hljs-string">"\n"</span>) + <span class="hljs-number">1</span>)
|
||||
<span class="hljs-keyword">else</span>
|
||||
currentColumn += fragment.code.length</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-13">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-13">¶</a>
|
||||
</div>
|
||||
<p>Copy the code from each fragment into the final JavaScript.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> js += fragment.code
|
||||
|
||||
<span class="hljs-keyword">if</span> options.header
|
||||
header = <span class="hljs-string">"Generated by CoffeeScript <span class="hljs-subst">#{@VERSION}</span>"</span>
|
||||
js = <span class="hljs-string">"// <span class="hljs-subst">#{header}</span>\n<span class="hljs-subst">#{js}</span>"</span>
|
||||
|
||||
<span class="hljs-keyword">if</span> generateSourceMap
|
||||
v3SourceMap = map.generate(options, code)
|
||||
|
||||
<span class="hljs-keyword">if</span> options.inlineMap
|
||||
encoded = base64encode JSON.stringify v3SourceMap
|
||||
sourceMapDataURI = <span class="hljs-string">"//# sourceMappingURL=data:application/json;base64,<span class="hljs-subst">#{encoded}</span>"</span>
|
||||
sourceURL = <span class="hljs-string">"//# sourceURL=<span class="hljs-subst">#{options.filename ? <span class="hljs-string">'coffeescript'</span>}</span>"</span>
|
||||
js = <span class="hljs-string">"<span class="hljs-subst">#{js}</span>\n<span class="hljs-subst">#{sourceMapDataURI}</span>\n<span class="hljs-subst">#{sourceURL}</span>"</span>
|
||||
|
||||
<span class="hljs-keyword">if</span> options.sourceMap
|
||||
{
|
||||
js
|
||||
sourceMap: map
|
||||
v3SourceMap: JSON.stringify v3SourceMap, <span class="hljs-literal">null</span>, <span class="hljs-number">2</span>
|
||||
}
|
||||
<span class="hljs-keyword">else</span>
|
||||
js</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-14">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-14">¶</a>
|
||||
</div>
|
||||
<p>Tokenize a string of CoffeeScript code, and return the array of tokens.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.tokens = withPrettyErrors (code, options) ->
|
||||
lexer.tokenize code, options</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-15">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
</div>
|
||||
<p>Parse a string of CoffeeScript code or an array of lexed tokens, and
|
||||
return the AST. You can then compile it by calling <code>.compile()</code> on the root,
|
||||
or traverse it by using <code>.traverseChildren()</code> with a callback.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.nodes = withPrettyErrors (source, options) ->
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-keyword">typeof</span> source <span class="hljs-keyword">is</span> <span class="hljs-string">'string'</span>
|
||||
parser.parse lexer.tokenize source, options
|
||||
<span class="hljs-keyword">else</span>
|
||||
parser.parse source</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-16">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-16">¶</a>
|
||||
</div>
|
||||
<p>Compile and execute a string of CoffeeScript (on the server), correctly
|
||||
setting <code>__filename</code>, <code>__dirname</code>, and relative <code>require()</code>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.run = <span class="hljs-function"><span class="hljs-params">(code, options = {})</span> -></span>
|
||||
mainModule = <span class="hljs-built_in">require</span>.main</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-17">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-17">¶</a>
|
||||
</div>
|
||||
<p>Set the filename.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> mainModule.filename = process.argv[<span class="hljs-number">1</span>] =
|
||||
<span class="hljs-keyword">if</span> options.filename <span class="hljs-keyword">then</span> fs.realpathSync(options.filename) <span class="hljs-keyword">else</span> <span class="hljs-string">'.'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-18">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
</div>
|
||||
<p>Clear the module cache.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> mainModule.moduleCache <span class="hljs-keyword">and</span>= {}</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-19">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-19">¶</a>
|
||||
</div>
|
||||
<p>Assign paths for node_modules loading</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> dir = <span class="hljs-keyword">if</span> options.filename
|
||||
path.dirname fs.realpathSync options.filename
|
||||
<span class="hljs-keyword">else</span>
|
||||
fs.realpathSync <span class="hljs-string">'.'</span>
|
||||
mainModule.paths = <span class="hljs-built_in">require</span>(<span class="hljs-string">'module'</span>)._nodeModulePaths dir</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-20">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-20">¶</a>
|
||||
</div>
|
||||
<p>Compile.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> helpers.isCoffee(mainModule.filename) <span class="hljs-keyword">or</span> <span class="hljs-built_in">require</span>.extensions
|
||||
answer = compile code, options
|
||||
code = answer.js ? answer
|
||||
|
||||
mainModule._compile code, mainModule.filename</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-21">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-21">¶</a>
|
||||
</div>
|
||||
<p>Compile and evaluate a string of CoffeeScript (in a Node.js-like environment).
|
||||
The CoffeeScript REPL uses this to run the input.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.eval = <span class="hljs-function"><span class="hljs-params">(code, options = {})</span> -></span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> code = code.trim()
|
||||
createContext = vm.Script.createContext ? vm.createContext
|
||||
|
||||
isContext = vm.isContext ? (ctx) ->
|
||||
options.sandbox <span class="hljs-keyword">instanceof</span> createContext().constructor
|
||||
|
||||
<span class="hljs-keyword">if</span> createContext
|
||||
<span class="hljs-keyword">if</span> options.sandbox?
|
||||
<span class="hljs-keyword">if</span> isContext options.sandbox
|
||||
sandbox = options.sandbox
|
||||
<span class="hljs-keyword">else</span>
|
||||
sandbox = createContext()
|
||||
sandbox[k] = v <span class="hljs-keyword">for</span> own k, v <span class="hljs-keyword">of</span> options.sandbox
|
||||
sandbox.<span class="hljs-built_in">global</span> = sandbox.root = sandbox.GLOBAL = sandbox
|
||||
<span class="hljs-keyword">else</span>
|
||||
sandbox = <span class="hljs-built_in">global</span>
|
||||
sandbox.__filename = options.filename || <span class="hljs-string">'eval'</span>
|
||||
sandbox.__dirname = path.dirname sandbox.__filename</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-22">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-22">¶</a>
|
||||
</div>
|
||||
<p>define module/require only if they chose not to specify their own</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">unless</span> sandbox <span class="hljs-keyword">isnt</span> <span class="hljs-built_in">global</span> <span class="hljs-keyword">or</span> sandbox.<span class="hljs-built_in">module</span> <span class="hljs-keyword">or</span> sandbox.<span class="hljs-built_in">require</span>
|
||||
Module = <span class="hljs-built_in">require</span> <span class="hljs-string">'module'</span>
|
||||
sandbox.<span class="hljs-built_in">module</span> = _module = <span class="hljs-keyword">new</span> Module(options.modulename || <span class="hljs-string">'eval'</span>)
|
||||
sandbox.<span class="hljs-built_in">require</span> = _require = <span class="hljs-function"><span class="hljs-params">(path)</span> -></span> Module._load path, _module, <span class="hljs-literal">true</span>
|
||||
_module.filename = sandbox.__filename
|
||||
<span class="hljs-keyword">for</span> r <span class="hljs-keyword">in</span> Object.getOwnPropertyNames <span class="hljs-built_in">require</span> <span class="hljs-keyword">when</span> r <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> [<span class="hljs-string">'paths'</span>, <span class="hljs-string">'arguments'</span>, <span class="hljs-string">'caller'</span>]
|
||||
_require[r] = <span class="hljs-built_in">require</span>[r]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-23">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-23">¶</a>
|
||||
</div>
|
||||
<p>use the same hack node currently uses for their own REPL</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> _require.paths = _module.paths = Module._nodeModulePaths process.cwd()
|
||||
_require.resolve = <span class="hljs-function"><span class="hljs-params">(request)</span> -></span> Module._resolveFilename request, _module
|
||||
o = {}
|
||||
o[k] = v <span class="hljs-keyword">for</span> own k, v <span class="hljs-keyword">of</span> options
|
||||
o.bare = <span class="hljs-literal">on</span> <span class="hljs-comment"># ensure return value</span>
|
||||
js = compile code, o
|
||||
<span class="hljs-keyword">if</span> sandbox <span class="hljs-keyword">is</span> <span class="hljs-built_in">global</span>
|
||||
vm.runInThisContext js
|
||||
<span class="hljs-keyword">else</span>
|
||||
vm.runInContext js, sandbox
|
||||
|
||||
exports.register = <span class="hljs-function">-></span> <span class="hljs-built_in">require</span> <span class="hljs-string">'./register'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-24">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-24">¶</a>
|
||||
</div>
|
||||
<p>Throw error with deprecation warning when depending upon implicit <code>require.extensions</code> registration</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> <span class="hljs-built_in">require</span>.extensions
|
||||
<span class="hljs-keyword">for</span> ext <span class="hljs-keyword">in</span> @FILE_EXTENSIONS <span class="hljs-keyword">then</span> <span class="hljs-keyword">do</span> (ext) ->
|
||||
<span class="hljs-built_in">require</span>.extensions[ext] ?= <span class="hljs-function">-></span>
|
||||
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"""
|
||||
Use CoffeeScript.register() or require the coffee-script/register module to require <span class="hljs-subst">#{ext}</span> files.
|
||||
"""</span>
|
||||
|
||||
exports._compileFile = <span class="hljs-function"><span class="hljs-params">(filename, sourceMap = <span class="hljs-literal">no</span>, inlineMap = <span class="hljs-literal">no</span>)</span> -></span>
|
||||
raw = fs.readFileSync filename, <span class="hljs-string">'utf8'</span>
|
||||
stripped = <span class="hljs-keyword">if</span> raw.charCodeAt(<span class="hljs-number">0</span>) <span class="hljs-keyword">is</span> <span class="hljs-number">0xFEFF</span> <span class="hljs-keyword">then</span> raw.substring <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> raw
|
||||
|
||||
<span class="hljs-keyword">try</span>
|
||||
answer = compile stripped, {
|
||||
filename, sourceMap, inlineMap
|
||||
sourceFiles: [filename]
|
||||
literate: helpers.isLiterate filename
|
||||
}
|
||||
<span class="hljs-keyword">catch</span> err</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-25">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-25">¶</a>
|
||||
</div>
|
||||
<p>As the filename and code of a dynamically loaded file will be different
|
||||
from the original file compiled with CoffeeScript.run, add that
|
||||
information to error so it can be pretty-printed later.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">throw</span> helpers.updateSyntaxError err, stripped, filename
|
||||
|
||||
answer</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-26">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-26">¶</a>
|
||||
</div>
|
||||
<p>Instantiate a Lexer for our use here.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>lexer = <span class="hljs-keyword">new</span> Lexer</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-27">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-27">¶</a>
|
||||
</div>
|
||||
<p>The real Lexer produces a generic stream of tokens. This object provides a
|
||||
thin wrapper around it, compatible with the Jison API. We can then pass it
|
||||
directly as a “Jison lexer”.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>parser.lexer =
|
||||
lex: <span class="hljs-function">-></span>
|
||||
token = parser.tokens[@pos++]
|
||||
<span class="hljs-keyword">if</span> token
|
||||
[tag, @yytext, @yylloc] = token
|
||||
parser.errorToken = token.origin <span class="hljs-keyword">or</span> token
|
||||
@yylineno = @yylloc.first_line
|
||||
<span class="hljs-keyword">else</span>
|
||||
tag = <span class="hljs-string">''</span>
|
||||
|
||||
tag
|
||||
setInput: <span class="hljs-function"><span class="hljs-params">(tokens)</span> -></span>
|
||||
parser.tokens = tokens
|
||||
@pos = <span class="hljs-number">0</span>
|
||||
upcomingInput: <span class="hljs-function">-></span>
|
||||
<span class="hljs-string">""</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-28">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-28">¶</a>
|
||||
</div>
|
||||
<p>Make all the AST nodes visible to the parser.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>parser.yy = <span class="hljs-built_in">require</span> <span class="hljs-string">'./nodes'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-29">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-29">¶</a>
|
||||
</div>
|
||||
<p>Override Jison’s default error handling function.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>parser.yy.parseError = <span class="hljs-function"><span class="hljs-params">(message, {token})</span> -></span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-30">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-30">¶</a>
|
||||
</div>
|
||||
<p>Disregard Jison’s message, it contains redundant line number information.
|
||||
Disregard the token, we take its value directly from the lexer in case
|
||||
the error is caused by a generated token which might refer to its origin.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> {errorToken, tokens} = parser
|
||||
[errorTag, errorText, errorLoc] = errorToken
|
||||
|
||||
errorText = <span class="hljs-keyword">switch</span>
|
||||
<span class="hljs-keyword">when</span> errorToken <span class="hljs-keyword">is</span> tokens[tokens.length - <span class="hljs-number">1</span>]
|
||||
<span class="hljs-string">'end of input'</span>
|
||||
<span class="hljs-keyword">when</span> errorTag <span class="hljs-keyword">in</span> [<span class="hljs-string">'INDENT'</span>, <span class="hljs-string">'OUTDENT'</span>]
|
||||
<span class="hljs-string">'indentation'</span>
|
||||
<span class="hljs-keyword">when</span> errorTag <span class="hljs-keyword">in</span> [<span class="hljs-string">'IDENTIFIER'</span>, <span class="hljs-string">'NUMBER'</span>, <span class="hljs-string">'INFINITY'</span>, <span class="hljs-string">'STRING'</span>, <span class="hljs-string">'STRING_START'</span>, <span class="hljs-string">'REGEX'</span>, <span class="hljs-string">'REGEX_START'</span>]
|
||||
errorTag.replace(<span class="hljs-regexp">/_START$/</span>, <span class="hljs-string">''</span>).toLowerCase()
|
||||
<span class="hljs-keyword">else</span>
|
||||
helpers.nameWhitespaceCharacter errorText</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-31">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-31">¶</a>
|
||||
</div>
|
||||
<p>The second argument has a <code>loc</code> property, which should have the location
|
||||
data for this token. Unfortunately, Jison seems to send an outdated <code>loc</code>
|
||||
(from the previous token), so we take the location information directly
|
||||
from the lexer.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> helpers.throwSyntaxError <span class="hljs-string">"unexpected <span class="hljs-subst">#{errorText}</span>"</span>, errorLoc</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
882
docs/v1/annotated-source/command.html
Normal file
@@ -0,0 +1,882 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>command.coffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="register.html">
|
||||
register.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>command.coffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
<p>The <code>coffee</code> utility. Handles command-line compilation of CoffeeScript
|
||||
into various forms: saved into <code>.js</code> files or printed to stdout
|
||||
or recompiled every time the source is saved,
|
||||
printed as a token stream or as the syntax tree, or launch an
|
||||
interactive REPL.</p>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-2">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-2">¶</a>
|
||||
</div>
|
||||
<p>External dependencies.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>fs = <span class="hljs-built_in">require</span> <span class="hljs-string">'fs'</span>
|
||||
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span>
|
||||
helpers = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span>
|
||||
optparse = <span class="hljs-built_in">require</span> <span class="hljs-string">'./optparse'</span>
|
||||
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffee-script'</span>
|
||||
{spawn, exec} = <span class="hljs-built_in">require</span> <span class="hljs-string">'child_process'</span>
|
||||
{EventEmitter} = <span class="hljs-built_in">require</span> <span class="hljs-string">'events'</span>
|
||||
|
||||
useWinPathSep = path.sep <span class="hljs-keyword">is</span> <span class="hljs-string">'\\'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-3">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-3">¶</a>
|
||||
</div>
|
||||
<p>Allow CoffeeScript to emit Node.js events.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>helpers.extend CoffeeScript, <span class="hljs-keyword">new</span> EventEmitter
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">printLine</span> = <span class="hljs-params">(line)</span> -></span> process.stdout.write line + <span class="hljs-string">'\n'</span>
|
||||
<span class="hljs-function"><span class="hljs-title">printWarn</span> = <span class="hljs-params">(line)</span> -></span> process.stderr.write line + <span class="hljs-string">'\n'</span>
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">hidden</span> = <span class="hljs-params">(file)</span> -></span> <span class="hljs-regexp">/^\.|~$/</span>.test file</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-4">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-4">¶</a>
|
||||
</div>
|
||||
<p>The help banner that is printed in conjunction with <code>-h</code>/<code>--help</code>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>BANNER = <span class="hljs-string">'''
|
||||
Usage: coffee [options] path/to/script.coffee -- [args]
|
||||
|
||||
If called without options, `coffee` will run your script.
|
||||
'''</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-5">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-5">¶</a>
|
||||
</div>
|
||||
<p>The list of all the valid option flags that <code>coffee</code> knows how to handle.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>SWITCHES = [
|
||||
[<span class="hljs-string">'-b'</span>, <span class="hljs-string">'--bare'</span>, <span class="hljs-string">'compile without a top-level function wrapper'</span>]
|
||||
[<span class="hljs-string">'-c'</span>, <span class="hljs-string">'--compile'</span>, <span class="hljs-string">'compile to JavaScript and save as .js files'</span>]
|
||||
[<span class="hljs-string">'-e'</span>, <span class="hljs-string">'--eval'</span>, <span class="hljs-string">'pass a string from the command line as input'</span>]
|
||||
[<span class="hljs-string">'-h'</span>, <span class="hljs-string">'--help'</span>, <span class="hljs-string">'display this help message'</span>]
|
||||
[<span class="hljs-string">'-i'</span>, <span class="hljs-string">'--interactive'</span>, <span class="hljs-string">'run an interactive CoffeeScript REPL'</span>]
|
||||
[<span class="hljs-string">'-j'</span>, <span class="hljs-string">'--join [FILE]'</span>, <span class="hljs-string">'concatenate the source CoffeeScript before compiling'</span>]
|
||||
[<span class="hljs-string">'-m'</span>, <span class="hljs-string">'--map'</span>, <span class="hljs-string">'generate source map and save as .js.map files'</span>]
|
||||
[<span class="hljs-string">'-M'</span>, <span class="hljs-string">'--inline-map'</span>, <span class="hljs-string">'generate source map and include it directly in output'</span>]
|
||||
[<span class="hljs-string">'-n'</span>, <span class="hljs-string">'--nodes'</span>, <span class="hljs-string">'print out the parse tree that the parser produces'</span>]
|
||||
[ <span class="hljs-string">'--nodejs [ARGS]'</span>, <span class="hljs-string">'pass options directly to the "node" binary'</span>]
|
||||
[ <span class="hljs-string">'--no-header'</span>, <span class="hljs-string">'suppress the "Generated by" header'</span>]
|
||||
[<span class="hljs-string">'-o'</span>, <span class="hljs-string">'--output [DIR]'</span>, <span class="hljs-string">'set the output directory for compiled JavaScript'</span>]
|
||||
[<span class="hljs-string">'-p'</span>, <span class="hljs-string">'--print'</span>, <span class="hljs-string">'print out the compiled JavaScript'</span>]
|
||||
[<span class="hljs-string">'-r'</span>, <span class="hljs-string">'--require [MODULE*]'</span>, <span class="hljs-string">'require the given module before eval or REPL'</span>]
|
||||
[<span class="hljs-string">'-s'</span>, <span class="hljs-string">'--stdio'</span>, <span class="hljs-string">'listen for and compile scripts over stdio'</span>]
|
||||
[<span class="hljs-string">'-l'</span>, <span class="hljs-string">'--literate'</span>, <span class="hljs-string">'treat stdio as literate style coffee-script'</span>]
|
||||
[<span class="hljs-string">'-t'</span>, <span class="hljs-string">'--tokens'</span>, <span class="hljs-string">'print out the tokens that the lexer/rewriter produce'</span>]
|
||||
[<span class="hljs-string">'-v'</span>, <span class="hljs-string">'--version'</span>, <span class="hljs-string">'display the version number'</span>]
|
||||
[<span class="hljs-string">'-w'</span>, <span class="hljs-string">'--watch'</span>, <span class="hljs-string">'watch scripts for changes and rerun commands'</span>]
|
||||
]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-6">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-6">¶</a>
|
||||
</div>
|
||||
<p>Top-level objects shared by all the functions.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>opts = {}
|
||||
sources = []
|
||||
sourceCode = []
|
||||
notSources = {}
|
||||
watchedDirs = {}
|
||||
optionParser = <span class="hljs-literal">null</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-7">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-7">¶</a>
|
||||
</div>
|
||||
<p>Run <code>coffee</code> by parsing passed options and determining what action to take.
|
||||
Many flags cause us to divert before compiling anything. Flags passed after
|
||||
<code>--</code> will be passed verbatim to your script as arguments in <code>process.argv</code></p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.run = <span class="hljs-function">-></span>
|
||||
parseOptions()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
<p>Make the REPL <em>CLI</em> use the global context so as to (a) be consistent with the
|
||||
<code>node</code> REPL CLI and, therefore, (b) make packages that modify native prototypes
|
||||
(such as ‘colors’ and ‘sugar’) work as expected.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> replCliOpts = useGlobal: <span class="hljs-literal">yes</span>
|
||||
opts.prelude = makePrelude opts.<span class="hljs-built_in">require</span> <span class="hljs-keyword">if</span> opts.<span class="hljs-built_in">require</span>
|
||||
replCliOpts.prelude = opts.prelude
|
||||
<span class="hljs-keyword">return</span> forkNode() <span class="hljs-keyword">if</span> opts.nodejs
|
||||
<span class="hljs-keyword">return</span> usage() <span class="hljs-keyword">if</span> opts.help
|
||||
<span class="hljs-keyword">return</span> version() <span class="hljs-keyword">if</span> opts.version
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-built_in">require</span>(<span class="hljs-string">'./repl'</span>).start(replCliOpts) <span class="hljs-keyword">if</span> opts.interactive
|
||||
<span class="hljs-keyword">return</span> compileStdio() <span class="hljs-keyword">if</span> opts.stdio
|
||||
<span class="hljs-keyword">return</span> compileScript <span class="hljs-literal">null</span>, opts.arguments[<span class="hljs-number">0</span>] <span class="hljs-keyword">if</span> opts.eval
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-built_in">require</span>(<span class="hljs-string">'./repl'</span>).start(replCliOpts) <span class="hljs-keyword">unless</span> opts.arguments.length
|
||||
literals = <span class="hljs-keyword">if</span> opts.run <span class="hljs-keyword">then</span> opts.arguments.splice <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> []
|
||||
process.argv = process.argv[<span class="hljs-number">0.</span><span class="hljs-number">.1</span>].concat literals
|
||||
process.argv[<span class="hljs-number">0</span>] = <span class="hljs-string">'coffee'</span>
|
||||
|
||||
opts.output = path.resolve opts.output <span class="hljs-keyword">if</span> opts.output
|
||||
<span class="hljs-keyword">if</span> opts.join
|
||||
opts.join = path.resolve opts.join
|
||||
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
|
||||
|
||||
The --join option is deprecated and will be removed in a future version.
|
||||
|
||||
If for some reason it's necessary to share local variables between files,
|
||||
replace...
|
||||
|
||||
$ coffee --compile --join bundle.js -- a.coffee b.coffee c.coffee
|
||||
|
||||
with...
|
||||
|
||||
$ cat a.coffee b.coffee c.coffee | coffee --compile --stdio > bundle.js
|
||||
|
||||
'''</span>
|
||||
<span class="hljs-keyword">for</span> source <span class="hljs-keyword">in</span> opts.arguments
|
||||
source = path.resolve source
|
||||
compilePath source, <span class="hljs-literal">yes</span>, source
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">makePrelude</span> = <span class="hljs-params">(requires)</span> -></span>
|
||||
requires.map (<span class="hljs-built_in">module</span>) ->
|
||||
[_, name, <span class="hljs-built_in">module</span>] = match <span class="hljs-keyword">if</span> match = <span class="hljs-built_in">module</span>.match(<span class="hljs-regexp">/^(.*)=(.*)$/</span>)
|
||||
name ||= helpers.baseFileName <span class="hljs-built_in">module</span>, <span class="hljs-literal">yes</span>, useWinPathSep
|
||||
<span class="hljs-string">"<span class="hljs-subst">#{name}</span> = require('<span class="hljs-subst">#{<span class="hljs-built_in">module</span>}</span>')"</span>
|
||||
.join <span class="hljs-string">';'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-9">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
</div>
|
||||
<p>Compile a path, which could be a script or a directory. If a directory
|
||||
is passed, recursively compile all ‘.coffee’, ‘.litcoffee’, and ‘.coffee.md’
|
||||
extension source files in it and all subdirectories.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">compilePath</span> = <span class="hljs-params">(source, topLevel, base)</span> -></span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> source <span class="hljs-keyword">in</span> sources <span class="hljs-keyword">or</span>
|
||||
watchedDirs[source] <span class="hljs-keyword">or</span>
|
||||
<span class="hljs-keyword">not</span> topLevel <span class="hljs-keyword">and</span> (notSources[source] <span class="hljs-keyword">or</span> hidden source)
|
||||
<span class="hljs-keyword">try</span>
|
||||
stats = fs.statSync source
|
||||
<span class="hljs-keyword">catch</span> err
|
||||
<span class="hljs-keyword">if</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span>
|
||||
<span class="hljs-built_in">console</span>.error <span class="hljs-string">"File not found: <span class="hljs-subst">#{source}</span>"</span>
|
||||
process.exit <span class="hljs-number">1</span>
|
||||
<span class="hljs-keyword">throw</span> err
|
||||
<span class="hljs-keyword">if</span> stats.isDirectory()
|
||||
<span class="hljs-keyword">if</span> path.basename(source) <span class="hljs-keyword">is</span> <span class="hljs-string">'node_modules'</span>
|
||||
notSources[source] = <span class="hljs-literal">yes</span>
|
||||
<span class="hljs-keyword">return</span>
|
||||
<span class="hljs-keyword">if</span> opts.run
|
||||
compilePath findDirectoryIndex(source), topLevel, base
|
||||
<span class="hljs-keyword">return</span>
|
||||
watchDir source, base <span class="hljs-keyword">if</span> opts.watch
|
||||
<span class="hljs-keyword">try</span>
|
||||
files = fs.readdirSync source
|
||||
<span class="hljs-keyword">catch</span> err
|
||||
<span class="hljs-keyword">if</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span> <span class="hljs-keyword">then</span> <span class="hljs-keyword">return</span> <span class="hljs-keyword">else</span> <span class="hljs-keyword">throw</span> err
|
||||
<span class="hljs-keyword">for</span> file <span class="hljs-keyword">in</span> files
|
||||
compilePath (path.join source, file), <span class="hljs-literal">no</span>, base
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> topLevel <span class="hljs-keyword">or</span> helpers.isCoffee source
|
||||
sources.push source
|
||||
sourceCode.push <span class="hljs-literal">null</span>
|
||||
<span class="hljs-keyword">delete</span> notSources[source]
|
||||
watch source, base <span class="hljs-keyword">if</span> opts.watch
|
||||
<span class="hljs-keyword">try</span>
|
||||
code = fs.readFileSync source
|
||||
<span class="hljs-keyword">catch</span> err
|
||||
<span class="hljs-keyword">if</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span> <span class="hljs-keyword">then</span> <span class="hljs-keyword">return</span> <span class="hljs-keyword">else</span> <span class="hljs-keyword">throw</span> err
|
||||
compileScript(source, code.toString(), base)
|
||||
<span class="hljs-keyword">else</span>
|
||||
notSources[source] = <span class="hljs-literal">yes</span>
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">findDirectoryIndex</span> = <span class="hljs-params">(source)</span> -></span>
|
||||
<span class="hljs-keyword">for</span> ext <span class="hljs-keyword">in</span> CoffeeScript.FILE_EXTENSIONS
|
||||
index = path.join source, <span class="hljs-string">"index<span class="hljs-subst">#{ext}</span>"</span>
|
||||
<span class="hljs-keyword">try</span>
|
||||
<span class="hljs-keyword">return</span> index <span class="hljs-keyword">if</span> (fs.statSync index).isFile()
|
||||
<span class="hljs-keyword">catch</span> err
|
||||
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span>
|
||||
<span class="hljs-built_in">console</span>.error <span class="hljs-string">"Missing index.coffee or index.litcoffee in <span class="hljs-subst">#{source}</span>"</span>
|
||||
process.exit <span class="hljs-number">1</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-10">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
</div>
|
||||
<p>Compile a single source script, containing the given code, according to the
|
||||
requested options. If evaluating the script directly sets <code>__filename</code>,
|
||||
<code>__dirname</code> and <code>module.filename</code> to be correct relative to the script’s path.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">compileScript</span> = <span class="hljs-params">(file, input, base = <span class="hljs-literal">null</span>)</span> -></span>
|
||||
o = opts
|
||||
options = compileOptions file, base
|
||||
<span class="hljs-keyword">try</span>
|
||||
t = task = {file, input, options}
|
||||
CoffeeScript.emit <span class="hljs-string">'compile'</span>, task
|
||||
<span class="hljs-keyword">if</span> o.tokens
|
||||
printTokens CoffeeScript.tokens t.input, t.options
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> o.nodes
|
||||
printLine CoffeeScript.nodes(t.input, t.options).toString().trim()
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> o.run
|
||||
CoffeeScript.register()
|
||||
CoffeeScript.eval opts.prelude, t.options <span class="hljs-keyword">if</span> opts.prelude
|
||||
CoffeeScript.run t.input, t.options
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> o.join <span class="hljs-keyword">and</span> t.file <span class="hljs-keyword">isnt</span> o.join
|
||||
t.input = helpers.invertLiterate t.input <span class="hljs-keyword">if</span> helpers.isLiterate file
|
||||
sourceCode[sources.indexOf(t.file)] = t.input
|
||||
compileJoin()
|
||||
<span class="hljs-keyword">else</span>
|
||||
compiled = CoffeeScript.compile t.input, t.options
|
||||
t.output = compiled
|
||||
<span class="hljs-keyword">if</span> o.map
|
||||
t.output = compiled.js
|
||||
t.sourceMap = compiled.v3SourceMap
|
||||
|
||||
CoffeeScript.emit <span class="hljs-string">'success'</span>, task
|
||||
<span class="hljs-keyword">if</span> o.<span class="hljs-built_in">print</span>
|
||||
printLine t.output.trim()
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> o.compile <span class="hljs-keyword">or</span> o.map
|
||||
writeJs base, t.file, t.output, options.jsPath, t.sourceMap
|
||||
<span class="hljs-keyword">catch</span> err
|
||||
CoffeeScript.emit <span class="hljs-string">'failure'</span>, err, task
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> CoffeeScript.listeners(<span class="hljs-string">'failure'</span>).length
|
||||
message = err?.stack <span class="hljs-keyword">or</span> <span class="hljs-string">"<span class="hljs-subst">#{err}</span>"</span>
|
||||
<span class="hljs-keyword">if</span> o.watch
|
||||
printLine message + <span class="hljs-string">'\x07'</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
printWarn message
|
||||
process.exit <span class="hljs-number">1</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-11">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
</div>
|
||||
<p>Attach the appropriate listeners to compile scripts incoming over <strong>stdin</strong>,
|
||||
and write them back to <strong>stdout</strong>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">compileStdio</span> = -></span>
|
||||
buffers = []
|
||||
stdin = process.openStdin()
|
||||
stdin.<span class="hljs-literal">on</span> <span class="hljs-string">'data'</span>, <span class="hljs-function"><span class="hljs-params">(buffer)</span> -></span>
|
||||
buffers.push buffer <span class="hljs-keyword">if</span> buffer
|
||||
stdin.<span class="hljs-literal">on</span> <span class="hljs-string">'end'</span>, <span class="hljs-function">-></span>
|
||||
compileScript <span class="hljs-literal">null</span>, Buffer.concat(buffers).toString()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-12">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
</div>
|
||||
<p>If all of the source files are done being read, concatenate and compile
|
||||
them together.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>joinTimeout = <span class="hljs-literal">null</span>
|
||||
<span class="hljs-function"><span class="hljs-title">compileJoin</span> = -></span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> opts.join
|
||||
<span class="hljs-keyword">unless</span> sourceCode.some(<span class="hljs-function"><span class="hljs-params">(code)</span> -></span> code <span class="hljs-keyword">is</span> <span class="hljs-literal">null</span>)
|
||||
clearTimeout joinTimeout
|
||||
joinTimeout = wait <span class="hljs-number">100</span>, <span class="hljs-function">-></span>
|
||||
compileScript opts.join, sourceCode.join(<span class="hljs-string">'\n'</span>), opts.join</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-13">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-13">¶</a>
|
||||
</div>
|
||||
<p>Watch a source CoffeeScript file using <code>fs.watch</code>, recompiling it every
|
||||
time the file is updated. May be used in combination with other options,
|
||||
such as <code>--print</code>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">watch</span> = <span class="hljs-params">(source, base)</span> -></span>
|
||||
watcher = <span class="hljs-literal">null</span>
|
||||
prevStats = <span class="hljs-literal">null</span>
|
||||
compileTimeout = <span class="hljs-literal">null</span>
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">watchErr</span> = <span class="hljs-params">(err)</span> -></span>
|
||||
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> source <span class="hljs-keyword">in</span> sources
|
||||
<span class="hljs-keyword">try</span>
|
||||
rewatch()
|
||||
compile()
|
||||
<span class="hljs-keyword">catch</span>
|
||||
removeSource source, base
|
||||
compileJoin()
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">compile</span> = -></span>
|
||||
clearTimeout compileTimeout
|
||||
compileTimeout = wait <span class="hljs-number">25</span>, <span class="hljs-function">-></span>
|
||||
fs.stat source, <span class="hljs-function"><span class="hljs-params">(err, stats)</span> -></span>
|
||||
<span class="hljs-keyword">return</span> watchErr err <span class="hljs-keyword">if</span> err
|
||||
<span class="hljs-keyword">return</span> rewatch() <span class="hljs-keyword">if</span> prevStats <span class="hljs-keyword">and</span>
|
||||
stats.size <span class="hljs-keyword">is</span> prevStats.size <span class="hljs-keyword">and</span>
|
||||
stats.mtime.getTime() <span class="hljs-keyword">is</span> prevStats.mtime.getTime()
|
||||
prevStats = stats
|
||||
fs.readFile source, <span class="hljs-function"><span class="hljs-params">(err, code)</span> -></span>
|
||||
<span class="hljs-keyword">return</span> watchErr err <span class="hljs-keyword">if</span> err
|
||||
compileScript(source, code.toString(), base)
|
||||
rewatch()
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">startWatcher</span> = -></span>
|
||||
watcher = fs.watch source
|
||||
.<span class="hljs-literal">on</span> <span class="hljs-string">'change'</span>, compile
|
||||
.<span class="hljs-literal">on</span> <span class="hljs-string">'error'</span>, <span class="hljs-function"><span class="hljs-params">(err)</span> -></span>
|
||||
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'EPERM'</span>
|
||||
removeSource source, base
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">rewatch</span> = -></span>
|
||||
watcher?.close()
|
||||
startWatcher()
|
||||
|
||||
<span class="hljs-keyword">try</span>
|
||||
startWatcher()
|
||||
<span class="hljs-keyword">catch</span> err
|
||||
watchErr err</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-14">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-14">¶</a>
|
||||
</div>
|
||||
<p>Watch a directory of files for new additions.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">watchDir</span> = <span class="hljs-params">(source, base)</span> -></span>
|
||||
watcher = <span class="hljs-literal">null</span>
|
||||
readdirTimeout = <span class="hljs-literal">null</span>
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">startWatcher</span> = -></span>
|
||||
watcher = fs.watch source
|
||||
.<span class="hljs-literal">on</span> <span class="hljs-string">'error'</span>, <span class="hljs-function"><span class="hljs-params">(err)</span> -></span>
|
||||
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'EPERM'</span>
|
||||
stopWatcher()
|
||||
.<span class="hljs-literal">on</span> <span class="hljs-string">'change'</span>, <span class="hljs-function">-></span>
|
||||
clearTimeout readdirTimeout
|
||||
readdirTimeout = wait <span class="hljs-number">25</span>, <span class="hljs-function">-></span>
|
||||
<span class="hljs-keyword">try</span>
|
||||
files = fs.readdirSync source
|
||||
<span class="hljs-keyword">catch</span> err
|
||||
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span>
|
||||
<span class="hljs-keyword">return</span> stopWatcher()
|
||||
<span class="hljs-keyword">for</span> file <span class="hljs-keyword">in</span> files
|
||||
compilePath (path.join source, file), <span class="hljs-literal">no</span>, base
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">stopWatcher</span> = -></span>
|
||||
watcher.close()
|
||||
removeSourceDir source, base
|
||||
|
||||
watchedDirs[source] = <span class="hljs-literal">yes</span>
|
||||
<span class="hljs-keyword">try</span>
|
||||
startWatcher()
|
||||
<span class="hljs-keyword">catch</span> err
|
||||
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span>
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">removeSourceDir</span> = <span class="hljs-params">(source, base)</span> -></span>
|
||||
<span class="hljs-keyword">delete</span> watchedDirs[source]
|
||||
sourcesChanged = <span class="hljs-literal">no</span>
|
||||
<span class="hljs-keyword">for</span> file <span class="hljs-keyword">in</span> sources <span class="hljs-keyword">when</span> source <span class="hljs-keyword">is</span> path.dirname file
|
||||
removeSource file, base
|
||||
sourcesChanged = <span class="hljs-literal">yes</span>
|
||||
compileJoin() <span class="hljs-keyword">if</span> sourcesChanged</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-15">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
</div>
|
||||
<p>Remove a file from our source list, and source code cache. Optionally remove
|
||||
the compiled JS version as well.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">removeSource</span> = <span class="hljs-params">(source, base)</span> -></span>
|
||||
index = sources.indexOf source
|
||||
sources.splice index, <span class="hljs-number">1</span>
|
||||
sourceCode.splice index, <span class="hljs-number">1</span>
|
||||
<span class="hljs-keyword">unless</span> opts.join
|
||||
silentUnlink outputPath source, base
|
||||
silentUnlink outputPath source, base, <span class="hljs-string">'.js.map'</span>
|
||||
timeLog <span class="hljs-string">"removed <span class="hljs-subst">#{source}</span>"</span>
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">silentUnlink</span> = <span class="hljs-params">(path)</span> -></span>
|
||||
<span class="hljs-keyword">try</span>
|
||||
fs.unlinkSync path
|
||||
<span class="hljs-keyword">catch</span> err
|
||||
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">in</span> [<span class="hljs-string">'ENOENT'</span>, <span class="hljs-string">'EPERM'</span>]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-16">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-16">¶</a>
|
||||
</div>
|
||||
<p>Get the corresponding output JavaScript path for a source file.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">outputPath</span> = <span class="hljs-params">(source, base, extension=<span class="hljs-string">".js"</span>)</span> -></span>
|
||||
basename = helpers.baseFileName source, <span class="hljs-literal">yes</span>, useWinPathSep
|
||||
srcDir = path.dirname source
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> opts.output
|
||||
dir = srcDir
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> source <span class="hljs-keyword">is</span> base
|
||||
dir = opts.output
|
||||
<span class="hljs-keyword">else</span>
|
||||
dir = path.join opts.output, path.relative base, srcDir
|
||||
path.join dir, basename + extension</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-17">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-17">¶</a>
|
||||
</div>
|
||||
<p>Recursively mkdir, like <code>mkdir -p</code>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">mkdirp</span> = <span class="hljs-params">(dir, fn)</span> -></span>
|
||||
mode = <span class="hljs-number">0</span>o777 & ~process.umask()
|
||||
|
||||
<span class="hljs-keyword">do</span> mkdirs = <span class="hljs-function"><span class="hljs-params">(p = dir, fn)</span> -></span>
|
||||
fs.exists p, <span class="hljs-function"><span class="hljs-params">(exists)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> exists
|
||||
fn()
|
||||
<span class="hljs-keyword">else</span>
|
||||
mkdirs path.dirname(p), <span class="hljs-function">-></span>
|
||||
fs.mkdir p, mode, <span class="hljs-function"><span class="hljs-params">(err)</span> -></span>
|
||||
<span class="hljs-keyword">return</span> fn err <span class="hljs-keyword">if</span> err
|
||||
fn()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-18">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
</div>
|
||||
<p>Write out a JavaScript source file with the compiled code. By default, files
|
||||
are written out in <code>cwd</code> as <code>.js</code> files with the same name, but the output
|
||||
directory can be customized with <code>--output</code>.</p>
|
||||
<p>If <code>generatedSourceMap</code> is provided, this will write a <code>.js.map</code> file into the
|
||||
same directory as the <code>.js</code> file.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">writeJs</span> = <span class="hljs-params">(base, sourcePath, js, jsPath, generatedSourceMap = <span class="hljs-literal">null</span>)</span> -></span>
|
||||
sourceMapPath = outputPath sourcePath, base, <span class="hljs-string">".js.map"</span>
|
||||
jsDir = path.dirname jsPath
|
||||
<span class="hljs-function"> <span class="hljs-title">compile</span> = -></span>
|
||||
<span class="hljs-keyword">if</span> opts.compile
|
||||
js = <span class="hljs-string">' '</span> <span class="hljs-keyword">if</span> js.length <= <span class="hljs-number">0</span>
|
||||
<span class="hljs-keyword">if</span> generatedSourceMap <span class="hljs-keyword">then</span> js = <span class="hljs-string">"<span class="hljs-subst">#{js}</span>\n//# sourceMappingURL=<span class="hljs-subst">#{helpers.baseFileName sourceMapPath, <span class="hljs-literal">no</span>, useWinPathSep}</span>\n"</span>
|
||||
fs.writeFile jsPath, js, <span class="hljs-function"><span class="hljs-params">(err)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> err
|
||||
printLine err.message
|
||||
process.exit <span class="hljs-number">1</span>
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> opts.compile <span class="hljs-keyword">and</span> opts.watch
|
||||
timeLog <span class="hljs-string">"compiled <span class="hljs-subst">#{sourcePath}</span>"</span>
|
||||
<span class="hljs-keyword">if</span> generatedSourceMap
|
||||
fs.writeFile sourceMapPath, generatedSourceMap, <span class="hljs-function"><span class="hljs-params">(err)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> err
|
||||
printLine <span class="hljs-string">"Could not write source map: <span class="hljs-subst">#{err.message}</span>"</span>
|
||||
process.exit <span class="hljs-number">1</span>
|
||||
fs.exists jsDir, <span class="hljs-function"><span class="hljs-params">(itExists)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> itExists <span class="hljs-keyword">then</span> compile() <span class="hljs-keyword">else</span> mkdirp jsDir, compile</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-19">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-19">¶</a>
|
||||
</div>
|
||||
<p>Convenience for cleaner setTimeouts.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">wait</span> = <span class="hljs-params">(milliseconds, func)</span> -></span> setTimeout func, milliseconds</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-20">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-20">¶</a>
|
||||
</div>
|
||||
<p>When watching scripts, it’s useful to log changes with the timestamp.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">timeLog</span> = <span class="hljs-params">(message)</span> -></span>
|
||||
<span class="hljs-built_in">console</span>.log <span class="hljs-string">"<span class="hljs-subst">#{(<span class="hljs-keyword">new</span> Date).toLocaleTimeString()}</span> - <span class="hljs-subst">#{message}</span>"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-21">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-21">¶</a>
|
||||
</div>
|
||||
<p>Pretty-print a stream of tokens, sans location data.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">printTokens</span> = <span class="hljs-params">(tokens)</span> -></span>
|
||||
strings = <span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> tokens
|
||||
tag = token[<span class="hljs-number">0</span>]
|
||||
value = token[<span class="hljs-number">1</span>].toString().replace(<span class="hljs-regexp">/\n/</span>, <span class="hljs-string">'\\n'</span>)
|
||||
<span class="hljs-string">"[<span class="hljs-subst">#{tag}</span> <span class="hljs-subst">#{value}</span>]"</span>
|
||||
printLine strings.join(<span class="hljs-string">' '</span>)</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-22">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-22">¶</a>
|
||||
</div>
|
||||
<p>Use the <a href="optparse.html">OptionParser module</a> to extract all options from
|
||||
<code>process.argv</code> that are specified in <code>SWITCHES</code>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">parseOptions</span> = -></span>
|
||||
optionParser = <span class="hljs-keyword">new</span> optparse.OptionParser SWITCHES, BANNER
|
||||
o = opts = optionParser.parse process.argv[<span class="hljs-number">2.</span>.]
|
||||
o.compile <span class="hljs-keyword">or</span>= !!o.output
|
||||
o.run = <span class="hljs-keyword">not</span> (o.compile <span class="hljs-keyword">or</span> o.<span class="hljs-built_in">print</span> <span class="hljs-keyword">or</span> o.map)
|
||||
o.<span class="hljs-built_in">print</span> = !! (o.<span class="hljs-built_in">print</span> <span class="hljs-keyword">or</span> (o.eval <span class="hljs-keyword">or</span> o.stdio <span class="hljs-keyword">and</span> o.compile))</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-23">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-23">¶</a>
|
||||
</div>
|
||||
<p>The compile-time options to pass to the CoffeeScript compiler.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">compileOptions</span> = <span class="hljs-params">(filename, base)</span> -></span>
|
||||
answer = {
|
||||
filename
|
||||
literate: opts.literate <span class="hljs-keyword">or</span> helpers.isLiterate(filename)
|
||||
bare: opts.bare
|
||||
header: opts.compile <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> opts[<span class="hljs-string">'no-header'</span>]
|
||||
sourceMap: opts.map
|
||||
inlineMap: opts[<span class="hljs-string">'inline-map'</span>]
|
||||
}
|
||||
<span class="hljs-keyword">if</span> filename
|
||||
<span class="hljs-keyword">if</span> base
|
||||
cwd = process.cwd()
|
||||
jsPath = outputPath filename, base
|
||||
jsDir = path.dirname jsPath
|
||||
answer = helpers.merge answer, {
|
||||
jsPath
|
||||
sourceRoot: path.relative jsDir, cwd
|
||||
sourceFiles: [path.relative cwd, filename]
|
||||
generatedFile: helpers.baseFileName(jsPath, <span class="hljs-literal">no</span>, useWinPathSep)
|
||||
}
|
||||
<span class="hljs-keyword">else</span>
|
||||
answer = helpers.merge answer,
|
||||
sourceRoot: <span class="hljs-string">""</span>
|
||||
sourceFiles: [helpers.baseFileName filename, <span class="hljs-literal">no</span>, useWinPathSep]
|
||||
generatedFile: helpers.baseFileName(filename, <span class="hljs-literal">yes</span>, useWinPathSep) + <span class="hljs-string">".js"</span>
|
||||
answer</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-24">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-24">¶</a>
|
||||
</div>
|
||||
<p>Start up a new Node.js instance with the arguments in <code>--nodejs</code> passed to
|
||||
the <code>node</code> binary, preserving the other options.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">forkNode</span> = -></span>
|
||||
nodeArgs = opts.nodejs.split <span class="hljs-regexp">/\s+/</span>
|
||||
args = process.argv[<span class="hljs-number">1.</span>.]
|
||||
args.splice args.indexOf(<span class="hljs-string">'--nodejs'</span>), <span class="hljs-number">2</span>
|
||||
p = spawn process.execPath, nodeArgs.concat(args),
|
||||
cwd: process.cwd()
|
||||
env: process.env
|
||||
stdio: [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>]
|
||||
p.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>, <span class="hljs-function"><span class="hljs-params">(code)</span> -></span> process.exit code</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-25">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-25">¶</a>
|
||||
</div>
|
||||
<p>Print the <code>--help</code> usage message and exit. Deprecated switches are not
|
||||
shown.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">usage</span> = -></span>
|
||||
printLine (<span class="hljs-keyword">new</span> optparse.OptionParser SWITCHES, BANNER).help()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-26">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-26">¶</a>
|
||||
</div>
|
||||
<p>Print the <code>--version</code> message and exit.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">version</span> = -></span>
|
||||
printLine <span class="hljs-string">"CoffeeScript version <span class="hljs-subst">#{CoffeeScript.VERSION}</span>"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -21,11 +21,11 @@
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'novecento-bold';
|
||||
src: url('public/fonts/novecento-bold.eot');
|
||||
src: url('public/fonts/novecento-bold.eot?#iefix') format('embedded-opentype'),
|
||||
url('public/fonts/novecento-bold.woff') format('woff'),
|
||||
url('public/fonts/novecento-bold.ttf') format('truetype');
|
||||
font-family: 'roboto-black';
|
||||
src: url('public/fonts/roboto-black.eot');
|
||||
src: url('public/fonts/roboto-black.eot?#iefix') format('embedded-opentype'),
|
||||
url('public/fonts/roboto-black.woff') format('woff'),
|
||||
url('public/fonts/roboto-black.ttf') format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
@@ -67,7 +67,7 @@ h1, h2, h3, h4, h5, h6 {
|
||||
color: #112233;
|
||||
line-height: 1em;
|
||||
font-weight: normal;
|
||||
font-family: "novecento-bold";
|
||||
font-family: "roboto-black";
|
||||
text-transform: uppercase;
|
||||
margin: 30px 0 15px 0;
|
||||
}
|
||||
@@ -75,10 +75,13 @@ h1, h2, h3, h4, h5, h6 {
|
||||
h1 {
|
||||
margin-top: 40px;
|
||||
}
|
||||
h2 {
|
||||
font-size: 1.26em;
|
||||
}
|
||||
|
||||
hr {
|
||||
border: 0;
|
||||
background: 1px solid #ddd;
|
||||
background: 1px #ddd;
|
||||
height: 1px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
@@ -180,9 +183,18 @@ ul.sections > li > div {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#jump_page_wrapper{
|
||||
position: fixed;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
#jump_page {
|
||||
padding: 5px 0 3px;
|
||||
margin: 0 0 25px 25px;
|
||||
max-height: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
#jump_page .source {
|
||||
@@ -213,7 +225,6 @@ ul.sections > li > div {
|
||||
}
|
||||
|
||||
ul.sections > li > div.content {
|
||||
background: #f5f5ff;
|
||||
overflow-x:auto;
|
||||
-webkit-box-shadow: inset 0 0 5px #e5e5ee;
|
||||
box-shadow: inset 0 0 5px #e5e5ee;
|
||||
@@ -314,7 +325,6 @@ ul.sections > li > div {
|
||||
ul.sections > li > div.content {
|
||||
padding: 13px;
|
||||
vertical-align: top;
|
||||
background: #f5f5ff;
|
||||
border: none;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
@@ -384,126 +394,125 @@ pre code {
|
||||
background: #f8f8ff
|
||||
}
|
||||
|
||||
pre .comment,
|
||||
pre .template_comment,
|
||||
pre .diff .header,
|
||||
pre .javadoc {
|
||||
pre .hljs-comment,
|
||||
pre .hljs-template_comment,
|
||||
pre .hljs-diff .hljs-header,
|
||||
pre .hljs-javadoc {
|
||||
color: #408080;
|
||||
font-style: italic
|
||||
}
|
||||
|
||||
pre .keyword,
|
||||
pre .assignment,
|
||||
pre .literal,
|
||||
pre .css .rule .keyword,
|
||||
pre .winutils,
|
||||
pre .javascript .title,
|
||||
pre .lisp .title,
|
||||
pre .subst,
|
||||
pre .reserved {
|
||||
pre .hljs-keyword,
|
||||
pre .hljs-assignment,
|
||||
pre .hljs-literal,
|
||||
pre .hljs-css .hljs-rule .hljs-keyword,
|
||||
pre .hljs-winutils,
|
||||
pre .hljs-javascript .hljs-title,
|
||||
pre .hljs-lisp .hljs-title,
|
||||
pre .hljs-subst {
|
||||
color: #954121;
|
||||
/*font-weight: bold*/
|
||||
}
|
||||
|
||||
pre .number,
|
||||
pre .hexcolor {
|
||||
pre .hljs-number,
|
||||
pre .hljs-hexcolor {
|
||||
color: #40a070
|
||||
}
|
||||
|
||||
pre .string,
|
||||
pre .tag .value,
|
||||
pre .phpdoc,
|
||||
pre .tex .formula {
|
||||
pre .hljs-string,
|
||||
pre .hljs-tag .hljs-value,
|
||||
pre .hljs-phpdoc,
|
||||
pre .hljs-tex .hljs-formula {
|
||||
color: #219161;
|
||||
}
|
||||
|
||||
pre .title,
|
||||
pre .id {
|
||||
pre .hljs-title,
|
||||
pre .hljs-id {
|
||||
color: #19469D;
|
||||
}
|
||||
pre .params {
|
||||
pre .hljs-params {
|
||||
color: #00F;
|
||||
}
|
||||
|
||||
pre .javascript .title,
|
||||
pre .lisp .title,
|
||||
pre .subst {
|
||||
pre .hljs-javascript .hljs-title,
|
||||
pre .hljs-lisp .hljs-title,
|
||||
pre .hljs-subst {
|
||||
font-weight: normal
|
||||
}
|
||||
|
||||
pre .class .title,
|
||||
pre .haskell .label,
|
||||
pre .tex .command {
|
||||
pre .hljs-class .hljs-title,
|
||||
pre .hljs-haskell .hljs-label,
|
||||
pre .hljs-tex .hljs-command {
|
||||
color: #458;
|
||||
font-weight: bold
|
||||
}
|
||||
|
||||
pre .tag,
|
||||
pre .tag .title,
|
||||
pre .rules .property,
|
||||
pre .django .tag .keyword {
|
||||
pre .hljs-tag,
|
||||
pre .hljs-tag .hljs-title,
|
||||
pre .hljs-rules .hljs-property,
|
||||
pre .hljs-django .hljs-tag .hljs-keyword {
|
||||
color: #000080;
|
||||
font-weight: normal
|
||||
}
|
||||
|
||||
pre .attribute,
|
||||
pre .variable,
|
||||
pre .instancevar,
|
||||
pre .lisp .body {
|
||||
pre .hljs-attribute,
|
||||
pre .hljs-variable,
|
||||
pre .hljs-instancevar,
|
||||
pre .hljs-lisp .hljs-body {
|
||||
color: #008080
|
||||
}
|
||||
|
||||
pre .regexp {
|
||||
pre .hljs-regexp {
|
||||
color: #B68
|
||||
}
|
||||
|
||||
pre .class {
|
||||
pre .hljs-class {
|
||||
color: #458;
|
||||
font-weight: bold
|
||||
}
|
||||
|
||||
pre .symbol,
|
||||
pre .ruby .symbol .string,
|
||||
pre .ruby .symbol .keyword,
|
||||
pre .ruby .symbol .keymethods,
|
||||
pre .lisp .keyword,
|
||||
pre .tex .special,
|
||||
pre .input_number {
|
||||
pre .hljs-symbol,
|
||||
pre .hljs-ruby .hljs-symbol .hljs-string,
|
||||
pre .hljs-ruby .hljs-symbol .hljs-keyword,
|
||||
pre .hljs-ruby .hljs-symbol .hljs-keymethods,
|
||||
pre .hljs-lisp .hljs-keyword,
|
||||
pre .hljs-tex .hljs-special,
|
||||
pre .hljs-input_number {
|
||||
color: #990073
|
||||
}
|
||||
|
||||
pre .builtin,
|
||||
pre .constructor,
|
||||
pre .built_in,
|
||||
pre .lisp .title {
|
||||
pre .hljs-builtin,
|
||||
pre .hljs-constructor,
|
||||
pre .hljs-built_in,
|
||||
pre .hljs-lisp .hljs-title {
|
||||
color: #0086b3
|
||||
}
|
||||
|
||||
pre .preprocessor,
|
||||
pre .pi,
|
||||
pre .doctype,
|
||||
pre .shebang,
|
||||
pre .cdata {
|
||||
pre .hljs-preprocessor,
|
||||
pre .hljs-pi,
|
||||
pre .hljs-doctype,
|
||||
pre .hljs-shebang,
|
||||
pre .hljs-cdata {
|
||||
color: #999;
|
||||
font-weight: bold
|
||||
}
|
||||
|
||||
pre .deletion {
|
||||
pre .hljs-deletion {
|
||||
background: #fdd
|
||||
}
|
||||
|
||||
pre .addition {
|
||||
pre .hljs-addition {
|
||||
background: #dfd
|
||||
}
|
||||
|
||||
pre .diff .change {
|
||||
pre .hljs-diff .hljs-change {
|
||||
background: #0086b3
|
||||
}
|
||||
|
||||
pre .chunk {
|
||||
pre .hljs-chunk {
|
||||
color: #aaa
|
||||
}
|
||||
|
||||
pre .tex .formula {
|
||||
pre .hljs-tex .hljs-formula {
|
||||
opacity: 0.5;
|
||||
}
|
||||
1715
docs/v1/annotated-source/grammar.html
Normal file
612
docs/v1/annotated-source/helpers.html
Normal file
@@ -0,0 +1,612 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>helpers.coffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="register.html">
|
||||
register.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>helpers.coffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
<p>This file contains the common helper functions that we’d like to share among
|
||||
the <strong>Lexer</strong>, <strong>Rewriter</strong>, and the <strong>Nodes</strong>. Merge objects, flatten
|
||||
arrays, count characters, that sort of thing.</p>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-2">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-2">¶</a>
|
||||
</div>
|
||||
<p>Peek at the beginning of a given string to see if it matches a sequence.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.starts = <span class="hljs-function"><span class="hljs-params">(string, literal, start)</span> -></span>
|
||||
literal <span class="hljs-keyword">is</span> string.substr start, literal.length</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-3">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-3">¶</a>
|
||||
</div>
|
||||
<p>Peek at the end of a given string to see if it matches a sequence.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.ends = <span class="hljs-function"><span class="hljs-params">(string, literal, back)</span> -></span>
|
||||
len = literal.length
|
||||
literal <span class="hljs-keyword">is</span> string.substr string.length - len - (back <span class="hljs-keyword">or</span> <span class="hljs-number">0</span>), len</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-4">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-4">¶</a>
|
||||
</div>
|
||||
<p>Repeat a string <code>n</code> times.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.repeat = repeat = <span class="hljs-function"><span class="hljs-params">(str, n)</span> -></span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-5">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-5">¶</a>
|
||||
</div>
|
||||
<p>Use clever algorithm to have O(log(n)) string concatenation operations.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> res = <span class="hljs-string">''</span>
|
||||
<span class="hljs-keyword">while</span> n > <span class="hljs-number">0</span>
|
||||
res += str <span class="hljs-keyword">if</span> n & <span class="hljs-number">1</span>
|
||||
n >>>= <span class="hljs-number">1</span>
|
||||
str += str
|
||||
res</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-6">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-6">¶</a>
|
||||
</div>
|
||||
<p>Trim out all falsy values from an array.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.compact = <span class="hljs-function"><span class="hljs-params">(array)</span> -></span>
|
||||
item <span class="hljs-keyword">for</span> item <span class="hljs-keyword">in</span> array <span class="hljs-keyword">when</span> item</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-7">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-7">¶</a>
|
||||
</div>
|
||||
<p>Count the number of occurrences of a string in a string.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.count = <span class="hljs-function"><span class="hljs-params">(string, substr)</span> -></span>
|
||||
num = pos = <span class="hljs-number">0</span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span>/<span class="hljs-number">0</span> <span class="hljs-keyword">unless</span> substr.length
|
||||
num++ <span class="hljs-keyword">while</span> pos = <span class="hljs-number">1</span> + string.indexOf substr, pos
|
||||
num</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
<p>Merge objects, returning a fresh copy with attributes from both sides.
|
||||
Used every time <code>Base#compile</code> is called, to allow properties in the
|
||||
options hash to propagate down the tree without polluting other branches.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.merge = <span class="hljs-function"><span class="hljs-params">(options, overrides)</span> -></span>
|
||||
extend (extend {}, options), overrides</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-9">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
</div>
|
||||
<p>Extend a source object with the properties of another object (shallow copy).</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>extend = exports.extend = <span class="hljs-function"><span class="hljs-params">(object, properties)</span> -></span>
|
||||
<span class="hljs-keyword">for</span> key, val <span class="hljs-keyword">of</span> properties
|
||||
object[key] = val
|
||||
object</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-10">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
</div>
|
||||
<p>Return a flattened version of an array.
|
||||
Handy for getting a list of <code>children</code> from the nodes.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.flatten = flatten = <span class="hljs-function"><span class="hljs-params">(array)</span> -></span>
|
||||
flattened = []
|
||||
<span class="hljs-keyword">for</span> element <span class="hljs-keyword">in</span> array
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-string">'[object Array]'</span> <span class="hljs-keyword">is</span> Object::toString.call element
|
||||
flattened = flattened.concat flatten element
|
||||
<span class="hljs-keyword">else</span>
|
||||
flattened.push element
|
||||
flattened</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-11">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
</div>
|
||||
<p>Delete a key from an object, returning the value. Useful when a node is
|
||||
looking for a particular method in an options hash.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.del = <span class="hljs-function"><span class="hljs-params">(obj, key)</span> -></span>
|
||||
val = obj[key]
|
||||
<span class="hljs-keyword">delete</span> obj[key]
|
||||
val</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-12">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
</div>
|
||||
<p>Typical Array::some</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.some = Array::some ? (fn) ->
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-literal">true</span> <span class="hljs-keyword">for</span> e <span class="hljs-keyword">in</span> <span class="hljs-keyword">this</span> <span class="hljs-keyword">when</span> fn e
|
||||
<span class="hljs-literal">false</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-13">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-13">¶</a>
|
||||
</div>
|
||||
<p>Simple function for inverting Literate CoffeeScript code by putting the
|
||||
documentation in comments, producing a string of CoffeeScript code that
|
||||
can be compiled “normally”.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.invertLiterate = <span class="hljs-function"><span class="hljs-params">(code)</span> -></span>
|
||||
maybe_code = <span class="hljs-literal">true</span>
|
||||
lines = <span class="hljs-keyword">for</span> line <span class="hljs-keyword">in</span> code.split(<span class="hljs-string">'\n'</span>)
|
||||
<span class="hljs-keyword">if</span> maybe_code <span class="hljs-keyword">and</span> <span class="hljs-regexp">/^([ ]{4}|[ ]{0,3}\t)/</span>.test line
|
||||
line
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> maybe_code = <span class="hljs-regexp">/^\s*$/</span>.test line
|
||||
line
|
||||
<span class="hljs-keyword">else</span>
|
||||
<span class="hljs-string">'# '</span> + line
|
||||
lines.join <span class="hljs-string">'\n'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-14">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-14">¶</a>
|
||||
</div>
|
||||
<p>Merge two jison-style location data objects together.
|
||||
If <code>last</code> is not provided, this will simply return <code>first</code>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">buildLocationData</span> = <span class="hljs-params">(first, last)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> last
|
||||
first
|
||||
<span class="hljs-keyword">else</span>
|
||||
first_line: first.first_line
|
||||
first_column: first.first_column
|
||||
last_line: last.last_line
|
||||
last_column: last.last_column</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-15">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
</div>
|
||||
<p>This returns a function which takes an object as a parameter, and if that
|
||||
object is an AST node, updates that object’s locationData.
|
||||
The object is returned either way.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.addLocationDataFn = <span class="hljs-function"><span class="hljs-params">(first, last)</span> -></span>
|
||||
(obj) ->
|
||||
<span class="hljs-keyword">if</span> ((<span class="hljs-keyword">typeof</span> obj) <span class="hljs-keyword">is</span> <span class="hljs-string">'object'</span>) <span class="hljs-keyword">and</span> (!!obj[<span class="hljs-string">'updateLocationDataIfMissing'</span>])
|
||||
obj.updateLocationDataIfMissing buildLocationData(first, last)
|
||||
|
||||
<span class="hljs-keyword">return</span> obj</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-16">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-16">¶</a>
|
||||
</div>
|
||||
<p>Convert jison location data to a string.
|
||||
<code>obj</code> can be a token, or a locationData.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.locationDataToString = <span class="hljs-function"><span class="hljs-params">(obj)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> (<span class="hljs-string">"2"</span> <span class="hljs-keyword">of</span> obj) <span class="hljs-keyword">and</span> (<span class="hljs-string">"first_line"</span> <span class="hljs-keyword">of</span> obj[<span class="hljs-number">2</span>]) <span class="hljs-keyword">then</span> locationData = obj[<span class="hljs-number">2</span>]
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> <span class="hljs-string">"first_line"</span> <span class="hljs-keyword">of</span> obj <span class="hljs-keyword">then</span> locationData = obj
|
||||
|
||||
<span class="hljs-keyword">if</span> locationData
|
||||
<span class="hljs-string">"<span class="hljs-subst">#{locationData.first_line + <span class="hljs-number">1</span>}</span>:<span class="hljs-subst">#{locationData.first_column + <span class="hljs-number">1</span>}</span>-"</span> +
|
||||
<span class="hljs-string">"<span class="hljs-subst">#{locationData.last_line + <span class="hljs-number">1</span>}</span>:<span class="hljs-subst">#{locationData.last_column + <span class="hljs-number">1</span>}</span>"</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
<span class="hljs-string">"No location data"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-17">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-17">¶</a>
|
||||
</div>
|
||||
<p>A <code>.coffee.md</code> compatible version of <code>basename</code>, that returns the file sans-extension.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.baseFileName = <span class="hljs-function"><span class="hljs-params">(file, stripExt = <span class="hljs-literal">no</span>, useWinPathSep = <span class="hljs-literal">no</span>)</span> -></span>
|
||||
pathSep = <span class="hljs-keyword">if</span> useWinPathSep <span class="hljs-keyword">then</span> <span class="hljs-regexp">/\\|\//</span> <span class="hljs-keyword">else</span> <span class="hljs-regexp">/\//</span>
|
||||
parts = file.split(pathSep)
|
||||
file = parts[parts.length - <span class="hljs-number">1</span>]
|
||||
<span class="hljs-keyword">return</span> file <span class="hljs-keyword">unless</span> stripExt <span class="hljs-keyword">and</span> file.indexOf(<span class="hljs-string">'.'</span>) >= <span class="hljs-number">0</span>
|
||||
parts = file.split(<span class="hljs-string">'.'</span>)
|
||||
parts.pop()
|
||||
parts.pop() <span class="hljs-keyword">if</span> parts[parts.length - <span class="hljs-number">1</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'coffee'</span> <span class="hljs-keyword">and</span> parts.length > <span class="hljs-number">1</span>
|
||||
parts.join(<span class="hljs-string">'.'</span>)</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-18">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
</div>
|
||||
<p>Determine if a filename represents a CoffeeScript file.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.isCoffee = <span class="hljs-function"><span class="hljs-params">(file)</span> -></span> <span class="hljs-regexp">/\.((lit)?coffee|coffee\.md)$/</span>.test file</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-19">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-19">¶</a>
|
||||
</div>
|
||||
<p>Determine if a filename represents a Literate CoffeeScript file.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.isLiterate = <span class="hljs-function"><span class="hljs-params">(file)</span> -></span> <span class="hljs-regexp">/\.(litcoffee|coffee\.md)$/</span>.test file</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-20">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-20">¶</a>
|
||||
</div>
|
||||
<p>Throws a SyntaxError from a given location.
|
||||
The error’s <code>toString</code> will return an error message following the “standard”
|
||||
format <code><filename>:<line>:<col>: <message></code> plus the line with the error and a
|
||||
marker showing where the error is.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.throwSyntaxError = <span class="hljs-function"><span class="hljs-params">(message, location)</span> -></span>
|
||||
error = <span class="hljs-keyword">new</span> SyntaxError message
|
||||
error.location = location
|
||||
error.toString = syntaxErrorToString</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-21">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-21">¶</a>
|
||||
</div>
|
||||
<p>Instead of showing the compiler’s stacktrace, show our custom error message
|
||||
(this is useful when the error bubbles up in Node.js applications that
|
||||
compile CoffeeScript for example).</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> error.stack = error.toString()
|
||||
|
||||
<span class="hljs-keyword">throw</span> error</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-22">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-22">¶</a>
|
||||
</div>
|
||||
<p>Update a compiler SyntaxError with source code information if it didn’t have
|
||||
it already.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.updateSyntaxError = <span class="hljs-function"><span class="hljs-params">(error, code, filename)</span> -></span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-23">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-23">¶</a>
|
||||
</div>
|
||||
<p>Avoid screwing up the <code>stack</code> property of other errors (i.e. possible bugs).</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> error.toString <span class="hljs-keyword">is</span> syntaxErrorToString
|
||||
error.code <span class="hljs-keyword">or</span>= code
|
||||
error.filename <span class="hljs-keyword">or</span>= filename
|
||||
error.stack = error.toString()
|
||||
error
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">syntaxErrorToString</span> = -></span>
|
||||
<span class="hljs-keyword">return</span> Error::toString.call @ <span class="hljs-keyword">unless</span> @code <span class="hljs-keyword">and</span> @location
|
||||
|
||||
{first_line, first_column, last_line, last_column} = @location
|
||||
last_line ?= first_line
|
||||
last_column ?= first_column
|
||||
|
||||
filename = @filename <span class="hljs-keyword">or</span> <span class="hljs-string">'[stdin]'</span>
|
||||
codeLine = @code.split(<span class="hljs-string">'\n'</span>)[first_line]
|
||||
start = first_column</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-24">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-24">¶</a>
|
||||
</div>
|
||||
<p>Show only the first line on multi-line errors.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> end = <span class="hljs-keyword">if</span> first_line <span class="hljs-keyword">is</span> last_line <span class="hljs-keyword">then</span> last_column + <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> codeLine.length
|
||||
marker = codeLine[...start].replace(<span class="hljs-regexp">/[^\s]/g</span>, <span class="hljs-string">' '</span>) + repeat(<span class="hljs-string">'^'</span>, end - start)</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-25">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-25">¶</a>
|
||||
</div>
|
||||
<p>Check to see if we’re running on a color-enabled TTY.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> process?
|
||||
colorsEnabled = process.stdout?.isTTY <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> process.env?.NODE_DISABLE_COLORS
|
||||
|
||||
<span class="hljs-keyword">if</span> @colorful ? colorsEnabled
|
||||
<span class="hljs-function"> <span class="hljs-title">colorize</span> = <span class="hljs-params">(str)</span> -></span> <span class="hljs-string">"\x1B[1;31m<span class="hljs-subst">#{str}</span>\x1B[0m"</span>
|
||||
codeLine = codeLine[...start] + colorize(codeLine[start...end]) + codeLine[end..]
|
||||
marker = colorize marker
|
||||
|
||||
<span class="hljs-string">"""
|
||||
<span class="hljs-subst">#{filename}</span>:<span class="hljs-subst">#{first_line + <span class="hljs-number">1</span>}</span>:<span class="hljs-subst">#{first_column + <span class="hljs-number">1</span>}</span>: error: <span class="hljs-subst">#{@message}</span>
|
||||
<span class="hljs-subst">#{codeLine}</span>
|
||||
<span class="hljs-subst">#{marker}</span>
|
||||
"""</span>
|
||||
|
||||
exports.nameWhitespaceCharacter = <span class="hljs-function"><span class="hljs-params">(string)</span> -></span>
|
||||
<span class="hljs-keyword">switch</span> string
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-string">' '</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'space'</span>
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-string">'\n'</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'newline'</span>
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-string">'\r'</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'carriage return'</span>
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-string">'\t'</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'tab'</span>
|
||||
<span class="hljs-keyword">else</span> string</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
129
docs/v1/annotated-source/index.html
Normal file
@@ -0,0 +1,129 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>index.coffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="register.html">
|
||||
register.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>index.coffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
<p>Loader for CoffeeScript as a Node.js library.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports[key] = val <span class="hljs-keyword">for</span> key, val <span class="hljs-keyword">of</span> <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffee-script'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
2242
docs/v1/annotated-source/lexer.html
Normal file
5179
docs/v1/annotated-source/nodes.html
Normal file
366
docs/v1/annotated-source/optparse.html
Normal file
@@ -0,0 +1,366 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>optparse.coffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="register.html">
|
||||
register.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>optparse.coffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>{repeat} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-2">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-2">¶</a>
|
||||
</div>
|
||||
<p>A simple <strong>OptionParser</strong> class to parse option flags from the command-line.
|
||||
Use it like so:</p>
|
||||
<pre><code>parser = <span class="hljs-keyword">new</span> OptionParser switches, helpBanner
|
||||
options = parser.parse process.argv
|
||||
</code></pre><p>The first non-option is considered to be the start of the file (and file
|
||||
option) list, and all subsequent arguments are left unparsed.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.OptionParser = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">OptionParser</span></span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-3">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-3">¶</a>
|
||||
</div>
|
||||
<p>Initialize with a list of valid options, in the form:</p>
|
||||
<pre><code>[short-flag, long-flag, description]
|
||||
</code></pre><p>Along with an optional banner for the usage help.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> constructor: <span class="hljs-function"><span class="hljs-params">(rules, @banner)</span> -></span>
|
||||
@rules = buildRules rules</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-4">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-4">¶</a>
|
||||
</div>
|
||||
<p>Parse the list of arguments, populating an <code>options</code> object with all of the
|
||||
specified options, and return it. Options after the first non-option
|
||||
argument are treated as arguments. <code>options.arguments</code> will be an array
|
||||
containing the remaining arguments. This is a simpler API than many option
|
||||
parsers that allow you to attach callback actions for every flag. Instead,
|
||||
you’re responsible for interpreting the options object.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> parse: <span class="hljs-function"><span class="hljs-params">(args)</span> -></span>
|
||||
options = arguments: []
|
||||
skippingArgument = <span class="hljs-literal">no</span>
|
||||
originalArgs = args
|
||||
args = normalizeArguments args
|
||||
<span class="hljs-keyword">for</span> arg, i <span class="hljs-keyword">in</span> args
|
||||
<span class="hljs-keyword">if</span> skippingArgument
|
||||
skippingArgument = <span class="hljs-literal">no</span>
|
||||
<span class="hljs-keyword">continue</span>
|
||||
<span class="hljs-keyword">if</span> arg <span class="hljs-keyword">is</span> <span class="hljs-string">'--'</span>
|
||||
pos = originalArgs.indexOf <span class="hljs-string">'--'</span>
|
||||
options.arguments = options.arguments.concat originalArgs[(pos + <span class="hljs-number">1</span>)..]
|
||||
<span class="hljs-keyword">break</span>
|
||||
isOption = !!(arg.match(LONG_FLAG) <span class="hljs-keyword">or</span> arg.match(SHORT_FLAG))</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-5">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-5">¶</a>
|
||||
</div>
|
||||
<p>the CS option parser is a little odd; options after the first
|
||||
non-option argument are treated as non-option arguments themselves</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> seenNonOptionArg = options.arguments.length > <span class="hljs-number">0</span>
|
||||
<span class="hljs-keyword">unless</span> seenNonOptionArg
|
||||
matchedRule = <span class="hljs-literal">no</span>
|
||||
<span class="hljs-keyword">for</span> rule <span class="hljs-keyword">in</span> @rules
|
||||
<span class="hljs-keyword">if</span> rule.shortFlag <span class="hljs-keyword">is</span> arg <span class="hljs-keyword">or</span> rule.longFlag <span class="hljs-keyword">is</span> arg
|
||||
value = <span class="hljs-literal">true</span>
|
||||
<span class="hljs-keyword">if</span> rule.hasArgument
|
||||
skippingArgument = <span class="hljs-literal">yes</span>
|
||||
value = args[i + <span class="hljs-number">1</span>]
|
||||
options[rule.name] = <span class="hljs-keyword">if</span> rule.isList <span class="hljs-keyword">then</span> (options[rule.name] <span class="hljs-keyword">or</span> []).concat value <span class="hljs-keyword">else</span> value
|
||||
matchedRule = <span class="hljs-literal">yes</span>
|
||||
<span class="hljs-keyword">break</span>
|
||||
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"unrecognized option: <span class="hljs-subst">#{arg}</span>"</span> <span class="hljs-keyword">if</span> isOption <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> matchedRule
|
||||
<span class="hljs-keyword">if</span> seenNonOptionArg <span class="hljs-keyword">or</span> <span class="hljs-keyword">not</span> isOption
|
||||
options.arguments.push arg
|
||||
options</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-6">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-6">¶</a>
|
||||
</div>
|
||||
<p>Return the help text for this <strong>OptionParser</strong>, listing and describing all
|
||||
of the valid options, for <code>--help</code> and such.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> help: <span class="hljs-function">-></span>
|
||||
lines = []
|
||||
lines.unshift <span class="hljs-string">"<span class="hljs-subst">#{@banner}</span>\n"</span> <span class="hljs-keyword">if</span> @banner
|
||||
<span class="hljs-keyword">for</span> rule <span class="hljs-keyword">in</span> @rules
|
||||
spaces = <span class="hljs-number">15</span> - rule.longFlag.length
|
||||
spaces = <span class="hljs-keyword">if</span> spaces > <span class="hljs-number">0</span> <span class="hljs-keyword">then</span> repeat <span class="hljs-string">' '</span>, spaces <span class="hljs-keyword">else</span> <span class="hljs-string">''</span>
|
||||
letPart = <span class="hljs-keyword">if</span> rule.shortFlag <span class="hljs-keyword">then</span> rule.shortFlag + <span class="hljs-string">', '</span> <span class="hljs-keyword">else</span> <span class="hljs-string">' '</span>
|
||||
lines.push <span class="hljs-string">' '</span> + letPart + rule.longFlag + spaces + rule.description
|
||||
<span class="hljs-string">"\n<span class="hljs-subst">#{ lines.join(<span class="hljs-string">'\n'</span>) }</span>\n"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-7">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-7">¶</a>
|
||||
</div>
|
||||
<h2 id="helpers">Helpers</h2>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-9">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
</div>
|
||||
<p>Regex matchers for option flags.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>LONG_FLAG = <span class="hljs-regexp">/^(--\w[\w\-]*)/</span>
|
||||
SHORT_FLAG = <span class="hljs-regexp">/^(-\w)$/</span>
|
||||
MULTI_FLAG = <span class="hljs-regexp">/^-(\w{2,})/</span>
|
||||
OPTIONAL = <span class="hljs-regexp">/\[(\w+(\*?))\]/</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-10">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
</div>
|
||||
<p>Build and return the list of option rules. If the optional <em>short-flag</em> is
|
||||
unspecified, leave it out by padding with <code>null</code>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">buildRules</span> = <span class="hljs-params">(rules)</span> -></span>
|
||||
<span class="hljs-keyword">for</span> tuple <span class="hljs-keyword">in</span> rules
|
||||
tuple.unshift <span class="hljs-literal">null</span> <span class="hljs-keyword">if</span> tuple.length < <span class="hljs-number">3</span>
|
||||
buildRule tuple...</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-11">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
</div>
|
||||
<p>Build a rule from a <code>-o</code> short flag, a <code>--output [DIR]</code> long flag, and the
|
||||
description of what the option does.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">buildRule</span> = <span class="hljs-params">(shortFlag, longFlag, description, options = {})</span> -></span>
|
||||
match = longFlag.match(OPTIONAL)
|
||||
longFlag = longFlag.match(LONG_FLAG)[<span class="hljs-number">1</span>]
|
||||
{
|
||||
name: longFlag.substr <span class="hljs-number">2</span>
|
||||
shortFlag: shortFlag
|
||||
longFlag: longFlag
|
||||
description: description
|
||||
hasArgument: !!(match <span class="hljs-keyword">and</span> match[<span class="hljs-number">1</span>])
|
||||
isList: !!(match <span class="hljs-keyword">and</span> match[<span class="hljs-number">2</span>])
|
||||
}</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-12">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
</div>
|
||||
<p>Normalize arguments by expanding merged flags into multiple flags. This allows
|
||||
you to have <code>-wl</code> be the same as <code>--watch --lint</code>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">normalizeArguments</span> = <span class="hljs-params">(args)</span> -></span>
|
||||
args = args[..]
|
||||
result = []
|
||||
<span class="hljs-keyword">for</span> arg <span class="hljs-keyword">in</span> args
|
||||
<span class="hljs-keyword">if</span> match = arg.match MULTI_FLAG
|
||||
result.push <span class="hljs-string">'-'</span> + l <span class="hljs-keyword">for</span> l <span class="hljs-keyword">in</span> match[<span class="hljs-number">1</span>].split <span class="hljs-string">''</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
result.push arg
|
||||
result</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
0
documentation/docs/public/fonts/aller-bold.eot → docs/v1/annotated-source/public/fonts/aller-bold.eot
Executable file → Normal file
0
documentation/docs/public/fonts/aller-bold.ttf → docs/v1/annotated-source/public/fonts/aller-bold.ttf
Executable file → Normal file
0
documentation/docs/public/fonts/aller-bold.woff → docs/v1/annotated-source/public/fonts/aller-bold.woff
Executable file → Normal file
0
documentation/docs/public/fonts/aller-light.eot → docs/v1/annotated-source/public/fonts/aller-light.eot
Executable file → Normal file
0
documentation/docs/public/fonts/aller-light.ttf → docs/v1/annotated-source/public/fonts/aller-light.ttf
Executable file → Normal file
0
documentation/docs/public/fonts/aller-light.woff → docs/v1/annotated-source/public/fonts/aller-light.woff
Executable file → Normal file
BIN
docs/v1/annotated-source/public/fonts/roboto-black.eot
Executable file
BIN
docs/v1/annotated-source/public/fonts/roboto-black.ttf
Executable file
BIN
docs/v1/annotated-source/public/fonts/roboto-black.woff
Executable file
251
docs/v1/annotated-source/register.html
Normal file
@@ -0,0 +1,251 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>register.coffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="register.html">
|
||||
register.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>register.coffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffee-script'</span>
|
||||
child_process = <span class="hljs-built_in">require</span> <span class="hljs-string">'child_process'</span>
|
||||
helpers = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span>
|
||||
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-2">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-2">¶</a>
|
||||
</div>
|
||||
<p>Load and run a CoffeeScript file for Node, stripping any <code>BOM</code>s.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">loadFile</span> = <span class="hljs-params">(<span class="hljs-built_in">module</span>, filename)</span> -></span>
|
||||
answer = CoffeeScript._compileFile filename, <span class="hljs-literal">no</span>, <span class="hljs-literal">yes</span>
|
||||
<span class="hljs-built_in">module</span>._compile answer, filename</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-3">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-3">¶</a>
|
||||
</div>
|
||||
<p>If the installed version of Node supports <code>require.extensions</code>, register
|
||||
CoffeeScript as an extension.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> <span class="hljs-built_in">require</span>.extensions
|
||||
<span class="hljs-keyword">for</span> ext <span class="hljs-keyword">in</span> CoffeeScript.FILE_EXTENSIONS
|
||||
<span class="hljs-built_in">require</span>.extensions[ext] = loadFile</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-4">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-4">¶</a>
|
||||
</div>
|
||||
<p>Patch Node’s module loader to be able to handle multi-dot extensions.
|
||||
This is a horrible thing that should not be required.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> Module = <span class="hljs-built_in">require</span> <span class="hljs-string">'module'</span>
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">findExtension</span> = <span class="hljs-params">(filename)</span> -></span>
|
||||
extensions = path.basename(filename).split <span class="hljs-string">'.'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-5">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-5">¶</a>
|
||||
</div>
|
||||
<p>Remove the initial dot from dotfiles.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> extensions.shift() <span class="hljs-keyword">if</span> extensions[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">''</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-6">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-6">¶</a>
|
||||
</div>
|
||||
<p>Start with the longest possible extension and work our way shortwards.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">while</span> extensions.shift()
|
||||
curExtension = <span class="hljs-string">'.'</span> + extensions.join <span class="hljs-string">'.'</span>
|
||||
<span class="hljs-keyword">return</span> curExtension <span class="hljs-keyword">if</span> Module._extensions[curExtension]
|
||||
<span class="hljs-string">'.js'</span>
|
||||
|
||||
Module::load = <span class="hljs-function"><span class="hljs-params">(filename)</span> -></span>
|
||||
@filename = filename
|
||||
@paths = Module._nodeModulePaths path.dirname filename
|
||||
extension = findExtension filename
|
||||
Module._extensions[extension](<span class="hljs-keyword">this</span>, filename)
|
||||
@loaded = <span class="hljs-literal">true</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-7">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-7">¶</a>
|
||||
</div>
|
||||
<p>If we’re on Node, patch <code>child_process.fork</code> so that Coffee scripts are able
|
||||
to fork both CoffeeScript files, and JavaScript files, directly.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> child_process
|
||||
{fork} = child_process
|
||||
binary = <span class="hljs-built_in">require</span>.resolve <span class="hljs-string">'../../bin/coffee'</span>
|
||||
child_process.fork = <span class="hljs-function"><span class="hljs-params">(path, args, options)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> helpers.isCoffee path
|
||||
<span class="hljs-keyword">unless</span> Array.isArray args
|
||||
options = args <span class="hljs-keyword">or</span> {}
|
||||
args = []
|
||||
args = [path].concat args
|
||||
path = binary
|
||||
fork path, args, options</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
624
docs/v1/annotated-source/repl.html
Normal file
@@ -0,0 +1,624 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>repl.coffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="register.html">
|
||||
register.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>repl.coffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>fs = <span class="hljs-built_in">require</span> <span class="hljs-string">'fs'</span>
|
||||
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span>
|
||||
vm = <span class="hljs-built_in">require</span> <span class="hljs-string">'vm'</span>
|
||||
nodeREPL = <span class="hljs-built_in">require</span> <span class="hljs-string">'repl'</span>
|
||||
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffee-script'</span>
|
||||
{merge, updateSyntaxError} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span>
|
||||
|
||||
replDefaults =
|
||||
prompt: <span class="hljs-string">'coffee> '</span>,
|
||||
historyFile: path.join process.env.HOME, <span class="hljs-string">'.coffee_history'</span> <span class="hljs-keyword">if</span> process.env.HOME
|
||||
historyMaxInputSize: <span class="hljs-number">10240</span>
|
||||
eval: <span class="hljs-function"><span class="hljs-params">(input, context, filename, cb)</span> -></span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-2">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-2">¶</a>
|
||||
</div>
|
||||
<p>XXX: multiline hack.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> input = input.replace <span class="hljs-regexp">/\uFF00/g</span>, <span class="hljs-string">'\n'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-3">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-3">¶</a>
|
||||
</div>
|
||||
<p>Node’s REPL sends the input ending with a newline and then wrapped in
|
||||
parens. Unwrap all that.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> input = input.replace <span class="hljs-regexp">/^\(([\s\S]*)\n\)$/m</span>, <span class="hljs-string">'$1'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-4">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-4">¶</a>
|
||||
</div>
|
||||
<p>Node’s REPL v6.9.1+ sends the input wrapped in a try/catch statement.
|
||||
Unwrap that too.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> input = input.replace <span class="hljs-regexp">/^\s*try\s*{([\s\S]*)}\s*catch.*$/m</span>, <span class="hljs-string">'$1'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-5">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-5">¶</a>
|
||||
</div>
|
||||
<p>Require AST nodes to do some AST manipulation.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> {Block, Assign, Value, Literal} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./nodes'</span>
|
||||
|
||||
<span class="hljs-keyword">try</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-6">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-6">¶</a>
|
||||
</div>
|
||||
<p>Tokenize the clean input.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> tokens = CoffeeScript.tokens input</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-7">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-7">¶</a>
|
||||
</div>
|
||||
<p>Collect referenced variable names just like in <code>CoffeeScript.compile</code>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> referencedVars = (
|
||||
token[<span class="hljs-number">1</span>] <span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> tokens <span class="hljs-keyword">when</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'IDENTIFIER'</span>
|
||||
)</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
<p>Generate the AST of the tokens.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> ast = CoffeeScript.nodes tokens</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-9">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
</div>
|
||||
<p>Add assignment to <code>_</code> variable to force the input to be an expression.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> ast = <span class="hljs-keyword">new</span> Block [
|
||||
<span class="hljs-keyword">new</span> Assign (<span class="hljs-keyword">new</span> Value <span class="hljs-keyword">new</span> Literal <span class="hljs-string">'_'</span>), ast, <span class="hljs-string">'='</span>
|
||||
]
|
||||
js = ast.compile {bare: <span class="hljs-literal">yes</span>, locals: Object.keys(context), referencedVars}
|
||||
cb <span class="hljs-literal">null</span>, runInContext js, context, filename
|
||||
<span class="hljs-keyword">catch</span> err</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-10">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
</div>
|
||||
<p>AST’s <code>compile</code> does not add source code information to syntax errors.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> updateSyntaxError err, input
|
||||
cb err
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">runInContext</span> = <span class="hljs-params">(js, context, filename)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> context <span class="hljs-keyword">is</span> <span class="hljs-built_in">global</span>
|
||||
vm.runInThisContext js, filename
|
||||
<span class="hljs-keyword">else</span>
|
||||
vm.runInContext js, context, filename
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">addMultilineHandler</span> = <span class="hljs-params">(repl)</span> -></span>
|
||||
{rli, inputStream, outputStream} = repl</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-11">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
</div>
|
||||
<p>Node 0.11.12 changed API, prompt is now _prompt.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> origPrompt = repl._prompt ? repl.prompt
|
||||
|
||||
multiline =
|
||||
enabled: <span class="hljs-literal">off</span>
|
||||
initialPrompt: origPrompt.replace <span class="hljs-regexp">/^[^> ]*/</span>, <span class="hljs-function"><span class="hljs-params">(x)</span> -></span> x.replace <span class="hljs-regexp">/./g</span>, <span class="hljs-string">'-'</span>
|
||||
prompt: origPrompt.replace <span class="hljs-regexp">/^[^> ]*>?/</span>, <span class="hljs-function"><span class="hljs-params">(x)</span> -></span> x.replace <span class="hljs-regexp">/./g</span>, <span class="hljs-string">'.'</span>
|
||||
buffer: <span class="hljs-string">''</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-12">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
</div>
|
||||
<p>Proxy node’s line listener</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> nodeLineListener = rli.listeners(<span class="hljs-string">'line'</span>)[<span class="hljs-number">0</span>]
|
||||
rli.removeListener <span class="hljs-string">'line'</span>, nodeLineListener
|
||||
rli.<span class="hljs-literal">on</span> <span class="hljs-string">'line'</span>, <span class="hljs-function"><span class="hljs-params">(cmd)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> multiline.enabled
|
||||
multiline.buffer += <span class="hljs-string">"<span class="hljs-subst">#{cmd}</span>\n"</span>
|
||||
rli.setPrompt multiline.prompt
|
||||
rli.prompt <span class="hljs-literal">true</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
rli.setPrompt origPrompt
|
||||
nodeLineListener cmd
|
||||
<span class="hljs-keyword">return</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-13">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-13">¶</a>
|
||||
</div>
|
||||
<p>Handle Ctrl-v</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> inputStream.<span class="hljs-literal">on</span> <span class="hljs-string">'keypress'</span>, <span class="hljs-function"><span class="hljs-params">(char, key)</span> -></span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> key <span class="hljs-keyword">and</span> key.ctrl <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> key.meta <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> key.shift <span class="hljs-keyword">and</span> key.name <span class="hljs-keyword">is</span> <span class="hljs-string">'v'</span>
|
||||
<span class="hljs-keyword">if</span> multiline.enabled</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-14">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-14">¶</a>
|
||||
</div>
|
||||
<p>allow arbitrarily switching between modes any time before multiple lines are entered</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">unless</span> multiline.buffer.match <span class="hljs-regexp">/\n/</span>
|
||||
multiline.enabled = <span class="hljs-keyword">not</span> multiline.enabled
|
||||
rli.setPrompt origPrompt
|
||||
rli.prompt <span class="hljs-literal">true</span>
|
||||
<span class="hljs-keyword">return</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-15">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
</div>
|
||||
<p>no-op unless the current line is empty</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> rli.line? <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> rli.line.match <span class="hljs-regexp">/^\s*$/</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-16">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-16">¶</a>
|
||||
</div>
|
||||
<p>eval, print, loop</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> multiline.enabled = <span class="hljs-keyword">not</span> multiline.enabled
|
||||
rli.line = <span class="hljs-string">''</span>
|
||||
rli.cursor = <span class="hljs-number">0</span>
|
||||
rli.output.cursorTo <span class="hljs-number">0</span>
|
||||
rli.output.clearLine <span class="hljs-number">1</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-17">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-17">¶</a>
|
||||
</div>
|
||||
<p>XXX: multiline hack</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> multiline.buffer = multiline.buffer.replace <span class="hljs-regexp">/\n/g</span>, <span class="hljs-string">'\uFF00'</span>
|
||||
rli.emit <span class="hljs-string">'line'</span>, multiline.buffer
|
||||
multiline.buffer = <span class="hljs-string">''</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
multiline.enabled = <span class="hljs-keyword">not</span> multiline.enabled
|
||||
rli.setPrompt multiline.initialPrompt
|
||||
rli.prompt <span class="hljs-literal">true</span>
|
||||
<span class="hljs-keyword">return</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-18">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
</div>
|
||||
<p>Store and load command history from a file</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">addHistory</span> = <span class="hljs-params">(repl, filename, maxSize)</span> -></span>
|
||||
lastLine = <span class="hljs-literal">null</span>
|
||||
<span class="hljs-keyword">try</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-19">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-19">¶</a>
|
||||
</div>
|
||||
<p>Get file info and at most maxSize of command history</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> stat = fs.statSync filename
|
||||
size = Math.min maxSize, stat.size</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-20">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-20">¶</a>
|
||||
</div>
|
||||
<p>Read last <code>size</code> bytes from the file</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> readFd = fs.openSync filename, <span class="hljs-string">'r'</span>
|
||||
buffer = <span class="hljs-keyword">new</span> Buffer(size)
|
||||
fs.readSync readFd, buffer, <span class="hljs-number">0</span>, size, stat.size - size
|
||||
fs.closeSync readFd</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-21">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-21">¶</a>
|
||||
</div>
|
||||
<p>Set the history on the interpreter</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> repl.rli.history = buffer.toString().split(<span class="hljs-string">'\n'</span>).reverse()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-22">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-22">¶</a>
|
||||
</div>
|
||||
<p>If the history file was truncated we should pop off a potential partial line</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> repl.rli.history.pop() <span class="hljs-keyword">if</span> stat.size > maxSize</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-23">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-23">¶</a>
|
||||
</div>
|
||||
<p>Shift off the final blank newline</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> repl.rli.history.shift() <span class="hljs-keyword">if</span> repl.rli.history[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">''</span>
|
||||
repl.rli.historyIndex = <span class="hljs-number">-1</span>
|
||||
lastLine = repl.rli.history[<span class="hljs-number">0</span>]
|
||||
|
||||
fd = fs.openSync filename, <span class="hljs-string">'a'</span>
|
||||
|
||||
repl.rli.addListener <span class="hljs-string">'line'</span>, <span class="hljs-function"><span class="hljs-params">(code)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> code <span class="hljs-keyword">and</span> code.length <span class="hljs-keyword">and</span> code <span class="hljs-keyword">isnt</span> <span class="hljs-string">'.history'</span> <span class="hljs-keyword">and</span> code <span class="hljs-keyword">isnt</span> <span class="hljs-string">'.exit'</span> <span class="hljs-keyword">and</span> lastLine <span class="hljs-keyword">isnt</span> code</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-24">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-24">¶</a>
|
||||
</div>
|
||||
<p>Save the latest command in the file</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> fs.writeSync fd, <span class="hljs-string">"<span class="hljs-subst">#{code}</span>\n"</span>
|
||||
lastLine = code
|
||||
|
||||
repl.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>, <span class="hljs-function">-></span> fs.closeSync fd</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-25">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-25">¶</a>
|
||||
</div>
|
||||
<p>Add a command to show the history stack</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> repl.commands[getCommandId(repl, <span class="hljs-string">'history'</span>)] =
|
||||
help: <span class="hljs-string">'Show command history'</span>
|
||||
action: <span class="hljs-function">-></span>
|
||||
repl.outputStream.write <span class="hljs-string">"<span class="hljs-subst">#{repl.rli.history[..].reverse().join <span class="hljs-string">'\n'</span>}</span>\n"</span>
|
||||
repl.displayPrompt()
|
||||
<span class="hljs-function">
|
||||
<span class="hljs-title">getCommandId</span> = <span class="hljs-params">(repl, commandName)</span> -></span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-26">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-26">¶</a>
|
||||
</div>
|
||||
<p>Node 0.11 changed API, a command such as ‘.help’ is now stored as ‘help’</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> commandsHaveLeadingDot = repl.commands[<span class="hljs-string">'.help'</span>]?
|
||||
<span class="hljs-keyword">if</span> commandsHaveLeadingDot <span class="hljs-keyword">then</span> <span class="hljs-string">".<span class="hljs-subst">#{commandName}</span>"</span> <span class="hljs-keyword">else</span> commandName
|
||||
|
||||
<span class="hljs-built_in">module</span>.exports =
|
||||
start: <span class="hljs-function"><span class="hljs-params">(opts = {})</span> -></span>
|
||||
[major, minor, build] = process.versions.node.split(<span class="hljs-string">'.'</span>).map (n) -> parseInt(n)
|
||||
|
||||
<span class="hljs-keyword">if</span> major <span class="hljs-keyword">is</span> <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> minor < <span class="hljs-number">8</span>
|
||||
<span class="hljs-built_in">console</span>.warn <span class="hljs-string">"Node 0.8.0+ required for CoffeeScript REPL"</span>
|
||||
process.exit <span class="hljs-number">1</span>
|
||||
|
||||
CoffeeScript.register()
|
||||
process.argv = [<span class="hljs-string">'coffee'</span>].concat process.argv[<span class="hljs-number">2.</span>.]
|
||||
opts = merge replDefaults, opts
|
||||
repl = nodeREPL.start opts
|
||||
runInContext opts.prelude, repl.context, <span class="hljs-string">'prelude'</span> <span class="hljs-keyword">if</span> opts.prelude
|
||||
repl.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>, <span class="hljs-function">-></span> repl.outputStream.write <span class="hljs-string">'\n'</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> repl.rli.closed
|
||||
addMultilineHandler repl
|
||||
addHistory repl, opts.historyFile, opts.historyMaxInputSize <span class="hljs-keyword">if</span> opts.historyFile</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-27">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-27">¶</a>
|
||||
</div>
|
||||
<p>Adapt help inherited from the node REPL</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> repl.commands[getCommandId(repl, <span class="hljs-string">'load'</span>)].help = <span class="hljs-string">'Load code from a file into this REPL session'</span>
|
||||
repl</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
1241
docs/v1/annotated-source/rewriter.html
Normal file
398
docs/v1/annotated-source/scope.html
Normal file
@@ -0,0 +1,398 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>scope.litcoffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="register.html">
|
||||
register.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>scope.litcoffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
<p>The <strong>Scope</strong> class regulates lexical scoping within CoffeeScript. As you
|
||||
generate code, you create a tree of scopes in the same shape as the nested
|
||||
function bodies. Each scope knows about the variables declared within it,
|
||||
and has a reference to its parent enclosing scope. In this way, we know which
|
||||
variables are new and need to be declared with <code>var</code>, and which are shared
|
||||
with external scopes.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.Scope = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Scope</span></span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-2">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-2">¶</a>
|
||||
</div>
|
||||
<p>Initialize a scope with its parent, for lookups up the chain,
|
||||
as well as a reference to the <strong>Block</strong> node it belongs to, which is
|
||||
where it should declare its variables, a reference to the function that
|
||||
it belongs to, and a list of variables referenced in the source code
|
||||
and therefore should be avoided when generating variables.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> constructor: <span class="hljs-function"><span class="hljs-params">(@parent, @expressions, @method, @referencedVars)</span> -></span>
|
||||
@variables = [{name: <span class="hljs-string">'arguments'</span>, type: <span class="hljs-string">'arguments'</span>}]
|
||||
@positions = {}
|
||||
@utilities = {} <span class="hljs-keyword">unless</span> @parent</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-3">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-3">¶</a>
|
||||
</div>
|
||||
<p>The <code>@root</code> is the top-level <strong>Scope</strong> object for a given file.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> @root = @parent?.root ? <span class="hljs-keyword">this</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-4">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-4">¶</a>
|
||||
</div>
|
||||
<p>Adds a new variable or overrides an existing one.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> add: <span class="hljs-function"><span class="hljs-params">(name, type, immediate)</span> -></span>
|
||||
<span class="hljs-keyword">return</span> @parent.add name, type, immediate <span class="hljs-keyword">if</span> @shared <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> immediate
|
||||
<span class="hljs-keyword">if</span> Object::hasOwnProperty.call @positions, name
|
||||
@variables[@positions[name]].type = type
|
||||
<span class="hljs-keyword">else</span>
|
||||
@positions[name] = @variables.push({name, type}) - <span class="hljs-number">1</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-5">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-5">¶</a>
|
||||
</div>
|
||||
<p>When <code>super</code> is called, we need to find the name of the current method we’re
|
||||
in, so that we know how to invoke the same method of the parent class. This
|
||||
can get complicated if super is being called from an inner function.
|
||||
<code>namedMethod</code> will walk up the scope tree until it either finds the first
|
||||
function object that has a name filled in, or bottoms out.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> namedMethod: <span class="hljs-function">-></span>
|
||||
<span class="hljs-keyword">return</span> @method <span class="hljs-keyword">if</span> @method?.name <span class="hljs-keyword">or</span> !@parent
|
||||
@parent.namedMethod()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-6">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-6">¶</a>
|
||||
</div>
|
||||
<p>Look up a variable name in lexical scope, and declare it if it does not
|
||||
already exist.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> find: <span class="hljs-function"><span class="hljs-params">(name)</span> -></span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-literal">yes</span> <span class="hljs-keyword">if</span> @check name
|
||||
@add name, <span class="hljs-string">'var'</span>
|
||||
<span class="hljs-literal">no</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-7">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-7">¶</a>
|
||||
</div>
|
||||
<p>Reserve a variable name as originating from a function parameter for this
|
||||
scope. No <code>var</code> required for internal references.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> parameter: <span class="hljs-function"><span class="hljs-params">(name)</span> -></span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> @shared <span class="hljs-keyword">and</span> @parent.check name, <span class="hljs-literal">yes</span>
|
||||
@add name, <span class="hljs-string">'param'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
<p>Just check to see if a variable has already been declared, without reserving,
|
||||
walks up to the root scope.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> check: <span class="hljs-function"><span class="hljs-params">(name)</span> -></span>
|
||||
!!(@type(name) <span class="hljs-keyword">or</span> @parent?.check(name))</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-9">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
</div>
|
||||
<p>Generate a temporary variable name at the given index.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> temporary: <span class="hljs-function"><span class="hljs-params">(name, index, single=<span class="hljs-literal">false</span>)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> single
|
||||
startCode = name.charCodeAt(<span class="hljs-number">0</span>)
|
||||
endCode = <span class="hljs-string">'z'</span>.charCodeAt(<span class="hljs-number">0</span>)
|
||||
diff = endCode - startCode
|
||||
newCode = startCode + index % (diff + <span class="hljs-number">1</span>)
|
||||
letter = String.fromCharCode(newCode)
|
||||
num = index <span class="hljs-regexp">//</span> (diff + <span class="hljs-number">1</span>)
|
||||
<span class="hljs-string">"<span class="hljs-subst">#{letter}</span><span class="hljs-subst">#{num <span class="hljs-keyword">or</span> <span class="hljs-string">''</span>}</span>"</span>
|
||||
<span class="hljs-keyword">else</span>
|
||||
<span class="hljs-string">"<span class="hljs-subst">#{name}</span><span class="hljs-subst">#{index <span class="hljs-keyword">or</span> <span class="hljs-string">''</span>}</span>"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-10">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
</div>
|
||||
<p>Gets the type of a variable.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> type: <span class="hljs-function"><span class="hljs-params">(name)</span> -></span>
|
||||
<span class="hljs-keyword">return</span> v.type <span class="hljs-keyword">for</span> v <span class="hljs-keyword">in</span> @variables <span class="hljs-keyword">when</span> v.name <span class="hljs-keyword">is</span> name
|
||||
<span class="hljs-literal">null</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-11">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
</div>
|
||||
<p>If we need to store an intermediate result, find an available name for a
|
||||
compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on…</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> freeVariable: <span class="hljs-function"><span class="hljs-params">(name, options={})</span> -></span>
|
||||
index = <span class="hljs-number">0</span>
|
||||
<span class="hljs-keyword">loop</span>
|
||||
temp = @temporary name, index, options.single
|
||||
<span class="hljs-keyword">break</span> <span class="hljs-keyword">unless</span> @check(temp) <span class="hljs-keyword">or</span> temp <span class="hljs-keyword">in</span> @root.referencedVars
|
||||
index++
|
||||
@add temp, <span class="hljs-string">'var'</span>, <span class="hljs-literal">yes</span> <span class="hljs-keyword">if</span> options.reserve ? <span class="hljs-literal">true</span>
|
||||
temp</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-12">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
</div>
|
||||
<p>Ensure that an assignment is made at the top of this scope
|
||||
(or at the top-level scope, if requested).</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> assign: <span class="hljs-function"><span class="hljs-params">(name, value)</span> -></span>
|
||||
@add name, {value, assigned: <span class="hljs-literal">yes</span>}, <span class="hljs-literal">yes</span>
|
||||
@hasAssignments = <span class="hljs-literal">yes</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-13">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-13">¶</a>
|
||||
</div>
|
||||
<p>Does this scope have any declared variables?</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> hasDeclarations: <span class="hljs-function">-></span>
|
||||
!!@declaredVariables().length</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-14">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-14">¶</a>
|
||||
</div>
|
||||
<p>Return the list of variables first declared in this scope.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> declaredVariables: <span class="hljs-function">-></span>
|
||||
(v.name <span class="hljs-keyword">for</span> v <span class="hljs-keyword">in</span> @variables <span class="hljs-keyword">when</span> v.type <span class="hljs-keyword">is</span> <span class="hljs-string">'var'</span>).sort()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-15">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
</div>
|
||||
<p>Return the list of assignments that are supposed to be made at the top
|
||||
of this scope.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> assignedVariables: <span class="hljs-function">-></span>
|
||||
<span class="hljs-string">"<span class="hljs-subst">#{v.name}</span> = <span class="hljs-subst">#{v.type.value}</span>"</span> <span class="hljs-keyword">for</span> v <span class="hljs-keyword">in</span> @variables <span class="hljs-keyword">when</span> v.type.assigned</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
523
docs/v1/annotated-source/sourcemap.html
Normal file
@@ -0,0 +1,523 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>sourcemap.litcoffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="register.html">
|
||||
register.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>sourcemap.litcoffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
<p>Source maps allow JavaScript runtimes to match running JavaScript back to
|
||||
the original source code that corresponds to it. This can be minified
|
||||
JavaScript, but in our case, we’re concerned with mapping pretty-printed
|
||||
JavaScript back to CoffeeScript.</p>
|
||||
<p>In order to produce maps, we must keep track of positions (line number, column number)
|
||||
that originated every node in the syntax tree, and be able to generate a
|
||||
<a href="https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit">map file</a>
|
||||
— which is a compact, VLQ-encoded representation of the JSON serialization
|
||||
of this information — to write out alongside the generated JavaScript.</p>
|
||||
<h2 id="linemap">LineMap</h2>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-2">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-2">¶</a>
|
||||
</div>
|
||||
<p>A <strong>LineMap</strong> object keeps track of information about original line and column
|
||||
positions for a single line of output JavaScript code.
|
||||
<strong>SourceMaps</strong> are implemented in terms of <strong>LineMaps</strong>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">LineMap</span></span>
|
||||
constructor: <span class="hljs-function"><span class="hljs-params">(@line)</span> -></span>
|
||||
@columns = []
|
||||
|
||||
add: <span class="hljs-function"><span class="hljs-params">(column, [sourceLine, sourceColumn], options={})</span> -></span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> @columns[column] <span class="hljs-keyword">and</span> options.noReplace
|
||||
@columns[column] = {line: @line, column, sourceLine, sourceColumn}
|
||||
|
||||
sourceLocation: <span class="hljs-function"><span class="hljs-params">(column)</span> -></span>
|
||||
column-- <span class="hljs-keyword">until</span> (mapping = @columns[column]) <span class="hljs-keyword">or</span> (column <= <span class="hljs-number">0</span>)
|
||||
mapping <span class="hljs-keyword">and</span> [mapping.sourceLine, mapping.sourceColumn]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-3">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-3">¶</a>
|
||||
</div>
|
||||
<h2 id="sourcemap">SourceMap</h2>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-4">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-4">¶</a>
|
||||
</div>
|
||||
<p>Maps locations in a single generated JavaScript file back to locations in
|
||||
the original CoffeeScript source file.</p>
|
||||
<p>This is intentionally agnostic towards how a source map might be represented on
|
||||
disk. Once the compiler is ready to produce a “v3”-style source map, we can walk
|
||||
through the arrays of line and column buffer to produce it.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">SourceMap</span></span>
|
||||
constructor: <span class="hljs-function">-></span>
|
||||
@lines = []</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-5">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-5">¶</a>
|
||||
</div>
|
||||
<p>Adds a mapping to this SourceMap. <code>sourceLocation</code> and <code>generatedLocation</code>
|
||||
are both <code>[line, column]</code> arrays. If <code>options.noReplace</code> is true, then if there
|
||||
is already a mapping for the specified <code>line</code> and <code>column</code>, this will have no
|
||||
effect.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> add: <span class="hljs-function"><span class="hljs-params">(sourceLocation, generatedLocation, options = {})</span> -></span>
|
||||
[line, column] = generatedLocation
|
||||
lineMap = (@lines[line] <span class="hljs-keyword">or</span>= <span class="hljs-keyword">new</span> LineMap(line))
|
||||
lineMap.add column, sourceLocation, options</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-6">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-6">¶</a>
|
||||
</div>
|
||||
<p>Look up the original position of a given <code>line</code> and <code>column</code> in the generated
|
||||
code.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> sourceLocation: <span class="hljs-function"><span class="hljs-params">([line, column])</span> -></span>
|
||||
line-- <span class="hljs-keyword">until</span> (lineMap = @lines[line]) <span class="hljs-keyword">or</span> (line <= <span class="hljs-number">0</span>)
|
||||
lineMap <span class="hljs-keyword">and</span> lineMap.sourceLocation column</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-7">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-7">¶</a>
|
||||
</div>
|
||||
<h2 id="v3-sourcemap-generation">V3 SourceMap Generation</h2>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
<p>Builds up a V3 source map, returning the generated JSON as a string.
|
||||
<code>options.sourceRoot</code> may be used to specify the sourceRoot written to the source
|
||||
map. Also, <code>options.sourceFiles</code> and <code>options.generatedFile</code> may be passed to
|
||||
set “sources” and “file”, respectively.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> generate: <span class="hljs-function"><span class="hljs-params">(options = {}, code = <span class="hljs-literal">null</span>)</span> -></span>
|
||||
writingline = <span class="hljs-number">0</span>
|
||||
lastColumn = <span class="hljs-number">0</span>
|
||||
lastSourceLine = <span class="hljs-number">0</span>
|
||||
lastSourceColumn = <span class="hljs-number">0</span>
|
||||
needComma = <span class="hljs-literal">no</span>
|
||||
buffer = <span class="hljs-string">""</span>
|
||||
|
||||
<span class="hljs-keyword">for</span> lineMap, lineNumber <span class="hljs-keyword">in</span> @lines <span class="hljs-keyword">when</span> lineMap
|
||||
<span class="hljs-keyword">for</span> mapping <span class="hljs-keyword">in</span> lineMap.columns <span class="hljs-keyword">when</span> mapping
|
||||
<span class="hljs-keyword">while</span> writingline < mapping.line
|
||||
lastColumn = <span class="hljs-number">0</span>
|
||||
needComma = <span class="hljs-literal">no</span>
|
||||
buffer += <span class="hljs-string">";"</span>
|
||||
writingline++</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-9">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
</div>
|
||||
<p>Write a comma if we’ve already written a segment on this line.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> needComma
|
||||
buffer += <span class="hljs-string">","</span>
|
||||
needComma = <span class="hljs-literal">no</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-10">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
</div>
|
||||
<p>Write the next segment. Segments can be 1, 4, or 5 values. If just one, then it
|
||||
is a generated column which doesn’t match anything in the source code.</p>
|
||||
<p>The starting column in the generated source, relative to any previous recorded
|
||||
column for the current line:</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> buffer += @encodeVlq mapping.column - lastColumn
|
||||
lastColumn = mapping.column</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-11">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
</div>
|
||||
<p>The index into the list of sources:</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> buffer += @encodeVlq <span class="hljs-number">0</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-12">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
</div>
|
||||
<p>The starting line in the original source, relative to the previous source line.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> buffer += @encodeVlq mapping.sourceLine - lastSourceLine
|
||||
lastSourceLine = mapping.sourceLine</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-13">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-13">¶</a>
|
||||
</div>
|
||||
<p>The starting column in the original source, relative to the previous column.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> buffer += @encodeVlq mapping.sourceColumn - lastSourceColumn
|
||||
lastSourceColumn = mapping.sourceColumn
|
||||
needComma = <span class="hljs-literal">yes</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-14">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-14">¶</a>
|
||||
</div>
|
||||
<p>Produce the canonical JSON object format for a “v3” source map.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> v3 =
|
||||
version: <span class="hljs-number">3</span>
|
||||
file: options.generatedFile <span class="hljs-keyword">or</span> <span class="hljs-string">''</span>
|
||||
sourceRoot: options.sourceRoot <span class="hljs-keyword">or</span> <span class="hljs-string">''</span>
|
||||
sources: options.sourceFiles <span class="hljs-keyword">or</span> [<span class="hljs-string">''</span>]
|
||||
names: []
|
||||
mappings: buffer
|
||||
|
||||
v3.sourcesContent = [code] <span class="hljs-keyword">if</span> options.inlineMap
|
||||
|
||||
v3</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-15">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
</div>
|
||||
<h2 id="base64-vlq-encoding">Base64 VLQ Encoding</h2>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-16">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-16">¶</a>
|
||||
</div>
|
||||
<p>Note that SourceMap VLQ encoding is “backwards”. MIDI-style VLQ encoding puts
|
||||
the most-significant-bit (MSB) from the original value into the MSB of the VLQ
|
||||
encoded value (see <a href="http://en.wikipedia.org/wiki/File:Uintvar_coding.svg">Wikipedia</a>).
|
||||
SourceMap VLQ does things the other way around, with the least significat four
|
||||
bits of the original value encoded into the first byte of the VLQ encoded value.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> VLQ_SHIFT = <span class="hljs-number">5</span>
|
||||
VLQ_CONTINUATION_BIT = <span class="hljs-number">1</span> << VLQ_SHIFT <span class="hljs-comment"># 0010 0000</span>
|
||||
VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - <span class="hljs-number">1</span> <span class="hljs-comment"># 0001 1111</span>
|
||||
|
||||
encodeVlq: <span class="hljs-function"><span class="hljs-params">(value)</span> -></span>
|
||||
answer = <span class="hljs-string">''</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-17">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-17">¶</a>
|
||||
</div>
|
||||
<p>Least significant bit represents the sign.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> signBit = <span class="hljs-keyword">if</span> value < <span class="hljs-number">0</span> <span class="hljs-keyword">then</span> <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> <span class="hljs-number">0</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-18">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
</div>
|
||||
<p>The next bits are the actual value.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> valueToEncode = (Math.abs(value) << <span class="hljs-number">1</span>) + signBit</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-19">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-19">¶</a>
|
||||
</div>
|
||||
<p>Make sure we encode at least one character, even if valueToEncode is 0.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">while</span> valueToEncode <span class="hljs-keyword">or</span> <span class="hljs-keyword">not</span> answer
|
||||
nextChunk = valueToEncode & VLQ_VALUE_MASK
|
||||
valueToEncode = valueToEncode >> VLQ_SHIFT
|
||||
nextChunk |= VLQ_CONTINUATION_BIT <span class="hljs-keyword">if</span> valueToEncode
|
||||
answer += @encodeBase64 nextChunk
|
||||
|
||||
answer</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-20">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-20">¶</a>
|
||||
</div>
|
||||
<h2 id="regular-base64-encoding">Regular Base64 Encoding</h2>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-21">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-21">¶</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> BASE64_CHARS = <span class="hljs-string">'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'</span>
|
||||
|
||||
encodeBase64: <span class="hljs-function"><span class="hljs-params">(value)</span> -></span>
|
||||
BASE64_CHARS[value] <span class="hljs-keyword">or</span> <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"Cannot Base64 encode value: <span class="hljs-subst">#{value}</span>"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-22">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-22">¶</a>
|
||||
</div>
|
||||
<p>Our API for source maps is just the <code>SourceMap</code> class.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">module</span>.exports = SourceMap</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
396
docs/v1/browser-compiler/coffee-script.js
Normal file
@@ -0,0 +1,396 @@
|
||||
/**
|
||||
* CoffeeScript Compiler v1.12.2
|
||||
* http://coffeescript.org
|
||||
*
|
||||
* Copyright 2011, Jeremy Ashkenas
|
||||
* Released under the MIT License
|
||||
*/
|
||||
var $jscomp={scope:{},checkStringArgs:function(t,ya,qa){if(null==t)throw new TypeError("The 'this' value for String.prototype."+qa+" must not be null or undefined");if(ya instanceof RegExp)throw new TypeError("First argument to String.prototype."+qa+" must not be a regular expression");return t+""}};
|
||||
$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(t,ya,qa){if(qa.get||qa.set)throw new TypeError("ES3 does not support getters and setters.");t!=Array.prototype&&t!=Object.prototype&&(t[ya]=qa.value)};$jscomp.getGlobal=function(t){return"undefined"!=typeof window&&window===t?t:"undefined"!=typeof global&&null!=global?global:t};$jscomp.global=$jscomp.getGlobal(this);
|
||||
$jscomp.polyfill=function(t,ya,qa,g){if(ya){qa=$jscomp.global;t=t.split(".");for(g=0;g<t.length-1;g++){var va=t[g];va in qa||(qa[va]={});qa=qa[va]}t=t[t.length-1];g=qa[t];ya=ya(g);ya!=g&&null!=ya&&$jscomp.defineProperty(qa,t,{configurable:!0,writable:!0,value:ya})}};
|
||||
$jscomp.polyfill("String.prototype.repeat",function(t){return t?t:function(t){var qa=$jscomp.checkStringArgs(this,null,"repeat");if(0>t||1342177279<t)throw new RangeError("Invalid count value");t|=0;for(var g="";t;)if(t&1&&(g+=qa),t>>>=1)qa+=qa;return g}},"es6-impl","es3");$jscomp.findInternal=function(t,ya,qa){t instanceof String&&(t=String(t));for(var g=t.length,va=0;va<g;va++){var xa=t[va];if(ya.call(qa,xa,va,t))return{i:va,v:xa}}return{i:-1,v:void 0}};
|
||||
$jscomp.polyfill("Array.prototype.find",function(t){return t?t:function(t,qa){return $jscomp.findInternal(this,t,qa).v}},"es6-impl","es3");$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.symbolCounter_=0;$jscomp.Symbol=function(t){return $jscomp.SYMBOL_PREFIX+(t||"")+$jscomp.symbolCounter_++};
|
||||
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var t=$jscomp.global.Symbol.iterator;t||(t=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[t]&&$jscomp.defineProperty(Array.prototype,t,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};
|
||||
$jscomp.arrayIterator=function(t){var ya=0;return $jscomp.iteratorPrototype(function(){return ya<t.length?{done:!1,value:t[ya++]}:{done:!0}})};$jscomp.iteratorPrototype=function(t){$jscomp.initSymbolIterator();t={next:t};t[$jscomp.global.Symbol.iterator]=function(){return this};return t};$jscomp.array=$jscomp.array||{};
|
||||
$jscomp.iteratorFromArray=function(t,ya){$jscomp.initSymbolIterator();t instanceof String&&(t+="");var qa=0,g={next:function(){if(qa<t.length){var va=qa++;return{value:ya(va,t[va]),done:!1}}g.next=function(){return{done:!0,value:void 0}};return g.next()}};g[Symbol.iterator]=function(){return g};return g};$jscomp.polyfill("Array.prototype.keys",function(t){return t?t:function(){return $jscomp.iteratorFromArray(this,function(t){return t})}},"es6-impl","es3");
|
||||
(function(t){var ya=function(){function t(g){return t[g]}t["../../package.json"]={name:"coffee-script",description:"Unfancy JavaScript",keywords:["javascript","language","coffeescript","compiler"],author:"Jeremy Ashkenas",version:"1.12.2",license:"MIT",engines:{node:"\x3e\x3d0.8.0"},directories:{lib:"./lib/coffee-script"},main:"./lib/coffee-script/coffee-script",bin:{coffee:"./bin/coffee",cake:"./bin/cake"},files:["bin","lib","register.js","repl.js"],preferGlobal:!0,scripts:{test:"node ./bin/cake test",
|
||||
"test-harmony":"node --harmony ./bin/cake test"},homepage:"http://coffeescript.org",bugs:"https://github.com/jashkenas/coffeescript/issues",repository:{type:"git",url:"git://github.com/jashkenas/coffeescript.git"},devDependencies:{docco:"~0.7.0","google-closure-compiler-js":"^20161201.0.0","highlight.js":"~9.9.0",jison:"\x3e\x3d0.4.17",marked:"^0.3.6",underscore:"~1.8.3"}};t["./helpers"]=function(){var g={};(function(){var t,xa,D,a,c,Ca;g.starts=function(a,c,m){return c===a.substr(m,c.length)};g.ends=
|
||||
function(a,c,m){var f;f=c.length;return c===a.substr(a.length-f-(m||0),f)};g.repeat=c=function(a,c){var f;for(f="";0<c;)c&1&&(f+=a),c>>>=1,a+=a;return f};g.compact=function(a){var f,c,g,D;D=[];f=0;for(g=a.length;f<g;f++)(c=a[f])&&D.push(c);return D};g.count=function(a,c){var f,p;f=p=0;if(!c.length)return 1/0;for(;p=1+a.indexOf(c,p);)f++;return f};g.merge=function(a,c){return xa(xa({},a),c)};xa=g.extend=function(a,c){var f,p;for(f in c)p=c[f],a[f]=p;return a};g.flatten=D=function(a){var f,c,g,F;c=
|
||||
[];g=0;for(F=a.length;g<F;g++)f=a[g],"[object Array]"===Object.prototype.toString.call(f)?c=c.concat(D(f)):c.push(f);return c};g.del=function(a,c){var f;f=a[c];delete a[c];return f};g.some=null!=(a=Array.prototype.some)?a:function(a){var f,c,g;c=0;for(g=this.length;c<g;c++)if(f=this[c],a(f))return!0;return!1};g.invertLiterate=function(a){var f;f=!0;var c,g,D,x;D=a.split("\n");x=[];c=0;for(g=D.length;c<g;c++)a=D[c],f&&/^([ ]{4}|[ ]{0,3}\t)/.test(a)?x.push(a):(f=/^\s*$/.test(a))?x.push(a):x.push("# "+
|
||||
a);return x.join("\n")};t=function(a,c){return c?{first_line:a.first_line,first_column:a.first_column,last_line:c.last_line,last_column:c.last_column}:a};g.addLocationDataFn=function(a,c){return function(f){"object"===typeof f&&f.updateLocationDataIfMissing&&f.updateLocationDataIfMissing(t(a,c));return f}};g.locationDataToString=function(a){var f;"2"in a&&"first_line"in a[2]?f=a[2]:"first_line"in a&&(f=a);return f?f.first_line+1+":"+(f.first_column+1)+"-"+(f.last_line+1+":"+(f.last_column+1)):"No location data"};
|
||||
g.baseFileName=function(a,c,g){null==c&&(c=!1);null==g&&(g=!1);a=a.split(g?/\\|\//:/\//);a=a[a.length-1];if(!(c&&0<=a.indexOf(".")))return a;a=a.split(".");a.pop();"coffee"===a[a.length-1]&&1<a.length&&a.pop();return a.join(".")};g.isCoffee=function(a){return/\.((lit)?coffee|coffee\.md)$/.test(a)};g.isLiterate=function(a){return/\.(litcoffee|coffee\.md)$/.test(a)};g.throwSyntaxError=function(a,c){a=new SyntaxError(a);a.location=c;a.toString=Ca;a.stack=a.toString();throw a;};g.updateSyntaxError=function(a,
|
||||
c,g){a.toString===Ca&&(a.code||(a.code=c),a.filename||(a.filename=g),a.stack=a.toString());return a};Ca=function(){var a,g,m,D,F,x,y,v,E,t;if(!this.code||!this.location)return Error.prototype.toString.call(this);a=this.location;x=a.first_line;F=a.first_column;m=a.last_line;y=a.last_column;null==m&&(m=x);null==y&&(y=F);D=this.filename||"[stdin]";a=this.code.split("\n")[x];m=x===m?y+1:a.length;y=a.slice(0,F).replace(/[^\s]/g," ")+c("^",m-F);"undefined"!==typeof process&&null!==process&&(g=(null!=(v=
|
||||
process.stdout)?v.isTTY:void 0)&&!(null!=(E=process.env)&&E.NODE_DISABLE_COLORS));if(null!=(t=this.colorful)?t:g)g=function(a){return"\u001b[1;31m"+a+"\u001b[0m"},a=a.slice(0,F)+g(a.slice(F,m))+a.slice(m),y=g(y);return D+":"+(x+1)+":"+(F+1)+": error: "+this.message+"\n"+a+"\n"+y};g.nameWhitespaceCharacter=function(a){switch(a){case " ":return"space";case "\n":return"newline";case "\r":return"carriage return";case "\t":return"tab";default:return a}}}).call(this);return g}();t["./rewriter"]=function(){var g=
|
||||
{};(function(){var t,xa,D,a,c,Ca,f,p,m,H,F,x,y,v,E,N,l,h,u=[].indexOf||function(a){for(var c=0,f=this.length;c<f;c++)if(c in this&&this[c]===a)return c;return-1},w=[].slice;v=function(a,c,f){a=[a,c];a.generated=!0;f&&(a.origin=f);return a};g.Rewriter=function(){function h(){}h.prototype.rewrite=function(a){this.tokens=a;this.removeLeadingNewlines();this.closeOpenCalls();this.closeOpenIndexes();this.normalizeLines();this.tagPostfixConditionals();this.addImplicitBracesAndParens();this.addLocationDataToGeneratedTokens();
|
||||
this.fixOutdentLocationData();return this.tokens};h.prototype.scanTokens=function(a){var c,f,k;k=this.tokens;for(c=0;f=k[c];)c+=a.call(this,f,c,k);return!0};h.prototype.detectEnd=function(f,h,g){var k,L,I,n,z;z=this.tokens;for(k=0;n=z[f];){if(0===k&&h.call(this,n,f))return g.call(this,n,f);if(!n||0>k)return g.call(this,n,f-1);(L=n[0],0<=u.call(c,L))?k+=1:(I=n[0],0<=u.call(a,I))&&--k;f+=1}return f-1};h.prototype.removeLeadingNewlines=function(){var a,c,f,k,h;k=this.tokens;a=c=0;for(f=k.length;c<f&&
|
||||
(h=k[a][0],"TERMINATOR"===h);a=++c);if(a)return this.tokens.splice(0,a)};h.prototype.closeOpenCalls=function(){var a,c;c=function(a,c){var f;return")"===(f=a[0])||"CALL_END"===f||"OUTDENT"===a[0]&&")"===this.tag(c-1)};a=function(a,c){return this.tokens["OUTDENT"===a[0]?c-1:c][0]="CALL_END"};return this.scanTokens(function(f,k){"CALL_START"===f[0]&&this.detectEnd(k+1,c,a);return 1})};h.prototype.closeOpenIndexes=function(){var a,c;c=function(a,c){var f;return"]"===(f=a[0])||"INDEX_END"===f};a=function(a,
|
||||
c){return a[0]="INDEX_END"};return this.scanTokens(function(f,k){"INDEX_START"===f[0]&&this.detectEnd(k+1,c,a);return 1})};h.prototype.indexOfTag=function(){var a,c,f,k,h,g,n;c=arguments[0];h=2<=arguments.length?w.call(arguments,1):[];f=k=a=0;for(g=h.length;0<=g?k<g:k>g;f=0<=g?++k:--k){for(;"HERECOMMENT"===this.tag(c+f+a);)a+=2;if(null!=h[f]&&("string"===typeof h[f]&&(h[f]=[h[f]]),n=this.tag(c+f+a),0>u.call(h[f],n)))return-1}return c+f+a-1};h.prototype.looksObjectish=function(f){var h;if(-1<this.indexOfTag(f,
|
||||
"@",null,":")||-1<this.indexOfTag(f,null,":"))return!0;f=this.indexOfTag(f,c);return-1<f&&(h=null,this.detectEnd(f+1,function(c){var f;return f=c[0],0<=u.call(a,f)},function(a,c){return h=c}),":"===this.tag(h+1))?!0:!1};h.prototype.findTagsBackwards=function(f,h){var g,k,L,z,n,l,m;for(g=[];0<=f&&(g.length||(z=this.tag(f),0>u.call(h,z))&&((n=this.tag(f),0>u.call(c,n))||this.tokens[f].generated)&&(l=this.tag(f),0>u.call(F,l)));)(k=this.tag(f),0<=u.call(a,k))&&g.push(this.tag(f)),(L=this.tag(f),0<=u.call(c,
|
||||
L))&&g.length&&g.pop(),--f;return m=this.tag(f),0<=u.call(h,m)};h.prototype.addImplicitBracesAndParens=function(){var h,g;h=[];g=null;return this.scanTokens(function(l,k,z){var L,n,r,D,I,M,w,G,B,A,x,C,y,E,t,H,N,J;J=l[0];A=(x=0<k?z[k-1]:[])[0];B=(k<z.length-1?z[k+1]:[])[0];t=function(){return h[h.length-1]};H=k;r=function(a){return k-H+a};D=function(){var a,c;return null!=(a=t())?null!=(c=a[2])?c.ours:void 0:void 0};I=function(){var a;return D()&&"("===(null!=(a=t())?a[0]:void 0)};w=function(){var a;
|
||||
return D()&&"{"===(null!=(a=t())?a[0]:void 0)};M=function(){var a;return D&&"CONTROL"===(null!=(a=t())?a[0]:void 0)};N=function(a){var c;c=null!=a?a:k;h.push(["(",c,{ours:!0}]);z.splice(c,0,v("CALL_START","("));if(null==a)return k+=1};L=function(){h.pop();z.splice(k,0,v("CALL_END",")",["","end of input",l[2]]));return k+=1};G=function(a,c){var f;null==c&&(c=!0);f=null!=a?a:k;h.push(["{",f,{sameLine:!0,startsLine:c,ours:!0}]);c=new String("{");c.generated=!0;z.splice(f,0,v("{",c,l));if(null==a)return k+=
|
||||
1};n=function(a){a=null!=a?a:k;h.pop();z.splice(a,0,v("}","}",l));return k+=1};if(I()&&("IF"===J||"TRY"===J||"FINALLY"===J||"CATCH"===J||"CLASS"===J||"SWITCH"===J))return h.push(["CONTROL",k,{ours:!0}]),r(1);if("INDENT"===J&&D()){if("\x3d\x3e"!==A&&"-\x3e"!==A&&"["!==A&&"("!==A&&","!==A&&"{"!==A&&"TRY"!==A&&"ELSE"!==A&&"\x3d"!==A)for(;I();)L();M()&&h.pop();h.push([J,k]);return r(1)}if(0<=u.call(c,J))return h.push([J,k]),r(1);if(0<=u.call(a,J)){for(;D();)I()?L():w()?n():h.pop();g=h.pop()}if((0<=u.call(p,
|
||||
J)&&l.spaced||"?"===J&&0<k&&!z[k-1].spaced)&&(0<=u.call(Ca,B)||0<=u.call(m,B)&&(null==(C=z[k+1])||!C.spaced)&&(null==(y=z[k+1])||!y.newLine)))return"?"===J&&(J=l[0]="FUNC_EXIST"),N(k+1),r(2);if(0<=u.call(p,J)&&-1<this.indexOfTag(k+1,"INDENT")&&this.looksObjectish(k+2)&&!this.findTagsBackwards(k,"CLASS EXTENDS IF CATCH SWITCH LEADING_WHEN FOR WHILE UNTIL".split(" ")))return N(k+1),h.push(["INDENT",k+2]),r(3);if(":"===J){for(n=function(){var c;switch(!1){case c=this.tag(k-1),0>u.call(a,c):return g[1];
|
||||
case "@"!==this.tag(k-2):return k-2;default:return k-1}}.call(this);"HERECOMMENT"===this.tag(n-2);)n-=2;this.insideForDeclaration="FOR"===B;M=0===n||(E=this.tag(n-1),0<=u.call(F,E))||z[n-1].newLine;if(t()&&(w=t(),E=w[0],x=w[1],("{"===E||"INDENT"===E&&"{"===this.tag(x-1))&&(M||","===this.tag(n-1)||"{"===this.tag(n-1))))return r(1);G(n,!!M);return r(2)}w()&&0<=u.call(F,J)&&(t()[2].sameLine=!1);G="OUTDENT"===A||x.newLine;if(0<=u.call(f,J)||0<=u.call(xa,J)&&G)for(;D();)if(G=t(),E=G[0],x=G[1],E=G[2],G=
|
||||
E.sameLine,M=E.startsLine,I()&&","!==A)L();else if(w()&&!this.insideForDeclaration&&G&&"TERMINATOR"!==J&&":"!==A)n();else if(!w()||"TERMINATOR"!==J||","===A||M&&this.looksObjectish(k+1))break;else{if("HERECOMMENT"===B)return r(1);n()}if(!(","!==J||this.looksObjectish(k+1)||!w()||this.insideForDeclaration||"TERMINATOR"===B&&this.looksObjectish(k+2)))for(B="OUTDENT"===B?1:0;w();)n(k+B);return r(1)})};h.prototype.addLocationDataToGeneratedTokens=function(){return this.scanTokens(function(a,c,f){var h,
|
||||
g,u;if(a[2]||!a.generated&&!a.explicit)return 1;"{"===a[0]&&(h=null!=(u=f[c+1])?u[2]:void 0)?(g=h.first_line,h=h.first_column):(h=null!=(g=f[c-1])?g[2]:void 0)?(g=h.last_line,h=h.last_column):g=h=0;a[2]={first_line:g,first_column:h,last_line:g,last_column:h};return 1})};h.prototype.fixOutdentLocationData=function(){return this.scanTokens(function(a,c,f){if(!("OUTDENT"===a[0]||a.generated&&"CALL_END"===a[0]||a.generated&&"}"===a[0]))return 1;c=f[c-1][2];a[2]={first_line:c.last_line,first_column:c.last_column,
|
||||
last_line:c.last_line,last_column:c.last_column};return 1})};h.prototype.normalizeLines=function(){var a,c,f,h,g;g=f=h=null;c=function(a,c){var f,h,k,n;return";"!==a[1]&&(f=a[0],0<=u.call(x,f))&&!("TERMINATOR"===a[0]&&(h=this.tag(c+1),0<=u.call(D,h)))&&!("ELSE"===a[0]&&"THEN"!==g)&&!!("CATCH"!==(k=a[0])&&"FINALLY"!==k||"-\x3e"!==g&&"\x3d\x3e"!==g)||(n=a[0],0<=u.call(xa,n))&&this.tokens[c-1].newLine};a=function(a,c){return this.tokens.splice(","===this.tag(c-1)?c-1:c,0,h)};return this.scanTokens(function(k,
|
||||
n,l){var z,m,p;k=k[0];if("TERMINATOR"===k){if("ELSE"===this.tag(n+1)&&"OUTDENT"!==this.tag(n-1))return l.splice.apply(l,[n,1].concat(w.call(this.indentation()))),1;if(z=this.tag(n+1),0<=u.call(D,z))return l.splice(n,1),0}if("CATCH"===k)for(z=m=1;2>=m;z=++m)if("OUTDENT"===(p=this.tag(n+z))||"TERMINATOR"===p||"FINALLY"===p)return l.splice.apply(l,[n+z,0].concat(w.call(this.indentation()))),2+z;0<=u.call(y,k)&&"INDENT"!==this.tag(n+1)&&("ELSE"!==k||"IF"!==this.tag(n+1))&&(g=k,p=this.indentation(l[n]),
|
||||
f=p[0],h=p[1],"THEN"===g&&(f.fromThen=!0),l.splice(n+1,0,f),this.detectEnd(n+2,c,a),"THEN"===k&&l.splice(n,1));return 1})};h.prototype.tagPostfixConditionals=function(){var a,c,f;f=null;c=function(a,c){a=a[0];c=this.tokens[c-1][0];return"TERMINATOR"===a||"INDENT"===a&&0>u.call(y,c)};a=function(a,c){if("INDENT"!==a[0]||a.generated&&!a.fromThen)return f[0]="POST_"+f[0]};return this.scanTokens(function(h,g){if("IF"!==h[0])return 1;f=h;this.detectEnd(g+1,c,a);return 1})};h.prototype.indentation=function(a){var c,
|
||||
f;c=["INDENT",2];f=["OUTDENT",2];a?(c.generated=f.generated=!0,c.origin=f.origin=a):c.explicit=f.explicit=!0;return[c,f]};h.prototype.generate=v;h.prototype.tag=function(a){var c;return null!=(c=this.tokens[a])?c[0]:void 0};return h}();t=[["(",")"],["[","]"],["{","}"],["INDENT","OUTDENT"],["CALL_START","CALL_END"],["PARAM_START","PARAM_END"],["INDEX_START","INDEX_END"],["STRING_START","STRING_END"],["REGEX_START","REGEX_END"]];g.INVERSES=H={};c=[];a=[];E=0;for(l=t.length;E<l;E++)h=t[E],N=h[0],h=h[1],
|
||||
c.push(H[h]=N),a.push(H[N]=h);D=["CATCH","THEN","ELSE","FINALLY"].concat(a);p="IDENTIFIER PROPERTY SUPER ) CALL_END ] INDEX_END @ THIS".split(" ");Ca="IDENTIFIER PROPERTY NUMBER INFINITY NAN STRING STRING_START REGEX REGEX_START JS NEW PARAM_START CLASS IF TRY SWITCH THIS UNDEFINED NULL BOOL UNARY YIELD UNARY_MATH SUPER THROW @ -\x3e \x3d\x3e [ ( { -- ++".split(" ");m=["+","-"];f="POST_IF FOR WHILE UNTIL WHEN BY LOOP TERMINATOR".split(" ");y="ELSE -\x3e \x3d\x3e TRY FINALLY THEN".split(" ");x="TERMINATOR CATCH FINALLY ELSE OUTDENT LEADING_WHEN".split(" ");
|
||||
F=["TERMINATOR","INDENT","OUTDENT"];xa=[".","?.","::","?::"]}).call(this);return g}();t["./lexer"]=function(){var g={};(function(){var va,xa,D,a,c,Ca,f,p,m,H,F,x,y,v,E,N,l,h,u,w,G,L,z,I,k,M,P,n,r,V,U,Q,ba,S,B,A,X,C,O,Y,Z,W,aa,J,ca,R,qa,ya,Wa,ka,da,fa,ha,ia,la,oa,K,ja,ra,ea=[].indexOf||function(a){for(var c=0,f=this.length;c<f;c++)if(c in this&&this[c]===a)return c;return-1},ma=[].slice;K=t("./rewriter");C=K.Rewriter;G=K.INVERSES;K=t("./helpers");fa=K.count;ja=K.repeat;ha=K.invertLiterate;ra=K.throwSyntaxError;
|
||||
g.Lexer=function(){function g(){}g.prototype.tokenize=function(a,c){var f,h,T,g;null==c&&(c={});this.literate=c.literate;this.outdebt=this.indebt=this.baseIndent=this.indent=0;this.indents=[];this.ends=[];this.tokens=[];this.exportSpecifierList=this.seenExport=this.seenImport=this.seenFor=!1;this.chunkLine=c.line||0;this.chunkColumn=c.column||0;a=this.clean(a);for(T=0;this.chunk=a.slice(T);)if(f=this.identifierToken()||this.commentToken()||this.whitespaceToken()||this.lineToken()||this.stringToken()||
|
||||
this.numberToken()||this.regexToken()||this.jsToken()||this.literalToken(),g=this.getLineAndColumnFromChunk(f),this.chunkLine=g[0],this.chunkColumn=g[1],T+=f,c.untilBalanced&&0===this.ends.length)return{tokens:this.tokens,index:T};this.closeIndentation();(h=this.ends.pop())&&this.error("missing "+h.tag,h.origin[2]);return!1===c.rewrite?this.tokens:(new C).rewrite(this.tokens)};g.prototype.clean=function(a){a.charCodeAt(0)===va&&(a=a.slice(1));a=a.replace(/\r/g,"").replace(qa,"");da.test(a)&&(a="\n"+
|
||||
a,this.chunkLine--);this.literate&&(a=ha(a));return a};g.prototype.identifierToken=function(){var f,h,g,n,u,m,D,p,w,G,r;if(!(h=l.exec(this.chunk)))return 0;u=h[0];g=h[1];h=h[2];n=g.length;m=void 0;if("own"===g&&"FOR"===this.tag())return this.token("OWN",g),g.length;if("from"===g&&"YIELD"===this.tag())return this.token("FROM",g),g.length;if("as"===g&&this.seenImport){if("*"===this.value())this.tokens[this.tokens.length-1][0]="IMPORT_ALL";else if(D=this.value(),0<=ea.call(Ca,D))this.tokens[this.tokens.length-
|
||||
1][0]="IDENTIFIER";if("DEFAULT"===(p=this.tag())||"IMPORT_ALL"===p||"IDENTIFIER"===p)return this.token("AS",g),g.length}if("as"===g&&this.seenExport&&"IDENTIFIER"===this.tag())return this.token("AS",g),g.length;if("default"===g&&this.seenExport)return this.token("DEFAULT",g),g.length;D=this.tokens;D=D[D.length-1];r=h||null!=D&&("."===(w=D[0])||"?."===w||"::"===w||"?::"===w||!D.spaced&&"@"===D[0])?"PROPERTY":"IDENTIFIER";"IDENTIFIER"!==r||!(0<=ea.call(z,g)||0<=ea.call(Ca,g))||this.exportSpecifierList&&
|
||||
0<=ea.call(Ca,g)?"IDENTIFIER"===r&&this.seenFor&&"from"===g&&ia(D)&&(r="FORFROM",this.seenFor=!1):(r=g.toUpperCase(),"WHEN"===r&&(G=this.tag(),0<=ea.call(k,G))?r="LEADING_WHEN":"FOR"===r?this.seenFor=!0:"UNLESS"===r?r="IF":"IMPORT"===r?this.seenImport=!0:"EXPORT"===r?this.seenExport=!0:0<=ea.call(ya,r)?r="UNARY":0<=ea.call(A,r)&&("INSTANCEOF"!==r&&this.seenFor?(r="FOR"+r,this.seenFor=!1):(r="RELATION","!"===this.value()&&(m=this.tokens.pop(),g="!"+g))));"IDENTIFIER"===r&&0<=ea.call(X,g)&&this.error("reserved word '"+
|
||||
g+"'",{length:g.length});"PROPERTY"!==r&&(0<=ea.call(a,g)&&(f=g,g=c[g]),r=function(){switch(g){case "!":return"UNARY";case "\x3d\x3d":case "!\x3d":return"COMPARE";case "true":case "false":return"BOOL";case "break":case "continue":case "debugger":return"STATEMENT";case "\x26\x26":case "||":return g;default:return r}}());w=this.token(r,g,0,n);f&&(w.origin=[r,f,w[2]]);m&&(f=[m[2].first_line,m[2].first_column],w[2].first_line=f[0],w[2].first_column=f[1]);h&&(f=u.lastIndexOf(":"),this.token(":",":",f,
|
||||
h.length));return u.length};g.prototype.numberToken=function(){var a,c,f,g;if(!(c=V.exec(this.chunk)))return 0;f=c[0];c=f.length;switch(!1){case !/^0[BOX]/.test(f):this.error("radix prefix in '"+f+"' must be lowercase",{offset:1});break;case !/^(?!0x).*E/.test(f):this.error("exponential notation in '"+f+"' must be indicated with a lowercase 'e'",{offset:f.indexOf("E")});break;case !/^0\d*[89]/.test(f):this.error("decimal literal '"+f+"' must not be prefixed with '0'",{length:c});break;case !/^0\d+/.test(f):this.error("octal literal '"+
|
||||
f+"' must be prefixed with '0o'",{length:c})}a=function(){switch(f.charAt(1)){case "b":return 2;case "o":return 8;case "x":return 16;default:return null}}();a=null!=a?parseInt(f.slice(2),a):parseFloat(f);if("b"===(g=f.charAt(1))||"o"===g)f="0x"+a.toString(16);this.token(Infinity===a?"INFINITY":"NUMBER",f,0,c);return c};g.prototype.stringToken=function(){var a,c,f,g,h,k,n,u,l,r,D,m;l=(ca.exec(this.chunk)||[])[0];if(!l)return 0;this.tokens.length&&"from"===this.value()&&(this.seenImport||this.seenExport)&&
|
||||
(this.tokens[this.tokens.length-1][0]="FROM");f=function(){switch(l){case "'":return J;case '"':return W;case "'''":return y;case '"""':return F}}();g=3===l.length;f=this.matchWithInterpolations(f,l);m=f.tokens;h=f.index;a=m.length-1;f=l.charAt(0);if(g){n=null;for(g=function(){var a,c,f;f=[];k=a=0;for(c=m.length;a<c;k=++a)D=m[k],"NEOSTRING"===D[0]&&f.push(D[1]);return f}().join("#{}");c=x.exec(g);)if(c=c[1],null===n||0<(r=c.length)&&r<n.length)n=c;n&&(u=RegExp("\\n"+n,"g"));this.mergeInterpolationTokens(m,
|
||||
{delimiter:f},function(c){return function(f,g){f=c.formatString(f);u&&(f=f.replace(u,"\n"));0===g&&(f=f.replace(I,""));g===a&&(f=f.replace(R,""));return f}}(this))}else this.mergeInterpolationTokens(m,{delimiter:f},function(c){return function(f,g){f=c.formatString(f);return f=f.replace(Y,function(c,h){return 0===g&&0===h||g===a&&h+c.length===f.length?"":" "})}}(this));return h};g.prototype.commentToken=function(){var a,c,g;if(!(g=this.chunk.match(f)))return 0;a=g[0];if(c=g[1])(g=H.exec(a))&&this.error("block comments cannot contain "+
|
||||
g[0],{offset:g.index,length:g[0].length}),0<=c.indexOf("\n")&&(c=c.replace(RegExp("\\n"+ja(" ",this.indent),"g"),"\n")),this.token("HERECOMMENT",c,0,a.length);return a.length};g.prototype.jsToken=function(){var a,c;if("`"!==this.chunk.charAt(0)||!(a=N.exec(this.chunk)||L.exec(this.chunk)))return 0;c=a[1].replace(/\\+(`|$)/g,function(a){return a.slice(-Math.ceil(a.length/2))});this.token("JS",c,0,a[0].length);return a[0].length};g.prototype.regexToken=function(){var a,c,f,g,h,k,n,l;switch(!1){case !(c=
|
||||
B.exec(this.chunk)):this.error("regular expressions cannot begin with "+c[2],{offset:c.index+c[1].length});break;case !(c=this.matchWithInterpolations(v,"///")):l=c.tokens;h=c.index;break;case !(c=ba.exec(this.chunk)):n=c[0];a=c[1];c=c[2];this.validateEscapes(a,{isRegex:!0,offsetInChunk:1});h=n.length;k=this.tokens;if(k=k[k.length-1])if(k.spaced&&(f=k[0],0<=ea.call(xa,f))){if(!c||Q.test(n))return 0}else if(g=k[0],0<=ea.call(r,g))return 0;c||this.error("missing / (unclosed regex)");break;default:return 0}g=
|
||||
S.exec(this.chunk.slice(h))[0];f=h+g.length;c=this.makeToken("REGEX",null,0,f);switch(!1){case !!ka.test(g):this.error("invalid regular expression flags "+g,{offset:h,length:g.length});break;case !(n||1===l.length):null==a&&(a=this.formatHeregex(l[0][1]));this.token("REGEX",""+this.makeDelimitedLiteral(a,{delimiter:"/"})+g,0,f,c);break;default:this.token("REGEX_START","(",0,0,c),this.token("IDENTIFIER","RegExp",0,0),this.token("CALL_START","(",0,0),this.mergeInterpolationTokens(l,{delimiter:'"',double:!0},
|
||||
this.formatHeregex),g&&(this.token(",",",",h,0),this.token("STRING",'"'+g+'"',h,g.length)),this.token(")",")",f,0),this.token("REGEX_END",")",f,0)}return f};g.prototype.lineToken=function(){var a,c,f;if(!(c=n.exec(this.chunk)))return 0;c=c[0];this.seenFor=!1;f=c.length-1-c.lastIndexOf("\n");a=this.unfinished();if(f-this.indebt===this.indent)return a?this.suppressNewlines():this.newlineToken(0),c.length;if(f>this.indent){if(a)return this.indebt=f-this.indent,this.suppressNewlines(),c.length;if(!this.tokens.length)return this.baseIndent=
|
||||
this.indent=f,c.length;a=f-this.indent+this.outdebt;this.token("INDENT",a,c.length-f,f);this.indents.push(a);this.ends.push({tag:"OUTDENT"});this.outdebt=this.indebt=0;this.indent=f}else f<this.baseIndent?this.error("missing indentation",{offset:c.length}):(this.indebt=0,this.outdentToken(this.indent-f,a,c.length));return c.length};g.prototype.outdentToken=function(a,c,f){var g,k,T,n;for(g=this.indent-a;0<a;)(T=this.indents[this.indents.length-1])?T===this.outdebt?(a-=this.outdebt,this.outdebt=0):
|
||||
T<this.outdebt?(this.outdebt-=T,a-=T):(k=this.indents.pop()+this.outdebt,f&&(n=this.chunk[f],0<=ea.call(h,n))&&(g-=k-a,a=k),this.outdebt=0,this.pair("OUTDENT"),this.token("OUTDENT",a,0,f),a-=k):a=0;k&&(this.outdebt-=a);for(;";"===this.value();)this.tokens.pop();"TERMINATOR"===this.tag()||c||this.token("TERMINATOR","\n",f,0);this.indent=g;return this};g.prototype.whitespaceToken=function(){var a,c;if(!(a=da.exec(this.chunk))&&"\n"!==this.chunk.charAt(0))return 0;c=this.tokens;(c=c[c.length-1])&&(c[a?
|
||||
"spaced":"newLine"]=!0);return a?a[0].length:0};g.prototype.newlineToken=function(a){for(;";"===this.value();)this.tokens.pop();"TERMINATOR"!==this.tag()&&this.token("TERMINATOR","\n",a,0);return this};g.prototype.suppressNewlines=function(){"\\"===this.value()&&this.tokens.pop();return this};g.prototype.literalToken=function(){var a,c,f,g,h,k,n,l;(a=U.exec(this.chunk))?(a=a[0],D.test(a)&&this.tagParameters()):a=this.chunk.charAt(0);l=a;g=this.tokens;if((g=g[g.length-1])&&0<=ea.call(["\x3d"].concat(ma.call(m)),
|
||||
a)&&(n=!1,"\x3d"!==a||"||"!==(f=g[1])&&"\x26\x26"!==f||g.spaced||(g[0]="COMPOUND_ASSIGN",g[1]+="\x3d",g=this.tokens[this.tokens.length-2],n=!0),g&&"PROPERTY"!==g[0]&&(f=null!=(c=g.origin)?c:g,(c=la(g[1],f[1]))&&this.error(c,f[2])),n))return a.length;"{"===a&&"EXPORT"===(null!=g?g[0]:void 0)?this.exportSpecifierList=!0:this.exportSpecifierList&&"}"===a&&(this.exportSpecifierList=!1);if(";"===a)this.seenFor=this.seenImport=this.seenExport=!1,l="TERMINATOR";else if("*"===a&&"EXPORT"===g[0])l="EXPORT_ALL";
|
||||
else if(0<=ea.call(P,a))l="MATH";else if(0<=ea.call(p,a))l="COMPARE";else if(0<=ea.call(m,a))l="COMPOUND_ASSIGN";else if(0<=ea.call(ya,a))l="UNARY";else if(0<=ea.call(Wa,a))l="UNARY_MATH";else if(0<=ea.call(O,a))l="SHIFT";else if("?"===a&&null!=g&&g.spaced)l="BIN?";else if(g&&!g.spaced)if("("===a&&(h=g[0],0<=ea.call(xa,h)))"?"===g[0]&&(g[0]="FUNC_EXIST"),l="CALL_START";else if("["===a&&(k=g[0],0<=ea.call(u,k)))switch(l="INDEX_START",g[0]){case "?":g[0]="INDEX_SOAK"}h=this.makeToken(l,a);switch(a){case "(":case "{":case "[":this.ends.push({tag:G[a],
|
||||
origin:h});break;case ")":case "}":case "]":this.pair(a)}this.tokens.push(h);return a.length};g.prototype.tagParameters=function(){var a,c,f,g;if(")"!==this.tag())return this;c=[];g=this.tokens;a=g.length;for(g[--a][0]="PARAM_END";f=g[--a];)switch(f[0]){case ")":c.push(f);break;case "(":case "CALL_START":if(c.length)c.pop();else return"("===f[0]&&(f[0]="PARAM_START"),this}return this};g.prototype.closeIndentation=function(){return this.outdentToken(this.indent)};g.prototype.matchWithInterpolations=
|
||||
function(a,c){var f,h,k,n,l,u,m,T;T=[];l=c.length;if(this.chunk.slice(0,l)!==c)return null;for(m=this.chunk.slice(l);;){n=a.exec(m)[0];this.validateEscapes(n,{isRegex:"/"===c.charAt(0),offsetInChunk:l});T.push(this.makeToken("NEOSTRING",n,l));m=m.slice(n.length);l+=n.length;if("#{"!==m.slice(0,2))break;f=this.getLineAndColumnFromChunk(l+1);n=f[0];f=f[1];f=(new g).tokenize(m.slice(1),{line:n,column:f,untilBalanced:!0});n=f.tokens;h=f.index;h+=1;u=n[0];f=n[n.length-1];u[0]=u[1]="(";f[0]=f[1]=")";f.origin=
|
||||
["","end of interpolation",f[2]];"TERMINATOR"===(null!=(k=n[1])?k[0]:void 0)&&n.splice(1,1);T.push(["TOKENS",n]);m=m.slice(h);l+=h}m.slice(0,c.length)!==c&&this.error("missing "+c,{length:c.length});a=T[0];k=T[T.length-1];a[2].first_column-=c.length;"\n"===k[1].substr(-1)?(k[2].last_line+=1,k[2].last_column=c.length-1):k[2].last_column+=c.length;0===k[1].length&&--k[2].last_column;return{tokens:T,index:l+c.length}};g.prototype.mergeInterpolationTokens=function(a,c,f){var g,h,k,n,l,u,m,D,r,T,w,p;1<
|
||||
a.length&&(D=this.token("STRING_START","(",0,0));k=this.tokens.length;n=l=0;for(u=a.length;l<u;n=++l){T=a[n];g=T[0];p=T[1];switch(g){case "TOKENS":if(2===p.length)continue;m=p[0];w=p;break;case "NEOSTRING":g=f(T[1],n);if(0===g.length)if(0===n)h=this.tokens.length;else continue;2===n&&null!=h&&this.tokens.splice(h,2);T[0]="STRING";T[1]=this.makeDelimitedLiteral(g,c);m=T;w=[T]}this.tokens.length>k&&(n=this.token("+","+"),n[2]={first_line:m[2].first_line,first_column:m[2].first_column,last_line:m[2].first_line,
|
||||
last_column:m[2].first_column});(r=this.tokens).push.apply(r,w)}if(D)return a=a[a.length-1],D.origin=["STRING",null,{first_line:D[2].first_line,first_column:D[2].first_column,last_line:a[2].last_line,last_column:a[2].last_column}],D=this.token("STRING_END",")"),D[2]={first_line:a[2].last_line,first_column:a[2].last_column,last_line:a[2].last_line,last_column:a[2].last_column}};g.prototype.pair=function(a){var c;c=this.ends;c=c[c.length-1];return a!==(c=null!=c?c.tag:void 0)?("OUTDENT"!==c&&this.error("unmatched "+
|
||||
a),c=this.indents,c=c[c.length-1],this.outdentToken(c,!0),this.pair(a)):this.ends.pop()};g.prototype.getLineAndColumnFromChunk=function(a){var c,f;if(0===a)return[this.chunkLine,this.chunkColumn];f=a>=this.chunk.length?this.chunk:this.chunk.slice(0,+(a-1)+1||9E9);a=fa(f,"\n");c=this.chunkColumn;0<a?(c=f.split("\n"),c=c[c.length-1],c=c.length):c+=f.length;return[this.chunkLine+a,c]};g.prototype.makeToken=function(a,c,f,g){var h,k;null==f&&(f=0);null==g&&(g=c.length);h={};k=this.getLineAndColumnFromChunk(f);
|
||||
h.first_line=k[0];h.first_column=k[1];f=this.getLineAndColumnFromChunk(f+(0<g?g-1:0));h.last_line=f[0];h.last_column=f[1];return[a,c,h]};g.prototype.token=function(a,c,f,g,h){a=this.makeToken(a,c,f,g);h&&(a.origin=h);this.tokens.push(a);return a};g.prototype.tag=function(){var a;a=this.tokens;a=a[a.length-1];return null!=a?a[0]:void 0};g.prototype.value=function(){var a;a=this.tokens;a=a[a.length-1];return null!=a?a[1]:void 0};g.prototype.unfinished=function(){var a;return M.test(this.chunk)||"\\"===
|
||||
(a=this.tag())||"."===a||"?."===a||"?::"===a||"UNARY"===a||"MATH"===a||"UNARY_MATH"===a||"+"===a||"-"===a||"**"===a||"SHIFT"===a||"RELATION"===a||"COMPARE"===a||"\x26"===a||"^"===a||"|"===a||"\x26\x26"===a||"||"===a||"BIN?"===a||"THROW"===a||"EXTENDS"===a};g.prototype.formatString=function(a){return a.replace(aa,"$1")};g.prototype.formatHeregex=function(a){return a.replace(E,"$1$2")};g.prototype.validateEscapes=function(a,c){var f,g,h,k,n;null==c&&(c={});if(g=w.exec(a))if(g[0],a=g[1],h=g[2],f=g[3],
|
||||
n=g[4],!c.isRegex||!h||"0"===h.charAt(0))return f="\\"+(h||f||n),this.error((h?"octal escape sequences are not allowed":"invalid escape sequence")+" "+f,{offset:(null!=(k=c.offsetInChunk)?k:0)+g.index+a.length,length:f.length})};g.prototype.makeDelimitedLiteral=function(a,c){null==c&&(c={});""===a&&"/"===c.delimiter&&(a="(?:)");a=a.replace(RegExp("(\\\\\\\\)|(\\\\0(?\x3d[1-7]))|\\\\?("+c.delimiter+")|\\\\?(?:(\\n)|(\\r)|(\\u2028)|(\\u2029))|(\\\\.)","g"),function(a,f,g,h,k,n,l,m,u){switch(!1){case !f:return c.double?
|
||||
f+f:f;case !g:return"\\x00";case !h:return"\\"+h;case !k:return"\\n";case !n:return"\\r";case !l:return"\\u2028";case !m:return"\\u2029";case !u:return c.double?"\\"+u:u}});return""+c.delimiter+a+c.delimiter};g.prototype.error=function(a,c){var f,g,h,k,n;null==c&&(c={});c="first_line"in c?c:(k=this.getLineAndColumnFromChunk(null!=(h=c.offset)?h:0),g=k[0],f=k[1],k,{first_line:g,first_column:f,last_column:f+(null!=(n=c.length)?n:1)-1});return ra(a,c)};return g}();la=function(a,c){null==c&&(c=a);switch(!1){case 0>
|
||||
ea.call(ma.call(z).concat(ma.call(Ca)),a):return"keyword '"+c+"' can't be assigned";case 0>ea.call(Z,a):return"'"+c+"' can't be assigned";case 0>ea.call(X,a):return"reserved word '"+c+"' can't be assigned";default:return!1}};g.isUnassignable=la;ia=function(a){var c;return"IDENTIFIER"===a[0]?("from"===a[1]&&(a[1][0]="IDENTIFIER",!0),!0):"FOR"===a[0]?!1:"{"===(c=a[1])||"["===c||","===c||":"===c?!1:!0};z="true false null this new delete typeof in instanceof return throw break continue debugger yield if else switch for while do try catch finally class extends super import export default".split(" ");
|
||||
Ca="undefined Infinity NaN then unless until loop of by when".split(" ");c={and:"\x26\x26",or:"||",is:"\x3d\x3d",isnt:"!\x3d",not:"!",yes:"true",no:"false",on:"true",off:"false"};a=function(){var a;a=[];for(oa in c)a.push(oa);return a}();Ca=Ca.concat(a);X="case function var void with const let enum native implements interface package private protected public static".split(" ");Z=["arguments","eval"];g.JS_FORBIDDEN=z.concat(X).concat(Z);va=65279;l=/^(?!\d)((?:(?!\s)[$\w\x7f-\uffff])+)([^\n\S]*:(?!:))?/;
|
||||
V=/^0b[01]+|^0o[0-7]+|^0x[\da-f]+|^\d*\.?\d+(?:e[+-]?\d+)?/i;U=/^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>*\/%])\2=?|\?(\.|::)|\.{2,3})/;da=/^[^\n\S]+/;f=/^###([^#][\s\S]*?)(?:###[^\n\S]*|###$)|^(?:\s*#(?!##[^#]).*)+/;D=/^[-=]>/;n=/^(?:\n[^\n\S]*)+/;L=/^`(?!``)((?:[^`\\]|\\[\s\S])*)`/;N=/^```((?:[^`\\]|\\[\s\S]|`(?!``))*)```/;ca=/^(?:'''|"""|'|")/;J=/^(?:[^\\']|\\[\s\S])*/;W=/^(?:[^\\"#]|\\[\s\S]|\#(?!\{))*/;y=/^(?:[^\\']|\\[\s\S]|'(?!''))*/;F=/^(?:[^\\"#]|\\[\s\S]|"(?!"")|\#(?!\{))*/;aa=
|
||||
/((?:\\\\)+)|\\[^\S\n]*\n\s*/g;Y=/\s*\n\s*/g;x=/\n+([^\n\S]*)(?=\S)/g;ba=/^\/(?!\/)((?:[^[\/\n\\]|\\[^\n]|\[(?:\\[^\n]|[^\]\n\\])*\])*)(\/)?/;S=/^\w*/;ka=/^(?!.*(.).*\1)[imgy]*$/;v=/^(?:[^\\\/#]|\\[\s\S]|\/(?!\/\/)|\#(?!\{))*/;E=/((?:\\\\)+)|\\(\s)|\s+(?:#.*)?/g;B=/^(\/|\/{3}\s*)(\*)/;Q=/^\/=?\s/;H=/\*\//;M=/^\s*(?:,|\??\.(?![.\d])|::)/;w=/((?:^|[^\\])(?:\\\\)*)\\(?:(0[0-7]|[1-7])|(x(?![\da-fA-F]{2}).{0,2})|(u(?![\da-fA-F]{4}).{0,4}))/;I=/^[^\n\S]*\n/;R=/\n[^\n\S]*$/;qa=/\s+$/;m="-\x3d +\x3d /\x3d *\x3d %\x3d ||\x3d \x26\x26\x3d ?\x3d \x3c\x3c\x3d \x3e\x3e\x3d \x3e\x3e\x3e\x3d \x26\x3d ^\x3d |\x3d **\x3d //\x3d %%\x3d".split(" ");
|
||||
ya=["NEW","TYPEOF","DELETE","DO"];Wa=["!","~"];O=["\x3c\x3c","\x3e\x3e","\x3e\x3e\x3e"];p="\x3d\x3d !\x3d \x3c \x3e \x3c\x3d \x3e\x3d".split(" ");P=["*","/","%","//","%%"];A=["IN","OF","INSTANCEOF"];xa="IDENTIFIER PROPERTY ) ] ? @ THIS SUPER".split(" ");u=xa.concat("NUMBER INFINITY NAN STRING STRING_END REGEX REGEX_END BOOL NULL UNDEFINED } ::".split(" "));r=u.concat(["++","--"]);k=["INDENT","OUTDENT","TERMINATOR"];h=[")","}","]"]}).call(this);return g}();t["./parser"]=function(){var g={},va={exports:g},
|
||||
xa=function(){function g(){this.yy={}}var a=function(a,q,pa,b){pa=pa||{};for(b=a.length;b--;pa[a[b]]=q);return pa},c=[1,22],t=[1,25],f=[1,83],p=[1,79],m=[1,84],H=[1,85],F=[1,81],x=[1,82],y=[1,56],v=[1,58],E=[1,59],N=[1,60],l=[1,61],h=[1,62],u=[1,49],w=[1,50],G=[1,32],L=[1,68],z=[1,69],I=[1,78],k=[1,47],M=[1,51],P=[1,52],n=[1,67],r=[1,65],V=[1,66],U=[1,64],Q=[1,42],ba=[1,48],S=[1,63],B=[1,73],A=[1,74],X=[1,75],C=[1,76],O=[1,46],Y=[1,72],Z=[1,34],W=[1,35],aa=[1,36],J=[1,37],ca=[1,38],R=[1,39],xa=[1,
|
||||
86],va=[1,6,32,42,131],qa=[1,101],ka=[1,89],da=[1,88],fa=[1,87],ha=[1,90],ia=[1,91],la=[1,92],oa=[1,93],K=[1,94],ja=[1,95],ra=[1,96],ea=[1,97],ma=[1,98],sa=[1,99],T=[1,100],ya=[1,104],ta=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],Ia=[2,165],Sa=[1,110],Ga=[1,111],Ta=[1,112],Fa=[1,113],Oa=[1,115],Pa=[1,116],La=[1,109],za=[1,6,32,42,131,133,135,139,156],na=[2,27],ga=[1,123],Ha=[1,121],Aa=[1,6,31,32,40,41,42,65,70,73,82,
|
||||
83,84,85,87,89,90,94,113,114,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],Xa=[2,94],b=[1,6,31,32,42,46,65,70,73,82,83,84,85,87,89,90,94,113,114,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],q=[2,73],pa=[1,128],e=[1,133],d=[1,134],wa=[1,136],Ma=[1,6,31,32,40,41,42,55,65,70,73,82,83,84,85,87,89,90,94,113,114,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,
|
||||
174],ua=[2,91],Gb=[1,6,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],ab=[2,63],Hb=[1,166],bb=[1,178],Va=[1,180],Ib=[1,175],Na=[1,182],ub=[1,184],Ja=[1,6,31,32,40,41,42,55,65,70,73,82,83,84,85,87,89,90,94,96,113,114,115,120,122,131,133,134,135,139,140,156,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175],Jb=[2,110],Kb=[1,6,31,32,40,41,42,58,65,70,73,82,83,84,85,87,89,90,94,113,114,115,120,122,131,133,134,135,
|
||||
139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],Lb=[1,6,31,32,40,41,42,46,58,65,70,73,82,83,84,85,87,89,90,94,113,114,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],Mb=[40,41,114],Nb=[1,241],vb=[1,240],Ka=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156],Ea=[2,71],Ob=[1,250],Ua=[6,31,32,65,70],hb=[6,31,32,55,65,70,73],cb=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,159,160,164,166,167,
|
||||
168,169,170,171,172,173,174],Pb=[40,41,82,83,84,85,87,90,113,114],ib=[1,269],db=[2,62],jb=[1,279],Ya=[1,281],wb=[1,286],eb=[1,288],Qb=[2,186],xb=[1,6,31,32,40,41,42,55,65,70,73,82,83,84,85,87,89,90,94,113,114,115,120,122,131,133,134,135,139,140,146,147,148,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],kb=[1,297],Qa=[6,31,32,70,115,120],Rb=[1,6,31,32,40,41,42,55,58,65,70,73,82,83,84,85,87,89,90,94,96,113,114,115,120,122,131,133,134,135,139,140,146,147,148,156,159,160,161,162,163,164,
|
||||
165,166,167,168,169,170,171,172,173,174,175],Sb=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,140,156],Za=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,134,140,156],lb=[146,147,148],mb=[70,146,147,148],nb=[6,31,94],Tb=[1,311],Ba=[6,31,32,70,94],Ub=[6,31,32,58,70,94],yb=[6,31,32,55,58,70,94],Vb=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,159,160,166,167,168,169,170,171,172,173,174],Wb=[12,28,34,38,40,41,44,45,48,49,50,51,52,53,61,62,63,67,68,89,92,95,97,105,112,117,118,119,125,
|
||||
129,130,133,135,137,139,149,155,157,158,159,160,161,162],Xb=[2,175],Ra=[6,31,32],fb=[2,72],Yb=[1,323],Zb=[1,324],$b=[1,6,31,32,42,65,70,73,89,94,115,120,122,127,128,131,133,134,135,139,140,151,153,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],ob=[32,151,153],ac=[1,6,32,42,65,70,73,89,94,115,120,122,131,134,140,156],pb=[1,350],zb=[1,356],Ab=[1,6,32,42,131,156],gb=[2,86],qb=[1,366],rb=[1,367],bc=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,151,156,159,160,163,164,
|
||||
165,166,167,168,169,170,171,172,173,174],Bb=[1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,135,139,140,156],cc=[1,380],dc=[1,381],Cb=[6,31,32,94],ec=[6,31,32,70],Db=[1,6,31,32,42,65,70,73,89,94,115,120,122,127,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],fc=[31,70],sb=[1,407],tb=[1,408],Eb=[1,414],Fb=[1,415],gc={trace:function(){},yy:{},symbols_:{error:2,Root:3,Body:4,Line:5,TERMINATOR:6,Expression:7,Statement:8,YieldReturn:9,Return:10,Comment:11,STATEMENT:12,
|
||||
Import:13,Export:14,Value:15,Invocation:16,Code:17,Operation:18,Assign:19,If:20,Try:21,While:22,For:23,Switch:24,Class:25,Throw:26,Yield:27,YIELD:28,FROM:29,Block:30,INDENT:31,OUTDENT:32,Identifier:33,IDENTIFIER:34,Property:35,PROPERTY:36,AlphaNumeric:37,NUMBER:38,String:39,STRING:40,STRING_START:41,STRING_END:42,Regex:43,REGEX:44,REGEX_START:45,REGEX_END:46,Literal:47,JS:48,UNDEFINED:49,NULL:50,BOOL:51,INFINITY:52,NAN:53,Assignable:54,"\x3d":55,AssignObj:56,ObjAssignable:57,":":58,SimpleObjAssignable:59,
|
||||
ThisProperty:60,RETURN:61,HERECOMMENT:62,PARAM_START:63,ParamList:64,PARAM_END:65,FuncGlyph:66,"-\x3e":67,"\x3d\x3e":68,OptComma:69,",":70,Param:71,ParamVar:72,"...":73,Array:74,Object:75,Splat:76,SimpleAssignable:77,Accessor:78,Parenthetical:79,Range:80,This:81,".":82,"?.":83,"::":84,"?::":85,Index:86,INDEX_START:87,IndexValue:88,INDEX_END:89,INDEX_SOAK:90,Slice:91,"{":92,AssignList:93,"}":94,CLASS:95,EXTENDS:96,IMPORT:97,ImportDefaultSpecifier:98,ImportNamespaceSpecifier:99,ImportSpecifierList:100,
|
||||
ImportSpecifier:101,AS:102,DEFAULT:103,IMPORT_ALL:104,EXPORT:105,ExportSpecifierList:106,EXPORT_ALL:107,ExportSpecifier:108,OptFuncExist:109,Arguments:110,Super:111,SUPER:112,FUNC_EXIST:113,CALL_START:114,CALL_END:115,ArgList:116,THIS:117,"@":118,"[":119,"]":120,RangeDots:121,"..":122,Arg:123,SimpleArgs:124,TRY:125,Catch:126,FINALLY:127,CATCH:128,THROW:129,"(":130,")":131,WhileSource:132,WHILE:133,WHEN:134,UNTIL:135,Loop:136,LOOP:137,ForBody:138,FOR:139,BY:140,ForStart:141,ForSource:142,ForVariables:143,
|
||||
OWN:144,ForValue:145,FORIN:146,FOROF:147,FORFROM:148,SWITCH:149,Whens:150,ELSE:151,When:152,LEADING_WHEN:153,IfBlock:154,IF:155,POST_IF:156,UNARY:157,UNARY_MATH:158,"-":159,"+":160,"--":161,"++":162,"?":163,MATH:164,"**":165,SHIFT:166,COMPARE:167,"\x26":168,"^":169,"|":170,"\x26\x26":171,"||":172,"BIN?":173,RELATION:174,COMPOUND_ASSIGN:175,$accept:0,$end:1},terminals_:{2:"error",6:"TERMINATOR",12:"STATEMENT",28:"YIELD",29:"FROM",31:"INDENT",32:"OUTDENT",34:"IDENTIFIER",36:"PROPERTY",38:"NUMBER",40:"STRING",
|
||||
41:"STRING_START",42:"STRING_END",44:"REGEX",45:"REGEX_START",46:"REGEX_END",48:"JS",49:"UNDEFINED",50:"NULL",51:"BOOL",52:"INFINITY",53:"NAN",55:"\x3d",58:":",61:"RETURN",62:"HERECOMMENT",63:"PARAM_START",65:"PARAM_END",67:"-\x3e",68:"\x3d\x3e",70:",",73:"...",82:".",83:"?.",84:"::",85:"?::",87:"INDEX_START",89:"INDEX_END",90:"INDEX_SOAK",92:"{",94:"}",95:"CLASS",96:"EXTENDS",97:"IMPORT",102:"AS",103:"DEFAULT",104:"IMPORT_ALL",105:"EXPORT",107:"EXPORT_ALL",112:"SUPER",113:"FUNC_EXIST",114:"CALL_START",
|
||||
115:"CALL_END",117:"THIS",118:"@",119:"[",120:"]",122:"..",125:"TRY",127:"FINALLY",128:"CATCH",129:"THROW",130:"(",131:")",133:"WHILE",134:"WHEN",135:"UNTIL",137:"LOOP",139:"FOR",140:"BY",144:"OWN",146:"FORIN",147:"FOROF",148:"FORFROM",149:"SWITCH",151:"ELSE",153:"LEADING_WHEN",155:"IF",156:"POST_IF",157:"UNARY",158:"UNARY_MATH",159:"-",160:"+",161:"--",162:"++",163:"?",164:"MATH",165:"**",166:"SHIFT",167:"COMPARE",168:"\x26",169:"^",170:"|",171:"\x26\x26",172:"||",173:"BIN?",174:"RELATION",175:"COMPOUND_ASSIGN"},
|
||||
productions_:[0,[3,0],[3,1],[4,1],[4,3],[4,2],[5,1],[5,1],[5,1],[8,1],[8,1],[8,1],[8,1],[8,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[27,1],[27,2],[27,3],[30,2],[30,3],[33,1],[35,1],[37,1],[37,1],[39,1],[39,3],[43,1],[43,3],[47,1],[47,1],[47,1],[47,1],[47,1],[47,1],[47,1],[47,1],[19,3],[19,4],[19,5],[56,1],[56,3],[56,5],[56,3],[56,5],[56,1],[59,1],[59,1],[59,1],[57,1],[57,1],[10,2],[10,1],[9,3],[9,2],[11,1],[17,5],[17,2],[66,1],[66,1],[69,0],[69,1],[64,0],[64,
|
||||
1],[64,3],[64,4],[64,6],[71,1],[71,2],[71,3],[71,1],[72,1],[72,1],[72,1],[72,1],[76,2],[77,1],[77,2],[77,2],[77,1],[54,1],[54,1],[54,1],[15,1],[15,1],[15,1],[15,1],[15,1],[78,2],[78,2],[78,2],[78,2],[78,1],[78,1],[86,3],[86,2],[88,1],[88,1],[75,4],[93,0],[93,1],[93,3],[93,4],[93,6],[25,1],[25,2],[25,3],[25,4],[25,2],[25,3],[25,4],[25,5],[13,2],[13,4],[13,4],[13,5],[13,7],[13,6],[13,9],[100,1],[100,3],[100,4],[100,4],[100,6],[101,1],[101,3],[101,1],[101,3],[98,1],[99,3],[14,3],[14,5],[14,2],[14,4],
|
||||
[14,5],[14,6],[14,3],[14,4],[14,7],[106,1],[106,3],[106,4],[106,4],[106,6],[108,1],[108,3],[108,3],[108,1],[16,3],[16,3],[16,3],[16,1],[111,1],[111,2],[109,0],[109,1],[110,2],[110,4],[81,1],[81,1],[60,2],[74,2],[74,4],[121,1],[121,1],[80,5],[91,3],[91,2],[91,2],[91,1],[116,1],[116,3],[116,4],[116,4],[116,6],[123,1],[123,1],[123,1],[124,1],[124,3],[21,2],[21,3],[21,4],[21,5],[126,3],[126,3],[126,2],[26,2],[79,3],[79,5],[132,2],[132,4],[132,2],[132,4],[22,2],[22,2],[22,2],[22,1],[136,2],[136,2],[23,
|
||||
2],[23,2],[23,2],[138,2],[138,4],[138,2],[141,2],[141,3],[145,1],[145,1],[145,1],[145,1],[143,1],[143,3],[142,2],[142,2],[142,4],[142,4],[142,4],[142,6],[142,6],[142,2],[142,4],[24,5],[24,7],[24,4],[24,6],[150,1],[150,2],[152,3],[152,4],[154,3],[154,5],[20,1],[20,3],[20,3],[20,3],[18,2],[18,2],[18,2],[18,2],[18,2],[18,2],[18,2],[18,2],[18,2],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,3],[18,5],[18,4],[18,3]],performAction:function(a,q,pa,b,c,e,d){a=
|
||||
e.length-1;switch(c){case 1:return this.$=b.addLocationDataFn(d[a],d[a])(new b.Block);case 2:return this.$=e[a];case 3:this.$=b.addLocationDataFn(d[a],d[a])(b.Block.wrap([e[a]]));break;case 4:this.$=b.addLocationDataFn(d[a-2],d[a])(e[a-2].push(e[a]));break;case 5:this.$=e[a-1];break;case 6:case 7:case 8:case 9:case 10:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 35:case 40:case 42:case 56:case 57:case 58:case 59:case 60:case 61:case 71:case 72:case 82:case 83:case 84:case 85:case 90:case 91:case 94:case 98:case 104:case 162:case 186:case 187:case 189:case 219:case 220:case 238:case 244:this.$=
|
||||
e[a];break;case 11:this.$=b.addLocationDataFn(d[a],d[a])(new b.StatementLiteral(e[a]));break;case 27:this.$=b.addLocationDataFn(d[a],d[a])(new b.Op(e[a],new b.Value(new b.Literal(""))));break;case 28:case 248:case 249:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Op(e[a-1],e[a]));break;case 29:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.Op(e[a-2].concat(e[a-1]),e[a]));break;case 30:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Block);break;case 31:case 105:this.$=b.addLocationDataFn(d[a-2],d[a])(e[a-
|
||||
1]);break;case 32:this.$=b.addLocationDataFn(d[a],d[a])(new b.IdentifierLiteral(e[a]));break;case 33:this.$=b.addLocationDataFn(d[a],d[a])(new b.PropertyName(e[a]));break;case 34:this.$=b.addLocationDataFn(d[a],d[a])(new b.NumberLiteral(e[a]));break;case 36:this.$=b.addLocationDataFn(d[a],d[a])(new b.StringLiteral(e[a]));break;case 37:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.StringWithInterpolations(e[a-1]));break;case 38:this.$=b.addLocationDataFn(d[a],d[a])(new b.RegexLiteral(e[a]));break;
|
||||
case 39:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.RegexWithInterpolations(e[a-1].args));break;case 41:this.$=b.addLocationDataFn(d[a],d[a])(new b.PassthroughLiteral(e[a]));break;case 43:this.$=b.addLocationDataFn(d[a],d[a])(new b.UndefinedLiteral);break;case 44:this.$=b.addLocationDataFn(d[a],d[a])(new b.NullLiteral);break;case 45:this.$=b.addLocationDataFn(d[a],d[a])(new b.BooleanLiteral(e[a]));break;case 46:this.$=b.addLocationDataFn(d[a],d[a])(new b.InfinityLiteral(e[a]));break;case 47:this.$=
|
||||
b.addLocationDataFn(d[a],d[a])(new b.NaNLiteral);break;case 48:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.Assign(e[a-2],e[a]));break;case 49:this.$=b.addLocationDataFn(d[a-3],d[a])(new b.Assign(e[a-3],e[a]));break;case 50:this.$=b.addLocationDataFn(d[a-4],d[a])(new b.Assign(e[a-4],e[a-1]));break;case 51:case 87:case 92:case 93:case 95:case 96:case 97:case 221:case 222:this.$=b.addLocationDataFn(d[a],d[a])(new b.Value(e[a]));break;case 52:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.Assign(b.addLocationDataFn(d[a-
|
||||
2])(new b.Value(e[a-2])),e[a],"object",{operatorToken:b.addLocationDataFn(d[a-1])(new b.Literal(e[a-1]))}));break;case 53:this.$=b.addLocationDataFn(d[a-4],d[a])(new b.Assign(b.addLocationDataFn(d[a-4])(new b.Value(e[a-4])),e[a-1],"object",{operatorToken:b.addLocationDataFn(d[a-3])(new b.Literal(e[a-3]))}));break;case 54:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.Assign(b.addLocationDataFn(d[a-2])(new b.Value(e[a-2])),e[a],null,{operatorToken:b.addLocationDataFn(d[a-1])(new b.Literal(e[a-1]))}));
|
||||
break;case 55:this.$=b.addLocationDataFn(d[a-4],d[a])(new b.Assign(b.addLocationDataFn(d[a-4])(new b.Value(e[a-4])),e[a-1],null,{operatorToken:b.addLocationDataFn(d[a-3])(new b.Literal(e[a-3]))}));break;case 62:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Return(e[a]));break;case 63:this.$=b.addLocationDataFn(d[a],d[a])(new b.Return);break;case 64:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.YieldReturn(e[a]));break;case 65:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.YieldReturn);break;case 66:this.$=
|
||||
b.addLocationDataFn(d[a],d[a])(new b.Comment(e[a]));break;case 67:this.$=b.addLocationDataFn(d[a-4],d[a])(new b.Code(e[a-3],e[a],e[a-1]));break;case 68:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Code([],e[a],e[a-1]));break;case 69:this.$=b.addLocationDataFn(d[a],d[a])("func");break;case 70:this.$=b.addLocationDataFn(d[a],d[a])("boundfunc");break;case 73:case 110:this.$=b.addLocationDataFn(d[a],d[a])([]);break;case 74:case 111:case 130:case 150:case 181:case 223:this.$=b.addLocationDataFn(d[a],
|
||||
d[a])([e[a]]);break;case 75:case 112:case 131:case 151:case 182:this.$=b.addLocationDataFn(d[a-2],d[a])(e[a-2].concat(e[a]));break;case 76:case 113:case 132:case 152:case 183:this.$=b.addLocationDataFn(d[a-3],d[a])(e[a-3].concat(e[a]));break;case 77:case 114:case 134:case 154:case 185:this.$=b.addLocationDataFn(d[a-5],d[a])(e[a-5].concat(e[a-2]));break;case 78:this.$=b.addLocationDataFn(d[a],d[a])(new b.Param(e[a]));break;case 79:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Param(e[a-1],null,!0));
|
||||
break;case 80:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.Param(e[a-2],e[a]));break;case 81:case 188:this.$=b.addLocationDataFn(d[a],d[a])(new b.Expansion);break;case 86:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Splat(e[a-1]));break;case 88:this.$=b.addLocationDataFn(d[a-1],d[a])(e[a-1].add(e[a]));break;case 89:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Value(e[a-1],[].concat(e[a])));break;case 99:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Access(e[a]));break;case 100:this.$=b.addLocationDataFn(d[a-
|
||||
1],d[a])(new b.Access(e[a],"soak"));break;case 101:this.$=b.addLocationDataFn(d[a-1],d[a])([b.addLocationDataFn(d[a-1])(new b.Access(new b.PropertyName("prototype"))),b.addLocationDataFn(d[a])(new b.Access(e[a]))]);break;case 102:this.$=b.addLocationDataFn(d[a-1],d[a])([b.addLocationDataFn(d[a-1])(new b.Access(new b.PropertyName("prototype"),"soak")),b.addLocationDataFn(d[a])(new b.Access(e[a]))]);break;case 103:this.$=b.addLocationDataFn(d[a],d[a])(new b.Access(new b.PropertyName("prototype")));
|
||||
break;case 106:this.$=b.addLocationDataFn(d[a-1],d[a])(b.extend(e[a],{soak:!0}));break;case 107:this.$=b.addLocationDataFn(d[a],d[a])(new b.Index(e[a]));break;case 108:this.$=b.addLocationDataFn(d[a],d[a])(new b.Slice(e[a]));break;case 109:this.$=b.addLocationDataFn(d[a-3],d[a])(new b.Obj(e[a-2],e[a-3].generated));break;case 115:this.$=b.addLocationDataFn(d[a],d[a])(new b.Class);break;case 116:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Class(null,null,e[a]));break;case 117:this.$=b.addLocationDataFn(d[a-
|
||||
2],d[a])(new b.Class(null,e[a]));break;case 118:this.$=b.addLocationDataFn(d[a-3],d[a])(new b.Class(null,e[a-1],e[a]));break;case 119:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Class(e[a]));break;case 120:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.Class(e[a-1],null,e[a]));break;case 121:this.$=b.addLocationDataFn(d[a-3],d[a])(new b.Class(e[a-2],e[a]));break;case 122:this.$=b.addLocationDataFn(d[a-4],d[a])(new b.Class(e[a-3],e[a-1],e[a]));break;case 123:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.ImportDeclaration(null,
|
||||
e[a]));break;case 124:this.$=b.addLocationDataFn(d[a-3],d[a])(new b.ImportDeclaration(new b.ImportClause(e[a-2],null),e[a]));break;case 125:this.$=b.addLocationDataFn(d[a-3],d[a])(new b.ImportDeclaration(new b.ImportClause(null,e[a-2]),e[a]));break;case 126:this.$=b.addLocationDataFn(d[a-4],d[a])(new b.ImportDeclaration(new b.ImportClause(null,new b.ImportSpecifierList([])),e[a]));break;case 127:this.$=b.addLocationDataFn(d[a-6],d[a])(new b.ImportDeclaration(new b.ImportClause(null,new b.ImportSpecifierList(e[a-
|
||||
4])),e[a]));break;case 128:this.$=b.addLocationDataFn(d[a-5],d[a])(new b.ImportDeclaration(new b.ImportClause(e[a-4],e[a-2]),e[a]));break;case 129:this.$=b.addLocationDataFn(d[a-8],d[a])(new b.ImportDeclaration(new b.ImportClause(e[a-7],new b.ImportSpecifierList(e[a-4])),e[a]));break;case 133:case 153:case 168:case 184:this.$=b.addLocationDataFn(d[a-3],d[a])(e[a-2]);break;case 135:this.$=b.addLocationDataFn(d[a],d[a])(new b.ImportSpecifier(e[a]));break;case 136:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.ImportSpecifier(e[a-
|
||||
2],e[a]));break;case 137:this.$=b.addLocationDataFn(d[a],d[a])(new b.ImportSpecifier(new b.Literal(e[a])));break;case 138:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.ImportSpecifier(new b.Literal(e[a-2]),e[a]));break;case 139:this.$=b.addLocationDataFn(d[a],d[a])(new b.ImportDefaultSpecifier(e[a]));break;case 140:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.ImportNamespaceSpecifier(new b.Literal(e[a-2]),e[a]));break;case 141:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.ExportNamedDeclaration(new b.ExportSpecifierList([])));
|
||||
break;case 142:this.$=b.addLocationDataFn(d[a-4],d[a])(new b.ExportNamedDeclaration(new b.ExportSpecifierList(e[a-2])));break;case 143:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.ExportNamedDeclaration(e[a]));break;case 144:this.$=b.addLocationDataFn(d[a-3],d[a])(new b.ExportNamedDeclaration(new b.Assign(e[a-2],e[a],null,{moduleDeclaration:"export"})));break;case 145:this.$=b.addLocationDataFn(d[a-4],d[a])(new b.ExportNamedDeclaration(new b.Assign(e[a-3],e[a],null,{moduleDeclaration:"export"})));
|
||||
break;case 146:this.$=b.addLocationDataFn(d[a-5],d[a])(new b.ExportNamedDeclaration(new b.Assign(e[a-4],e[a-1],null,{moduleDeclaration:"export"})));break;case 147:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.ExportDefaultDeclaration(e[a]));break;case 148:this.$=b.addLocationDataFn(d[a-3],d[a])(new b.ExportAllDeclaration(new b.Literal(e[a-2]),e[a]));break;case 149:this.$=b.addLocationDataFn(d[a-6],d[a])(new b.ExportNamedDeclaration(new b.ExportSpecifierList(e[a-4]),e[a]));break;case 155:this.$=b.addLocationDataFn(d[a],
|
||||
d[a])(new b.ExportSpecifier(e[a]));break;case 156:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.ExportSpecifier(e[a-2],e[a]));break;case 157:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.ExportSpecifier(e[a-2],new b.Literal(e[a])));break;case 158:this.$=b.addLocationDataFn(d[a],d[a])(new b.ExportSpecifier(new b.Literal(e[a])));break;case 159:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.TaggedTemplateCall(e[a-2],e[a],e[a-1]));break;case 160:case 161:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.Call(e[a-
|
||||
2],e[a],e[a-1]));break;case 163:this.$=b.addLocationDataFn(d[a],d[a])(new b.SuperCall);break;case 164:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.SuperCall(e[a]));break;case 165:this.$=b.addLocationDataFn(d[a],d[a])(!1);break;case 166:this.$=b.addLocationDataFn(d[a],d[a])(!0);break;case 167:this.$=b.addLocationDataFn(d[a-1],d[a])([]);break;case 169:case 170:this.$=b.addLocationDataFn(d[a],d[a])(new b.Value(new b.ThisLiteral));break;case 171:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Value(b.addLocationDataFn(d[a-
|
||||
1])(new b.ThisLiteral),[b.addLocationDataFn(d[a])(new b.Access(e[a]))],"this"));break;case 172:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Arr([]));break;case 173:this.$=b.addLocationDataFn(d[a-3],d[a])(new b.Arr(e[a-2]));break;case 174:this.$=b.addLocationDataFn(d[a],d[a])("inclusive");break;case 175:this.$=b.addLocationDataFn(d[a],d[a])("exclusive");break;case 176:this.$=b.addLocationDataFn(d[a-4],d[a])(new b.Range(e[a-3],e[a-1],e[a-2]));break;case 177:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.Range(e[a-
|
||||
2],e[a],e[a-1]));break;case 178:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Range(e[a-1],null,e[a]));break;case 179:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Range(null,e[a],e[a-1]));break;case 180:this.$=b.addLocationDataFn(d[a],d[a])(new b.Range(null,null,e[a]));break;case 190:this.$=b.addLocationDataFn(d[a-2],d[a])([].concat(e[a-2],e[a]));break;case 191:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Try(e[a]));break;case 192:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.Try(e[a-1],e[a][0],
|
||||
e[a][1]));break;case 193:this.$=b.addLocationDataFn(d[a-3],d[a])(new b.Try(e[a-2],null,null,e[a]));break;case 194:this.$=b.addLocationDataFn(d[a-4],d[a])(new b.Try(e[a-3],e[a-2][0],e[a-2][1],e[a]));break;case 195:this.$=b.addLocationDataFn(d[a-2],d[a])([e[a-1],e[a]]);break;case 196:this.$=b.addLocationDataFn(d[a-2],d[a])([b.addLocationDataFn(d[a-1])(new b.Value(e[a-1])),e[a]]);break;case 197:this.$=b.addLocationDataFn(d[a-1],d[a])([null,e[a]]);break;case 198:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Throw(e[a]));
|
||||
break;case 199:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.Parens(e[a-1]));break;case 200:this.$=b.addLocationDataFn(d[a-4],d[a])(new b.Parens(e[a-2]));break;case 201:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.While(e[a]));break;case 202:this.$=b.addLocationDataFn(d[a-3],d[a])(new b.While(e[a-2],{guard:e[a]}));break;case 203:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.While(e[a],{invert:!0}));break;case 204:this.$=b.addLocationDataFn(d[a-3],d[a])(new b.While(e[a-2],{invert:!0,guard:e[a]}));
|
||||
break;case 205:this.$=b.addLocationDataFn(d[a-1],d[a])(e[a-1].addBody(e[a]));break;case 206:case 207:this.$=b.addLocationDataFn(d[a-1],d[a])(e[a].addBody(b.addLocationDataFn(d[a-1])(b.Block.wrap([e[a-1]]))));break;case 208:this.$=b.addLocationDataFn(d[a],d[a])(e[a]);break;case 209:this.$=b.addLocationDataFn(d[a-1],d[a])((new b.While(b.addLocationDataFn(d[a-1])(new b.BooleanLiteral("true")))).addBody(e[a]));break;case 210:this.$=b.addLocationDataFn(d[a-1],d[a])((new b.While(b.addLocationDataFn(d[a-
|
||||
1])(new b.BooleanLiteral("true")))).addBody(b.addLocationDataFn(d[a])(b.Block.wrap([e[a]]))));break;case 211:case 212:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.For(e[a-1],e[a]));break;case 213:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.For(e[a],e[a-1]));break;case 214:this.$=b.addLocationDataFn(d[a-1],d[a])({source:b.addLocationDataFn(d[a])(new b.Value(e[a]))});break;case 215:this.$=b.addLocationDataFn(d[a-3],d[a])({source:b.addLocationDataFn(d[a-2])(new b.Value(e[a-2])),step:e[a]});break;
|
||||
case 216:b=b.addLocationDataFn(d[a-1],d[a]);e[a].own=e[a-1].own;e[a].ownTag=e[a-1].ownTag;e[a].name=e[a-1][0];e[a].index=e[a-1][1];this.$=b(e[a]);break;case 217:this.$=b.addLocationDataFn(d[a-1],d[a])(e[a]);break;case 218:c=b.addLocationDataFn(d[a-2],d[a]);e[a].own=!0;e[a].ownTag=b.addLocationDataFn(d[a-1])(new b.Literal(e[a-1]));this.$=c(e[a]);break;case 224:this.$=b.addLocationDataFn(d[a-2],d[a])([e[a-2],e[a]]);break;case 225:this.$=b.addLocationDataFn(d[a-1],d[a])({source:e[a]});break;case 226:this.$=
|
||||
b.addLocationDataFn(d[a-1],d[a])({source:e[a],object:!0});break;case 227:this.$=b.addLocationDataFn(d[a-3],d[a])({source:e[a-2],guard:e[a]});break;case 228:this.$=b.addLocationDataFn(d[a-3],d[a])({source:e[a-2],guard:e[a],object:!0});break;case 229:this.$=b.addLocationDataFn(d[a-3],d[a])({source:e[a-2],step:e[a]});break;case 230:this.$=b.addLocationDataFn(d[a-5],d[a])({source:e[a-4],guard:e[a-2],step:e[a]});break;case 231:this.$=b.addLocationDataFn(d[a-5],d[a])({source:e[a-4],step:e[a-2],guard:e[a]});
|
||||
break;case 232:this.$=b.addLocationDataFn(d[a-1],d[a])({source:e[a],from:!0});break;case 233:this.$=b.addLocationDataFn(d[a-3],d[a])({source:e[a-2],guard:e[a],from:!0});break;case 234:this.$=b.addLocationDataFn(d[a-4],d[a])(new b.Switch(e[a-3],e[a-1]));break;case 235:this.$=b.addLocationDataFn(d[a-6],d[a])(new b.Switch(e[a-5],e[a-3],e[a-1]));break;case 236:this.$=b.addLocationDataFn(d[a-3],d[a])(new b.Switch(null,e[a-1]));break;case 237:this.$=b.addLocationDataFn(d[a-5],d[a])(new b.Switch(null,e[a-
|
||||
3],e[a-1]));break;case 239:this.$=b.addLocationDataFn(d[a-1],d[a])(e[a-1].concat(e[a]));break;case 240:this.$=b.addLocationDataFn(d[a-2],d[a])([[e[a-1],e[a]]]);break;case 241:this.$=b.addLocationDataFn(d[a-3],d[a])([[e[a-2],e[a-1]]]);break;case 242:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.If(e[a-1],e[a],{type:e[a-2]}));break;case 243:this.$=b.addLocationDataFn(d[a-4],d[a])(e[a-4].addElse(b.addLocationDataFn(d[a-2],d[a])(new b.If(e[a-1],e[a],{type:e[a-2]}))));break;case 245:this.$=b.addLocationDataFn(d[a-
|
||||
2],d[a])(e[a-2].addElse(e[a]));break;case 246:case 247:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.If(e[a],b.addLocationDataFn(d[a-2])(b.Block.wrap([e[a-2]])),{type:e[a-1],statement:!0}));break;case 250:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Op("-",e[a]));break;case 251:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Op("+",e[a]));break;case 252:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Op("--",e[a]));break;case 253:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Op("++",e[a]));break;case 254:this.$=
|
||||
b.addLocationDataFn(d[a-1],d[a])(new b.Op("--",e[a-1],null,!0));break;case 255:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Op("++",e[a-1],null,!0));break;case 256:this.$=b.addLocationDataFn(d[a-1],d[a])(new b.Existence(e[a-1]));break;case 257:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.Op("+",e[a-2],e[a]));break;case 258:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.Op("-",e[a-2],e[a]));break;case 259:case 260:case 261:case 262:case 263:case 264:case 265:case 266:case 267:case 268:this.$=b.addLocationDataFn(d[a-
|
||||
2],d[a])(new b.Op(e[a-1],e[a-2],e[a]));break;case 269:d=b.addLocationDataFn(d[a-2],d[a]);e="!"===e[a-1].charAt(0)?(new b.Op(e[a-1].slice(1),e[a-2],e[a])).invert():new b.Op(e[a-1],e[a-2],e[a]);this.$=d(e);break;case 270:this.$=b.addLocationDataFn(d[a-2],d[a])(new b.Assign(e[a-2],e[a],e[a-1]));break;case 271:this.$=b.addLocationDataFn(d[a-4],d[a])(new b.Assign(e[a-4],e[a-1],e[a-3]));break;case 272:this.$=b.addLocationDataFn(d[a-3],d[a])(new b.Assign(e[a-3],e[a],e[a-2]));break;case 273:this.$=b.addLocationDataFn(d[a-
|
||||
2],d[a])(new b.Extends(e[a-2],e[a]))}},table:[{1:[2,1],3:1,4:2,5:3,7:4,8:5,9:6,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:t,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,
|
||||
158:W,159:aa,160:J,161:ca,162:R},{1:[3]},{1:[2,2],6:xa},a(va,[2,3]),a(va,[2,6],{141:77,132:102,138:103,133:B,135:A,139:C,156:qa,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(va,[2,7],{141:77,132:105,138:106,133:B,135:A,139:C,156:ya}),a(va,[2,8]),a(ta,[2,14],{109:107,78:108,86:114,40:Ia,41:Ia,114:Ia,82:Sa,83:Ga,84:Ta,85:Fa,87:Oa,90:Pa,113:La}),a(ta,[2,15],{86:114,109:117,78:118,82:Sa,83:Ga,84:Ta,85:Fa,87:Oa,90:Pa,113:La,114:Ia}),a(ta,[2,16]),a(ta,
|
||||
[2,17]),a(ta,[2,18]),a(ta,[2,19]),a(ta,[2,20]),a(ta,[2,21]),a(ta,[2,22]),a(ta,[2,23]),a(ta,[2,24]),a(ta,[2,25]),a(ta,[2,26]),a(za,[2,9]),a(za,[2,10]),a(za,[2,11]),a(za,[2,12]),a(za,[2,13]),a([1,6,32,42,131,133,135,139,156,163,164,165,166,167,168,169,170,171,172,173,174],na,{15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,10:20,11:21,13:23,14:24,54:26,47:27,79:28,80:29,81:30,111:31,66:33,77:40,154:41,132:43,136:44,138:45,74:53,75:54,37:55,43:57,33:70,60:71,141:77,39:80,7:120,
|
||||
8:122,12:c,28:ga,29:Ha,34:f,38:p,40:m,41:H,44:F,45:x,48:y,49:v,50:E,51:N,52:l,53:h,61:[1,119],62:w,63:G,67:L,68:z,92:I,95:k,97:M,105:P,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,137:X,149:O,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R}),a(Aa,Xa,{55:[1,124]}),a(Aa,[2,95]),a(Aa,[2,96]),a(Aa,[2,97]),a(Aa,[2,98]),a(b,[2,162]),a([6,31,65,70],q,{64:125,71:126,72:127,33:129,60:130,74:131,75:132,34:f,73:pa,92:I,118:e,119:d}),{30:135,31:wa},{7:137,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,
|
||||
20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:138,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,
|
||||
25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:139,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,
|
||||
34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:140,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,
|
||||
43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{15:142,16:143,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:144,60:71,74:53,75:54,77:141,79:28,80:29,81:30,92:I,111:31,112:n,117:r,118:V,119:U,
|
||||
130:S},{15:142,16:143,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:144,60:71,74:53,75:54,77:145,79:28,80:29,81:30,92:I,111:31,112:n,117:r,118:V,119:U,130:S},a(Ma,ua,{96:[1,149],161:[1,146],162:[1,147],175:[1,148]}),a(ta,[2,244],{151:[1,150]}),{30:151,31:wa},{30:152,31:wa},a(ta,[2,208]),{30:153,31:wa},{7:154,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,31:[1,155],33:70,34:f,37:55,
|
||||
38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a(Gb,[2,115],{47:27,79:28,80:29,81:30,111:31,74:53,75:54,37:55,43:57,33:70,60:71,39:80,15:142,16:143,54:144,30:156,77:158,31:wa,34:f,38:p,40:m,41:H,44:F,45:x,48:y,49:v,
|
||||
50:E,51:N,52:l,53:h,92:I,96:[1,157],112:n,117:r,118:V,119:U,130:S}),{7:159,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,
|
||||
157:Z,158:W,159:aa,160:J,161:ca,162:R},a(za,ab,{15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,10:20,11:21,13:23,14:24,54:26,47:27,79:28,80:29,81:30,111:31,66:33,77:40,154:41,132:43,136:44,138:45,74:53,75:54,37:55,43:57,33:70,60:71,141:77,39:80,8:122,7:160,12:c,28:ga,34:f,38:p,40:m,41:H,44:F,45:x,48:y,49:v,50:E,51:N,52:l,53:h,61:u,62:w,63:G,67:L,68:z,92:I,95:k,97:M,105:P,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,137:X,149:O,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R}),
|
||||
a([1,6,31,32,42,70,94,131,133,135,139,156],[2,66]),{33:165,34:f,39:161,40:m,41:H,92:[1,164],98:162,99:163,104:Hb},{25:168,33:169,34:f,92:[1,167],95:k,103:[1,170],107:[1,171]},a(Ma,[2,92]),a(Ma,[2,93]),a(Aa,[2,40]),a(Aa,[2,41]),a(Aa,[2,42]),a(Aa,[2,43]),a(Aa,[2,44]),a(Aa,[2,45]),a(Aa,[2,46]),a(Aa,[2,47]),{4:172,5:3,7:4,8:5,9:6,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:t,31:[1,173],33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,
|
||||
47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:174,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,31:bb,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,
|
||||
52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,73:Va,74:53,75:54,76:179,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,116:176,117:r,118:V,119:U,120:Ib,123:177,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a(Aa,[2,169]),a(Aa,[2,170],{35:181,36:Na}),a([1,6,31,32,42,46,65,70,73,82,83,84,85,87,89,90,94,113,115,120,122,131,133,134,135,139,140,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],
|
||||
[2,163],{110:183,114:ub}),{31:[2,69]},{31:[2,70]},a(Ja,[2,87]),a(Ja,[2,90]),{7:185,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,
|
||||
155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:186,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,
|
||||
161:ca,162:R},{7:187,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:189,8:122,10:20,
|
||||
11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,30:188,31:wa,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{33:194,34:f,60:195,74:196,75:197,
|
||||
80:190,92:I,118:e,119:U,143:191,144:[1,192],145:193},{142:198,146:[1,199],147:[1,200],148:[1,201]},a([6,31,70,94],Jb,{39:80,93:202,56:203,57:204,59:205,11:206,37:207,33:208,35:209,60:210,34:f,36:Na,38:p,40:m,41:H,62:w,118:e}),a(Kb,[2,34]),a(Kb,[2,35]),a(Aa,[2,38]),{15:142,16:211,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:144,60:71,74:53,75:54,77:212,79:28,80:29,81:30,92:I,111:31,112:n,117:r,118:V,119:U,130:S},a([1,6,29,31,32,40,41,42,55,58,65,70,73,
|
||||
82,83,84,85,87,89,90,94,96,102,113,114,115,120,122,131,133,134,135,139,140,146,147,148,156,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175],[2,32]),a(Lb,[2,36]),{4:213,5:3,7:4,8:5,9:6,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:t,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,
|
||||
111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a(va,[2,5],{7:4,8:5,9:6,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,10:20,11:21,13:23,14:24,54:26,47:27,79:28,80:29,81:30,111:31,66:33,77:40,154:41,132:43,136:44,138:45,74:53,75:54,37:55,43:57,33:70,60:71,141:77,39:80,5:214,12:c,28:t,34:f,38:p,40:m,41:H,44:F,45:x,48:y,49:v,50:E,51:N,52:l,53:h,61:u,62:w,63:G,67:L,
|
||||
68:z,92:I,95:k,97:M,105:P,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,133:B,135:A,137:X,139:C,149:O,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R}),a(ta,[2,256]),{7:215,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,
|
||||
125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:216,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,
|
||||
135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:217,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,
|
||||
141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:218,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,
|
||||
158:W,159:aa,160:J,161:ca,162:R},{7:219,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},
|
||||
{7:220,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:221,8:122,10:20,11:21,12:c,
|
||||
13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:222,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,
|
||||
19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:223,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,
|
||||
24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:224,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,
|
||||
33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:225,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,
|
||||
40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:226,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,
|
||||
48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:227,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,
|
||||
54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:228,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,
|
||||
67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a(ta,[2,207]),a(ta,[2,212]),{7:229,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,
|
||||
67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a(ta,[2,206]),a(ta,[2,211]),{39:230,40:m,41:H,110:231,114:ub},a(Ja,[2,88]),a(Mb,[2,166]),{35:232,36:Na},{35:233,36:Na},a(Ja,[2,103],{35:234,36:Na}),{35:235,36:Na},a(Ja,[2,104]),{7:237,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,
|
||||
25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,73:Nb,74:53,75:54,77:40,79:28,80:29,81:30,88:236,91:238,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,121:239,122:vb,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{86:242,87:Oa,90:Pa},{110:243,114:ub},a(Ja,[2,89]),a(va,[2,65],{15:7,16:8,17:9,18:10,19:11,20:12,
|
||||
21:13,22:14,23:15,24:16,25:17,26:18,27:19,10:20,11:21,13:23,14:24,54:26,47:27,79:28,80:29,81:30,111:31,66:33,77:40,154:41,132:43,136:44,138:45,74:53,75:54,37:55,43:57,33:70,60:71,141:77,39:80,8:122,7:244,12:c,28:ga,34:f,38:p,40:m,41:H,44:F,45:x,48:y,49:v,50:E,51:N,52:l,53:h,61:u,62:w,63:G,67:L,68:z,92:I,95:k,97:M,105:P,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,133:ab,135:ab,139:ab,156:ab,137:X,149:O,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R}),a(Ka,[2,28],{141:77,132:102,138:103,159:ka,160:da,163:fa,
|
||||
164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),{7:245,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,
|
||||
155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{132:105,133:B,135:A,138:106,139:C,141:77,156:ya},a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,163,164,165,166,167,168,169,170,171,172,173,174],na,{15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,10:20,11:21,13:23,14:24,54:26,47:27,79:28,80:29,81:30,111:31,66:33,77:40,154:41,132:43,136:44,138:45,74:53,75:54,37:55,43:57,33:70,60:71,141:77,39:80,7:120,8:122,12:c,28:ga,29:Ha,34:f,38:p,40:m,41:H,44:F,45:x,
|
||||
48:y,49:v,50:E,51:N,52:l,53:h,61:u,62:w,63:G,67:L,68:z,92:I,95:k,97:M,105:P,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,137:X,149:O,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R}),{6:[1,247],7:246,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,31:[1,248],33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,
|
||||
105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a([6,31],Ea,{69:251,65:[1,249],70:Ob}),a(Ua,[2,74]),a(Ua,[2,78],{55:[1,253],73:[1,252]}),a(Ua,[2,81]),a(hb,[2,82]),a(hb,[2,83]),a(hb,[2,84]),a(hb,[2,85]),{35:181,36:Na},{7:254,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,31:bb,33:70,34:f,37:55,38:p,39:80,40:m,41:H,
|
||||
43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,73:Va,74:53,75:54,76:179,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,116:176,117:r,118:V,119:U,120:Ib,123:177,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a(ta,[2,68]),{4:256,5:3,7:4,8:5,9:6,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:t,32:[1,255],
|
||||
33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,159,160,164,165,166,167,168,169,170,171,172,173,174],[2,248],{141:77,132:102,138:103,
|
||||
163:fa}),a(cb,[2,249],{141:77,132:102,138:103,163:fa,165:ia}),a(cb,[2,250],{141:77,132:102,138:103,163:fa,165:ia}),a(cb,[2,251],{141:77,132:102,138:103,163:fa,165:ia}),a(ta,[2,252],{40:ua,41:ua,82:ua,83:ua,84:ua,85:ua,87:ua,90:ua,113:ua,114:ua}),a(Mb,Ia,{109:107,78:108,86:114,82:Sa,83:Ga,84:Ta,85:Fa,87:Oa,90:Pa,113:La}),{78:118,82:Sa,83:Ga,84:Ta,85:Fa,86:114,87:Oa,90:Pa,109:117,113:La,114:Ia},a(Pb,Xa),a(ta,[2,253],{40:ua,41:ua,82:ua,83:ua,84:ua,85:ua,87:ua,90:ua,113:ua,114:ua}),a(ta,[2,254]),a(ta,
|
||||
[2,255]),{6:[1,259],7:257,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,31:[1,258],33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},
|
||||
{7:260,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{30:261,31:wa,155:[1,262]},a(ta,
|
||||
[2,191],{126:263,127:[1,264],128:[1,265]}),a(ta,[2,205]),a(ta,[2,213]),{31:[1,266],132:102,133:B,135:A,138:103,139:C,141:77,156:qa,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T},{150:267,152:268,153:ib},a(ta,[2,116]),{7:270,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,
|
||||
63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a(Gb,[2,119],{30:271,31:wa,40:ua,41:ua,82:ua,83:ua,84:ua,85:ua,87:ua,90:ua,113:ua,114:ua,96:[1,272]}),a(Ka,[2,198],{141:77,132:102,138:103,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(za,db,{141:77,132:102,138:103,
|
||||
159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(za,[2,123]),{29:[1,273],70:[1,274]},{29:[1,275]},{31:jb,33:280,34:f,94:[1,276],100:277,101:278,103:Ya},a([29,70],[2,139]),{102:[1,282]},{31:wb,33:287,34:f,94:[1,283],103:eb,106:284,108:285},a(za,[2,143]),{55:[1,289]},{7:290,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,
|
||||
49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{29:[1,291]},{6:xa,131:[1,292]},{4:293,5:3,7:4,8:5,9:6,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:t,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,
|
||||
47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a([6,31,70,120],Qb,{141:77,132:102,138:103,121:294,73:[1,295],122:vb,133:B,135:A,139:C,156:qa,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(xb,[2,172]),
|
||||
a([6,31,120],Ea,{69:296,70:kb}),a(Qa,[2,181]),{7:254,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,31:bb,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,73:Va,74:53,75:54,76:179,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,116:298,117:r,118:V,119:U,123:177,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,
|
||||
154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a(Qa,[2,187]),a(Qa,[2,188]),a(Rb,[2,171]),a(Rb,[2,33]),a(b,[2,164]),{7:254,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,31:bb,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,73:Va,74:53,75:54,76:179,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,115:[1,299],116:300,117:r,118:V,119:U,
|
||||
123:177,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{30:301,31:wa,132:102,133:B,135:A,138:103,139:C,141:77,156:qa,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T},a(Sb,[2,201],{141:77,132:102,138:103,133:B,134:[1,302],135:A,139:C,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(Sb,[2,203],{141:77,132:102,138:103,133:B,
|
||||
134:[1,303],135:A,139:C,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(ta,[2,209]),a(Za,[2,210],{141:77,132:102,138:103,133:B,135:A,139:C,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,156,159,160,163,164,165,166,167,168,169,170,171,172,173,174],[2,214],{140:[1,304]}),a(lb,[2,217]),{33:194,34:f,60:195,74:196,75:197,92:I,118:e,119:d,
|
||||
143:305,145:193},a(lb,[2,223],{70:[1,306]}),a(mb,[2,219]),a(mb,[2,220]),a(mb,[2,221]),a(mb,[2,222]),a(ta,[2,216]),{7:307,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,
|
||||
137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:308,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,
|
||||
154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:309,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,
|
||||
160:J,161:ca,162:R},a(nb,Ea,{69:310,70:Tb}),a(Ba,[2,111]),a(Ba,[2,51],{58:[1,312]}),a(Ub,[2,60],{55:[1,313]}),a(Ba,[2,56]),a(Ub,[2,61]),a(yb,[2,57]),a(yb,[2,58]),a(yb,[2,59]),{46:[1,314],78:118,82:Sa,83:Ga,84:Ta,85:Fa,86:114,87:Oa,90:Pa,109:117,113:La,114:Ia},a(Pb,ua),{6:xa,42:[1,315]},a(va,[2,4]),a(Vb,[2,257],{141:77,132:102,138:103,163:fa,164:ha,165:ia}),a(Vb,[2,258],{141:77,132:102,138:103,163:fa,164:ha,165:ia}),a(cb,[2,259],{141:77,132:102,138:103,163:fa,165:ia}),a(cb,[2,260],{141:77,132:102,
|
||||
138:103,163:fa,165:ia}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,166,167,168,169,170,171,172,173,174],[2,261],{141:77,132:102,138:103,159:ka,160:da,163:fa,164:ha,165:ia}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,167,168,169,170,171,172,173],[2,262],{141:77,132:102,138:103,159:ka,160:da,163:fa,164:ha,165:ia,166:la,174:T}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,168,169,170,171,172,173],[2,263],{141:77,132:102,
|
||||
138:103,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,174:T}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,169,170,171,172,173],[2,264],{141:77,132:102,138:103,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,174:T}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,170,171,172,173],[2,265],{141:77,132:102,138:103,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,174:T}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,
|
||||
139,140,156,171,172,173],[2,266],{141:77,132:102,138:103,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,174:T}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,172,173],[2,267],{141:77,132:102,138:103,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,174:T}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,173],[2,268],{141:77,132:102,138:103,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,
|
||||
171:ea,172:ma,174:T}),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,140,156,167,168,169,170,171,172,173,174],[2,269],{141:77,132:102,138:103,159:ka,160:da,163:fa,164:ha,165:ia,166:la}),a(Za,[2,247],{141:77,132:102,138:103,133:B,135:A,139:C,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(Za,[2,246],{141:77,132:102,138:103,133:B,135:A,139:C,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),
|
||||
a(b,[2,159]),a(b,[2,160]),a(Ja,[2,99]),a(Ja,[2,100]),a(Ja,[2,101]),a(Ja,[2,102]),{89:[1,316]},{73:Nb,89:[2,107],121:317,122:vb,132:102,133:B,135:A,138:103,139:C,141:77,156:qa,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T},{89:[2,108]},{7:318,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,
|
||||
60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,89:[2,180],92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a(Wb,[2,174]),a(Wb,Xb),a(Ja,[2,106]),a(b,[2,161]),a(va,[2,64],{141:77,132:102,138:103,133:db,135:db,139:db,156:db,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(Ka,[2,29],{141:77,132:102,
|
||||
138:103,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(Ka,[2,48],{141:77,132:102,138:103,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),{7:319,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,
|
||||
75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:320,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,
|
||||
92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{66:321,67:L,68:z},a(Ra,fb,{72:127,33:129,60:130,74:131,75:132,71:322,34:f,73:pa,92:I,118:e,119:d}),{6:Yb,31:Zb},a(Ua,[2,79]),{7:325,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,
|
||||
51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a(Qa,Qb,{141:77,132:102,138:103,73:[1,326],133:B,135:A,139:C,156:qa,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a($b,[2,30]),{6:xa,32:[1,327]},a(Ka,[2,270],{141:77,132:102,
|
||||
138:103,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),{7:328,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,
|
||||
138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:329,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,
|
||||
155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a(Ka,[2,273],{141:77,132:102,138:103,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(ta,[2,245]),{7:330,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,
|
||||
105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a(ta,[2,192],{127:[1,331]}),{30:332,31:wa},{30:335,31:wa,33:333,34:f,75:334,92:I},{150:336,152:268,153:ib},{32:[1,337],151:[1,338],152:339,153:ib},a(ob,[2,238]),{7:341,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,
|
||||
47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,124:340,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a(ac,[2,117],{141:77,132:102,138:103,30:342,31:wa,133:B,135:A,139:C,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(ta,[2,120]),{7:343,8:122,10:20,
|
||||
11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{39:344,40:m,41:H},{92:[1,346],99:345,104:Hb},{39:347,
|
||||
40:m,41:H},{29:[1,348]},a(nb,Ea,{69:349,70:pb}),a(Ba,[2,130]),{31:jb,33:280,34:f,100:351,101:278,103:Ya},a(Ba,[2,135],{102:[1,352]}),a(Ba,[2,137],{102:[1,353]}),{33:354,34:f},a(za,[2,141]),a(nb,Ea,{69:355,70:zb}),a(Ba,[2,150]),{31:wb,33:287,34:f,103:eb,106:357,108:285},a(Ba,[2,155],{102:[1,358]}),a(Ba,[2,158]),{6:[1,360],7:359,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,31:[1,361],33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,
|
||||
45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a(Ab,[2,147],{141:77,132:102,138:103,133:B,135:A,139:C,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),{39:362,40:m,41:H},a(Aa,[2,199]),{6:xa,32:[1,363]},
|
||||
{7:364,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a([12,28,34,38,40,41,44,45,48,
|
||||
49,50,51,52,53,61,62,63,67,68,92,95,97,105,112,117,118,119,125,129,130,133,135,137,139,149,155,157,158,159,160,161,162],Xb,{6:gb,31:gb,70:gb,120:gb}),{6:qb,31:rb,120:[1,365]},a([6,31,32,115,120],fb,{15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,10:20,11:21,13:23,14:24,54:26,47:27,79:28,80:29,81:30,111:31,66:33,77:40,154:41,132:43,136:44,138:45,74:53,75:54,37:55,43:57,33:70,60:71,141:77,39:80,8:122,76:179,7:254,123:368,12:c,28:ga,34:f,38:p,40:m,41:H,44:F,45:x,48:y,49:v,
|
||||
50:E,51:N,52:l,53:h,61:u,62:w,63:G,67:L,68:z,73:Va,92:I,95:k,97:M,105:P,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,133:B,135:A,137:X,139:C,149:O,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R}),a(Ra,Ea,{69:369,70:kb}),a(b,[2,167]),a([6,31,115],Ea,{69:370,70:kb}),a(bc,[2,242]),{7:371,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,
|
||||
62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:372,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,
|
||||
75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:373,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,
|
||||
92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a(lb,[2,218]),{33:194,34:f,60:195,74:196,75:197,92:I,118:e,119:d,145:374},a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,135,139,156],[2,225],{141:77,132:102,138:103,134:[1,375],140:[1,376],159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(Bb,[2,226],{141:77,132:102,
|
||||
138:103,134:[1,377],159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(Bb,[2,232],{141:77,132:102,138:103,134:[1,378],159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),{6:cc,31:dc,94:[1,379]},a(Cb,fb,{39:80,57:204,59:205,11:206,37:207,33:208,35:209,60:210,56:382,34:f,36:Na,38:p,40:m,41:H,62:w,118:e}),{7:383,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,
|
||||
26:18,27:19,28:ga,31:[1,384],33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:385,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,
|
||||
31:[1,386],33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a(Aa,[2,39]),a(Lb,[2,37]),a(Ja,[2,105]),{7:387,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,
|
||||
26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,89:[2,178],92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{89:[2,179],132:102,133:B,135:A,138:103,139:C,141:77,156:qa,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,
|
||||
170:ra,171:ea,172:ma,173:sa,174:T},a(Ka,[2,49],{141:77,132:102,138:103,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),{32:[1,388],132:102,133:B,135:A,138:103,139:C,141:77,156:qa,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T},{30:389,31:wa},a(Ua,[2,75]),{33:129,34:f,60:130,71:390,72:127,73:pa,74:131,75:132,92:I,118:e,119:d},a(ec,q,{71:126,72:127,33:129,60:130,74:131,75:132,64:391,34:f,73:pa,92:I,118:e,
|
||||
119:d}),a(Ua,[2,80],{141:77,132:102,138:103,133:B,135:A,139:C,156:qa,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(Qa,gb),a($b,[2,31]),{32:[1,392],132:102,133:B,135:A,138:103,139:C,141:77,156:qa,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T},a(Ka,[2,272],{141:77,132:102,138:103,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),{30:393,31:wa,132:102,
|
||||
133:B,135:A,138:103,139:C,141:77,156:qa,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T},{30:394,31:wa},a(ta,[2,193]),{30:395,31:wa},{30:396,31:wa},a(Db,[2,197]),{32:[1,397],151:[1,398],152:339,153:ib},a(ta,[2,236]),{30:399,31:wa},a(ob,[2,239]),{30:400,31:wa,70:[1,401]},a(fc,[2,189],{141:77,132:102,138:103,133:B,135:A,139:C,156:qa,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(ta,[2,118]),a(ac,[2,
|
||||
121],{141:77,132:102,138:103,30:402,31:wa,133:B,135:A,139:C,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(za,[2,124]),{29:[1,403]},{31:jb,33:280,34:f,100:404,101:278,103:Ya},a(za,[2,125]),{39:405,40:m,41:H},{6:sb,31:tb,94:[1,406]},a(Cb,fb,{33:280,101:409,34:f,103:Ya}),a(Ra,Ea,{69:410,70:pb}),{33:411,34:f},{33:412,34:f},{29:[2,140]},{6:Eb,31:Fb,94:[1,413]},a(Cb,fb,{33:287,108:416,34:f,103:eb}),a(Ra,Ea,{69:417,70:zb}),{33:418,34:f,103:[1,419]},a(Ab,
|
||||
[2,144],{141:77,132:102,138:103,133:B,135:A,139:C,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),{7:420,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,
|
||||
130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:421,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,
|
||||
137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a(za,[2,148]),{131:[1,422]},{120:[1,423],132:102,133:B,135:A,138:103,139:C,141:77,156:qa,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T},a(xb,[2,173]),{7:254,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,
|
||||
60:71,61:u,62:w,63:G,66:33,67:L,68:z,73:Va,74:53,75:54,76:179,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,123:424,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:254,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,31:bb,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,
|
||||
61:u,62:w,63:G,66:33,67:L,68:z,73:Va,74:53,75:54,76:179,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,116:425,117:r,118:V,119:U,123:177,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a(Qa,[2,182]),{6:qb,31:rb,32:[1,426]},{6:qb,31:rb,115:[1,427]},a(Za,[2,202],{141:77,132:102,138:103,133:B,135:A,139:C,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(Za,[2,
|
||||
204],{141:77,132:102,138:103,133:B,135:A,139:C,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(Za,[2,215],{141:77,132:102,138:103,133:B,135:A,139:C,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(lb,[2,224]),{7:428,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,
|
||||
50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:429,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,
|
||||
61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:430,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,
|
||||
74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:431,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,
|
||||
81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a(xb,[2,109]),{11:206,33:208,34:f,35:209,36:Na,37:207,38:p,39:80,40:m,41:H,56:432,57:204,59:205,60:210,62:w,118:e},a(ec,Jb,{39:80,56:203,57:204,59:205,11:206,37:207,33:208,35:209,60:210,93:433,34:f,36:Na,38:p,40:m,41:H,62:w,118:e}),a(Ba,[2,112]),a(Ba,[2,52],{141:77,132:102,138:103,133:B,135:A,139:C,156:qa,159:ka,
|
||||
160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),{7:434,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,
|
||||
149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},a(Ba,[2,54],{141:77,132:102,138:103,133:B,135:A,139:C,156:qa,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),{7:435,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,
|
||||
81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{89:[2,177],132:102,133:B,135:A,138:103,139:C,141:77,156:qa,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T},a(ta,[2,50]),a(ta,[2,67]),a(Ua,[2,76]),a(Ra,Ea,{69:436,70:Ob}),a(ta,[2,271]),a(bc,[2,243]),a(ta,[2,194]),a(Db,[2,195]),a(Db,[2,196]),a(ta,[2,234]),{30:437,31:wa},
|
||||
{32:[1,438]},a(ob,[2,240],{6:[1,439]}),{7:440,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,
|
||||
162:R},a(ta,[2,122]),{39:441,40:m,41:H},a(nb,Ea,{69:442,70:pb}),a(za,[2,126]),{29:[1,443]},{33:280,34:f,101:444,103:Ya},{31:jb,33:280,34:f,100:445,101:278,103:Ya},a(Ba,[2,131]),{6:sb,31:tb,32:[1,446]},a(Ba,[2,136]),a(Ba,[2,138]),a(za,[2,142],{29:[1,447]}),{33:287,34:f,103:eb,108:448},{31:wb,33:287,34:f,103:eb,106:449,108:285},a(Ba,[2,151]),{6:Eb,31:Fb,32:[1,450]},a(Ba,[2,156]),a(Ba,[2,157]),a(Ab,[2,145],{141:77,132:102,138:103,133:B,135:A,139:C,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,
|
||||
169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),{32:[1,451],132:102,133:B,135:A,138:103,139:C,141:77,156:qa,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T},a(Aa,[2,200]),a(Aa,[2,176]),a(Qa,[2,183]),a(Ra,Ea,{69:452,70:kb}),a(Qa,[2,184]),a(b,[2,168]),a([1,6,31,32,42,65,70,73,89,94,115,120,122,131,133,134,135,139,156],[2,227],{141:77,132:102,138:103,140:[1,453],159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),
|
||||
a(Bb,[2,229],{141:77,132:102,138:103,134:[1,454],159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(Ka,[2,228],{141:77,132:102,138:103,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(Ka,[2,233],{141:77,132:102,138:103,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(Ba,[2,113]),a(Ra,Ea,{69:455,70:Tb}),{32:[1,456],132:102,133:B,135:A,138:103,139:C,
|
||||
141:77,156:qa,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T},{32:[1,457],132:102,133:B,135:A,138:103,139:C,141:77,156:qa,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T},{6:Yb,31:Zb,32:[1,458]},{32:[1,459]},a(ta,[2,237]),a(ob,[2,241]),a(fc,[2,190],{141:77,132:102,138:103,133:B,135:A,139:C,156:qa,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(za,[2,
|
||||
128]),{6:sb,31:tb,94:[1,460]},{39:461,40:m,41:H},a(Ba,[2,132]),a(Ra,Ea,{69:462,70:pb}),a(Ba,[2,133]),{39:463,40:m,41:H},a(Ba,[2,152]),a(Ra,Ea,{69:464,70:zb}),a(Ba,[2,153]),a(za,[2,146]),{6:qb,31:rb,32:[1,465]},{7:466,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,
|
||||
92:I,95:k,97:M,105:P,111:31,112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{7:467,8:122,10:20,11:21,12:c,13:23,14:24,15:7,16:8,17:9,18:10,19:11,20:12,21:13,22:14,23:15,24:16,25:17,26:18,27:19,28:ga,33:70,34:f,37:55,38:p,39:80,40:m,41:H,43:57,44:F,45:x,47:27,48:y,49:v,50:E,51:N,52:l,53:h,54:26,60:71,61:u,62:w,63:G,66:33,67:L,68:z,74:53,75:54,77:40,79:28,80:29,81:30,92:I,95:k,97:M,105:P,111:31,
|
||||
112:n,117:r,118:V,119:U,125:Q,129:ba,130:S,132:43,133:B,135:A,136:44,137:X,138:45,139:C,141:77,149:O,154:41,155:Y,157:Z,158:W,159:aa,160:J,161:ca,162:R},{6:cc,31:dc,32:[1,468]},a(Ba,[2,53]),a(Ba,[2,55]),a(Ua,[2,77]),a(ta,[2,235]),{29:[1,469]},a(za,[2,127]),{6:sb,31:tb,32:[1,470]},a(za,[2,149]),{6:Eb,31:Fb,32:[1,471]},a(Qa,[2,185]),a(Ka,[2,230],{141:77,132:102,138:103,159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(Ka,[2,231],{141:77,132:102,138:103,
|
||||
159:ka,160:da,163:fa,164:ha,165:ia,166:la,167:oa,168:K,169:ja,170:ra,171:ea,172:ma,173:sa,174:T}),a(Ba,[2,114]),{39:472,40:m,41:H},a(Ba,[2,134]),a(Ba,[2,154]),a(za,[2,129])],defaultActions:{68:[2,69],69:[2,70],238:[2,108],354:[2,140]},parseError:function(a,b){if(b.recoverable)this.trace(a);else{var d=function(a,b){this.message=a;this.hash=b};d.prototype=Error;throw new d(a,b);}},parse:function(a){var b=[0],d=[null],e=[],q=this.table,pa="",c=0,f=0,g=0,h=e.slice.call(arguments,1),wa=Object.create(this.lexer),
|
||||
Ma={},k;for(k in this.yy)Object.prototype.hasOwnProperty.call(this.yy,k)&&(Ma[k]=this.yy[k]);wa.setInput(a,Ma);Ma.lexer=wa;Ma.parser=this;"undefined"==typeof wa.yylloc&&(wa.yylloc={});k=wa.yylloc;e.push(k);var n=wa.options&&wa.options.ranges;this.parseError="function"===typeof Ma.parseError?Ma.parseError:Object.getPrototypeOf(this).parseError;for(var l,Xa,m,u,D={},r,ua;;){m=b[b.length-1];if(this.defaultActions[m])u=this.defaultActions[m];else{if(null===l||"undefined"==typeof l)l=wa.lex()||1,"number"!==
|
||||
typeof l&&(l=this.symbols_[l]||l);u=q[m]&&q[m][l]}if("undefined"===typeof u||!u.length||!u[0]){var w;ua=[];for(r in q[m])this.terminals_[r]&&2<r&&ua.push("'"+this.terminals_[r]+"'");w=wa.showPosition?"Parse error on line "+(c+1)+":\n"+wa.showPosition()+"\nExpecting "+ua.join(", ")+", got '"+(this.terminals_[l]||l)+"'":"Parse error on line "+(c+1)+": Unexpected "+(1==l?"end of input":"'"+(this.terminals_[l]||l)+"'");this.parseError(w,{text:wa.match,token:this.terminals_[l]||l,line:wa.yylineno,loc:k,
|
||||
expected:ua})}if(u[0]instanceof Array&&1<u.length)throw Error("Parse Error: multiple actions possible at state: "+m+", token: "+l);switch(u[0]){case 1:b.push(l);d.push(wa.yytext);e.push(wa.yylloc);b.push(u[1]);l=null;Xa?(l=Xa,Xa=null):(f=wa.yyleng,pa=wa.yytext,c=wa.yylineno,k=wa.yylloc,0<g&&g--);break;case 2:ua=this.productions_[u[1]][1];D.$=d[d.length-ua];D._$={first_line:e[e.length-(ua||1)].first_line,last_line:e[e.length-1].last_line,first_column:e[e.length-(ua||1)].first_column,last_column:e[e.length-
|
||||
1].last_column};n&&(D._$.range=[e[e.length-(ua||1)].range[0],e[e.length-1].range[1]]);m=this.performAction.apply(D,[pa,f,c,Ma,u[1],d,e].concat(h));if("undefined"!==typeof m)return m;ua&&(b=b.slice(0,-2*ua),d=d.slice(0,-1*ua),e=e.slice(0,-1*ua));b.push(this.productions_[u[1]][0]);d.push(D.$);e.push(D._$);u=q[b[b.length-2]][b[b.length-1]];b.push(u);break;case 3:return!0}}}};g.prototype=gc;gc.Parser=g;return new g}();"undefined"!==typeof t&&"undefined"!==typeof g&&(g.parser=xa,g.Parser=xa.Parser,g.parse=
|
||||
function(){return xa.parse.apply(xa,arguments)},g.main=function(D){D[1]||(console.log("Usage: "+D[0]+" FILE"),process.exit(1));D=t("fs").readFileSync(t("path").normalize(D[1]),"utf8");return g.parser.parse(D)},"undefined"!==typeof va&&t.main===va&&g.main(process.argv.slice(1)));return va.exports}();t["./scope"]=function(){var g={};(function(){var t=[].indexOf||function(g){for(var D=0,a=this.length;D<a;D++)if(D in this&&this[D]===g)return D;return-1};g.Scope=function(){function g(g,a,c,t){var f,D;
|
||||
this.parent=g;this.expressions=a;this.method=c;this.referencedVars=t;this.variables=[{name:"arguments",type:"arguments"}];this.positions={};this.parent||(this.utilities={});this.root=null!=(f=null!=(D=this.parent)?D.root:void 0)?f:this}g.prototype.add=function(g,a,c){return this.shared&&!c?this.parent.add(g,a,c):Object.prototype.hasOwnProperty.call(this.positions,g)?this.variables[this.positions[g]].type=a:this.positions[g]=this.variables.push({name:g,type:a})-1};g.prototype.namedMethod=function(){var g;
|
||||
return null!=(g=this.method)&&g.name||!this.parent?this.method:this.parent.namedMethod()};g.prototype.find=function(g){if(this.check(g))return!0;this.add(g,"var");return!1};g.prototype.parameter=function(g){if(!this.shared||!this.parent.check(g,!0))return this.add(g,"param")};g.prototype.check=function(g){var a;return!!(this.type(g)||null!=(a=this.parent)&&a.check(g))};g.prototype.temporary=function(g,a,c){null==c&&(c=!1);return c?(c=g.charCodeAt(0),g=122-c,c=String.fromCharCode(c+a%(g+1)),a=Math.floor(a/
|
||||
(g+1)),""+c+(a||"")):""+g+(a||"")};g.prototype.type=function(g){var a,c,D,f;D=this.variables;a=0;for(c=D.length;a<c;a++)if(f=D[a],f.name===g)return f.type;return null};g.prototype.freeVariable=function(g,a){var c,D,f;null==a&&(a={});for(c=0;;){f=this.temporary(g,c,a.single);if(!(this.check(f)||0<=t.call(this.root.referencedVars,f)))break;c++}(null!=(D=a.reserve)?D:1)&&this.add(f,"var",!0);return f};g.prototype.assign=function(g,a){this.add(g,{value:a,assigned:!0},!0);return this.hasAssignments=!0};
|
||||
g.prototype.hasDeclarations=function(){return!!this.declaredVariables().length};g.prototype.declaredVariables=function(){var g,a,c,t,f;t=this.variables;f=[];a=0;for(c=t.length;a<c;a++)g=t[a],"var"===g.type&&f.push(g.name);return f.sort()};g.prototype.assignedVariables=function(){var g,a,c,t,f;c=this.variables;t=[];g=0;for(a=c.length;g<a;g++)f=c[g],f.type.assigned&&t.push(f.name+" \x3d "+f.type.value);return t};return g}()}).call(this);return g}();t["./nodes"]=function(){var g={};(function(){var va,
|
||||
qa,D,a,c,Ca,f,p,m,H,F,x,y,v,E,N,l,h,u,w,G,L,z,I,k,M,P,n,r,V,U,Q,ba,S,B,A,X,C,O,Y,Z,W,aa,J,ca,R,ya,$a,Wa,ka,da,fa,ha,ia,la,oa,K,ja,ra,ea,ma,sa,T,Da,ta,Ia,Sa,Ga,Ta,Fa,Oa,Pa,La,za,na=function(a,b){function q(){this.constructor=a}for(var pa in b)ga.call(b,pa)&&(a[pa]=b[pa]);q.prototype=b.prototype;a.prototype=new q;a.__super__=b.prototype;return a},ga={}.hasOwnProperty,Ha=[].indexOf||function(a){for(var b=0,q=this.length;b<q;b++)if(b in this&&this[b]===a)return b;return-1},Aa=[].slice;Error.stackTraceLimit=
|
||||
Infinity;J=t("./scope").Scope;a=t("./lexer");Ga=a.isUnassignable;L=a.JS_FORBIDDEN;v=t("./helpers");ea=v.compact;T=v.flatten;sa=v.extend;Fa=v.merge;ma=v.del;a=v.addLocationDataFn;Ta=v.locationDataToString;Pa=v.throwSyntaxError;g.extend=sa;g.addLocationDataFn=a;ja=function(){return!0};Q=function(){return!1};fa=function(){return this};U=function(){this.negated=!this.negated;return this};g.CodeFragment=H=function(){function a(a,q){var b;this.code=""+q;this.locationData=null!=a?a.locationData:void 0;this.type=
|
||||
(null!=a?null!=(b=a.constructor)?b.name:void 0:void 0)||"unknown"}a.prototype.toString=function(){return""+this.code+(this.locationData?": "+Ta(this.locationData):"")};return a}();Da=function(a){var b,q,pa,e;e=[];q=0;for(pa=a.length;q<pa;q++)b=a[q],e.push(b.code);return e.join("")};g.Base=a=function(){function a(){}a.prototype.compile=function(a,q){return Da(this.compileToFragments(a,q))};a.prototype.compileToFragments=function(a,q){a=sa({},a);q&&(a.level=q);q=this.unfoldSoak(a)||this;q.tab=a.indent;
|
||||
return a.level!==n&&q.isStatement(a)?q.compileClosure(a):q.compileNode(a)};a.prototype.compileClosure=function(a){var b,pa,e,d;(e=this.jumps())&&e.error("cannot use a pure statement in an expression");a.sharedScope=!0;e=new m([],c.wrap([this]));b=[];if((pa=this.contains(Ia))||this.contains(Sa))b=[new ha],pa?(pa="apply",b.push(new h("arguments"))):pa="call",e=new K(e,[new va(new O(pa))]);a=(new f(e,b)).compileNode(a);if(e.isGenerator||null!=(d=e.base)&&d.isGenerator)a.unshift(this.makeCode("(yield* ")),
|
||||
a.push(this.makeCode(")"));return a};a.prototype.cache=function(a,q,pa){var b;if(null!=pa?pa(this):this.isComplex())return pa=new h(a.scope.freeVariable("ref")),b=new D(pa,this),q?[b.compileToFragments(a,q),[this.makeCode(pa.value)]]:[b,pa];pa=q?this.compileToFragments(a,q):this;return[pa,pa]};a.prototype.cacheToCodeFragments=function(a){return[Da(a[0]),Da(a[1])]};a.prototype.makeReturn=function(a){var b;b=this.unwrapAll();return a?new f(new r(a+".push"),[b]):new W(b)};a.prototype.contains=function(a){var b;
|
||||
b=void 0;this.traverseChildren(!1,function(q){if(a(q))return b=q,!1});return b};a.prototype.lastNonComment=function(a){var b;for(b=a.length;b--;)if(!(a[b]instanceof F))return a[b];return null};a.prototype.toString=function(a,q){var b;null==a&&(a="");null==q&&(q=this.constructor.name);b="\n"+a+q;this.soak&&(b+="?");this.eachChild(function(e){return b+=e.toString(a+da)});return b};a.prototype.eachChild=function(a){var b,pa,e,d,c,f,g;if(!this.children)return this;f=this.children;pa=0;for(d=f.length;pa<
|
||||
d;pa++)if(b=f[pa],this[b])for(g=T([this[b]]),e=0,c=g.length;e<c;e++)if(b=g[e],!1===a(b))return this;return this};a.prototype.traverseChildren=function(a,q){return this.eachChild(function(b){if(!1!==q(b))return b.traverseChildren(a,q)})};a.prototype.invert=function(){return new A("!",this)};a.prototype.unwrapAll=function(){var a;for(a=this;a!==(a=a.unwrap()););return a};a.prototype.children=[];a.prototype.isStatement=Q;a.prototype.jumps=Q;a.prototype.isComplex=ja;a.prototype.isChainable=Q;a.prototype.isAssignable=
|
||||
Q;a.prototype.isNumber=Q;a.prototype.unwrap=fa;a.prototype.unfoldSoak=Q;a.prototype.assigns=Q;a.prototype.updateLocationDataIfMissing=function(a){if(this.locationData)return this;this.locationData=a;return this.eachChild(function(b){return b.updateLocationDataIfMissing(a)})};a.prototype.error=function(a){return Pa(a,this.locationData)};a.prototype.makeCode=function(a){return new H(this,a)};a.prototype.wrapInBraces=function(a){return[].concat(this.makeCode("("),a,this.makeCode(")"))};a.prototype.joinFragmentArrays=
|
||||
function(a,q){var b,e,d,c,f;b=[];d=c=0;for(f=a.length;c<f;d=++c)e=a[d],d&&b.push(this.makeCode(q)),b=b.concat(e);return b};return a}();g.Block=c=function(a){function b(a){this.expressions=ea(T(a||[]))}na(b,a);b.prototype.children=["expressions"];b.prototype.push=function(a){this.expressions.push(a);return this};b.prototype.pop=function(){return this.expressions.pop()};b.prototype.unshift=function(a){this.expressions.unshift(a);return this};b.prototype.unwrap=function(){return 1===this.expressions.length?
|
||||
this.expressions[0]:this};b.prototype.isEmpty=function(){return!this.expressions.length};b.prototype.isStatement=function(a){var b,e,d,q;q=this.expressions;e=0;for(d=q.length;e<d;e++)if(b=q[e],b.isStatement(a))return!0;return!1};b.prototype.jumps=function(a){var b,e,d,q;q=this.expressions;e=0;for(d=q.length;e<d;e++)if(b=q[e],b=b.jumps(a))return b};b.prototype.makeReturn=function(a){var b,e;for(e=this.expressions.length;e--;)if(b=this.expressions[e],!(b instanceof F)){this.expressions[e]=b.makeReturn(a);
|
||||
b instanceof W&&!b.expression&&this.expressions.splice(e,1);break}return this};b.prototype.compileToFragments=function(a,pa){null==a&&(a={});return a.scope?b.__super__.compileToFragments.call(this,a,pa):this.compileRoot(a)};b.prototype.compileNode=function(a){var q,e,d,c,f,g,h;this.tab=a.indent;h=a.level===n;e=[];g=this.expressions;d=q=0;for(c=g.length;q<c;d=++q)f=g[d],f=f.unwrapAll(),f=f.unfoldSoak(a)||f,f instanceof b?e.push(f.compileNode(a)):h?(f.front=!0,d=f.compileToFragments(a),f.isStatement(a)||
|
||||
(d.unshift(this.makeCode(""+this.tab)),d.push(this.makeCode(";"))),e.push(d)):e.push(f.compileToFragments(a,k));if(h)return this.spaced?[].concat(this.joinFragmentArrays(e,"\n\n"),this.makeCode("\n")):this.joinFragmentArrays(e,"\n");q=e.length?this.joinFragmentArrays(e,", "):[this.makeCode("void 0")];return 1<e.length&&a.level>=k?this.wrapInBraces(q):q};b.prototype.compileRoot=function(a){var b,e,d,q,c;a.indent=a.bare?"":da;a.level=n;this.spaced=!0;a.scope=new J(null,this,null,null!=(d=a.referencedVars)?
|
||||
d:[]);c=a.locals||[];d=0;for(e=c.length;d<e;d++)q=c[d],a.scope.parameter(q);d=[];if(!a.bare){var f;f=this.expressions;e=[];b=q=0;for(c=f.length;q<c;b=++q){b=f[b];if(!(b.unwrap()instanceof F))break;e.push(b)}q=this.expressions.slice(e.length);this.expressions=e;e.length&&(d=this.compileNode(Fa(a,{indent:""})),d.push(this.makeCode("\n")));this.expressions=q}e=this.compileWithDeclarations(a);return a.bare?e:[].concat(d,this.makeCode("(function() {\n"),e,this.makeCode("\n}).call(this);\n"))};b.prototype.compileWithDeclarations=
|
||||
function(a){var b,e,d,q,c,f;d=[];f=this.expressions;q=c=0;for(b=f.length;c<b&&(e=f[q],e=e.unwrap(),e instanceof F||e instanceof r);q=++c);a=Fa(a,{level:n});q&&(e=this.expressions.splice(q,9E9),d=[this.spaced,!1],c=d[0],this.spaced=d[1],c=[this.compileNode(a),c],d=c[0],this.spaced=c[1],this.expressions=e);e=this.compileNode(a);c=a.scope;c.expressions===this&&(b=a.scope.hasDeclarations(),a=c.hasAssignments,b||a?(q&&d.push(this.makeCode("\n")),d.push(this.makeCode(this.tab+"var ")),b&&d.push(this.makeCode(c.declaredVariables().join(", "))),
|
||||
a&&(b&&d.push(this.makeCode(",\n"+(this.tab+da))),d.push(this.makeCode(c.assignedVariables().join(",\n"+(this.tab+da))))),d.push(this.makeCode(";\n"+(this.spaced?"\n":"")))):d.length&&e.length&&d.push(this.makeCode("\n")));return d.concat(e)};b.wrap=function(a){return 1===a.length&&a[0]instanceof b?a[0]:new b(a)};return b}(a);g.Literal=r=function(a){function b(a){this.value=a}na(b,a);b.prototype.isComplex=Q;b.prototype.assigns=function(a){return a===this.value};b.prototype.compileNode=function(a){return[this.makeCode(this.value)]};
|
||||
b.prototype.toString=function(){return" "+(this.isStatement()?b.__super__.toString.apply(this,arguments):this.constructor.name)+": "+this.value};return b}(a);g.NumberLiteral=S=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}na(b,a);return b}(r);g.InfinityLiteral=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}na(b,a);b.prototype.compileNode=function(){return[this.makeCode("2e308")]};return b}(S);g.NaNLiteral=function(a){function b(){b.__super__.constructor.call(this,
|
||||
"NaN")}na(b,a);b.prototype.compileNode=function(a){var b;b=[this.makeCode("0/0")];return a.level>=M?this.wrapInBraces(b):b};return b}(S);g.StringLiteral=$a=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}na(b,a);return b}(r);g.RegexLiteral=Z=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}na(b,a);return b}(r);g.PassthroughLiteral=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}na(b,a);return b}(r);g.IdentifierLiteral=
|
||||
h=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}na(b,a);b.prototype.isAssignable=ja;return b}(r);g.PropertyName=O=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}na(b,a);b.prototype.isAssignable=ja;return b}(r);g.StatementLiteral=ya=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}na(b,a);b.prototype.isStatement=ja;b.prototype.makeReturn=fa;b.prototype.jumps=function(a){if("break"===this.value&&!(null!=a&&a.loop||
|
||||
null!=a&&a.block)||"continue"===this.value&&(null==a||!a.loop))return this};b.prototype.compileNode=function(a){return[this.makeCode(""+this.tab+this.value+";")]};return b}(r);g.ThisLiteral=ha=function(a){function b(){b.__super__.constructor.call(this,"this")}na(b,a);b.prototype.compileNode=function(a){var b;a=null!=(b=a.scope.method)&&b.bound?a.scope.method.context:this.value;return[this.makeCode(a)]};return b}(r);g.UndefinedLiteral=oa=function(a){function b(){b.__super__.constructor.call(this,"undefined")}
|
||||
na(b,a);b.prototype.compileNode=function(a){return[this.makeCode(a.level>=z?"(void 0)":"void 0")]};return b}(r);g.NullLiteral=ba=function(a){function b(){b.__super__.constructor.call(this,"null")}na(b,a);return b}(r);g.BooleanLiteral=Ca=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}na(b,a);return b}(r);g.Return=W=function(a){function b(a){this.expression=a}na(b,a);b.prototype.children=["expression"];b.prototype.isStatement=ja;b.prototype.makeReturn=fa;b.prototype.jumps=
|
||||
fa;b.prototype.compileToFragments=function(a,pa){var e,d;e=null!=(d=this.expression)?d.makeReturn():void 0;return!e||e instanceof b?b.__super__.compileToFragments.call(this,a,pa):e.compileToFragments(a,pa)};b.prototype.compileNode=function(a){var b;b=[];b.push(this.makeCode(this.tab+("return"+(this.expression?" ":""))));this.expression&&(b=b.concat(this.expression.compileToFragments(a,P)));b.push(this.makeCode(";"));return b};return b}(a);g.YieldReturn=ra=function(a){function b(){return b.__super__.constructor.apply(this,
|
||||
arguments)}na(b,a);b.prototype.compileNode=function(a){null==a.scope.parent&&this.error("yield can only occur inside functions");return b.__super__.compileNode.apply(this,arguments)};return b}(W);g.Value=K=function(a){function b(a,pa,e){if(!pa&&a instanceof b)return a;this.base=a;this.properties=pa||[];e&&(this[e]=!0);return this}na(b,a);b.prototype.children=["base","properties"];b.prototype.add=function(a){this.properties=this.properties.concat(a);return this};b.prototype.hasProperties=function(){return!!this.properties.length};
|
||||
b.prototype.bareLiteral=function(a){return!this.properties.length&&this.base instanceof a};b.prototype.isArray=function(){return this.bareLiteral(qa)};b.prototype.isRange=function(){return this.bareLiteral(Y)};b.prototype.isComplex=function(){return this.hasProperties()||this.base.isComplex()};b.prototype.isAssignable=function(){return this.hasProperties()||this.base.isAssignable()};b.prototype.isNumber=function(){return this.bareLiteral(S)};b.prototype.isString=function(){return this.bareLiteral($a)};
|
||||
b.prototype.isRegex=function(){return this.bareLiteral(Z)};b.prototype.isUndefined=function(){return this.bareLiteral(oa)};b.prototype.isNull=function(){return this.bareLiteral(ba)};b.prototype.isBoolean=function(){return this.bareLiteral(Ca)};b.prototype.isAtomic=function(){var a,b,e,d;d=this.properties.concat(this.base);a=0;for(b=d.length;a<b;a++)if(e=d[a],e.soak||e instanceof f)return!1;return!0};b.prototype.isNotCallable=function(){return this.isNumber()||this.isString()||this.isRegex()||this.isArray()||
|
||||
this.isRange()||this.isSplice()||this.isObject()||this.isUndefined()||this.isNull()||this.isBoolean()};b.prototype.isStatement=function(a){return!this.properties.length&&this.base.isStatement(a)};b.prototype.assigns=function(a){return!this.properties.length&&this.base.assigns(a)};b.prototype.jumps=function(a){return!this.properties.length&&this.base.jumps(a)};b.prototype.isObject=function(a){return this.properties.length?!1:this.base instanceof B&&(!a||this.base.generated)};b.prototype.isSplice=function(){var a;
|
||||
a=this.properties;return a[a.length-1]instanceof ca};b.prototype.looksStatic=function(a){var b;return this.base.value===a&&1===this.properties.length&&"prototype"!==(null!=(b=this.properties[0].name)?b.value:void 0)};b.prototype.unwrap=function(){return this.properties.length?this:this.base};b.prototype.cacheReference=function(a){var q,e,d,c;q=this.properties;d=q[q.length-1];if(2>this.properties.length&&!this.base.isComplex()&&(null==d||!d.isComplex()))return[this,this];q=new b(this.base,this.properties.slice(0,
|
||||
-1));q.isComplex()&&(e=new h(a.scope.freeVariable("base")),q=new b(new C(new D(e,q))));if(!d)return[q,e];d.isComplex()&&(c=new h(a.scope.freeVariable("name")),d=new G(new D(c,d.index)),c=new G(c));return[q.add(d),new b(e||q.base,[c||d])]};b.prototype.compileNode=function(a){var b,e,d,q,c;this.base.front=this.front;c=this.properties;b=this.base.compileToFragments(a,c.length?z:null);c.length&&aa.test(Da(b))&&b.push(this.makeCode("."));e=0;for(d=c.length;e<d;e++)q=c[e],b.push.apply(b,q.compileToFragments(a));
|
||||
return b};b.prototype.unfoldSoak=function(a){return null!=this.unfoldedSoak?this.unfoldedSoak:this.unfoldedSoak=function(q){return function(){var e,d,c,pa,f;if(d=q.base.unfoldSoak(a))return(e=d.body.properties).push.apply(e,q.properties),d;f=q.properties;d=e=0;for(c=f.length;e<c;d=++e)if(pa=f[d],pa.soak)return pa.soak=!1,e=new b(q.base,q.properties.slice(0,d)),c=new b(q.base,q.properties.slice(d)),e.isComplex()&&(d=new h(a.scope.freeVariable("ref")),e=new C(new D(d,e)),c.base=d),new u(new x(e),c,
|
||||
{soak:!0});return!1}}(this)()};return b}(a);g.Comment=F=function(a){function b(a){this.comment=a}na(b,a);b.prototype.isStatement=ja;b.prototype.makeReturn=fa;b.prototype.compileNode=function(a,b){var e;e=this.comment.replace(/^(\s*)#(?=\s)/gm,"$1 *");e="/*"+Oa(e,this.tab)+(0<=Ha.call(e,"\n")?"\n"+this.tab:"")+" */";(b||a.level)===n&&(e=a.indent+e);return[this.makeCode("\n"),this.makeCode(e)]};return b}(a);g.Call=f=function(a){function b(a,b,e){this.variable=a;this.args=null!=b?b:[];this.soak=e;this.isNew=
|
||||
!1;this.variable instanceof K&&this.variable.isNotCallable()&&this.variable.error("literal is not a function")}na(b,a);b.prototype.children=["variable","args"];b.prototype.newInstance=function(){var a,c;a=(null!=(c=this.variable)?c.base:void 0)||this.variable;a instanceof b&&!a.isNew?a.newInstance():this.isNew=!0;return this};b.prototype.unfoldSoak=function(a){var q,e,d,c,f;if(this.soak){if(this instanceof ka)q=new r(this.superReference(a)),e=new K(q);else{if(e=La(a,this,"variable"))return e;e=(new K(this.variable)).cacheReference(a);
|
||||
q=e[0];e=e[1]}e=new b(e,this.args);e.isNew=this.isNew;q=new r("typeof "+q.compile(a)+' \x3d\x3d\x3d "function"');return new u(q,new K(e),{soak:!0})}q=this;for(d=[];;)if(q.variable instanceof b)d.push(q),q=q.variable;else{if(!(q.variable instanceof K))break;d.push(q);if(!((q=q.variable.base)instanceof b))break}f=d.reverse();d=0;for(c=f.length;d<c;d++)q=f[d],e&&(q.variable instanceof b?q.variable=e:q.variable.base=e),e=La(a,q,"variable");return e};b.prototype.compileNode=function(a){var b,e,d,q,c,f;
|
||||
null!=(d=this.variable)&&(d.front=this.front);d=R.compileSplattedArray(a,this.args,!0);if(d.length)return this.compileSplat(a,d);d=[];f=this.args;e=q=0;for(c=f.length;q<c;e=++q)b=f[e],e&&d.push(this.makeCode(", ")),d.push.apply(d,b.compileToFragments(a,k));b=[];this instanceof ka?(a=this.superReference(a)+(".call("+this.superThis(a)),d.length&&(a+=", "),b.push(this.makeCode(a))):(this.isNew&&b.push(this.makeCode("new ")),b.push.apply(b,this.variable.compileToFragments(a,z)),b.push(this.makeCode("(")));
|
||||
b.push.apply(b,d);b.push(this.makeCode(")"));return b};b.prototype.compileSplat=function(a,b){var e,d,q,c;if(this instanceof ka)return[].concat(this.makeCode(this.superReference(a)+".apply("+this.superThis(a)+", "),b,this.makeCode(")"));if(this.isNew)return e=this.tab+da,[].concat(this.makeCode("(function(func, args, ctor) {\n"+e+"ctor.prototype \x3d func.prototype;\n"+e+"var child \x3d new ctor, result \x3d func.apply(child, args);\n"+e+"return Object(result) \x3d\x3d\x3d result ? result : child;\n"+
|
||||
this.tab+"})("),this.variable.compileToFragments(a,k),this.makeCode(", "),b,this.makeCode(", function(){})"));e=[];d=new K(this.variable);(q=d.properties.pop())&&d.isComplex()?(c=a.scope.freeVariable("ref"),e=e.concat(this.makeCode("("+c+" \x3d "),d.compileToFragments(a,k),this.makeCode(")"),q.compileToFragments(a))):(d=d.compileToFragments(a,z),aa.test(Da(d))&&(d=this.wrapInBraces(d)),q?(c=Da(d),d.push.apply(d,q.compileToFragments(a))):c="null",e=e.concat(d));return e.concat(this.makeCode(".apply("+
|
||||
c+", "),b,this.makeCode(")"))};return b}(a);g.SuperCall=ka=function(a){function b(a){b.__super__.constructor.call(this,null,null!=a?a:[new R(new h("arguments"))]);this.isBare=null!=a}na(b,a);b.prototype.superReference=function(a){var b,e,d,c,q,f,g;c=a.scope.namedMethod();if(null!=c&&c.klass){d=c.klass;q=c.name;g=c.variable;d.isComplex()&&(e=new h(a.scope.parent.freeVariable("base")),b=new K(new C(new D(e,d))),g.base=b,g.properties.splice(0,d.properties.length));if(q.isComplex()||q instanceof G&&q.index.isAssignable())f=
|
||||
new h(a.scope.parent.freeVariable("name")),q=new G(new D(f,q.index)),g.properties.pop(),g.properties.push(q);b=[new va(new O("__super__"))];c["static"]&&b.push(new va(new O("constructor")));b.push(null!=f?new G(f):q);return(new K(null!=e?e:d,b)).compile(a)}return null!=c&&c.ctor?c.name+".__super__.constructor":this.error("cannot call super outside of an instance method.")};b.prototype.superThis=function(a){return(a=a.scope.method)&&!a.klass&&a.context||"this"};return b}(f);g.RegexWithInterpolations=
|
||||
function(a){function b(a){null==a&&(a=[]);b.__super__.constructor.call(this,new K(new h("RegExp")),a,!1)}na(b,a);return b}(f);g.TaggedTemplateCall=function(a){function b(a,pa,e){pa instanceof $a&&(pa=new Wa(c.wrap([new K(pa)])));b.__super__.constructor.call(this,a,[pa],e)}na(b,a);b.prototype.compileNode=function(a){a.inTaggedTemplateCall=!0;return this.variable.compileToFragments(a,z).concat(this.args[0].compileToFragments(a,k))};return b}(f);g.Extends=N=function(a){function b(a,b){this.child=a;this.parent=
|
||||
b}na(b,a);b.prototype.children=["child","parent"];b.prototype.compileToFragments=function(a){return(new f(new K(new r(za("extend",a))),[this.child,this.parent])).compileToFragments(a)};return b}(a);g.Access=va=function(a){function b(a,b){this.name=a;this.soak="soak"===b}na(b,a);b.prototype.children=["name"];b.prototype.compileToFragments=function(a){var b,e;a=this.name.compileToFragments(a);b=this.name.unwrap();return b instanceof O?(e=b.value,0<=Ha.call(L,e))?[this.makeCode('["')].concat(Aa.call(a),
|
||||
[this.makeCode('"]')]):[this.makeCode(".")].concat(Aa.call(a)):[this.makeCode("[")].concat(Aa.call(a),[this.makeCode("]")])};b.prototype.isComplex=Q;return b}(a);g.Index=G=function(a){function b(a){this.index=a}na(b,a);b.prototype.children=["index"];b.prototype.compileToFragments=function(a){return[].concat(this.makeCode("["),this.index.compileToFragments(a,P),this.makeCode("]"))};b.prototype.isComplex=function(){return this.index.isComplex()};return b}(a);g.Range=Y=function(a){function b(a,b,e){this.from=
|
||||
a;this.to=b;this.equals=(this.exclusive="exclusive"===e)?"":"\x3d"}na(b,a);b.prototype.children=["from","to"];b.prototype.compileVariables=function(a){var b,e;a=Fa(a,{top:!0});b=ma(a,"isComplex");e=this.cacheToCodeFragments(this.from.cache(a,k,b));this.fromC=e[0];this.fromVar=e[1];e=this.cacheToCodeFragments(this.to.cache(a,k,b));this.toC=e[0];this.toVar=e[1];if(e=ma(a,"step"))a=this.cacheToCodeFragments(e.cache(a,k,b)),this.step=a[0],this.stepVar=a[1];this.fromNum=this.from.isNumber()?Number(this.fromVar):
|
||||
null;this.toNum=this.to.isNumber()?Number(this.toVar):null;return this.stepNum=null!=e&&e.isNumber()?Number(this.stepVar):null};b.prototype.compileNode=function(a){var b,e,d,c,q,f,g,h,k,n;this.fromVar||this.compileVariables(a);if(!a.index)return this.compileArray(a);f=null!=this.fromNum&&null!=this.toNum;q=ma(a,"index");g=(a=ma(a,"name"))&&a!==q;n=q+" \x3d "+this.fromC;this.toC!==this.toVar&&(n+=", "+this.toC);this.step!==this.stepVar&&(n+=", "+this.step);c=[q+" \x3c"+this.equals,q+" \x3e"+this.equals];
|
||||
e=c[0];c=c[1];e=null!=this.stepNum?0<this.stepNum?e+" "+this.toVar:c+" "+this.toVar:f?(h=[this.fromNum,this.toNum],d=h[0],k=h[1],h,d<=k?e+" "+k:c+" "+k):(b=this.stepVar?this.stepVar+" \x3e 0":this.fromVar+" \x3c\x3d "+this.toVar,b+" ? "+e+" "+this.toVar+" : "+c+" "+this.toVar);b=this.stepVar?q+" +\x3d "+this.stepVar:f?g?d<=k?"++"+q:"--"+q:d<=k?q+"++":q+"--":g?b+" ? ++"+q+" : --"+q:b+" ? "+q+"++ : "+q+"--";g&&(n=a+" \x3d "+n);g&&(b=a+" \x3d "+b);return[this.makeCode(n+"; "+e+"; "+b)]};b.prototype.compileArray=
|
||||
function(a){var b,e,d,c,q,f,g,h,k;if((e=null!=this.fromNum&&null!=this.toNum)&&20>=Math.abs(this.fromNum-this.toNum))return b=function(){h=[];for(var a=f=this.fromNum,b=this.toNum;f<=b?a<=b:a>=b;f<=b?a++:a--)h.push(a);return h}.apply(this),this.exclusive&&b.pop(),[this.makeCode("["+b.join(", ")+"]")];c=this.tab+da;d=a.scope.freeVariable("i",{single:!0});g=a.scope.freeVariable("results");q="\n"+c+g+" \x3d [];";e?(a.index=d,e=Da(this.compileNode(a))):(k=d+" \x3d "+this.fromC+(this.toC!==this.toVar?
|
||||
", "+this.toC:""),e=this.fromVar+" \x3c\x3d "+this.toVar,e="var "+k+"; "+e+" ? "+d+" \x3c"+this.equals+" "+this.toVar+" : "+d+" \x3e"+this.equals+" "+this.toVar+"; "+e+" ? "+d+"++ : "+d+"--");d="{ "+g+".push("+d+"); }\n"+c+"return "+g+";\n"+a.indent;a=function(a){return null!=a?a.contains(Ia):void 0};if(a(this.from)||a(this.to))b=", arguments";return[this.makeCode("(function() {"+q+"\n"+c+"for ("+e+")"+d+"}).apply(this"+(null!=b?b:"")+")")]};return b}(a);g.Slice=ca=function(a){function b(a){this.range=
|
||||
a;b.__super__.constructor.call(this)}na(b,a);b.prototype.children=["range"];b.prototype.compileNode=function(a){var b,e,d,c,q;b=this.range;c=b.to;d=(b=b.from)&&b.compileToFragments(a,P)||[this.makeCode("0")];c&&(b=c.compileToFragments(a,P),e=Da(b),this.range.exclusive||-1!==+e)&&(q=", "+(this.range.exclusive?e:c.isNumber()?""+(+e+1):(b=c.compileToFragments(a,z),"+"+Da(b)+" + 1 || 9e9")));return[this.makeCode(".slice("+Da(d)+(q||"")+")")]};return b}(a);g.Obj=B=function(a){function b(a,b){this.generated=
|
||||
null!=b?b:!1;this.objects=this.properties=a||[]}na(b,a);b.prototype.children=["properties"];b.prototype.compileNode=function(a){var b,e,d,c,q,f,g,k,l,u,m,r,w;w=this.properties;if(this.generated)for(e=0,b=w.length;e<b;e++)d=w[e],d instanceof K&&d.error("cannot have an implicit value in an implicit object");e=b=0;for(d=w.length;b<d&&!(r=w[e],(r.variable||r).base instanceof C);e=++b);d=e<w.length;q=a.indent+=da;l=this.lastNonComment(this.properties);b=[];d&&(m=a.scope.freeVariable("obj"),b.push(this.makeCode("(\n"+
|
||||
q+m+" \x3d ")));b.push(this.makeCode("{"+(0===w.length||0===e?"}":"\n")));c=k=0;for(u=w.length;k<u;c=++k)r=w[c],c===e&&(0!==c&&b.push(this.makeCode("\n"+q+"}")),b.push(this.makeCode(",\n"))),g=c===w.length-1||c===e-1?"":r===l||r instanceof F?"\n":",\n",f=r instanceof F?"":q,d&&c<e&&(f+=da),r instanceof D&&("object"!==r.context&&r.operatorToken.error("unexpected "+r.operatorToken.value),r.variable instanceof K&&r.variable.hasProperties()&&r.variable.error("invalid object key")),r instanceof K&&r["this"]&&
|
||||
(r=new D(r.properties[0].name,r,"object")),r instanceof F||(c<e?r instanceof D||(r=new D(r,r,"object")):(r instanceof D?(c=r.variable,r=r.value):(r=r.base.cache(a),c=r[0],r=r[1],c instanceof h&&(c=new O(c.value))),r=new D(new K(new h(m),[new va(c)]),r))),f&&b.push(this.makeCode(f)),b.push.apply(b,r.compileToFragments(a,n)),g&&b.push(this.makeCode(g));d?b.push(this.makeCode(",\n"+q+m+"\n"+this.tab+")")):0!==w.length&&b.push(this.makeCode("\n"+this.tab+"}"));return this.front&&!d?this.wrapInBraces(b):
|
||||
b};b.prototype.assigns=function(a){var b,e,d,c;c=this.properties;b=0;for(e=c.length;b<e;b++)if(d=c[b],d.assigns(a))return!0;return!1};return b}(a);g.Arr=qa=function(a){function b(a){this.objects=a||[]}na(b,a);b.prototype.children=["objects"];b.prototype.compileNode=function(a){var b,e,d,c,q;if(!this.objects.length)return[this.makeCode("[]")];a.indent+=da;b=R.compileSplattedArray(a,this.objects);if(b.length)return b;b=[];var f;q=this.objects;f=[];d=0;for(c=q.length;d<c;d++)e=q[d],f.push(e.compileToFragments(a,
|
||||
k));d=c=0;for(q=f.length;c<q;d=++c)e=f[d],d&&b.push(this.makeCode(", ")),b.push.apply(b,e);0<=Da(b).indexOf("\n")?(b.unshift(this.makeCode("[\n"+a.indent)),b.push(this.makeCode("\n"+this.tab+"]"))):(b.unshift(this.makeCode("[")),b.push(this.makeCode("]")));return b};b.prototype.assigns=function(a){var b,e,d,c;c=this.objects;b=0;for(e=c.length;b<e;b++)if(d=c[b],d.assigns(a))return!0;return!1};return b}(a);g.Class=p=function(a){function b(a,b,e){this.variable=a;this.parent=b;this.body=null!=e?e:new c;
|
||||
this.boundFuncs=[];this.body.classBody=!0}na(b,a);b.prototype.children=["variable","parent","body"];b.prototype.defaultClassVariableName="_Class";b.prototype.determineName=function(){var a,b;if(!this.variable)return this.defaultClassVariableName;b=this.variable.properties;b=(a=b[b.length-1])?a instanceof va&&a.name:this.variable.base;if(!(b instanceof h||b instanceof O))return this.defaultClassVariableName;b=b.value;a||(a=Ga(b))&&this.variable.error(a);return 0<=Ha.call(L,b)?"_"+b:b};b.prototype.setContext=
|
||||
function(a){return this.body.traverseChildren(!1,function(b){if(b.classBody)return!1;if(b instanceof ha)return b.value=a;if(b instanceof m&&b.bound)return b.context=a})};b.prototype.addBoundFunctions=function(a){var b,e,d,c;c=this.boundFuncs;e=0;for(d=c.length;e<d;e++)b=c[e],b=(new K(new ha,[new va(b)])).compile(a),this.ctor.body.unshift(new r(b+" \x3d "+za("bind",a)+"("+b+", this)"))};b.prototype.addProperties=function(a,b,e){var d,c,f,q;q=a.base.properties.slice(0);var g;for(g=[];d=q.shift();)d instanceof
|
||||
D&&(c=d.variable.base,delete d.context,f=d.value,"constructor"===c.value?(this.ctor&&d.error("cannot define more than one constructor in a class"),f.bound&&d.error("cannot define a constructor as a bound function"),f instanceof m?d=this.ctor=f:(this.externalCtor=e.classScope.freeVariable("ctor"),d=new D(new h(this.externalCtor),f))):d.variable["this"]?f["static"]=!0:(a=c.isComplex()?new G(c):new va(c),d.variable=new K(new h(b),[new va(new O("prototype")),a]),f instanceof m&&f.bound&&(this.boundFuncs.push(c),
|
||||
f.bound=!1))),g.push(d);return ea(g)};b.prototype.walkBody=function(a,f){return this.traverseChildren(!1,function(e){return function(d){var q,g,pa,h,k,n,l;q=!0;if(d instanceof b)return!1;if(d instanceof c){l=g=d.expressions;pa=h=0;for(k=l.length;h<k;pa=++h)n=l[pa],n instanceof D&&n.variable.looksStatic(a)?n.value["static"]=!0:n instanceof K&&n.isObject(!0)&&(q=!1,g[pa]=e.addProperties(n,a,f));d.expressions=T(g)}return q&&!(d instanceof b)}}(this))};b.prototype.hoistDirectivePrologue=function(){var a,
|
||||
b,e;b=0;for(a=this.body.expressions;(e=a[b])&&e instanceof F||e instanceof K&&e.isString();)++b;return this.directives=a.splice(0,b)};b.prototype.ensureConstructor=function(a){this.ctor||(this.ctor=new m,this.externalCtor?this.ctor.body.push(new r(this.externalCtor+".apply(this, arguments)")):this.parent&&this.ctor.body.push(new r(a+".__super__.constructor.apply(this, arguments)")),this.ctor.body.makeReturn(),this.body.expressions.unshift(this.ctor));this.ctor.ctor=this.ctor.name=a;this.ctor.klass=
|
||||
null;return this.ctor.noReturn=!0};b.prototype.compileNode=function(a){var b,e,d,q,g;(e=this.body.jumps())&&e.error("Class bodies cannot contain pure statements");(b=this.body.contains(Ia))&&b.error("Class bodies shouldn't reference arguments");g=this.determineName();q=new h(g);e=new m([],c.wrap([this.body]));b=[];a.classScope=e.makeScope(a.scope);this.hoistDirectivePrologue();this.setContext(g);this.walkBody(g,a);this.ensureConstructor(g);this.addBoundFunctions(a);this.body.spaced=!0;this.body.expressions.push(q);
|
||||
this.parent&&(g=new h(a.classScope.freeVariable("superClass",{reserve:!1})),this.body.expressions.unshift(new N(q,g)),e.params.push(new X(g)),b.push(this.parent));(d=this.body.expressions).unshift.apply(d,this.directives);d=new C(new f(e,b));this.variable&&(d=new D(this.variable,d,null,{moduleDeclaration:this.moduleDeclaration}));return d.compileToFragments(a)};return b}(a);g.ModuleDeclaration=v=function(a){function b(a,b){this.clause=a;this.source=b;this.checkSource()}na(b,a);b.prototype.children=
|
||||
["clause","source"];b.prototype.isStatement=ja;b.prototype.jumps=fa;b.prototype.makeReturn=fa;b.prototype.checkSource=function(){if(null!=this.source&&this.source instanceof Wa)return this.source.error("the name of the module to be imported from must be an uninterpolated string")};b.prototype.checkScope=function(a,b){if(0!==a.indent.length)return this.error(b+" statements must be at top-level scope")};return b}(a);g.ImportDeclaration=function(a){function b(){return b.__super__.constructor.apply(this,
|
||||
arguments)}na(b,a);b.prototype.compileNode=function(a){var b,e;this.checkScope(a,"import");a.importedSymbols=[];b=[];b.push(this.makeCode(this.tab+"import "));null!=this.clause&&b.push.apply(b,this.clause.compileNode(a));null!=(null!=(e=this.source)?e.value:void 0)&&(null!==this.clause&&b.push(this.makeCode(" from ")),b.push(this.makeCode(this.source.value)));b.push(this.makeCode(";"));return b};return b}(v);g.ImportClause=function(a){function b(a,b){this.defaultBinding=a;this.namedImports=b}na(b,
|
||||
a);b.prototype.children=["defaultBinding","namedImports"];b.prototype.compileNode=function(a){var b;b=[];null!=this.defaultBinding&&(b.push.apply(b,this.defaultBinding.compileNode(a)),null!=this.namedImports&&b.push(this.makeCode(", ")));null!=this.namedImports&&b.push.apply(b,this.namedImports.compileNode(a));return b};return b}(a);g.ExportDeclaration=v=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}na(b,a);b.prototype.compileNode=function(a){var b,e;this.checkScope(a,
|
||||
"export");b=[];b.push(this.makeCode(this.tab+"export "));this instanceof E&&b.push(this.makeCode("default "));this instanceof E||!(this.clause instanceof D||this.clause instanceof p)||(this.clause instanceof p&&!this.clause.variable&&this.clause.error("anonymous classes cannot be exported"),b.push(this.makeCode("var ")),this.clause.moduleDeclaration="export");b=null!=this.clause.body&&this.clause.body instanceof c?b.concat(this.clause.compileToFragments(a,n)):b.concat(this.clause.compileNode(a));
|
||||
null!=(null!=(e=this.source)?e.value:void 0)&&b.push(this.makeCode(" from "+this.source.value));b.push(this.makeCode(";"));return b};return b}(v);g.ExportNamedDeclaration=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}na(b,a);return b}(v);g.ExportDefaultDeclaration=E=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}na(b,a);return b}(v);g.ExportAllDeclaration=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}na(b,
|
||||
a);return b}(v);g.ModuleSpecifierList=v=function(a){function b(a){this.specifiers=a}na(b,a);b.prototype.children=["specifiers"];b.prototype.compileNode=function(a){var b,e,d,c,f;b=[];a.indent+=da;var q;f=this.specifiers;q=[];d=0;for(c=f.length;d<c;d++)e=f[d],q.push(e.compileToFragments(a,k));if(0!==this.specifiers.length){b.push(this.makeCode("{\n"+a.indent));d=c=0;for(f=q.length;c<f;d=++c)e=q[d],d&&b.push(this.makeCode(",\n"+a.indent)),b.push.apply(b,e);b.push(this.makeCode("\n}"))}else b.push(this.makeCode("{}"));
|
||||
return b};return b}(a);g.ImportSpecifierList=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}na(b,a);return b}(v);g.ExportSpecifierList=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}na(b,a);return b}(v);g.ModuleSpecifier=V=function(a){function b(a,b,e){this.original=a;this.alias=b;this.moduleDeclarationType=e;this.identifier=null!=this.alias?this.alias.value:this.original.value}na(b,a);b.prototype.children=["original","alias"];b.prototype.compileNode=
|
||||
function(a){a.scope.add(this.identifier,this.moduleDeclarationType);a=[];a.push(this.makeCode(this.original.value));null!=this.alias&&a.push(this.makeCode(" as "+this.alias.value));return a};return b}(a);g.ImportSpecifier=v=function(a){function b(a,c){b.__super__.constructor.call(this,a,c,"import")}na(b,a);b.prototype.compileNode=function(a){var c;(c=this.identifier,0<=Ha.call(a.importedSymbols,c))||a.scope.check(this.identifier)?this.error("'"+this.identifier+"' has already been declared"):a.importedSymbols.push(this.identifier);
|
||||
return b.__super__.compileNode.call(this,a)};return b}(V);g.ImportDefaultSpecifier=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}na(b,a);return b}(v);g.ImportNamespaceSpecifier=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}na(b,a);return b}(v);g.ExportSpecifier=function(a){function b(a,c){b.__super__.constructor.call(this,a,c,"export")}na(b,a);return b}(V);g.Assign=D=function(a){function b(a,b,e,d){this.variable=a;this.value=b;this.context=
|
||||
e;null==d&&(d={});this.param=d.param;this.subpattern=d.subpattern;this.operatorToken=d.operatorToken;this.moduleDeclaration=d.moduleDeclaration}na(b,a);b.prototype.children=["variable","value"];b.prototype.isStatement=function(a){return(null!=a?a.level:void 0)===n&&null!=this.context&&(this.moduleDeclaration||0<=Ha.call(this.context,"?"))};b.prototype.checkAssignability=function(a,b){if(Object.prototype.hasOwnProperty.call(a.scope.positions,b.value)&&"import"===a.scope.variables[a.scope.positions[b.value]].type)return b.error("'"+
|
||||
b.value+"' is read-only")};b.prototype.assigns=function(a){return this["object"===this.context?"value":"variable"].assigns(a)};b.prototype.unfoldSoak=function(a){return La(a,this,"variable")};b.prototype.compileNode=function(a){var b,e,d,c,f,g,q;if(e=this.variable instanceof K){if(this.variable.isArray()||this.variable.isObject())return this.compilePatternMatch(a);if(this.variable.isSplice())return this.compileSplice(a);if("||\x3d"===(c=this.context)||"\x26\x26\x3d"===c||"?\x3d"===c)return this.compileConditional(a);
|
||||
if("**\x3d"===(f=this.context)||"//\x3d"===f||"%%\x3d"===f)return this.compileSpecialMath(a)}this.value instanceof m&&(this.value["static"]?(this.value.klass=this.variable.base,this.value.name=this.variable.properties[0],this.value.variable=this.variable):2<=(null!=(g=this.variable.properties)?g.length:void 0)&&(g=this.variable.properties,c=3<=g.length?Aa.call(g,0,d=g.length-2):(d=0,[]),f=g[d++],d=g[d++],"prototype"===(null!=(q=f.name)?q.value:void 0)&&(this.value.klass=new K(this.variable.base,c),
|
||||
this.value.name=d,this.value.variable=this.variable)));this.context||(q=this.variable.unwrapAll(),q.isAssignable()||this.variable.error("'"+this.variable.compile(a)+"' can't be assigned"),"function"===typeof q.hasProperties&&q.hasProperties()||(this.moduleDeclaration?(this.checkAssignability(a,q),a.scope.add(q.value,this.moduleDeclaration)):this.param?a.scope.add(q.value,"var"):(this.checkAssignability(a,q),a.scope.find(q.value))));q=this.value.compileToFragments(a,k);e&&this.variable.base instanceof
|
||||
B&&(this.variable.front=!0);e=this.variable.compileToFragments(a,k);if("object"===this.context){if(b=Da(e),0<=Ha.call(L,b))e.unshift(this.makeCode('"')),e.push(this.makeCode('"'));return e.concat(this.makeCode(": "),q)}b=e.concat(this.makeCode(" "+(this.context||"\x3d")+" "),q);return a.level<=k?b:this.wrapInBraces(b)};b.prototype.compilePatternMatch=function(a){var c,e,d,f,g,q,l,u,m,w,p,z,t,D,v,x;D=a.level===n;u=this.value;z=this.variable.base.objects;if(!(t=z.length))return e=u.compileToFragments(a),
|
||||
a.level>=M?this.wrapInBraces(e):e;p=z[0];1===t&&p instanceof y&&p.error("Destructuring assignment has no target");q=this.variable.isObject();if(D&&1===t&&!(p instanceof R))return d=null,p instanceof b&&"object"===p.context?(e=p,f=e.variable,g=f.base,p=e.value,p instanceof b&&(d=p.value,p=p.variable)):(p instanceof b&&(d=p.value,p=p.variable),g=q?p["this"]?p.properties[0].name:new O(p.unwrap().value):new S(0)),c=g.unwrap()instanceof O,u=new K(u),u.properties.push(new (c?va:G)(g)),(w=Ga(p.unwrap().value))&&
|
||||
p.error(w),d&&(u=new A("?",u,d)),(new b(p,u,null,{param:this.param})).compileToFragments(a,n);v=u.compileToFragments(a,k);x=Da(v);e=[];f=!1;u.unwrap()instanceof h&&!this.variable.assigns(x)||(e.push([this.makeCode((d=a.scope.freeVariable("ref"))+" \x3d ")].concat(Aa.call(v))),v=[this.makeCode(d)],x=d);d=u=0;for(m=z.length;u<m;d=++u){p=z[d];g=d;if(!f&&p instanceof R)w=p.name.unwrap().value,p=p.unwrap(),g=t+" \x3c\x3d "+x+".length ? "+za("slice",a)+".call("+x+", "+d,(c=t-d-1)?(l=a.scope.freeVariable("i",
|
||||
{single:!0}),g+=", "+l+" \x3d "+x+".length - "+c+") : ("+l+" \x3d "+d+", [])"):g+=") : []",g=new r(g),f=l+"++";else if(!f&&p instanceof y){if(c=t-d-1)1===c?f=x+".length - 1":(l=a.scope.freeVariable("i",{single:!0}),g=new r(l+" \x3d "+x+".length - "+c),f=l+"++",e.push(g.compileToFragments(a,k)));continue}else(p instanceof R||p instanceof y)&&p.error("multiple splats/expansions are disallowed in an assignment"),d=null,p instanceof b&&"object"===p.context?(g=p.variable,g=g.base,p=p.value,p instanceof
|
||||
b&&(d=p.value,p=p.variable)):(p instanceof b&&(d=p.value,p=p.variable),g=q?p["this"]?p.properties[0].name:new O(p.unwrap().value):new r(f||g)),w=p.unwrap().value,c=g.unwrap()instanceof O,g=new K(new r(x),[new (c?va:G)(g)]),d&&(g=new A("?",g,d));null!=w&&(w=Ga(w))&&p.error(w);e.push((new b(p,g,null,{param:this.param,subpattern:!0})).compileToFragments(a,k))}D||this.subpattern||e.push(v);e=this.joinFragmentArrays(e,", ");return a.level<k?e:this.wrapInBraces(e)};b.prototype.compileConditional=function(a){var c,
|
||||
e;e=this.variable.cacheReference(a);c=e[0];e=e[1];c.properties.length||!(c.base instanceof r)||c.base instanceof ha||a.scope.check(c.base.value)||this.variable.error('the variable "'+c.base.value+"\" can't be assigned with "+this.context+" because it has not been declared before");if(0<=Ha.call(this.context,"?"))return a.isExistentialEquals=!0,(new u(new x(c),e,{type:"if"})).addElse(new b(e,this.value,"\x3d")).compileToFragments(a);c=(new A(this.context.slice(0,-1),c,new b(e,this.value,"\x3d"))).compileToFragments(a);
|
||||
return a.level<=k?c:this.wrapInBraces(c)};b.prototype.compileSpecialMath=function(a){var c,e;e=this.variable.cacheReference(a);c=e[0];e=e[1];return(new b(c,new A(this.context.slice(0,-1),e,this.value))).compileToFragments(a)};b.prototype.compileSplice=function(a){var b,e,d,c,f,g;c=this.variable.properties.pop().range;d=c.from;b=c.to;e=c.exclusive;g=this.variable.compile(a);d?(f=this.cacheToCodeFragments(d.cache(a,M)),c=f[0],f=f[1]):c=f="0";b?null!=d&&d.isNumber()&&b.isNumber()?(b=b.compile(a)-f,e||
|
||||
(b+=1)):(b=b.compile(a,z)+" - "+f,e||(b+=" + 1")):b="9e9";e=this.value.cache(a,k);d=e[0];e=e[1];b=[].concat(this.makeCode("[].splice.apply("+g+", ["+c+", "+b+"].concat("),d,this.makeCode(")), "),e);return a.level>n?this.wrapInBraces(b):b};return b}(a);g.Code=m=function(a){function b(a,b,e){this.params=a||[];this.body=b||new c;this.bound="boundfunc"===e;this.isGenerator=!!this.body.contains(function(a){return a instanceof A&&a.isYield()||a instanceof ra})}na(b,a);b.prototype.children=["params","body"];
|
||||
b.prototype.isStatement=function(){return!!this.ctor};b.prototype.jumps=Q;b.prototype.makeScope=function(a){return new J(a,this.body,this)};b.prototype.compileNode=function(a){var g,e,d,q,k,n,l,m,p,w,t,x,G;this.bound&&null!=(e=a.scope.method)&&e.bound&&(this.context=a.scope.method.context);if(this.bound&&!this.context)return this.context="_this",e=new b([new X(new h(this.context))],new c([this])),e=new f(e,[new ha]),e.updateLocationDataIfMissing(this.locationData),e.compileNode(a);a.scope=ma(a,"classScope")||
|
||||
this.makeScope(a.scope);a.scope.shared=ma(a,"sharedScope");a.indent+=da;delete a.bare;delete a.isExistentialEquals;e=[];g=[];m=this.params;q=0;for(n=m.length;q<n;q++)l=m[q],l instanceof y||a.scope.parameter(l.asReference(a));m=this.params;q=0;for(n=m.length;q<n;q++)if(l=m[q],l.splat||l instanceof y){q=this.params;k=0;for(l=q.length;k<l;k++)p=q[k],p instanceof y||!p.name.value||a.scope.add(p.name.value,"var",!0);k=new D(new K(new qa(function(){var b,d,e,c;e=this.params;c=[];d=0;for(b=e.length;d<b;d++)p=
|
||||
e[d],c.push(p.asReference(a));return c}.call(this))),new K(new h("arguments")));break}t=this.params;m=0;for(q=t.length;m<q;m++)l=t[m],l.isComplex()?(G=w=l.asReference(a),l.value&&(G=new A("?",w,l.value)),g.push(new D(new K(l.name),G,"\x3d",{param:!0}))):(w=l,l.value&&(n=new r(w.name.value+" \x3d\x3d null"),G=new D(new K(l.name),l.value,"\x3d"),g.push(new u(n,G)))),k||e.push(w);l=this.body.isEmpty();k&&g.unshift(k);g.length&&(d=this.body.expressions).unshift.apply(d,g);d=k=0;for(g=e.length;k<g;d=++k)p=
|
||||
e[d],e[d]=p.compileToFragments(a),a.scope.parameter(Da(e[d]));x=[];this.eachParamName(function(a,b){0<=Ha.call(x,a)&&b.error("multiple parameters named "+a);return x.push(a)});l||this.noReturn||this.body.makeReturn();d="function";this.isGenerator&&(d+="*");this.ctor&&(d+=" "+this.name);g=[this.makeCode(d+"(")];d=l=0;for(k=e.length;l<k;d=++l)p=e[d],d&&g.push(this.makeCode(", ")),g.push.apply(g,p);g.push(this.makeCode(") {"));this.body.isEmpty()||(g=g.concat(this.makeCode("\n"),this.body.compileWithDeclarations(a),
|
||||
this.makeCode("\n"+this.tab)));g.push(this.makeCode("}"));return this.ctor?[this.makeCode(this.tab)].concat(Aa.call(g)):this.front||a.level>=z?this.wrapInBraces(g):g};b.prototype.eachParamName=function(a){var b,e,d,c,f;c=this.params;f=[];b=0;for(e=c.length;b<e;b++)d=c[b],f.push(d.eachName(a));return f};b.prototype.traverseChildren=function(a,c){if(a)return b.__super__.traverseChildren.call(this,a,c)};return b}(a);g.Param=X=function(a){function b(a,b,e){this.name=a;this.value=b;this.splat=e;(a=Ga(this.name.unwrapAll().value))&&
|
||||
this.name.error(a);this.name instanceof B&&this.name.generated&&(a=this.name.objects[0].operatorToken,a.error("unexpected "+a.value))}na(b,a);b.prototype.children=["name","value"];b.prototype.compileToFragments=function(a){return this.name.compileToFragments(a,k)};b.prototype.asReference=function(a){var b;if(this.reference)return this.reference;b=this.name;b["this"]?(b=b.properties[0].name.value,0<=Ha.call(L,b)&&(b="_"+b),b=new h(a.scope.freeVariable(b))):b.isComplex()&&(b=new h(a.scope.freeVariable("arg")));
|
||||
b=new K(b);this.splat&&(b=new R(b));b.updateLocationDataIfMissing(this.locationData);return this.reference=b};b.prototype.isComplex=function(){return this.name.isComplex()};b.prototype.eachName=function(a,b){var e,d,c,f;null==b&&(b=this.name);e=function(b){return a("@"+b.properties[0].name.value,b)};if(b instanceof r)return a(b.value,b);if(b instanceof K)return e(b);b=null!=(d=b.objects)?d:[];d=0;for(c=b.length;d<c;d++)f=b[d],f instanceof D&&null==f.context&&(f=f.variable),f instanceof D?(f.value instanceof
|
||||
D&&(f=f.value),this.eachName(a,f.value.unwrap())):f instanceof R?(f=f.name.unwrap(),a(f.value,f)):f instanceof K?f.isArray()||f.isObject()?this.eachName(a,f.base):f["this"]?e(f):a(f.base.value,f.base):f instanceof y||f.error("illegal parameter "+f.compile())};return b}(a);g.Splat=R=function(a){function b(a){this.name=a.compile?a:new r(a)}na(b,a);b.prototype.children=["name"];b.prototype.isAssignable=ja;b.prototype.assigns=function(a){return this.name.assigns(a)};b.prototype.compileToFragments=function(a){return this.name.compileToFragments(a)};
|
||||
b.prototype.unwrap=function(){return this.name};b.compileSplattedArray=function(a,c,e){var d,f,g,q,h,l;for(q=-1;(d=c[++q])&&!(d instanceof b););if(q>=c.length)return[];if(1===c.length)return d=c[0],c=d.compileToFragments(a,k),e?c:[].concat(d.makeCode(za("slice",a)+".call("),c,d.makeCode(")"));e=c.slice(q);g=h=0;for(l=e.length;h<l;g=++h)d=e[g],f=d.compileToFragments(a,k),e[g]=d instanceof b?[].concat(d.makeCode(za("slice",a)+".call("),f,d.makeCode(")")):[].concat(d.makeCode("["),f,d.makeCode("]"));
|
||||
if(0===q)return d=c[0],a=d.joinFragmentArrays(e.slice(1),", "),e[0].concat(d.makeCode(".concat("),a,d.makeCode(")"));h=c.slice(0,q);l=[];f=0;for(g=h.length;f<g;f++)d=h[f],l.push(d.compileToFragments(a,k));d=c[0].joinFragmentArrays(l,", ");a=c[q].joinFragmentArrays(e,", ");e=c[c.length-1];return[].concat(c[0].makeCode("["),d,c[q].makeCode("].concat("),a,e.makeCode(")"))};return b}(a);g.Expansion=y=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}na(b,a);b.prototype.isComplex=
|
||||
Q;b.prototype.compileNode=function(a){return this.error("Expansion must be used inside a destructuring assignment or parameter list")};b.prototype.asReference=function(a){return this};b.prototype.eachName=function(a){};return b}(a);g.While=v=function(a){function b(a,b){this.condition=null!=b&&b.invert?a.invert():a;this.guard=null!=b?b.guard:void 0}na(b,a);b.prototype.children=["condition","guard","body"];b.prototype.isStatement=ja;b.prototype.makeReturn=function(a){if(a)return b.__super__.makeReturn.apply(this,
|
||||
arguments);this.returns=!this.jumps({loop:!0});return this};b.prototype.addBody=function(a){this.body=a;return this};b.prototype.jumps=function(){var a,b,e,d;a=this.body.expressions;if(!a.length)return!1;b=0;for(d=a.length;b<d;b++)if(e=a[b],e=e.jumps({loop:!0}))return e;return!1};b.prototype.compileNode=function(a){var b,e,d;a.indent+=da;d="";b=this.body;b.isEmpty()?b=this.makeCode(""):(this.returns&&(b.makeReturn(e=a.scope.freeVariable("results")),d=""+this.tab+e+" \x3d [];\n"),this.guard&&(1<b.expressions.length?
|
||||
b.expressions.unshift(new u((new C(this.guard)).invert(),new ya("continue"))):this.guard&&(b=c.wrap([new u(this.guard,b)]))),b=[].concat(this.makeCode("\n"),b.compileToFragments(a,n),this.makeCode("\n"+this.tab)));a=[].concat(this.makeCode(d+this.tab+"while ("),this.condition.compileToFragments(a,P),this.makeCode(") {"),b,this.makeCode("}"));this.returns&&a.push(this.makeCode("\n"+this.tab+"return "+e+";"));return a};return b}(a);g.Op=A=function(a){function b(a,b,g,q){if("in"===a)return new w(b,g);
|
||||
if("do"===a)return this.generateDo(b);if("new"===a){if(b instanceof f&&!b["do"]&&!b.isNew)return b.newInstance();if(b instanceof m&&b.bound||b["do"])b=new C(b)}this.operator=c[a]||a;this.first=b;this.second=g;this.flip=!!q;return this}var c,g;na(b,a);c={"\x3d\x3d":"\x3d\x3d\x3d","!\x3d":"!\x3d\x3d",of:"in",yieldfrom:"yield*"};g={"!\x3d\x3d":"\x3d\x3d\x3d","\x3d\x3d\x3d":"!\x3d\x3d"};b.prototype.children=["first","second"];b.prototype.isNumber=function(){var a;return this.isUnary()&&("+"===(a=this.operator)||
|
||||
"-"===a)&&this.first instanceof K&&this.first.isNumber()};b.prototype.isYield=function(){var a;return"yield"===(a=this.operator)||"yield*"===a};b.prototype.isUnary=function(){return!this.second};b.prototype.isComplex=function(){return!this.isNumber()};b.prototype.isChainable=function(){var a;return"\x3c"===(a=this.operator)||"\x3e"===a||"\x3e\x3d"===a||"\x3c\x3d"===a||"\x3d\x3d\x3d"===a||"!\x3d\x3d"===a};b.prototype.invert=function(){var a,d,c;if(this.isChainable()&&this.first.isChainable()){a=!0;
|
||||
for(d=this;d&&d.operator;)a&&(a=d.operator in g),d=d.first;if(!a)return(new C(this)).invert();for(d=this;d&&d.operator;)d.invert=!d.invert,d.operator=g[d.operator],d=d.first;return this}return(d=g[this.operator])?(this.operator=d,this.first.unwrap()instanceof b&&this.first.invert(),this):this.second?(new C(this)).invert():"!"===this.operator&&(a=this.first.unwrap())instanceof b&&("!"===(c=a.operator)||"in"===c||"instanceof"===c)?a:new b("!",this)};b.prototype.unfoldSoak=function(a){var b;return("++"===
|
||||
(b=this.operator)||"--"===b||"delete"===b)&&La(a,this,"first")};b.prototype.generateDo=function(a){var b,e,c,g,q;g=[];q=(a instanceof D&&(b=a.value.unwrap())instanceof m?b:a).params||[];b=0;for(e=q.length;b<e;b++)c=q[b],c.value?(g.push(c.value),delete c.value):g.push(c);a=new f(a,g);a["do"]=!0;return a};b.prototype.compileNode=function(a){var b,e;b=this.isChainable()&&this.first.isChainable();b||(this.first.front=this.front);"delete"===this.operator&&a.scope.check(this.first.unwrapAll().value)&&this.error("delete operand may not be argument or var");
|
||||
("--"===(e=this.operator)||"++"===e)&&(e=Ga(this.first.unwrapAll().value))&&this.first.error(e);if(this.isYield())return this.compileYield(a);if(this.isUnary())return this.compileUnary(a);if(b)return this.compileChain(a);switch(this.operator){case "?":return this.compileExistence(a);case "**":return this.compilePower(a);case "//":return this.compileFloorDivision(a);case "%%":return this.compileModulo(a);default:return b=this.first.compileToFragments(a,M),e=this.second.compileToFragments(a,M),b=[].concat(b,
|
||||
this.makeCode(" "+this.operator+" "),e),a.level<=M?b:this.wrapInBraces(b)}};b.prototype.compileChain=function(a){var b;b=this.first.second.cache(a);this.first.second=b[0];b=b[1];a=this.first.compileToFragments(a,M).concat(this.makeCode(" "+(this.invert?"\x26\x26":"||")+" "),b.compileToFragments(a),this.makeCode(" "+this.operator+" "),this.second.compileToFragments(a,M));return this.wrapInBraces(a)};b.prototype.compileExistence=function(a){var b,e;this.first.isComplex()?(e=new h(a.scope.freeVariable("ref")),
|
||||
b=new C(new D(e,this.first))):e=b=this.first;return(new u(new x(b),e,{type:"if"})).addElse(this.second).compileToFragments(a)};b.prototype.compileUnary=function(a){var d,e,c;e=[];d=this.operator;e.push([this.makeCode(d)]);if("!"===d&&this.first instanceof x)return this.first.negated=!this.first.negated,this.first.compileToFragments(a);if(a.level>=z)return(new C(this)).compileToFragments(a);c="+"===d||"-"===d;("new"===d||"typeof"===d||"delete"===d||c&&this.first instanceof b&&this.first.operator===
|
||||
d)&&e.push([this.makeCode(" ")]);if(c&&this.first instanceof b||"new"===d&&this.first.isStatement(a))this.first=new C(this.first);e.push(this.first.compileToFragments(a,M));this.flip&&e.reverse();return this.joinFragmentArrays(e,"")};b.prototype.compileYield=function(a){var b,e,c;e=[];b=this.operator;null==a.scope.parent&&this.error("yield can only occur inside functions");0<=Ha.call(Object.keys(this.first),"expression")&&!(this.first instanceof ia)?null!=this.first.expression&&e.push(this.first.expression.compileToFragments(a,
|
||||
M)):(a.level>=P&&e.push([this.makeCode("(")]),e.push([this.makeCode(b)]),""!==(null!=(c=this.first.base)?c.value:void 0)&&e.push([this.makeCode(" ")]),e.push(this.first.compileToFragments(a,M)),a.level>=P&&e.push([this.makeCode(")")]));return this.joinFragmentArrays(e,"")};b.prototype.compilePower=function(a){var b;b=new K(new h("Math"),[new va(new O("pow"))]);return(new f(b,[this.first,this.second])).compileToFragments(a)};b.prototype.compileFloorDivision=function(a){var d,e;e=new K(new h("Math"),
|
||||
[new va(new O("floor"))]);d=new b("/",this.first,this.second);return(new f(e,[d])).compileToFragments(a)};b.prototype.compileModulo=function(a){var b;b=new K(new r(za("modulo",a)));return(new f(b,[this.first,this.second])).compileToFragments(a)};b.prototype.toString=function(a){return b.__super__.toString.call(this,a,this.constructor.name+" "+this.operator)};return b}(a);g.In=w=function(a){function b(a,b){this.object=a;this.array=b}na(b,a);b.prototype.children=["object","array"];b.prototype.invert=
|
||||
U;b.prototype.compileNode=function(a){var b,e,d,c,f;if(this.array instanceof K&&this.array.isArray()&&this.array.base.objects.length){f=this.array.base.objects;e=0;for(d=f.length;e<d;e++)if(c=f[e],c instanceof R){b=!0;break}if(!b)return this.compileOrTest(a)}return this.compileLoopTest(a)};b.prototype.compileOrTest=function(a){var b,e,d,c,f,g,q,h,k,l;b=this.object.cache(a,M);k=b[0];q=b[1];e=this.negated?[" !\x3d\x3d "," \x26\x26 "]:[" \x3d\x3d\x3d "," || "];b=e[0];e=e[1];l=[];h=this.array.base.objects;
|
||||
d=f=0;for(g=h.length;f<g;d=++f)c=h[d],d&&l.push(this.makeCode(e)),l=l.concat(d?q:k,this.makeCode(b),c.compileToFragments(a,z));return a.level<M?l:this.wrapInBraces(l)};b.prototype.compileLoopTest=function(a){var b,e,d;b=this.object.cache(a,k);d=b[0];e=b[1];b=[].concat(this.makeCode(za("indexOf",a)+".call("),this.array.compileToFragments(a,k),this.makeCode(", "),e,this.makeCode(") "+(this.negated?"\x3c 0":"\x3e\x3d 0")));if(Da(d)===Da(e))return b;b=d.concat(this.makeCode(", "),b);return a.level<k?
|
||||
b:this.wrapInBraces(b)};b.prototype.toString=function(a){return b.__super__.toString.call(this,a,this.constructor.name+(this.negated?"!":""))};return b}(a);g.Try=function(a){function b(a,b,e,d){this.attempt=a;this.errorVariable=b;this.recovery=e;this.ensure=d}na(b,a);b.prototype.children=["attempt","recovery","ensure"];b.prototype.isStatement=ja;b.prototype.jumps=function(a){var b;return this.attempt.jumps(a)||(null!=(b=this.recovery)?b.jumps(a):void 0)};b.prototype.makeReturn=function(a){this.attempt&&
|
||||
(this.attempt=this.attempt.makeReturn(a));this.recovery&&(this.recovery=this.recovery.makeReturn(a));return this};b.prototype.compileNode=function(a){var b,e,d,c,f;a.indent+=da;f=this.attempt.compileToFragments(a,n);b=this.recovery?(e=a.scope.freeVariable("error",{reserve:!1}),c=new h(e),this.errorVariable?(d=Ga(this.errorVariable.unwrapAll().value),d?this.errorVariable.error(d):void 0,this.recovery.unshift(new D(this.errorVariable,c))):void 0,[].concat(this.makeCode(" catch ("),c.compileToFragments(a),
|
||||
this.makeCode(") {\n"),this.recovery.compileToFragments(a,n),this.makeCode("\n"+this.tab+"}"))):this.ensure||this.recovery?[]:(e=a.scope.freeVariable("error",{reserve:!1}),[this.makeCode(" catch ("+e+") {}")]);a=this.ensure?[].concat(this.makeCode(" finally {\n"),this.ensure.compileToFragments(a,n),this.makeCode("\n"+this.tab+"}")):[];return[].concat(this.makeCode(this.tab+"try {\n"),f,this.makeCode("\n"+this.tab+"}"),b,a)};return b}(a);g.Throw=ia=function(a){function b(a){this.expression=a}na(b,
|
||||
a);b.prototype.children=["expression"];b.prototype.isStatement=ja;b.prototype.jumps=Q;b.prototype.makeReturn=fa;b.prototype.compileNode=function(a){return[].concat(this.makeCode(this.tab+"throw "),this.expression.compileToFragments(a),this.makeCode(";"))};return b}(a);g.Existence=x=function(a){function b(a){this.expression=a}na(b,a);b.prototype.children=["expression"];b.prototype.invert=U;b.prototype.compileNode=function(a){var b,e,d;this.expression.front=this.front;d=this.expression.compile(a,M);
|
||||
this.expression.unwrap()instanceof h&&!a.scope.check(d)?(e=this.negated?["\x3d\x3d\x3d","||"]:["!\x3d\x3d","\x26\x26"],b=e[0],e=e[1],d="typeof "+d+" "+b+' "undefined" '+e+" "+d+" "+b+" null"):d=d+" "+(this.negated?"\x3d\x3d":"!\x3d")+" null";return[this.makeCode(a.level<=I?d:"("+d+")")]};return b}(a);g.Parens=C=function(a){function b(a){this.body=a}na(b,a);b.prototype.children=["body"];b.prototype.unwrap=function(){return this.body};b.prototype.isComplex=function(){return this.body.isComplex()};b.prototype.compileNode=
|
||||
function(a){var b,e;b=this.body.unwrap();if(b instanceof K&&b.isAtomic())return b.front=this.front,b.compileToFragments(a);e=b.compileToFragments(a,P);return a.level<M&&(b instanceof A||b instanceof f||b instanceof l&&b.returns)?e:this.wrapInBraces(e)};return b}(a);g.StringWithInterpolations=Wa=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}na(b,a);b.prototype.compileNode=function(a){var c,e,d,f,g;if(!a.inTaggedTemplateCall)return b.__super__.compileNode.apply(this,
|
||||
arguments);d=this.body.unwrap();e=[];d.traverseChildren(!1,function(a){if(a instanceof $a)e.push(a);else if(a instanceof C)return e.push(a),!1;return!0});d=[];d.push(this.makeCode("`"));f=0;for(g=e.length;f<g;f++)c=e[f],c instanceof $a?(c=c.value.slice(1,-1),c=c.replace(/(\\*)(`|\$\{)/g,function(a,b,d){return 0===b.length%2?b+"\\"+d:a}),d.push(this.makeCode(c))):(d.push(this.makeCode("${")),d.push.apply(d,c.compileToFragments(a,P)),d.push(this.makeCode("}")));d.push(this.makeCode("`"));return d};
|
||||
return b}(C);g.For=l=function(a){function b(a,b){this.source=b.source;this.guard=b.guard;this.step=b.step;this.name=b.name;this.index=b.index;this.body=c.wrap([a]);this.own=!!b.own;this.object=!!b.object;(this.from=!!b.from)&&this.index&&this.index.error("cannot use index with for-from");this.own&&!this.object&&b.ownTag.error("cannot use own with for-"+(this.from?"from":"in"));this.object&&(a=[this.index,this.name],this.name=a[0],this.index=a[1]);this.index instanceof K&&this.index.error("index cannot be a pattern matching expression");
|
||||
this.range=this.source instanceof K&&this.source.base instanceof Y&&!this.source.properties.length&&!this.from;this.pattern=this.name instanceof K;this.range&&this.index&&this.index.error("indexes do not apply to range loops");this.range&&this.pattern&&this.name.error("cannot pattern match over range loops");this.returns=!1}na(b,a);b.prototype.children=["body","source","guard","step"];b.prototype.compileNode=function(a){var b,e,d,f,g,q,l,m,p,w,t,z,G,x,v,A,E,L,B,y,I;b=c.wrap([this.body]);p=b.expressions;
|
||||
p=p[p.length-1];(null!=p?p.jumps():void 0)instanceof W&&(this.returns=!1);v=this.range?this.source.base:this.source;d=a.scope;this.pattern||(m=this.name&&this.name.compile(a,k));p=this.index&&this.index.compile(a,k);m&&!this.pattern&&d.find(m);p&&d.find(p);this.returns&&(l=d.freeVariable("results"));this.from?this.pattern&&(t=d.freeVariable("x",{single:!0})):t=this.object&&p||d.freeVariable("i",{single:!0});z=(this.range||this.from)&&m||p||t;G=z!==t?z+" \x3d ":"";this.step&&!this.range&&(p=this.cacheToCodeFragments(this.step.cache(a,
|
||||
k,ta)),g=p[0],B=p[1],this.step.isNumber()&&(L=Number(B)));this.pattern&&(m=t);q=p=I="";w=this.tab+da;this.range?f=v.compileToFragments(Fa(a,{index:t,name:m,step:this.step,isComplex:ta})):(y=this.source.compile(a,k),!m&&!this.own||this.source.unwrap()instanceof h||(q+=""+this.tab+(v=d.freeVariable("ref"))+" \x3d "+y+";\n",y=v),!m||this.pattern||this.from||(x=m+" \x3d "+y+"["+z+"]"),this.object||this.from||(g!==B&&(q+=""+this.tab+g+";\n"),m=0>L,this.step&&null!=L&&m||(e=d.freeVariable("len")),f=""+
|
||||
G+t+" \x3d 0, "+e+" \x3d "+y+".length",g=""+G+t+" \x3d "+y+".length - 1",e=t+" \x3c "+e,d=t+" \x3e\x3d 0",this.step?(null!=L?m&&(e=d,f=g):(e=B+" \x3e 0 ? "+e+" : "+d,f="("+B+" \x3e 0 ? ("+f+") : "+g+")"),t=t+" +\x3d "+B):t=""+(z!==t?"++"+t:t+"++"),f=[this.makeCode(f+"; "+e+"; "+G+t)]));this.returns&&(A=""+this.tab+l+" \x3d [];\n",E="\n"+this.tab+"return "+l+";",b.makeReturn(l));this.guard&&(1<b.expressions.length?b.expressions.unshift(new u((new C(this.guard)).invert(),new ya("continue"))):this.guard&&
|
||||
(b=c.wrap([new u(this.guard,b)])));this.pattern&&b.expressions.unshift(new D(this.name,this.from?new h(z):new r(y+"["+z+"]")));l=[].concat(this.makeCode(q),this.pluckDirectCall(a,b));x&&(I="\n"+w+x+";");this.object?(f=[this.makeCode(z+" in "+y)],this.own&&(p="\n"+w+"if (!"+za("hasProp",a)+".call("+y+", "+z+")) continue;")):this.from&&(f=[this.makeCode(z+" of "+y)]);(a=b.compileToFragments(Fa(a,{indent:w}),n))&&0<a.length&&(a=[].concat(this.makeCode("\n"),a,this.makeCode("\n")));return[].concat(l,
|
||||
this.makeCode(""+(A||"")+this.tab+"for ("),f,this.makeCode(") {"+p+I),a,this.makeCode(this.tab+"}"+(E||"")))};b.prototype.pluckDirectCall=function(a,b){var c,d,g,q,k,l,p,u,r,w,t,z,G,x,v;d=[];r=b.expressions;k=l=0;for(p=r.length;l<p;k=++l)if(g=r[k],g=g.unwrapAll(),g instanceof f&&(v=null!=(w=g.variable)?w.unwrapAll():void 0,v instanceof m||v instanceof K&&(null!=(t=v.base)?t.unwrapAll():void 0)instanceof m&&1===v.properties.length&&("call"===(z=null!=(G=v.properties[0].name)?G.value:void 0)||"apply"===
|
||||
z)))q=(null!=(x=v.base)?x.unwrapAll():void 0)||v,u=new h(a.scope.freeVariable("fn")),c=new K(u),v.base&&(c=[c,v],v.base=c[0],c=c[1]),b.expressions[k]=new f(c,g.args),d=d.concat(this.makeCode(this.tab),(new D(u,q)).compileToFragments(a,n),this.makeCode(";\n"));return d};return b}(v);g.Switch=function(a){function b(a,b,c){this.subject=a;this.cases=b;this.otherwise=c}na(b,a);b.prototype.children=["subject","cases","otherwise"];b.prototype.isStatement=ja;b.prototype.jumps=function(a){var b,c,d,f,g;null==
|
||||
a&&(a={block:!0});f=this.cases;c=0;for(d=f.length;c<d;c++)if(b=f[c],b=b[1],b=b.jumps(a))return b;return null!=(g=this.otherwise)?g.jumps(a):void 0};b.prototype.makeReturn=function(a){var b,e,d,f,g;f=this.cases;b=0;for(e=f.length;b<e;b++)d=f[b],d[1].makeReturn(a);a&&(this.otherwise||(this.otherwise=new c([new r("void 0")])));null!=(g=this.otherwise)&&g.makeReturn(a);return this};b.prototype.compileNode=function(a){var b,c,d,f,g,h,k,q,l,p,m,u,w;k=a.indent+da;q=a.indent=k+da;h=[].concat(this.makeCode(this.tab+
|
||||
"switch ("),this.subject?this.subject.compileToFragments(a,P):this.makeCode("false"),this.makeCode(") {\n"));u=this.cases;g=l=0;for(p=u.length;l<p;g=++l){b=u[g];f=b[0];b=b[1];w=T([f]);f=0;for(m=w.length;f<m;f++)d=w[f],this.subject||(d=d.invert()),h=h.concat(this.makeCode(k+"case "),d.compileToFragments(a,P),this.makeCode(":\n"));0<(c=b.compileToFragments(a,n)).length&&(h=h.concat(c,this.makeCode("\n")));if(g===this.cases.length-1&&!this.otherwise)break;g=this.lastNonComment(b.expressions);g instanceof
|
||||
W||g instanceof r&&g.jumps()&&"debugger"!==g.value||h.push(d.makeCode(q+"break;\n"))}this.otherwise&&this.otherwise.expressions.length&&h.push.apply(h,[this.makeCode(k+"default:\n")].concat(Aa.call(this.otherwise.compileToFragments(a,n)),[this.makeCode("\n")]));h.push(this.makeCode(this.tab+"}"));return h};return b}(a);g.If=u=function(a){function b(a,b,c){this.body=b;null==c&&(c={});this.condition="unless"===c.type?a.invert():a;this.elseBody=null;this.isChain=!1;this.soak=c.soak}na(b,a);b.prototype.children=
|
||||
["condition","body","elseBody"];b.prototype.bodyNode=function(){var a;return null!=(a=this.body)?a.unwrap():void 0};b.prototype.elseBodyNode=function(){var a;return null!=(a=this.elseBody)?a.unwrap():void 0};b.prototype.addElse=function(a){this.isChain?this.elseBodyNode().addElse(a):(this.isChain=a instanceof b,this.elseBody=this.ensureBlock(a),this.elseBody.updateLocationDataIfMissing(a.locationData));return this};b.prototype.isStatement=function(a){var b;return(null!=a?a.level:void 0)===n||this.bodyNode().isStatement(a)||
|
||||
(null!=(b=this.elseBodyNode())?b.isStatement(a):void 0)};b.prototype.jumps=function(a){var b;return this.body.jumps(a)||(null!=(b=this.elseBody)?b.jumps(a):void 0)};b.prototype.compileNode=function(a){return this.isStatement(a)?this.compileStatement(a):this.compileExpression(a)};b.prototype.makeReturn=function(a){a&&(this.elseBody||(this.elseBody=new c([new r("void 0")])));this.body&&(this.body=new c([this.body.makeReturn(a)]));this.elseBody&&(this.elseBody=new c([this.elseBody.makeReturn(a)]));return this};
|
||||
b.prototype.ensureBlock=function(a){return a instanceof c?a:new c([a])};b.prototype.compileStatement=function(a){var c,e,d,f;c=ma(a,"chainChild");if(ma(a,"isExistentialEquals"))return(new b(this.condition.invert(),this.elseBodyNode(),{type:"if"})).compileToFragments(a);f=a.indent+da;d=this.condition.compileToFragments(a,P);e=this.ensureBlock(this.body).compileToFragments(Fa(a,{indent:f}));e=[].concat(this.makeCode("if ("),d,this.makeCode(") {\n"),e,this.makeCode("\n"+this.tab+"}"));c||e.unshift(this.makeCode(this.tab));
|
||||
if(!this.elseBody)return e;c=e.concat(this.makeCode(" else "));this.isChain?(a.chainChild=!0,c=c.concat(this.elseBody.unwrap().compileToFragments(a,n))):c=c.concat(this.makeCode("{\n"),this.elseBody.compileToFragments(Fa(a,{indent:f}),n),this.makeCode("\n"+this.tab+"}"));return c};b.prototype.compileExpression=function(a){var b,c,d;d=this.condition.compileToFragments(a,I);c=this.bodyNode().compileToFragments(a,k);b=this.elseBodyNode()?this.elseBodyNode().compileToFragments(a,k):[this.makeCode("void 0")];
|
||||
b=d.concat(this.makeCode(" ? "),c,this.makeCode(" : "),b);return a.level>=I?this.wrapInBraces(b):b};b.prototype.unfoldSoak=function(){return this.soak&&this};return b}(a);la={extend:function(a){return"function(child, parent) { for (var key in parent) { if ("+za("hasProp",a)+".call(parent, key)) child[key] \x3d parent[key]; } function ctor() { this.constructor \x3d child; } ctor.prototype \x3d parent.prototype; child.prototype \x3d new ctor(); child.__super__ \x3d parent.prototype; return child; }"},
|
||||
bind:function(){return"function(fn, me){ return function(){ return fn.apply(me, arguments); }; }"},indexOf:function(){return"[].indexOf || function(item) { for (var i \x3d 0, l \x3d this.length; i \x3c l; i++) { if (i in this \x26\x26 this[i] \x3d\x3d\x3d item) return i; } return -1; }"},modulo:function(){return"function(a, b) { return (+a % (b \x3d +b) + b) % b; }"},hasProp:function(){return"{}.hasOwnProperty"},slice:function(){return"[].slice"}};n=1;P=2;k=3;I=4;M=5;z=6;da=" ";aa=/^[+-]?\d+$/;za=
|
||||
function(a,b){var c,f;f=b.scope.root;if(a in f.utilities)return f.utilities[a];c=f.freeVariable(a);f.assign(c,la[a](b));return f.utilities[a]=c};Oa=function(a,b){a=a.replace(/\n/g,"$\x26"+b);return a.replace(/\s+$/,"")};Ia=function(a){return a instanceof h&&"arguments"===a.value};Sa=function(a){return a instanceof ha||a instanceof m&&a.bound||a instanceof ka};ta=function(a){return a.isComplex()||("function"===typeof a.isAssignable?a.isAssignable():void 0)};La=function(a,b,c){if(a=b[c].unfoldSoak(a))return b[c]=
|
||||
a.body,a.body=new K(b),a}}).call(this);return g}();t["./sourcemap"]=function(){var g={};(function(){var t;t=function(){function g(g){this.line=g;this.columns=[]}g.prototype.add=function(g,a,c){var t;t=a[0];a=a[1];null==c&&(c={});if(!this.columns[g]||!c.noReplace)return this.columns[g]={line:this.line,column:g,sourceLine:t,sourceColumn:a}};g.prototype.sourceLocation=function(g){for(var a;!((a=this.columns[g])||0>=g);)g--;return a&&[a.sourceLine,a.sourceColumn]};return g}();g=function(){function g(){this.lines=
|
||||
[]}g.prototype.add=function(g,a,c){var D,f;null==c&&(c={});f=a[0];a=a[1];return((D=this.lines)[f]||(D[f]=new t(f))).add(a,g,c)};g.prototype.sourceLocation=function(g){var a,c;a=g[0];for(g=g[1];!((c=this.lines[a])||0>=a);)a--;return c&&c.sourceLocation(g)};g.prototype.generate=function(g,a){var c,t,f,p,m,D,F,x,y,v,E,N,l;null==g&&(g={});null==a&&(a=null);m=D=p=l=0;v=!1;c="";E=this.lines;f=t=0;for(F=E.length;t<F;f=++t)if(f=E[f])for(N=f.columns,f=0,x=N.length;f<x;f++)if(y=N[f]){for(;l<y.line;)p=0,v=!1,
|
||||
c+=";",l++;v&&(c+=",");c+=this.encodeVlq(y.column-p);p=y.column;c+=this.encodeVlq(0);c+=this.encodeVlq(y.sourceLine-D);D=y.sourceLine;c+=this.encodeVlq(y.sourceColumn-m);m=y.sourceColumn;v=!0}c={version:3,file:g.generatedFile||"",sourceRoot:g.sourceRoot||"",sources:g.sourceFiles||[""],names:[],mappings:c};g.inlineMap&&(c.sourcesContent=[a]);return c};g.prototype.encodeVlq=function(g){var a,c;a="";for(c=(Math.abs(g)<<1)+(0>g?1:0);c||!a;)g=c&31,(c>>=5)&&(g|=32),a+=this.encodeBase64(g);return a};g.prototype.encodeBase64=
|
||||
function(g){var a;if(!(a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[g]))throw Error("Cannot Base64 encode value: "+g);return a};return g}()}).call(this);return g}();t["./coffee-script"]=function(){var g={};(function(){var qa,xa,D,a,c,Ca,f,p,m,H,F,x,y,v,E,N={}.hasOwnProperty;f=t("fs");E=t("vm");y=t("path");qa=t("./lexer").Lexer;x=t("./parser").parser;p=t("./helpers");xa=t("./sourcemap");c=t("../../package.json");g.VERSION=c.version;g.FILE_EXTENSIONS=[".coffee",".litcoffee",
|
||||
".coffee.md"];g.helpers=p;D=function(a){switch(!1){case "function"!==typeof Buffer:return(new Buffer(a)).toString("base64");case "function"!==typeof btoa:return btoa(encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,function(a,c){return String.fromCharCode("0x"+c)}));default:throw Error("Unable to base64 encode inline sourcemap.");}};c=function(a){return function(c,f){null==f&&(f={});try{return a.call(this,c,f)}catch(w){if("string"!==typeof c)throw w;throw p.updateSyntaxError(w,c,f.filename);}}};g.compile=
|
||||
a=c(function(a,c){var f,g,h,l,m,t,k,v,y,n,r,E;h=p.extend;c=h({},c);(h=c.sourceMap||c.inlineMap)&&(y=new xa);g=F.tokenize(a,c);l=c;v=[];m=0;for(t=g.length;m<t;m++)f=g[m],"IDENTIFIER"===f[0]&&v.push(f[1]);l.referencedVars=v;if(null==c.bare||!0!==c.bare)for(l=0,m=g.length;l<m;l++)if(f=g[l],"IMPORT"===(k=f[0])||"EXPORT"===k){c.bare=!0;break}m=x.parse(g).compileToFragments(c);g=0;c.header&&(g+=1);c.shiftLine&&(g+=1);f=0;k="";t=0;for(v=m.length;t<v;t++)l=m[t],h&&(l.locationData&&!/^[;\s]*$/.test(l.code)&&
|
||||
y.add([l.locationData.first_line,l.locationData.first_column],[g,f],{noReplace:!0}),n=p.count(l.code,"\n"),g+=n,f=n?l.code.length-(l.code.lastIndexOf("\n")+1):f+l.code.length),k+=l.code;c.header&&(f="Generated by CoffeeScript "+this.VERSION,k="// "+f+"\n"+k);h&&(E=y.generate(c,a));c.inlineMap&&(a=D(JSON.stringify(E)),h="//# sourceURL\x3d"+(null!=(r=c.filename)?r:"coffeescript"),k=k+"\n"+("//# sourceMappingURL\x3ddata:application/json;base64,"+a)+"\n"+h);return c.sourceMap?{js:k,sourceMap:y,v3SourceMap:JSON.stringify(E,
|
||||
null,2)}:k});g.tokens=c(function(a,c){return F.tokenize(a,c)});g.nodes=c(function(a,c){return"string"===typeof a?x.parse(F.tokenize(a,c)):x.parse(a)});g.run=function(c,g){var h,l,m;null==g&&(g={});l=t.main;l.filename=process.argv[1]=g.filename?f.realpathSync(g.filename):".";l.moduleCache&&(l.moduleCache={});h=g.filename?y.dirname(f.realpathSync(g.filename)):f.realpathSync(".");l.paths=t("module")._nodeModulePaths(h);if(!p.isCoffee(l.filename)||t.extensions)c=a(c,g),c=null!=(m=c.js)?m:c;return l._compile(c,
|
||||
l.filename)};g.eval=function(c,f){var g,h,l,m,p,v,k,x,D,n;null==f&&(f={});if(c=c.trim()){m=null!=(p=E.Script.createContext)?p:E.createContext;p=null!=(l=E.isContext)?l:function(a){return f.sandbox instanceof m().constructor};if(m){if(null!=f.sandbox){if(p(f.sandbox))n=f.sandbox;else for(v in n=m(),p=f.sandbox,p)N.call(p,v)&&(l=p[v],n[v]=l);n.global=n.root=n.GLOBAL=n}else n=global;n.__filename=f.filename||"eval";n.__dirname=y.dirname(n.__filename);if(n===global&&!n.module&&!n.require){g=t("module");
|
||||
n.module=h=new g(f.modulename||"eval");n.require=l=function(a){return g._load(a,h,!0)};h.filename=n.__filename;D=Object.getOwnPropertyNames(t);p=0;for(k=D.length;p<k;p++)x=D[p],"paths"!==x&&"arguments"!==x&&"caller"!==x&&(l[x]=t[x]);l.paths=h.paths=g._nodeModulePaths(process.cwd());l.resolve=function(a){return g._resolveFilename(a,h)}}}p={};for(v in f)N.call(f,v)&&(l=f[v],p[v]=l);p.bare=!0;c=a(c,p);return n===global?E.runInThisContext(c):E.runInContext(c,n)}};g.register=function(){return t("./register")};
|
||||
if(t.extensions)for(v=this.FILE_EXTENSIONS,Ca=function(a){var c;return null!=(c=t.extensions)[a]?c[a]:c[a]=function(){throw Error("Use CoffeeScript.register() or require the coffee-script/register module to require "+a+" files.");}},m=0,H=v.length;m<H;m++)c=v[m],Ca(c);g._compileFile=function(c,g,m){var h,l;null==g&&(g=!1);null==m&&(m=!1);l=f.readFileSync(c,"utf8");l=65279===l.charCodeAt(0)?l.substring(1):l;try{h=a(l,{filename:c,sourceMap:g,inlineMap:m,sourceFiles:[c],literate:p.isLiterate(c)})}catch(L){throw p.updateSyntaxError(L,
|
||||
l,c);}return h};F=new qa;x.lexer={lex:function(){var a,c;(c=x.tokens[this.pos++])?(a=c[0],this.yytext=c[1],this.yylloc=c[2],x.errorToken=c.origin||c,this.yylineno=this.yylloc.first_line):a="";return a},setInput:function(a){x.tokens=a;return this.pos=0},upcomingInput:function(){return""}};x.yy=t("./nodes");x.yy.parseError=function(a,c){var f,g,h,l;h=x.errorToken;l=x.tokens;f=h[0];g=h[1];a=h[2];g=function(){switch(!1){case h!==l[l.length-1]:return"end of input";case "INDENT"!==f&&"OUTDENT"!==f:return"indentation";
|
||||
case "IDENTIFIER"!==f&&"NUMBER"!==f&&"INFINITY"!==f&&"STRING"!==f&&"STRING_START"!==f&&"REGEX"!==f&&"REGEX_START"!==f:return f.replace(/_START$/,"").toLowerCase();default:return p.nameWhitespaceCharacter(g)}}();return p.throwSyntaxError("unexpected "+g,a)}}).call(this);return g}();t["./browser"]=function(){(function(){var g,qa,xa,D=[].indexOf||function(a){for(var c=0,g=this.length;c<g;c++)if(c in this&&this[c]===a)return c;return-1};g=t("./coffee-script");g.require=t;qa=g.compile;g.eval=function(a,
|
||||
c){null==c&&(c={});null==c.bare&&(c.bare=!0);return eval(qa(a,c))};g.run=function(a,c){null==c&&(c={});c.bare=!0;c.shiftLine=!0;return Function(qa(a,c))()};"undefined"!==typeof window&&null!==window&&("undefined"!==typeof btoa&&null!==btoa&&"undefined"!==typeof JSON&&null!==JSON&&(qa=function(a,c){null==c&&(c={});c.inlineMap=!0;return g.compile(a,c)}),g.load=function(a,c,t,f){var p;null==t&&(t={});null==f&&(f=!1);t.sourceFiles=[a];p=window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLHTTP"):
|
||||
new window.XMLHttpRequest;p.open("GET",a,!0);"overrideMimeType"in p&&p.overrideMimeType("text/plain");p.onreadystatechange=function(){var m;if(4===p.readyState){if(0===(m=p.status)||200===m)m=[p.responseText,t],f||g.run.apply(g,m);else throw Error("Could not load "+a);if(c)return c(m)}};return p.send(null)},xa=function(){var a,c,t,f,p,m,H,F,x,y,v;v=window.document.getElementsByTagName("script");c=["text/coffeescript","text/literate-coffeescript"];a=function(){var a,f,g,h;h=[];a=0;for(f=v.length;a<
|
||||
f;a++)x=v[a],(g=x.type,0<=D.call(c,g))&&h.push(x);return h}();m=0;t=function(){var c;c=a[m];if(c instanceof Array)return g.run.apply(g,c),m++,t()};f=function(f,m){var l,h;l={literate:f.type===c[1]};if(h=f.src||f.getAttribute("data-src"))return g.load(h,function(c){a[m]=c;return t()},l,!0);l.sourceFiles=["embedded"];return a[m]=[f.innerHTML,l]};p=H=0;for(F=a.length;H<F;p=++H)y=a[p],f(y,p);return t()},window.addEventListener?window.addEventListener("DOMContentLoaded",xa,!1):window.attachEvent("onload",
|
||||
xa))}).call(this);return{}}();return t["./coffee-script"]}();"function"===typeof define&&define.amd?define(function(){return ya}):t.CoffeeScript=ya})(this);
|
||||
3228
docs/v1/index.html
Normal file
11186
docs/v1/test.html
Normal file
@@ -1,6 +0,0 @@
|
||||
class Person
|
||||
constructor: (options) ->
|
||||
{@name, @age, @height} = options
|
||||
|
||||
tim = new Person age: 4
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# The first ten global properties.
|
||||
|
||||
globals = (name for name of window)[0...10]
|
||||
@@ -1,6 +0,0 @@
|
||||
Account = (customer, cart) ->
|
||||
@customer = customer
|
||||
@cart = cart
|
||||
|
||||
$('.shopping_cart').bind 'click', (event) =>
|
||||
@customer.purchase @cart
|
||||
@@ -1,290 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>browser.coffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>browser.coffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
<p>This <strong>Browser</strong> compatibility layer extends core CoffeeScript functions
|
||||
to make things work smoothly when compiling code directly in the browser.
|
||||
We add support for loading remote Coffee scripts via <strong>XHR</strong>, and
|
||||
<code>text/coffeescript</code> script tags, source maps via data-URLs, and so on.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
CoffeeScript = require <span class="string">'./coffee-script'</span>
|
||||
CoffeeScript.require = require
|
||||
compile = CoffeeScript.compile</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-2">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-2">¶</a>
|
||||
</div>
|
||||
<p>Use standard JavaScript <code>eval</code> to eval code.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>CoffeeScript.<span class="function"><span class="title">eval</span></span> = (code, options = {}) ->
|
||||
options.bare ?= <span class="literal">on</span>
|
||||
eval compile code, options</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-3">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-3">¶</a>
|
||||
</div>
|
||||
<p>Running code does not provide access to this scope.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>CoffeeScript.<span class="function"><span class="title">run</span></span> = (code, options = {}) ->
|
||||
options.bare = <span class="literal">on</span>
|
||||
options.shiftLine = <span class="literal">on</span>
|
||||
Function(compile code, options)()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-4">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-4">¶</a>
|
||||
</div>
|
||||
<p>If we're not in a browser environment, we're finished with the public API.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="keyword">return</span> <span class="keyword">unless</span> window?</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-5">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-5">¶</a>
|
||||
</div>
|
||||
<p>Include source maps where possible. If we've got a base64 encoder, a
|
||||
JSON serializer, and tools for escaping unicode characters, we're good to go.
|
||||
Ported from <a href="https://developer.mozilla.org/en-US/docs/DOM/window.btoa">https://developer.mozilla.org/en-US/docs/DOM/window.btoa</a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="keyword">if</span> btoa? <span class="keyword">and</span> JSON? <span class="keyword">and</span> unescape? <span class="keyword">and</span> encodeURIComponent?
|
||||
<span class="function"><span class="title">compile</span></span> = (code, options = {}) ->
|
||||
options.sourceMap = <span class="literal">true</span>
|
||||
options.inline = <span class="literal">true</span>
|
||||
{js, v3SourceMap} = CoffeeScript.compile code, options
|
||||
<span class="string">"<span class="subst">#{js}</span>\n//@ sourceMappingURL=data:application/json;base64,<span class="subst">#{btoa unescape encodeURIComponent v3SourceMap}</span>\n//@ sourceURL=coffeescript"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-6">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-6">¶</a>
|
||||
</div>
|
||||
<p>Load a remote script from the current domain via XHR.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>CoffeeScript.<span class="function"><span class="title">load</span></span> = (url, callback, options = {}) ->
|
||||
options.sourceFiles = [url]
|
||||
xhr = <span class="keyword">if</span> window.ActiveXObject
|
||||
<span class="keyword">new</span> window.ActiveXObject(<span class="string">'Microsoft.XMLHTTP'</span>)
|
||||
<span class="keyword">else</span>
|
||||
<span class="keyword">new</span> window.XMLHttpRequest()
|
||||
xhr.open <span class="string">'GET'</span>, url, <span class="literal">true</span>
|
||||
xhr.overrideMimeType <span class="string">'text/plain'</span> <span class="keyword">if</span> <span class="string">'overrideMimeType'</span> <span class="keyword">of</span> xhr
|
||||
xhr.<span class="function"><span class="title">onreadystatechange</span></span> = ->
|
||||
<span class="keyword">if</span> xhr.readyState <span class="keyword">is</span> <span class="number">4</span>
|
||||
<span class="keyword">if</span> xhr.status <span class="keyword">in</span> [<span class="number">0</span>, <span class="number">200</span>]
|
||||
CoffeeScript.run xhr.responseText, options
|
||||
<span class="keyword">else</span>
|
||||
<span class="keyword">throw</span> <span class="keyword">new</span> Error <span class="string">"Could not load <span class="subst">#{url}</span>"</span>
|
||||
callback() <span class="keyword">if</span> callback
|
||||
xhr.send <span class="literal">null</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-7">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-7">¶</a>
|
||||
</div>
|
||||
<p>Activate CoffeeScript in the browser by having it compile and evaluate
|
||||
all script tags with a content-type of <code>text/coffeescript</code>.
|
||||
This happens on page load.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">runScripts</span></span> = ->
|
||||
scripts = window.document.getElementsByTagName <span class="string">'script'</span>
|
||||
coffeetypes = [<span class="string">'text/coffeescript'</span>, <span class="string">'text/literate-coffeescript'</span>]
|
||||
coffees = (s <span class="keyword">for</span> s <span class="keyword">in</span> scripts <span class="keyword">when</span> s.type <span class="keyword">in</span> coffeetypes)
|
||||
index = <span class="number">0</span>
|
||||
length = coffees.length
|
||||
<span class="keyword">do</span> <span class="function"><span class="title">execute</span></span> = ->
|
||||
script = coffees[index++]
|
||||
mediatype = script?.type
|
||||
<span class="keyword">if</span> mediatype <span class="keyword">in</span> coffeetypes
|
||||
options = {literate: mediatype <span class="keyword">is</span> <span class="string">'text/literate-coffeescript'</span>}
|
||||
<span class="keyword">if</span> script.src
|
||||
CoffeeScript.load script.src, execute, options
|
||||
<span class="keyword">else</span>
|
||||
options.sourceFiles = [<span class="string">'embedded'</span>]
|
||||
CoffeeScript.run script.innerHTML, options
|
||||
execute()
|
||||
<span class="literal">null</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
<p>Listen for window load, both in decent browsers and in IE.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="keyword">if</span> window.addEventListener
|
||||
window.addEventListener <span class="string">'DOMContentLoaded'</span>, runScripts, <span class="literal">no</span>
|
||||
<span class="keyword">else</span>
|
||||
window.attachEvent <span class="string">'onload'</span>, runScripts</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,338 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>cake.coffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>cake.coffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
<p><code>cake</code> is a simplified version of <a href="http://www.gnu.org/software/make/">Make</a>
|
||||
(<a href="http://rake.rubyforge.org/">Rake</a>, <a href="http://github.com/280north/jake">Jake</a>)
|
||||
for CoffeeScript. You define tasks with names and descriptions in a Cakefile,
|
||||
and can call them from the command line, or invoke them from other tasks.
|
||||
|
||||
</p>
|
||||
<p>Running <code>cake</code> with no arguments will print out a list of all the tasks in the
|
||||
current directory's Cakefile.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-2">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-2">¶</a>
|
||||
</div>
|
||||
<p>External dependencies.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>fs = require <span class="string">'fs'</span>
|
||||
path = require <span class="string">'path'</span>
|
||||
helpers = require <span class="string">'./helpers'</span>
|
||||
optparse = require <span class="string">'./optparse'</span>
|
||||
CoffeeScript = require <span class="string">'./coffee-script'</span>
|
||||
|
||||
existsSync = fs.existsSync <span class="keyword">or</span> path.existsSync</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-3">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-3">¶</a>
|
||||
</div>
|
||||
<p>Keep track of the list of defined tasks, the accepted options, and so on.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>tasks = {}
|
||||
options = {}
|
||||
switches = []
|
||||
oparse = <span class="literal">null</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-4">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-4">¶</a>
|
||||
</div>
|
||||
<p>Mixin the top-level Cake functions for Cakefiles to use directly.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>helpers.extend global,</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-5">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-5">¶</a>
|
||||
</div>
|
||||
<p>Define a Cake task with a short name, an optional sentence description,
|
||||
and the function to run as the action itself.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> task: (name, description, action) ->
|
||||
[action, description] = [description, action] <span class="keyword">unless</span> action
|
||||
tasks[name] = {name, description, action}</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-6">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-6">¶</a>
|
||||
</div>
|
||||
<p>Define an option that the Cakefile accepts. The parsed options hash,
|
||||
containing all of the command-line options passed, will be made available
|
||||
as the first argument to the action.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> option: (letter, flag, description) ->
|
||||
switches.push [letter, flag, description]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-7">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-7">¶</a>
|
||||
</div>
|
||||
<p>Invoke another task in the current Cakefile.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> invoke: (name) ->
|
||||
missingTask name <span class="keyword">unless</span> tasks[name]
|
||||
tasks[name].action options</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
<p>Run <code>cake</code>. Executes all of the tasks you pass, in order. Note that Node's
|
||||
asynchrony may cause tasks to execute in a different order than you'd expect.
|
||||
If no tasks are passed, print the help screen. Keep a reference to the
|
||||
original directory name, when running Cake tasks from subdirectories.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">run</span></span> = ->
|
||||
global.__originalDirname = fs.realpathSync <span class="string">'.'</span>
|
||||
process.chdir cakefileDirectory __originalDirname
|
||||
args = process.argv[<span class="number">2.</span>.]
|
||||
CoffeeScript.run fs.readFileSync(<span class="string">'Cakefile'</span>).toString(), filename: <span class="string">'Cakefile'</span>
|
||||
oparse = <span class="keyword">new</span> optparse.OptionParser switches
|
||||
<span class="keyword">return</span> printTasks() <span class="keyword">unless</span> args.length
|
||||
<span class="keyword">try</span>
|
||||
options = oparse.parse(args)
|
||||
<span class="keyword">catch</span> e
|
||||
<span class="keyword">return</span> fatalError <span class="string">"<span class="subst">#{e}</span>"</span>
|
||||
invoke arg <span class="keyword">for</span> arg <span class="keyword">in</span> options.arguments</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-9">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
</div>
|
||||
<p>Display the list of Cake tasks in a format similar to <code>rake -T</code>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">printTasks</span></span> = ->
|
||||
relative = path.relative <span class="keyword">or</span> path.resolve
|
||||
cakefilePath = path.join relative(__originalDirname, process.cwd()), <span class="string">'Cakefile'</span>
|
||||
console.log <span class="string">"<span class="subst">#{cakefilePath}</span> defines the following tasks:\n"</span>
|
||||
<span class="keyword">for</span> name, task <span class="keyword">of</span> tasks
|
||||
spaces = <span class="number">20</span> - name.length
|
||||
spaces = <span class="keyword">if</span> spaces > <span class="number">0</span> <span class="keyword">then</span> Array(spaces + <span class="number">1</span>).join(<span class="string">' '</span>) <span class="keyword">else</span> <span class="string">''</span>
|
||||
desc = <span class="keyword">if</span> task.description <span class="keyword">then</span> <span class="string">"# <span class="subst">#{task.description}</span>"</span> <span class="keyword">else</span> <span class="string">''</span>
|
||||
console.log <span class="string">"cake <span class="subst">#{name}</span><span class="subst">#{spaces}</span> <span class="subst">#{desc}</span>"</span>
|
||||
console.log oparse.help() <span class="keyword">if</span> switches.length</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-10">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
</div>
|
||||
<p>Print an error and exit when attempting to use an invalid task/option.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">fatalError</span></span> = (message) ->
|
||||
console.error message + <span class="string">'\n'</span>
|
||||
console.log <span class="string">'To see a list of all tasks/options, run "cake"'</span>
|
||||
process.exit <span class="number">1</span>
|
||||
|
||||
<span class="function"><span class="title">missingTask</span></span> = (task) -> fatalError <span class="string">"No such task: <span class="subst">#{task}</span>"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-11">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
</div>
|
||||
<p>When <code>cake</code> is invoked, search in the current and all parent directories
|
||||
to find the relevant Cakefile.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">cakefileDirectory</span></span> = (dir) ->
|
||||
<span class="keyword">return</span> dir <span class="keyword">if</span> existsSync path.join dir, <span class="string">'Cakefile'</span>
|
||||
parent = path.normalize path.join dir, <span class="string">'..'</span>
|
||||
<span class="keyword">return</span> cakefileDirectory parent <span class="keyword">unless</span> parent <span class="keyword">is</span> dir
|
||||
<span class="keyword">throw</span> <span class="keyword">new</span> Error <span class="string">"Cakefile not found in <span class="subst">#{process.cwd()}</span>"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,874 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>coffee-script.coffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>coffee-script.coffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
<p>CoffeeScript can be used both on the server, as a command-line compiler based
|
||||
on Node.js/V8, or to run CoffeeScript directly in the browser. This module
|
||||
contains the main entry functions for tokenizing, parsing, and compiling
|
||||
source CoffeeScript into JavaScript.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
fs = require <span class="string">'fs'</span>
|
||||
vm = require <span class="string">'vm'</span>
|
||||
path = require <span class="string">'path'</span>
|
||||
child_process = require <span class="string">'child_process'</span>
|
||||
{Lexer} = require <span class="string">'./lexer'</span>
|
||||
{parser} = require <span class="string">'./parser'</span>
|
||||
helpers = require <span class="string">'./helpers'</span>
|
||||
SourceMap = require <span class="string">'./sourcemap'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-2">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-2">¶</a>
|
||||
</div>
|
||||
<p>The current CoffeeScript version number.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.VERSION = <span class="string">'1.6.3'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-3">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-3">¶</a>
|
||||
</div>
|
||||
<p>Expose helpers for testing.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.helpers = helpers</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-4">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-4">¶</a>
|
||||
</div>
|
||||
<p>Compile CoffeeScript code to JavaScript, using the Coffee/Jison compiler.
|
||||
|
||||
</p>
|
||||
<p>If <code>options.sourceMap</code> is specified, then <code>options.filename</code> must also be specified. All
|
||||
options that can be passed to <code>SourceMap#generate</code> may also be passed here.
|
||||
|
||||
</p>
|
||||
<p>This returns a javascript string, unless <code>options.sourceMap</code> is passed,
|
||||
in which case this returns a <code>{js, v3SourceMap, sourceMap}</code>
|
||||
object, where sourceMap is a sourcemap.coffee#SourceMap object, handy for doing programatic
|
||||
lookups.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.compile = <span class="function"><span class="title">compile</span></span> = (code, options = {}) ->
|
||||
{merge} = helpers
|
||||
|
||||
<span class="keyword">if</span> options.sourceMap
|
||||
map = <span class="keyword">new</span> SourceMap
|
||||
|
||||
fragments = parser.parse(lexer.tokenize code, options).compileToFragments options
|
||||
|
||||
currentLine = <span class="number">0</span>
|
||||
currentLine += <span class="number">1</span> <span class="keyword">if</span> options.header
|
||||
currentLine += <span class="number">1</span> <span class="keyword">if</span> options.shiftLine
|
||||
currentColumn = <span class="number">0</span>
|
||||
js = <span class="string">""</span>
|
||||
<span class="keyword">for</span> fragment <span class="keyword">in</span> fragments</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-5">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-5">¶</a>
|
||||
</div>
|
||||
<p>Update the sourcemap with data from each fragment
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="keyword">if</span> options.sourceMap
|
||||
<span class="keyword">if</span> fragment.locationData
|
||||
map.add(
|
||||
[fragment.locationData.first_line, fragment.locationData.first_column]
|
||||
[currentLine, currentColumn]
|
||||
{noReplace: <span class="literal">true</span>})
|
||||
newLines = helpers.count fragment.code, <span class="string">"\n"</span>
|
||||
currentLine += newLines
|
||||
currentColumn = fragment.code.length - (<span class="keyword">if</span> newLines <span class="keyword">then</span> fragment.code.lastIndexOf <span class="string">"\n"</span> <span class="keyword">else</span> <span class="number">0</span>)</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-6">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-6">¶</a>
|
||||
</div>
|
||||
<p>Copy the code from each fragment into the final JavaScript.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> js += fragment.code
|
||||
|
||||
<span class="keyword">if</span> options.header
|
||||
header = <span class="string">"Generated by CoffeeScript <span class="subst">#{@VERSION}</span>"</span>
|
||||
js = <span class="string">"// <span class="subst">#{header}</span>\n<span class="subst">#{js}</span>"</span>
|
||||
|
||||
<span class="keyword">if</span> options.sourceMap
|
||||
answer = {js}
|
||||
answer.sourceMap = map
|
||||
answer.v3SourceMap = map.generate(options, code)
|
||||
answer
|
||||
<span class="keyword">else</span>
|
||||
js</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-7">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-7">¶</a>
|
||||
</div>
|
||||
<p>Tokenize a string of CoffeeScript code, and return the array of tokens.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">tokens</span></span> = (code, options) ->
|
||||
lexer.tokenize code, options</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
<p>Parse a string of CoffeeScript code or an array of lexed tokens, and
|
||||
return the AST. You can then compile it by calling <code>.compile()</code> on the root,
|
||||
or traverse it by using <code>.traverseChildren()</code> with a callback.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">nodes</span></span> = (source, options) ->
|
||||
<span class="keyword">if</span> <span class="keyword">typeof</span> source <span class="keyword">is</span> <span class="string">'string'</span>
|
||||
parser.parse lexer.tokenize source, options
|
||||
<span class="keyword">else</span>
|
||||
parser.parse source</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-9">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
</div>
|
||||
<p>Compile and execute a string of CoffeeScript (on the server), correctly
|
||||
setting <code>__filename</code>, <code>__dirname</code>, and relative <code>require()</code>.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">run</span></span> = (code, options = {}) ->
|
||||
mainModule = require.main
|
||||
options.sourceMap ?= <span class="literal">true</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-10">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
</div>
|
||||
<p>Set the filename.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> mainModule.filename = process.argv[<span class="number">1</span>] =
|
||||
<span class="keyword">if</span> options.filename <span class="keyword">then</span> fs.realpathSync(options.filename) <span class="keyword">else</span> <span class="string">'.'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-11">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
</div>
|
||||
<p>Clear the module cache.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> mainModule.moduleCache <span class="keyword">and</span>= {}</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-12">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
</div>
|
||||
<p>Assign paths for node_modules loading
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> mainModule.paths = require(<span class="string">'module'</span>)._nodeModulePaths path.dirname fs.realpathSync options.filename <span class="keyword">or</span> <span class="string">'.'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-13">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-13">¶</a>
|
||||
</div>
|
||||
<p>Compile.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="keyword">if</span> <span class="keyword">not</span> helpers.isCoffee(mainModule.filename) <span class="keyword">or</span> require.extensions
|
||||
answer = compile(code, options)</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-14">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-14">¶</a>
|
||||
</div>
|
||||
<p>Attach sourceMap object to sourceMaps[options.filename] so that
|
||||
it is accessible by Error.prepareStackTrace.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="keyword">do</span> patchStackTrace
|
||||
sourceMaps[mainModule.filename] = answer.sourceMap
|
||||
mainModule._compile answer.js, mainModule.filename
|
||||
<span class="keyword">else</span>
|
||||
mainModule._compile code, mainModule.filename</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-15">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
</div>
|
||||
<p>Compile and evaluate a string of CoffeeScript (in a Node.js-like environment).
|
||||
The CoffeeScript REPL uses this to run the input.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">eval</span></span> = (code, options = {}) ->
|
||||
<span class="keyword">return</span> <span class="keyword">unless</span> code = code.trim()
|
||||
Script = vm.Script
|
||||
<span class="keyword">if</span> Script
|
||||
<span class="keyword">if</span> options.sandbox?
|
||||
<span class="keyword">if</span> options.sandbox <span class="keyword">instanceof</span> Script.createContext().constructor
|
||||
sandbox = options.sandbox
|
||||
<span class="keyword">else</span>
|
||||
sandbox = Script.createContext()
|
||||
sandbox[k] = v <span class="keyword">for</span> own k, v <span class="keyword">of</span> options.sandbox
|
||||
sandbox.global = sandbox.root = sandbox.GLOBAL = sandbox
|
||||
<span class="keyword">else</span>
|
||||
sandbox = global
|
||||
sandbox.__filename = options.filename || <span class="string">'eval'</span>
|
||||
sandbox.__dirname = path.dirname sandbox.__filename</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-16">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-16">¶</a>
|
||||
</div>
|
||||
<p>define module/require only if they chose not to specify their own
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="keyword">unless</span> sandbox <span class="keyword">isnt</span> global <span class="keyword">or</span> sandbox.module <span class="keyword">or</span> sandbox.require
|
||||
Module = require <span class="string">'module'</span>
|
||||
sandbox.module = _module = <span class="keyword">new</span> Module(options.modulename || <span class="string">'eval'</span>)
|
||||
sandbox.require = <span class="function"><span class="title">_require</span></span> = (path) -> Module._load path, _module, <span class="literal">true</span>
|
||||
_module.filename = sandbox.__filename
|
||||
_require[r] = require[r] <span class="keyword">for</span> r <span class="keyword">in</span> Object.getOwnPropertyNames require <span class="keyword">when</span> r <span class="keyword">isnt</span> <span class="string">'paths'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-17">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-17">¶</a>
|
||||
</div>
|
||||
<p>use the same hack node currently uses for their own REPL
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> _require.paths = _module.paths = Module._nodeModulePaths process.cwd()
|
||||
_require.<span class="function"><span class="title">resolve</span></span> = (request) -> Module._resolveFilename request, _module
|
||||
o = {}
|
||||
o[k] = v <span class="keyword">for</span> own k, v <span class="keyword">of</span> options
|
||||
o.bare = <span class="literal">on</span> <span class="comment"># ensure return value</span>
|
||||
js = compile code, o
|
||||
<span class="keyword">if</span> sandbox <span class="keyword">is</span> global
|
||||
vm.runInThisContext js
|
||||
<span class="keyword">else</span>
|
||||
vm.runInContext js, sandbox</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-18">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
</div>
|
||||
<p>Load and run a CoffeeScript file for Node, stripping any <code>BOM</code>s.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">loadFile</span></span> = (module, filename) ->
|
||||
raw = fs.readFileSync filename, <span class="string">'utf8'</span>
|
||||
stripped = <span class="keyword">if</span> raw.charCodeAt(<span class="number">0</span>) <span class="keyword">is</span> <span class="number">0xFEFF</span> <span class="keyword">then</span> raw.substring <span class="number">1</span> <span class="keyword">else</span> raw
|
||||
answer = compile(stripped, {filename, sourceMap: <span class="literal">true</span>, literate: helpers.isLiterate filename})
|
||||
sourceMaps[filename] = answer.sourceMap
|
||||
module._compile answer.js, filename</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-19">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-19">¶</a>
|
||||
</div>
|
||||
<p>If the installed version of Node supports <code>require.extensions</code>, register
|
||||
CoffeeScript as an extension.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="keyword">if</span> require.extensions
|
||||
<span class="keyword">for</span> ext <span class="keyword">in</span> [<span class="string">'.coffee'</span>, <span class="string">'.litcoffee'</span>, <span class="string">'.coffee.md'</span>]
|
||||
require.extensions[ext] = loadFile</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-20">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-20">¶</a>
|
||||
</div>
|
||||
<p>Patch Node's module loader to be able to handle mult-dot extensions.
|
||||
This is a horrible thing that should not be required. Perhaps, one day,
|
||||
when a truly benevolent dictator comes to rule over the Republik of Node,
|
||||
it won't be.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> Module = require <span class="string">'module'</span>
|
||||
|
||||
<span class="function"><span class="title">findExtension</span></span> = (filename) ->
|
||||
extensions = path.basename(filename).split <span class="string">'.'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-21">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-21">¶</a>
|
||||
</div>
|
||||
<p>Remove the initial dot from dotfiles.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> extensions.shift() <span class="keyword">if</span> extensions[<span class="number">0</span>] <span class="keyword">is</span> <span class="string">''</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-22">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-22">¶</a>
|
||||
</div>
|
||||
<p>Start with the longest possible extension and work our way shortwards.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="keyword">while</span> extensions.shift()
|
||||
curExtension = <span class="string">'.'</span> + extensions.join <span class="string">'.'</span>
|
||||
<span class="keyword">return</span> curExtension <span class="keyword">if</span> Module._extensions[curExtension]
|
||||
<span class="string">'.js'</span>
|
||||
|
||||
Module::<span class="function"><span class="title">load</span></span> = (filename) ->
|
||||
<span class="property">@filename</span> = filename
|
||||
<span class="property">@paths</span> = Module._nodeModulePaths path.dirname filename
|
||||
extension = findExtension filename
|
||||
Module._extensions[extension](<span class="keyword">this</span>, filename)
|
||||
<span class="property">@loaded</span> = <span class="literal">true</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-23">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-23">¶</a>
|
||||
</div>
|
||||
<p>If we're on Node, patch <code>child_process.fork</code> so that Coffee scripts are able
|
||||
to fork both CoffeeScript files, and JavaScript files, directly.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="keyword">if</span> child_process
|
||||
{fork} = child_process
|
||||
child_process.<span class="function"><span class="title">fork</span></span> = (path, args = [], options = {}) ->
|
||||
execPath = <span class="keyword">if</span> helpers.isCoffee(path) <span class="keyword">then</span> <span class="string">'coffee'</span> <span class="keyword">else</span> <span class="literal">null</span>
|
||||
<span class="keyword">if</span> <span class="keyword">not</span> Array.isArray args
|
||||
args = []
|
||||
options = args <span class="keyword">or</span> {}
|
||||
options.execPath <span class="keyword">or</span>= execPath
|
||||
fork path, args, options</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-24">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-24">¶</a>
|
||||
</div>
|
||||
<p>Instantiate a Lexer for our use here.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>lexer = <span class="keyword">new</span> Lexer</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-25">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-25">¶</a>
|
||||
</div>
|
||||
<p>The real Lexer produces a generic stream of tokens. This object provides a
|
||||
thin wrapper around it, compatible with the Jison API. We can then pass it
|
||||
directly as a "Jison lexer".
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>parser.lexer =
|
||||
lex: ->
|
||||
token = <span class="property">@tokens</span>[<span class="property">@pos</span>++]
|
||||
<span class="keyword">if</span> token
|
||||
[tag, <span class="property">@yytext</span>, <span class="property">@yylloc</span>] = token
|
||||
<span class="property">@yylineno</span> = <span class="property">@yylloc</span>.first_line
|
||||
<span class="keyword">else</span>
|
||||
tag = <span class="string">''</span>
|
||||
|
||||
tag
|
||||
setInput: (<span class="property">@tokens</span>) ->
|
||||
<span class="property">@pos</span> = <span class="number">0</span>
|
||||
upcomingInput: ->
|
||||
<span class="string">""</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-26">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-26">¶</a>
|
||||
</div>
|
||||
<p>Make all the AST nodes visible to the parser.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>parser.yy = require <span class="string">'./nodes'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-27">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-27">¶</a>
|
||||
</div>
|
||||
<p>Override Jison's default error handling function.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>parser.yy.<span class="function"><span class="title">parseError</span></span> = (message, {token}) -></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-28">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-28">¶</a>
|
||||
</div>
|
||||
<p>Disregard Jison's message, it contains redundant line numer information.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> message = <span class="string">"unexpected <span class="subst">#{<span class="keyword">if</span> token <span class="keyword">is</span> <span class="number">1</span> <span class="keyword">then</span> 'end <span class="keyword">of</span> input' <span class="keyword">else</span> token}</span>"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-29">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-29">¶</a>
|
||||
</div>
|
||||
<p>The second argument has a <code>loc</code> property, which should have the location
|
||||
data for this token. Unfortunately, Jison seems to send an outdated <code>loc</code>
|
||||
(from the previous token), so we take the location information directly
|
||||
from the lexer.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> helpers.throwSyntaxError message, parser.lexer.yylloc</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-30">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-30">¶</a>
|
||||
</div>
|
||||
<p>Based on <a href="http://goo.gl/ZTx1p">michaelficarra/CoffeeScriptRedux</a>
|
||||
NodeJS / V8 have no support for transforming positions in stack traces using
|
||||
sourceMap, so we must monkey-patch Error to display CoffeeScript source
|
||||
positions.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
patched = <span class="literal">false</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-31">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-31">¶</a>
|
||||
</div>
|
||||
<p>Map of filenames -> sourceMap object.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>sourceMaps = {}
|
||||
|
||||
<span class="function"><span class="title">patchStackTrace</span></span> = ->
|
||||
<span class="keyword">return</span> <span class="keyword">if</span> patched
|
||||
patched = <span class="literal">true</span>
|
||||
mainModule = require.main</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-32">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-32">¶</a>
|
||||
</div>
|
||||
<p>(Assigning to a property of the Module object in the normal module cache is
|
||||
unsuitable, because node deletes those objects from the cache if an
|
||||
exception is thrown in the module body.)
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
Error.<span class="function"><span class="title">prepareStackTrace</span></span> = (err, stack) ->
|
||||
sourceFiles = {}
|
||||
|
||||
<span class="function"><span class="title">getSourceMapping</span></span> = (filename, line, column) ->
|
||||
sourceMap = sourceMaps[filename]
|
||||
answer = sourceMap.sourceLocation [line - <span class="number">1</span>, column - <span class="number">1</span>] <span class="keyword">if</span> sourceMap
|
||||
<span class="keyword">if</span> answer <span class="keyword">then</span> [answer[<span class="number">0</span>] + <span class="number">1</span>, answer[<span class="number">1</span>] + <span class="number">1</span>] <span class="keyword">else</span> <span class="literal">null</span>
|
||||
|
||||
frames = <span class="keyword">for</span> frame <span class="keyword">in</span> stack
|
||||
<span class="keyword">break</span> <span class="keyword">if</span> frame.getFunction() <span class="keyword">is</span> exports.run
|
||||
<span class="string">" at <span class="subst">#{formatSourcePosition frame, getSourceMapping}</span>"</span>
|
||||
|
||||
<span class="string">"<span class="subst">#{err.name}</span>: <span class="subst">#{err.message ? ''}</span>\n<span class="subst">#{frames.join '\n'}</span>\n"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-33">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-33">¶</a>
|
||||
</div>
|
||||
<p>Based on <a href="http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js">http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js</a>
|
||||
Modified to handle sourceMap
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">formatSourcePosition</span></span> = (frame, getSourceMapping) ->
|
||||
fileName = <span class="literal">undefined</span>
|
||||
fileLocation = <span class="string">''</span>
|
||||
|
||||
<span class="keyword">if</span> frame.isNative()
|
||||
fileLocation = <span class="string">"native"</span>
|
||||
<span class="keyword">else</span>
|
||||
<span class="keyword">if</span> frame.isEval()
|
||||
fileName = frame.getScriptNameOrSourceURL()
|
||||
fileLocation = <span class="string">"<span class="subst">#{frame.getEvalOrigin()}</span>, "</span> <span class="keyword">unless</span> fileName
|
||||
<span class="keyword">else</span>
|
||||
fileName = frame.getFileName()
|
||||
|
||||
fileName <span class="keyword">or</span>= <span class="string">"<anonymous>"</span>
|
||||
|
||||
line = frame.getLineNumber()
|
||||
column = frame.getColumnNumber()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-34">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-34">¶</a>
|
||||
</div>
|
||||
<p>Check for a sourceMap position
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> source = getSourceMapping fileName, line, column
|
||||
fileLocation =
|
||||
<span class="keyword">if</span> source
|
||||
<span class="string">"<span class="subst">#{fileName}</span>:<span class="subst">#{source[<span class="number">0</span>]}</span>:<span class="subst">#{source[<span class="number">1</span>]}</span>, <js>:<span class="subst">#{line}</span>:<span class="subst">#{column}</span>"</span>
|
||||
<span class="keyword">else</span>
|
||||
<span class="string">"<span class="subst">#{fileName}</span>:<span class="subst">#{line}</span>:<span class="subst">#{column}</span>"</span>
|
||||
|
||||
|
||||
functionName = frame.getFunctionName()
|
||||
isConstructor = frame.isConstructor()
|
||||
isMethodCall = <span class="keyword">not</span> (frame.isToplevel() <span class="keyword">or</span> isConstructor)
|
||||
|
||||
<span class="keyword">if</span> isMethodCall
|
||||
methodName = frame.getMethodName()
|
||||
typeName = frame.getTypeName()
|
||||
|
||||
<span class="keyword">if</span> functionName
|
||||
tp = as = <span class="string">''</span>
|
||||
<span class="keyword">if</span> typeName <span class="keyword">and</span> functionName.indexOf typeName
|
||||
tp = <span class="string">"<span class="subst">#{typeName}</span>."</span>
|
||||
<span class="keyword">if</span> methodName <span class="keyword">and</span> functionName.indexOf(<span class="string">".<span class="subst">#{methodName}</span>"</span>) <span class="keyword">isnt</span> functionName.length - methodName.length - <span class="number">1</span>
|
||||
as = <span class="string">" [as <span class="subst">#{methodName}</span>]"</span>
|
||||
|
||||
<span class="string">"<span class="subst">#{tp}</span><span class="subst">#{functionName}</span><span class="subst">#{as}</span> (<span class="subst">#{fileLocation}</span>)"</span>
|
||||
<span class="keyword">else</span>
|
||||
<span class="string">"<span class="subst">#{typeName}</span>.<span class="subst">#{methodName <span class="keyword">or</span> '<anonymous>'}</span> (<span class="subst">#{fileLocation}</span>)"</span>
|
||||
<span class="keyword">else</span> <span class="keyword">if</span> isConstructor
|
||||
<span class="string">"new <span class="subst">#{functionName <span class="keyword">or</span> '<anonymous>'}</span> (<span class="subst">#{fileLocation}</span>)"</span>
|
||||
<span class="keyword">else</span> <span class="keyword">if</span> functionName
|
||||
<span class="string">"<span class="subst">#{functionName}</span> (<span class="subst">#{fileLocation}</span>)"</span>
|
||||
<span class="keyword">else</span>
|
||||
fileLocation</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,779 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>command.coffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>command.coffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
<p>The <code>coffee</code> utility. Handles command-line compilation of CoffeeScript
|
||||
into various forms: saved into <code>.js</code> files or printed to stdout
|
||||
or recompiled every time the source is saved,
|
||||
printed as a token stream or as the syntax tree, or launch an
|
||||
interactive REPL.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-2">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-2">¶</a>
|
||||
</div>
|
||||
<p>External dependencies.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>fs = require <span class="string">'fs'</span>
|
||||
path = require <span class="string">'path'</span>
|
||||
helpers = require <span class="string">'./helpers'</span>
|
||||
optparse = require <span class="string">'./optparse'</span>
|
||||
CoffeeScript = require <span class="string">'./coffee-script'</span>
|
||||
{spawn, exec} = require <span class="string">'child_process'</span>
|
||||
{EventEmitter} = require <span class="string">'events'</span>
|
||||
|
||||
exists = fs.exists <span class="keyword">or</span> path.exists
|
||||
useWinPathSep = path.sep <span class="keyword">is</span> <span class="string">'\\'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-3">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-3">¶</a>
|
||||
</div>
|
||||
<p>Allow CoffeeScript to emit Node.js events.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>helpers.extend CoffeeScript, <span class="keyword">new</span> EventEmitter
|
||||
|
||||
<span class="function"><span class="title">printLine</span></span> = (line) -> process.stdout.write line + <span class="string">'\n'</span>
|
||||
<span class="function"><span class="title">printWarn</span></span> = (line) -> process.stderr.write line + <span class="string">'\n'</span>
|
||||
|
||||
<span class="function"><span class="title">hidden</span></span> = (file) -> <span class="regexp">/^\.|~$/</span>.test file</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-4">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-4">¶</a>
|
||||
</div>
|
||||
<p>The help banner that is printed when <code>coffee</code> is called without arguments.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>BANNER = '''
|
||||
Usage: coffee [options] path/to/script.coffee -- [args]
|
||||
|
||||
If called without options, `coffee` will run your script.
|
||||
'''</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-5">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-5">¶</a>
|
||||
</div>
|
||||
<p>The list of all the valid option flags that <code>coffee</code> knows how to handle.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>SWITCHES = [
|
||||
[<span class="string">'-b'</span>, <span class="string">'--bare'</span>, <span class="string">'compile without a top-level function wrapper'</span>]
|
||||
[<span class="string">'-c'</span>, <span class="string">'--compile'</span>, <span class="string">'compile to JavaScript and save as .js files'</span>]
|
||||
[<span class="string">'-e'</span>, <span class="string">'--eval'</span>, <span class="string">'pass a string from the command line as input'</span>]
|
||||
[<span class="string">'-h'</span>, <span class="string">'--help'</span>, <span class="string">'display this help message'</span>]
|
||||
[<span class="string">'-i'</span>, <span class="string">'--interactive'</span>, <span class="string">'run an interactive CoffeeScript REPL'</span>]
|
||||
[<span class="string">'-j'</span>, <span class="string">'--join [FILE]'</span>, <span class="string">'concatenate the source CoffeeScript before compiling'</span>]
|
||||
[<span class="string">'-m'</span>, <span class="string">'--map'</span>, <span class="string">'generate source map and save as .map files'</span>]
|
||||
[<span class="string">'-n'</span>, <span class="string">'--nodes'</span>, <span class="string">'print out the parse tree that the parser produces'</span>]
|
||||
[ <span class="string">'--nodejs [ARGS]'</span>, <span class="string">'pass options directly to the "node" binary'</span>]
|
||||
[<span class="string">'-o'</span>, <span class="string">'--output [DIR]'</span>, <span class="string">'set the output directory for compiled JavaScript'</span>]
|
||||
[<span class="string">'-p'</span>, <span class="string">'--print'</span>, <span class="string">'print out the compiled JavaScript'</span>]
|
||||
[<span class="string">'-s'</span>, <span class="string">'--stdio'</span>, <span class="string">'listen for and compile scripts over stdio'</span>]
|
||||
[<span class="string">'-l'</span>, <span class="string">'--literate'</span>, <span class="string">'treat stdio as literate style coffee-script'</span>]
|
||||
[<span class="string">'-t'</span>, <span class="string">'--tokens'</span>, <span class="string">'print out the tokens that the lexer/rewriter produce'</span>]
|
||||
[<span class="string">'-v'</span>, <span class="string">'--version'</span>, <span class="string">'display the version number'</span>]
|
||||
[<span class="string">'-w'</span>, <span class="string">'--watch'</span>, <span class="string">'watch scripts for changes and rerun commands'</span>]
|
||||
]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-6">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-6">¶</a>
|
||||
</div>
|
||||
<p>Top-level objects shared by all the functions.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>opts = {}
|
||||
sources = []
|
||||
sourceCode = []
|
||||
notSources = {}
|
||||
watchers = {}
|
||||
optionParser = <span class="literal">null</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-7">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-7">¶</a>
|
||||
</div>
|
||||
<p>Run <code>coffee</code> by parsing passed options and determining what action to take.
|
||||
Many flags cause us to divert before compiling anything. Flags passed after
|
||||
<code>--</code> will be passed verbatim to your script as arguments in <code>process.argv</code>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">run</span></span> = ->
|
||||
parseOptions()
|
||||
<span class="keyword">return</span> forkNode() <span class="keyword">if</span> opts.nodejs
|
||||
<span class="keyword">return</span> usage() <span class="keyword">if</span> opts.help
|
||||
<span class="keyword">return</span> version() <span class="keyword">if</span> opts.version
|
||||
<span class="keyword">return</span> require(<span class="string">'./repl'</span>).start() <span class="keyword">if</span> opts.interactive
|
||||
<span class="keyword">if</span> opts.watch <span class="keyword">and</span> <span class="keyword">not</span> fs.watch
|
||||
<span class="keyword">return</span> printWarn <span class="string">"The --watch feature depends on Node v0.6.0+. You are running <span class="subst">#{process.version}</span>."</span>
|
||||
<span class="keyword">return</span> compileStdio() <span class="keyword">if</span> opts.stdio
|
||||
<span class="keyword">return</span> compileScript <span class="literal">null</span>, sources[<span class="number">0</span>] <span class="keyword">if</span> opts.eval
|
||||
<span class="keyword">return</span> require(<span class="string">'./repl'</span>).start() <span class="keyword">unless</span> sources.length
|
||||
literals = <span class="keyword">if</span> opts.run <span class="keyword">then</span> sources.splice <span class="number">1</span> <span class="keyword">else</span> []
|
||||
process.argv = process.argv[<span class="number">0.</span><span class="number">.1</span>].concat literals
|
||||
process.argv[<span class="number">0</span>] = <span class="string">'coffee'</span>
|
||||
<span class="keyword">for</span> source <span class="keyword">in</span> sources
|
||||
compilePath source, <span class="literal">yes</span>, path.normalize source</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
<p>Compile a path, which could be a script or a directory. If a directory
|
||||
is passed, recursively compile all '.coffee', '.litcoffee', and '.coffee.md'
|
||||
extension source files in it and all subdirectories.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">compilePath</span></span> = (source, topLevel, base) ->
|
||||
fs.stat source, (err, stats) ->
|
||||
<span class="keyword">throw</span> err <span class="keyword">if</span> err <span class="keyword">and</span> err.code <span class="keyword">isnt</span> <span class="string">'ENOENT'</span>
|
||||
<span class="keyword">if</span> err?.code <span class="keyword">is</span> <span class="string">'ENOENT'</span>
|
||||
console.error <span class="string">"File not found: <span class="subst">#{source}</span>"</span>
|
||||
process.exit <span class="number">1</span>
|
||||
<span class="keyword">if</span> stats.isDirectory() <span class="keyword">and</span> path.dirname(source) <span class="keyword">isnt</span> <span class="string">'node_modules'</span>
|
||||
watchDir source, base <span class="keyword">if</span> opts.watch
|
||||
fs.readdir source, (err, files) ->
|
||||
<span class="keyword">throw</span> err <span class="keyword">if</span> err <span class="keyword">and</span> err.code <span class="keyword">isnt</span> <span class="string">'ENOENT'</span>
|
||||
<span class="keyword">return</span> <span class="keyword">if</span> err?.code <span class="keyword">is</span> <span class="string">'ENOENT'</span>
|
||||
index = sources.indexOf source
|
||||
files = files.filter (file) -> <span class="keyword">not</span> hidden file
|
||||
sources[index..index] = (path.join source, file <span class="keyword">for</span> file <span class="keyword">in</span> files)
|
||||
sourceCode[index..index] = files.map -> <span class="literal">null</span>
|
||||
files.forEach (file) ->
|
||||
compilePath (path.join source, file), <span class="literal">no</span>, base
|
||||
<span class="keyword">else</span> <span class="keyword">if</span> topLevel <span class="keyword">or</span> helpers.isCoffee source
|
||||
watch source, base <span class="keyword">if</span> opts.watch
|
||||
fs.readFile source, (err, code) ->
|
||||
<span class="keyword">throw</span> err <span class="keyword">if</span> err <span class="keyword">and</span> err.code <span class="keyword">isnt</span> <span class="string">'ENOENT'</span>
|
||||
<span class="keyword">return</span> <span class="keyword">if</span> err?.code <span class="keyword">is</span> <span class="string">'ENOENT'</span>
|
||||
compileScript(source, code.toString(), base)
|
||||
<span class="keyword">else</span>
|
||||
notSources[source] = <span class="literal">yes</span>
|
||||
removeSource source, base</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-9">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
</div>
|
||||
<p>Compile a single source script, containing the given code, according to the
|
||||
requested options. If evaluating the script directly sets <code>__filename</code>,
|
||||
<code>__dirname</code> and <code>module.filename</code> to be correct relative to the script's path.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">compileScript</span></span> = (file, input, base=<span class="literal">null</span>) ->
|
||||
o = opts
|
||||
options = compileOptions file, base
|
||||
<span class="keyword">try</span>
|
||||
t = task = {file, input, options}
|
||||
CoffeeScript.emit <span class="string">'compile'</span>, task
|
||||
<span class="keyword">if</span> o.tokens <span class="keyword">then</span> printTokens CoffeeScript.tokens t.input, t.options
|
||||
<span class="keyword">else</span> <span class="keyword">if</span> o.nodes <span class="keyword">then</span> printLine CoffeeScript.nodes(t.input, t.options).toString().trim()
|
||||
<span class="keyword">else</span> <span class="keyword">if</span> o.run <span class="keyword">then</span> CoffeeScript.run t.input, t.options
|
||||
<span class="keyword">else</span> <span class="keyword">if</span> o.join <span class="keyword">and</span> t.file <span class="keyword">isnt</span> o.join
|
||||
t.input = helpers.invertLiterate t.input <span class="keyword">if</span> helpers.isLiterate file
|
||||
sourceCode[sources.indexOf(t.file)] = t.input
|
||||
compileJoin()
|
||||
<span class="keyword">else</span>
|
||||
compiled = CoffeeScript.compile t.input, t.options
|
||||
t.output = compiled
|
||||
<span class="keyword">if</span> o.map
|
||||
t.output = compiled.js
|
||||
t.sourceMap = compiled.v3SourceMap
|
||||
|
||||
CoffeeScript.emit <span class="string">'success'</span>, task
|
||||
<span class="keyword">if</span> o.print
|
||||
printLine t.output.trim()
|
||||
<span class="keyword">else</span> <span class="keyword">if</span> o.compile <span class="keyword">or</span> o.map
|
||||
writeJs base, t.file, t.output, options.jsPath, t.sourceMap
|
||||
<span class="keyword">catch</span> err
|
||||
CoffeeScript.emit <span class="string">'failure'</span>, err, task
|
||||
<span class="keyword">return</span> <span class="keyword">if</span> CoffeeScript.listeners(<span class="string">'failure'</span>).length
|
||||
useColors = process.stdout.isTTY <span class="keyword">and</span> <span class="keyword">not</span> process.env.NODE_DISABLE_COLORS
|
||||
message = helpers.prettyErrorMessage err, file <span class="keyword">or</span> <span class="string">'[stdin]'</span>, input, useColors
|
||||
<span class="keyword">if</span> o.watch
|
||||
printLine message + <span class="string">'\x07'</span>
|
||||
<span class="keyword">else</span>
|
||||
printWarn message
|
||||
process.exit <span class="number">1</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-10">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
</div>
|
||||
<p>Attach the appropriate listeners to compile scripts incoming over <strong>stdin</strong>,
|
||||
and write them back to <strong>stdout</strong>.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">compileStdio</span></span> = ->
|
||||
code = <span class="string">''</span>
|
||||
stdin = process.openStdin()
|
||||
stdin.<span class="literal">on</span> <span class="string">'data'</span>, (buffer) ->
|
||||
code += buffer.toString() <span class="keyword">if</span> buffer
|
||||
stdin.<span class="literal">on</span> <span class="string">'end'</span>, ->
|
||||
compileScript <span class="literal">null</span>, code</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-11">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
</div>
|
||||
<p>If all of the source files are done being read, concatenate and compile
|
||||
them together.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>joinTimeout = <span class="literal">null</span>
|
||||
<span class="function"><span class="title">compileJoin</span></span> = ->
|
||||
<span class="keyword">return</span> <span class="keyword">unless</span> opts.join
|
||||
<span class="keyword">unless</span> sourceCode.some((code) -> code <span class="keyword">is</span> <span class="literal">null</span>)
|
||||
clearTimeout joinTimeout
|
||||
joinTimeout = wait <span class="number">100</span>, ->
|
||||
compileScript opts.join, sourceCode.join(<span class="string">'\n'</span>), opts.join</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-12">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
</div>
|
||||
<p>Watch a source CoffeeScript file using <code>fs.watch</code>, recompiling it every
|
||||
time the file is updated. May be used in combination with other options,
|
||||
such as <code>--print</code>.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">watch</span></span> = (source, base) ->
|
||||
|
||||
prevStats = <span class="literal">null</span>
|
||||
compileTimeout = <span class="literal">null</span>
|
||||
|
||||
<span class="function"><span class="title">watchErr</span></span> = (e) ->
|
||||
<span class="keyword">if</span> e.code <span class="keyword">is</span> <span class="string">'ENOENT'</span>
|
||||
<span class="keyword">return</span> <span class="keyword">if</span> sources.indexOf(source) <span class="keyword">is</span> -<span class="number">1</span>
|
||||
<span class="keyword">try</span>
|
||||
rewatch()
|
||||
compile()
|
||||
<span class="keyword">catch</span> e
|
||||
removeSource source, base, <span class="literal">yes</span>
|
||||
compileJoin()
|
||||
<span class="keyword">else</span> <span class="keyword">throw</span> e
|
||||
|
||||
<span class="function"><span class="title">compile</span></span> = ->
|
||||
clearTimeout compileTimeout
|
||||
compileTimeout = wait <span class="number">25</span>, ->
|
||||
fs.stat source, (err, stats) ->
|
||||
<span class="keyword">return</span> watchErr err <span class="keyword">if</span> err
|
||||
<span class="keyword">return</span> rewatch() <span class="keyword">if</span> prevStats <span class="keyword">and</span> stats.size <span class="keyword">is</span> prevStats.size <span class="keyword">and</span>
|
||||
stats.mtime.getTime() <span class="keyword">is</span> prevStats.mtime.getTime()
|
||||
prevStats = stats
|
||||
fs.readFile source, (err, code) ->
|
||||
<span class="keyword">return</span> watchErr err <span class="keyword">if</span> err
|
||||
compileScript(source, code.toString(), base)
|
||||
rewatch()
|
||||
|
||||
<span class="keyword">try</span>
|
||||
watcher = fs.watch source, compile
|
||||
<span class="keyword">catch</span> e
|
||||
watchErr e
|
||||
|
||||
<span class="function"><span class="title">rewatch</span></span> = ->
|
||||
watcher?.close()
|
||||
watcher = fs.watch source, compile</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-13">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-13">¶</a>
|
||||
</div>
|
||||
<p>Watch a directory of files for new additions.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">watchDir</span></span> = (source, base) ->
|
||||
readdirTimeout = <span class="literal">null</span>
|
||||
<span class="keyword">try</span>
|
||||
watcher = fs.watch source, ->
|
||||
clearTimeout readdirTimeout
|
||||
readdirTimeout = wait <span class="number">25</span>, ->
|
||||
fs.readdir source, (err, files) ->
|
||||
<span class="keyword">if</span> err
|
||||
<span class="keyword">throw</span> err <span class="keyword">unless</span> err.code <span class="keyword">is</span> <span class="string">'ENOENT'</span>
|
||||
watcher.close()
|
||||
<span class="keyword">return</span> unwatchDir source, base
|
||||
<span class="keyword">for</span> file <span class="keyword">in</span> files <span class="keyword">when</span> <span class="keyword">not</span> hidden(file) <span class="keyword">and</span> <span class="keyword">not</span> notSources[file]
|
||||
file = path.join source, file
|
||||
<span class="keyword">continue</span> <span class="keyword">if</span> sources.some (s) -> s.indexOf(file) >= <span class="number">0</span>
|
||||
sources.push file
|
||||
sourceCode.push <span class="literal">null</span>
|
||||
compilePath file, <span class="literal">no</span>, base
|
||||
<span class="keyword">catch</span> e
|
||||
<span class="keyword">throw</span> e <span class="keyword">unless</span> e.code <span class="keyword">is</span> <span class="string">'ENOENT'</span>
|
||||
|
||||
<span class="function"><span class="title">unwatchDir</span></span> = (source, base) ->
|
||||
prevSources = sources[..]
|
||||
toRemove = (file <span class="keyword">for</span> file <span class="keyword">in</span> sources <span class="keyword">when</span> file.indexOf(source) >= <span class="number">0</span>)
|
||||
removeSource file, base, <span class="literal">yes</span> <span class="keyword">for</span> file <span class="keyword">in</span> toRemove
|
||||
<span class="keyword">return</span> <span class="keyword">unless</span> sources.some (s, i) -> prevSources[i] <span class="keyword">isnt</span> s
|
||||
compileJoin()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-14">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-14">¶</a>
|
||||
</div>
|
||||
<p>Remove a file from our source list, and source code cache. Optionally remove
|
||||
the compiled JS version as well.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">removeSource</span></span> = (source, base, removeJs) ->
|
||||
index = sources.indexOf source
|
||||
sources.splice index, <span class="number">1</span>
|
||||
sourceCode.splice index, <span class="number">1</span>
|
||||
<span class="keyword">if</span> removeJs <span class="keyword">and</span> <span class="keyword">not</span> opts.join
|
||||
jsPath = outputPath source, base
|
||||
exists jsPath, (itExists) ->
|
||||
<span class="keyword">if</span> itExists
|
||||
fs.unlink jsPath, (err) ->
|
||||
<span class="keyword">throw</span> err <span class="keyword">if</span> err <span class="keyword">and</span> err.code <span class="keyword">isnt</span> <span class="string">'ENOENT'</span>
|
||||
timeLog <span class="string">"removed <span class="subst">#{source}</span>"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-15">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
</div>
|
||||
<p>Get the corresponding output JavaScript path for a source file.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">outputPath</span></span> = (source, base, extension=<span class="string">".js"</span>) ->
|
||||
basename = helpers.baseFileName source, <span class="literal">yes</span>, useWinPathSep
|
||||
srcDir = path.dirname source
|
||||
baseDir = <span class="keyword">if</span> base <span class="keyword">is</span> <span class="string">'.'</span> <span class="keyword">then</span> srcDir <span class="keyword">else</span> srcDir.substring base.length
|
||||
dir = <span class="keyword">if</span> opts.output <span class="keyword">then</span> path.join opts.output, baseDir <span class="keyword">else</span> srcDir
|
||||
path.join dir, basename + extension</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-16">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-16">¶</a>
|
||||
</div>
|
||||
<p>Write out a JavaScript source file with the compiled code. By default, files
|
||||
are written out in <code>cwd</code> as <code>.js</code> files with the same name, but the output
|
||||
directory can be customized with <code>--output</code>.
|
||||
|
||||
</p>
|
||||
<p>If <code>generatedSourceMap</code> is provided, this will write a <code>.map</code> file into the
|
||||
same directory as the <code>.js</code> file.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">writeJs</span></span> = (base, sourcePath, js, jsPath, generatedSourceMap = <span class="literal">null</span>) ->
|
||||
sourceMapPath = outputPath sourcePath, base, <span class="string">".map"</span>
|
||||
jsDir = path.dirname jsPath
|
||||
<span class="function"><span class="title">compile</span></span> = ->
|
||||
<span class="keyword">if</span> opts.compile
|
||||
js = <span class="string">' '</span> <span class="keyword">if</span> js.length <= <span class="number">0</span>
|
||||
<span class="keyword">if</span> generatedSourceMap <span class="keyword">then</span> js = <span class="string">"<span class="subst">#{js}</span>\n/*\n//@ sourceMappingURL=<span class="subst">#{helpers.baseFileName sourceMapPath, <span class="literal">no</span>, useWinPathSep}</span>\n*/\n"</span>
|
||||
fs.writeFile jsPath, js, (err) ->
|
||||
<span class="keyword">if</span> err
|
||||
printLine err.message
|
||||
<span class="keyword">else</span> <span class="keyword">if</span> opts.compile <span class="keyword">and</span> opts.watch
|
||||
timeLog <span class="string">"compiled <span class="subst">#{sourcePath}</span>"</span>
|
||||
<span class="keyword">if</span> generatedSourceMap
|
||||
fs.writeFile sourceMapPath, generatedSourceMap, (err) ->
|
||||
<span class="keyword">if</span> err
|
||||
printLine <span class="string">"Could not write source map: <span class="subst">#{err.message}</span>"</span>
|
||||
exists jsDir, (itExists) ->
|
||||
<span class="keyword">if</span> itExists <span class="keyword">then</span> compile() <span class="keyword">else</span> exec <span class="string">"mkdir -p <span class="subst">#{jsDir}</span>"</span>, compile</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-17">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-17">¶</a>
|
||||
</div>
|
||||
<p>Convenience for cleaner setTimeouts.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">wait</span></span> = (milliseconds, func) -> setTimeout func, milliseconds</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-18">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
</div>
|
||||
<p>When watching scripts, it's useful to log changes with the timestamp.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">timeLog</span></span> = (message) ->
|
||||
console.log <span class="string">"<span class="subst">#{(<span class="keyword">new</span> Date).toLocaleTimeString()}</span> - <span class="subst">#{message}</span>"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-19">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-19">¶</a>
|
||||
</div>
|
||||
<p>Pretty-print a stream of tokens, sans location data.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">printTokens</span></span> = (tokens) ->
|
||||
strings = <span class="keyword">for</span> token <span class="keyword">in</span> tokens
|
||||
tag = token[<span class="number">0</span>]
|
||||
value = token[<span class="number">1</span>].toString().replace(<span class="regexp">/\n/</span>, <span class="string">'\\n'</span>)
|
||||
<span class="string">"[<span class="subst">#{tag}</span> <span class="subst">#{value}</span>]"</span>
|
||||
printLine strings.join(<span class="string">' '</span>)</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-20">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-20">¶</a>
|
||||
</div>
|
||||
<p>Use the <a href="optparse.html">OptionParser module</a> to extract all options from
|
||||
<code>process.argv</code> that are specified in <code>SWITCHES</code>.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">parseOptions</span></span> = ->
|
||||
optionParser = <span class="keyword">new</span> optparse.OptionParser SWITCHES, BANNER
|
||||
o = opts = optionParser.parse process.argv[<span class="number">2.</span>.]
|
||||
o.compile <span class="keyword">or</span>= !!o.output
|
||||
o.run = <span class="keyword">not</span> (o.compile <span class="keyword">or</span> o.print <span class="keyword">or</span> o.map)
|
||||
o.print = !! (o.print <span class="keyword">or</span> (o.eval <span class="keyword">or</span> o.stdio <span class="keyword">and</span> o.compile))
|
||||
sources = o.arguments
|
||||
sourceCode[i] = <span class="literal">null</span> <span class="keyword">for</span> source, i <span class="keyword">in</span> sources
|
||||
<span class="keyword">return</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-21">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-21">¶</a>
|
||||
</div>
|
||||
<p>The compile-time options to pass to the CoffeeScript compiler.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">compileOptions</span></span> = (filename, base) ->
|
||||
answer = {
|
||||
filename
|
||||
literate: opts.literate <span class="keyword">or</span> helpers.isLiterate(filename)
|
||||
bare: opts.bare
|
||||
header: opts.compile
|
||||
sourceMap: opts.map
|
||||
}
|
||||
<span class="keyword">if</span> filename
|
||||
<span class="keyword">if</span> base
|
||||
cwd = process.cwd()
|
||||
jsPath = outputPath filename, base
|
||||
jsDir = path.dirname jsPath
|
||||
answer = helpers.merge answer, {
|
||||
jsPath
|
||||
sourceRoot: path.relative jsDir, cwd
|
||||
sourceFiles: [path.relative cwd, filename]
|
||||
generatedFile: helpers.baseFileName(jsPath, <span class="literal">no</span>, useWinPathSep)
|
||||
}
|
||||
<span class="keyword">else</span>
|
||||
answer = helpers.merge answer,
|
||||
sourceRoot: <span class="string">""</span>
|
||||
sourceFiles: [helpers.baseFileName filename, <span class="literal">no</span>, useWinPathSep]
|
||||
generatedFile: helpers.baseFileName(filename, <span class="literal">yes</span>, useWinPathSep) + <span class="string">".js"</span>
|
||||
answer</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-22">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-22">¶</a>
|
||||
</div>
|
||||
<p>Start up a new Node.js instance with the arguments in <code>--nodejs</code> passed to
|
||||
the <code>node</code> binary, preserving the other options.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">forkNode</span></span> = ->
|
||||
nodeArgs = opts.nodejs.split <span class="regexp">/\s+/</span>
|
||||
args = process.argv[<span class="number">1.</span>.]
|
||||
args.splice args.indexOf(<span class="string">'--nodejs'</span>), <span class="number">2</span>
|
||||
spawn process.execPath, nodeArgs.concat(args),
|
||||
cwd: process.cwd()
|
||||
env: process.env
|
||||
customFds: [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-23">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-23">¶</a>
|
||||
</div>
|
||||
<p>Print the <code>--help</code> usage message and exit. Deprecated switches are not
|
||||
shown.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">usage</span></span> = ->
|
||||
printLine (<span class="keyword">new</span> optparse.OptionParser SWITCHES, BANNER).help()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-24">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-24">¶</a>
|
||||
</div>
|
||||
<p>Print the <code>--version</code> message and exit.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">version</span></span> = ->
|
||||
printLine <span class="string">"CoffeeScript version <span class="subst">#{CoffeeScript.VERSION}</span>"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,595 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>helpers.coffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>helpers.coffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
<p>This file contains the common helper functions that we'd like to share among
|
||||
the <strong>Lexer</strong>, <strong>Rewriter</strong>, and the <strong>Nodes</strong>. Merge objects, flatten
|
||||
arrays, count characters, that sort of thing.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-2">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-2">¶</a>
|
||||
</div>
|
||||
<p>Peek at the beginning of a given string to see if it matches a sequence.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">starts</span></span> = (string, literal, start) ->
|
||||
literal <span class="keyword">is</span> string.substr start, literal.length</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-3">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-3">¶</a>
|
||||
</div>
|
||||
<p>Peek at the end of a given string to see if it matches a sequence.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">ends</span></span> = (string, literal, back) ->
|
||||
len = literal.length
|
||||
literal <span class="keyword">is</span> string.substr string.length - len - (back <span class="keyword">or</span> <span class="number">0</span>), len</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-4">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-4">¶</a>
|
||||
</div>
|
||||
<p>Repeat a string <code>n</code> times.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.repeat = <span class="function"><span class="title">repeat</span></span> = (str, n) -></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-5">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-5">¶</a>
|
||||
</div>
|
||||
<p>Use clever algorithm to have O(log(n)) string concatenation operations.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> res = <span class="string">''</span>
|
||||
<span class="keyword">while</span> n > <span class="number">0</span>
|
||||
res += str <span class="keyword">if</span> n & <span class="number">1</span>
|
||||
n >>>= <span class="number">1</span>
|
||||
str += str
|
||||
res</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-6">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-6">¶</a>
|
||||
</div>
|
||||
<p>Trim out all falsy values from an array.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">compact</span></span> = (array) ->
|
||||
item <span class="keyword">for</span> item <span class="keyword">in</span> array <span class="keyword">when</span> item</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-7">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-7">¶</a>
|
||||
</div>
|
||||
<p>Count the number of occurrences of a string in a string.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">count</span></span> = (string, substr) ->
|
||||
num = pos = <span class="number">0</span>
|
||||
<span class="keyword">return</span> <span class="number">1</span>/<span class="number">0</span> <span class="keyword">unless</span> substr.length
|
||||
num++ <span class="keyword">while</span> pos = <span class="number">1</span> + string.indexOf substr, pos
|
||||
num</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
<p>Merge objects, returning a fresh copy with attributes from both sides.
|
||||
Used every time <code>Base#compile</code> is called, to allow properties in the
|
||||
options hash to propagate down the tree without polluting other branches.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">merge</span></span> = (options, overrides) ->
|
||||
extend (extend {}, options), overrides</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-9">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
</div>
|
||||
<p>Extend a source object with the properties of another object (shallow copy).
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>extend = exports.<span class="function"><span class="title">extend</span></span> = (object, properties) ->
|
||||
<span class="keyword">for</span> key, val <span class="keyword">of</span> properties
|
||||
object[key] = val
|
||||
object</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-10">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
</div>
|
||||
<p>Return a flattened version of an array.
|
||||
Handy for getting a list of <code>children</code> from the nodes.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.flatten = <span class="function"><span class="title">flatten</span></span> = (array) ->
|
||||
flattened = []
|
||||
<span class="keyword">for</span> element <span class="keyword">in</span> array
|
||||
<span class="keyword">if</span> element <span class="keyword">instanceof</span> Array
|
||||
flattened = flattened.concat flatten element
|
||||
<span class="keyword">else</span>
|
||||
flattened.push element
|
||||
flattened</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-11">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
</div>
|
||||
<p>Delete a key from an object, returning the value. Useful when a node is
|
||||
looking for a particular method in an options hash.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">del</span></span> = (obj, key) ->
|
||||
val = obj[key]
|
||||
<span class="keyword">delete</span> obj[key]
|
||||
val</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-12">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
</div>
|
||||
<p>Gets the last item of an array(-like) object.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.last = <span class="function"><span class="title">last</span></span> = (array, back) -> array[array.length - (back <span class="keyword">or</span> <span class="number">0</span>) - <span class="number">1</span>]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-13">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-13">¶</a>
|
||||
</div>
|
||||
<p>Typical Array::some
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.some = Array::some ? (fn) ->
|
||||
<span class="keyword">return</span> <span class="literal">true</span> <span class="keyword">for</span> e <span class="keyword">in</span> <span class="keyword">this</span> <span class="keyword">when</span> fn e
|
||||
<span class="literal">false</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-14">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-14">¶</a>
|
||||
</div>
|
||||
<p>Simple function for inverting Literate CoffeeScript code by putting the
|
||||
documentation in comments, producing a string of CoffeeScript code that
|
||||
can be compiled "normally".
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">invertLiterate</span></span> = (code) ->
|
||||
maybe_code = <span class="literal">true</span>
|
||||
lines = <span class="keyword">for</span> line <span class="keyword">in</span> code.split(<span class="string">'\n'</span>)
|
||||
<span class="keyword">if</span> maybe_code <span class="keyword">and</span> <span class="regexp">/^([ ]{4}|[ ]{0,3}\t)/</span>.test line
|
||||
line
|
||||
<span class="keyword">else</span> <span class="keyword">if</span> maybe_code = <span class="regexp">/^\s*$/</span>.test line
|
||||
line
|
||||
<span class="keyword">else</span>
|
||||
<span class="string">'# '</span> + line
|
||||
lines.join <span class="string">'\n'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-15">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
</div>
|
||||
<p>Merge two jison-style location data objects together.
|
||||
If <code>last</code> is not provided, this will simply return <code>first</code>.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">buildLocationData</span></span> = (first, last) ->
|
||||
<span class="keyword">if</span> <span class="keyword">not</span> last
|
||||
first
|
||||
<span class="keyword">else</span>
|
||||
first_line: first.first_line
|
||||
first_column: first.first_column
|
||||
last_line: last.last_line
|
||||
last_column: last.last_column</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-16">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-16">¶</a>
|
||||
</div>
|
||||
<p>This returns a function which takes an object as a parameter, and if that
|
||||
object is an AST node, updates that object's locationData.
|
||||
The object is returned either way.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">addLocationDataFn</span></span> = (first, last) ->
|
||||
(obj) ->
|
||||
<span class="keyword">if</span> ((<span class="keyword">typeof</span> obj) <span class="keyword">is</span> <span class="string">'object'</span>) <span class="keyword">and</span> (!!obj[<span class="string">'updateLocationDataIfMissing'</span>])
|
||||
obj.updateLocationDataIfMissing buildLocationData(first, last)
|
||||
|
||||
<span class="keyword">return</span> obj</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-17">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-17">¶</a>
|
||||
</div>
|
||||
<p>Convert jison location data to a string.
|
||||
<code>obj</code> can be a token, or a locationData.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">locationDataToString</span></span> = (obj) ->
|
||||
<span class="keyword">if</span> (<span class="string">"2"</span> <span class="keyword">of</span> obj) <span class="keyword">and</span> (<span class="string">"first_line"</span> <span class="keyword">of</span> obj[<span class="number">2</span>]) <span class="keyword">then</span> locationData = obj[<span class="number">2</span>]
|
||||
<span class="keyword">else</span> <span class="keyword">if</span> <span class="string">"first_line"</span> <span class="keyword">of</span> obj <span class="keyword">then</span> locationData = obj
|
||||
|
||||
<span class="keyword">if</span> locationData
|
||||
<span class="string">"<span class="subst">#{locationData.first_line + <span class="number">1</span>}</span>:<span class="subst">#{locationData.first_column + <span class="number">1</span>}</span>-"</span> +
|
||||
<span class="string">"<span class="subst">#{locationData.last_line + <span class="number">1</span>}</span>:<span class="subst">#{locationData.last_column + <span class="number">1</span>}</span>"</span>
|
||||
<span class="keyword">else</span>
|
||||
<span class="string">"No location data"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-18">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
</div>
|
||||
<p>A <code>.coffee.md</code> compatible version of <code>basename</code>, that returns the file sans-extension.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">baseFileName</span></span> = (file, stripExt = <span class="literal">no</span>, useWinPathSep = <span class="literal">no</span>) ->
|
||||
pathSep = <span class="keyword">if</span> useWinPathSep <span class="keyword">then</span> <span class="regexp">/\\|\// else /\//</span>
|
||||
parts = file.split(pathSep)
|
||||
file = parts[parts.length - <span class="number">1</span>]
|
||||
<span class="keyword">return</span> file <span class="keyword">unless</span> stripExt
|
||||
parts = file.split(<span class="string">'.'</span>)
|
||||
parts.pop()
|
||||
parts.pop() <span class="keyword">if</span> parts[parts.length - <span class="number">1</span>] <span class="keyword">is</span> <span class="string">'coffee'</span> <span class="keyword">and</span> parts.length > <span class="number">1</span>
|
||||
parts.join(<span class="string">'.'</span>)</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-19">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-19">¶</a>
|
||||
</div>
|
||||
<p>Determine if a filename represents a CoffeeScript file.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">isCoffee</span></span> = (file) -> <span class="regexp">/\.((lit)?coffee|coffee\.md)$/</span>.test file</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-20">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-20">¶</a>
|
||||
</div>
|
||||
<p>Determine if a filename represents a Literate CoffeeScript file.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">isLiterate</span></span> = (file) -> <span class="regexp">/\.(litcoffee|coffee\.md)$/</span>.test file</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-21">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-21">¶</a>
|
||||
</div>
|
||||
<p>Throws a SyntaxError with a source file location data attached to it in a
|
||||
property called <code>location</code>.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">throwSyntaxError</span></span> = (message, location) ->
|
||||
location.last_line ?= location.first_line
|
||||
location.last_column ?= location.first_column
|
||||
error = <span class="keyword">new</span> SyntaxError message
|
||||
error.location = location
|
||||
<span class="keyword">throw</span> error</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-22">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-22">¶</a>
|
||||
</div>
|
||||
<p>Creates a nice error message like, following the "standard" format
|
||||
</p>
|
||||
<p><filename>:<line>:<col>: <message> plus the line with the error and a marker
|
||||
showing where the error is.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.<span class="function"><span class="title">prettyErrorMessage</span></span> = (error, fileName, code, useColors) ->
|
||||
<span class="keyword">return</span> error.stack <span class="keyword">or</span> <span class="string">"<span class="subst">#{error}</span>"</span> <span class="keyword">unless</span> error.location
|
||||
|
||||
{first_line, first_column, last_line, last_column} = error.location
|
||||
codeLine = code.split(<span class="string">'\n'</span>)[first_line]
|
||||
start = first_column</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-23">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-23">¶</a>
|
||||
</div>
|
||||
<p>Show only the first line on multi-line errors.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> end = <span class="keyword">if</span> first_line <span class="keyword">is</span> last_line <span class="keyword">then</span> last_column + <span class="number">1</span> <span class="keyword">else</span> codeLine.length
|
||||
marker = repeat(<span class="string">' '</span>, start) + repeat(<span class="string">'^'</span>, end - start)
|
||||
|
||||
<span class="keyword">if</span> useColors
|
||||
<span class="function"><span class="title">colorize</span></span> = (str) -> <span class="string">"\x1B[1;31m<span class="subst">#{str}</span>\x1B[0m"</span>
|
||||
codeLine = codeLine[...start] + colorize(codeLine[start...end]) + codeLine[end..]
|
||||
marker = colorize marker
|
||||
|
||||
message = <span class="string">"""
|
||||
<span class="subst">#{fileName}</span>:<span class="subst">#{first_line + <span class="number">1</span>}</span>:<span class="subst">#{first_column + <span class="number">1</span>}</span>: error: <span class="subst">#{error.message}</span>
|
||||
<span class="subst">#{codeLine}</span>
|
||||
<span class="subst">#{marker}</span>
|
||||
"""</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-24">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-24">¶</a>
|
||||
</div>
|
||||
<p>Uncomment to add stacktrace.
|
||||
message += "\n#{error.stack}"
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
message</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,123 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>index.coffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>index.coffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
<p>Loader for CoffeeScript as a Node.js library.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports[key] = val <span class="keyword">for</span> key, val <span class="keyword">of</span> require <span class="string">'./coffee-script'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,372 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>optparse.coffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>optparse.coffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>{repeat} = require <span class="string">'./helpers'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-2">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-2">¶</a>
|
||||
</div>
|
||||
<p>A simple <strong>OptionParser</strong> class to parse option flags from the command-line.
|
||||
Use it like so:
|
||||
|
||||
</p>
|
||||
<pre><code>parser = new OptionParser switches, helpBanner
|
||||
options = parser.parse process.argv</code></pre>
|
||||
<p>The first non-option is considered to be the start of the file (and file
|
||||
option) list, and all subsequent arguments are left unparsed.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>exports.OptionParser = <span class="class"><span class="keyword">class</span> <span class="title">OptionParser</span></span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-3">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-3">¶</a>
|
||||
</div>
|
||||
<p>Initialize with a list of valid options, in the form:
|
||||
|
||||
</p>
|
||||
<pre><code>[short-flag, long-flag, description]</code></pre>
|
||||
<p>Along with an an optional banner for the usage help.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> constructor: (rules, <span class="property">@banner</span>) ->
|
||||
<span class="property">@rules</span> = buildRules rules</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-4">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-4">¶</a>
|
||||
</div>
|
||||
<p>Parse the list of arguments, populating an <code>options</code> object with all of the
|
||||
specified options, and return it. Options after the first non-option
|
||||
argument are treated as arguments. <code>options.arguments</code> will be an array
|
||||
containing the remaining arguments. This is a simpler API than many option
|
||||
parsers that allow you to attach callback actions for every flag. Instead,
|
||||
you're responsible for interpreting the options object.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> parse: (args) ->
|
||||
options = arguments: []
|
||||
skippingArgument = <span class="literal">no</span>
|
||||
originalArgs = args
|
||||
args = normalizeArguments args
|
||||
<span class="keyword">for</span> arg, i <span class="keyword">in</span> args
|
||||
<span class="keyword">if</span> skippingArgument
|
||||
skippingArgument = <span class="literal">no</span>
|
||||
<span class="keyword">continue</span>
|
||||
<span class="keyword">if</span> arg <span class="keyword">is</span> <span class="string">'--'</span>
|
||||
pos = originalArgs.indexOf <span class="string">'--'</span>
|
||||
options.arguments = options.arguments.concat originalArgs[(pos + <span class="number">1</span>)..]
|
||||
<span class="keyword">break</span>
|
||||
isOption = !!(arg.match(LONG_FLAG) <span class="keyword">or</span> arg.match(SHORT_FLAG))</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-5">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-5">¶</a>
|
||||
</div>
|
||||
<p>the CS option parser is a little odd; options after the first
|
||||
non-option argument are treated as non-option arguments themselves
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> seenNonOptionArg = options.arguments.length > <span class="number">0</span>
|
||||
<span class="keyword">unless</span> seenNonOptionArg
|
||||
matchedRule = <span class="literal">no</span>
|
||||
<span class="keyword">for</span> rule <span class="keyword">in</span> <span class="property">@rules</span>
|
||||
<span class="keyword">if</span> rule.shortFlag <span class="keyword">is</span> arg <span class="keyword">or</span> rule.longFlag <span class="keyword">is</span> arg
|
||||
value = <span class="literal">true</span>
|
||||
<span class="keyword">if</span> rule.hasArgument
|
||||
skippingArgument = <span class="literal">yes</span>
|
||||
value = args[i + <span class="number">1</span>]
|
||||
options[rule.name] = <span class="keyword">if</span> rule.isList <span class="keyword">then</span> (options[rule.name] <span class="keyword">or</span> []).concat value <span class="keyword">else</span> value
|
||||
matchedRule = <span class="literal">yes</span>
|
||||
<span class="keyword">break</span>
|
||||
<span class="keyword">throw</span> <span class="keyword">new</span> Error <span class="string">"unrecognized option: <span class="subst">#{arg}</span>"</span> <span class="keyword">if</span> isOption <span class="keyword">and</span> <span class="keyword">not</span> matchedRule
|
||||
<span class="keyword">if</span> seenNonOptionArg <span class="keyword">or</span> <span class="keyword">not</span> isOption
|
||||
options.arguments.push arg
|
||||
options</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-6">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-6">¶</a>
|
||||
</div>
|
||||
<p>Return the help text for this <strong>OptionParser</strong>, listing and describing all
|
||||
of the valid options, for <code>--help</code> and such.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> help: ->
|
||||
lines = []
|
||||
lines.unshift <span class="string">"<span class="subst">#{@banner}</span>\n"</span> <span class="keyword">if</span> <span class="property">@banner</span>
|
||||
<span class="keyword">for</span> rule <span class="keyword">in</span> <span class="property">@rules</span>
|
||||
spaces = <span class="number">15</span> - rule.longFlag.length
|
||||
spaces = <span class="keyword">if</span> spaces > <span class="number">0</span> <span class="keyword">then</span> repeat <span class="string">' '</span>, spaces <span class="keyword">else</span> <span class="string">''</span>
|
||||
letPart = <span class="keyword">if</span> rule.shortFlag <span class="keyword">then</span> rule.shortFlag + <span class="string">', '</span> <span class="keyword">else</span> <span class="string">' '</span>
|
||||
lines.push <span class="string">' '</span> + letPart + rule.longFlag + spaces + rule.description
|
||||
<span class="string">"\n<span class="subst">#{ lines.join('\n') }</span>\n"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-7">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap for-h2">
|
||||
<a class="pilcrow" href="#section-7">¶</a>
|
||||
</div>
|
||||
<h2>Helpers</h2>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-9">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
</div>
|
||||
<p>Regex matchers for option flags.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>LONG_FLAG = <span class="regexp">/^(--\w[\w\-]*)/</span>
|
||||
SHORT_FLAG = <span class="regexp">/^(-\w)$/</span>
|
||||
MULTI_FLAG = <span class="regexp">/^-(\w{2,})/</span>
|
||||
OPTIONAL = <span class="regexp">/\[(\w+(\*?))\]/</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-10">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
</div>
|
||||
<p>Build and return the list of option rules. If the optional <em>short-flag</em> is
|
||||
unspecified, leave it out by padding with <code>null</code>.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">buildRules</span></span> = (rules) ->
|
||||
<span class="keyword">for</span> tuple <span class="keyword">in</span> rules
|
||||
tuple.unshift <span class="literal">null</span> <span class="keyword">if</span> tuple.length < <span class="number">3</span>
|
||||
buildRule tuple...</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-11">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
</div>
|
||||
<p>Build a rule from a <code>-o</code> short flag, a <code>--output [DIR]</code> long flag, and the
|
||||
description of what the option does.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">buildRule</span></span> = (shortFlag, longFlag, description, options = {}) ->
|
||||
match = longFlag.match(OPTIONAL)
|
||||
longFlag = longFlag.match(LONG_FLAG)[<span class="number">1</span>]
|
||||
{
|
||||
name: longFlag.substr <span class="number">2</span>
|
||||
shortFlag: shortFlag
|
||||
longFlag: longFlag
|
||||
description: description
|
||||
hasArgument: !!(match <span class="keyword">and</span> match[<span class="number">1</span>])
|
||||
isList: !!(match <span class="keyword">and</span> match[<span class="number">2</span>])
|
||||
}</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-12">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
</div>
|
||||
<p>Normalize arguments by expanding merged flags into multiple flags. This allows
|
||||
you to have <code>-wl</code> be the same as <code>--watch --lint</code>.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">normalizeArguments</span></span> = (args) ->
|
||||
args = args[..]
|
||||
result = []
|
||||
<span class="keyword">for</span> arg <span class="keyword">in</span> args
|
||||
<span class="keyword">if</span> match = arg.match MULTI_FLAG
|
||||
result.push <span class="string">'-'</span> + l <span class="keyword">for</span> l <span class="keyword">in</span> match[<span class="number">1</span>].split <span class="string">''</span>
|
||||
<span class="keyword">else</span>
|
||||
result.push arg
|
||||
result</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,514 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>repl.coffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>repl.coffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>fs = require <span class="string">'fs'</span>
|
||||
path = require <span class="string">'path'</span>
|
||||
vm = require <span class="string">'vm'</span>
|
||||
nodeREPL = require <span class="string">'repl'</span>
|
||||
CoffeeScript = require <span class="string">'./coffee-script'</span>
|
||||
{merge, prettyErrorMessage} = require <span class="string">'./helpers'</span>
|
||||
|
||||
replDefaults =
|
||||
prompt: <span class="string">'coffee> '</span>,
|
||||
historyFile: path.join process.env.HOME, <span class="string">'.coffee_history'</span> <span class="keyword">if</span> process.env.HOME
|
||||
historyMaxInputSize: <span class="number">10240</span>
|
||||
eval: (input, context, filename, cb) -></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-2">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-2">¶</a>
|
||||
</div>
|
||||
<p>XXX: multiline hack.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> input = input.replace <span class="regexp">/\uFF00/g</span>, <span class="string">'\n'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-3">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-3">¶</a>
|
||||
</div>
|
||||
<p>Node's REPL sends the input ending with a newline and then wrapped in
|
||||
parens. Unwrap all that.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> input = input.replace <span class="regexp">/^\(([\s\S]*)\n\)$/m</span>, <span class="string">'$1'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-4">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-4">¶</a>
|
||||
</div>
|
||||
<p>Require AST nodes to do some AST manipulation.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> {Block, Assign, Value, Literal} = require <span class="string">'./nodes'</span>
|
||||
|
||||
<span class="keyword">try</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-5">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-5">¶</a>
|
||||
</div>
|
||||
<p>Generate the AST of the clean input.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> ast = CoffeeScript.nodes input</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-6">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-6">¶</a>
|
||||
</div>
|
||||
<p>Add assignment to <code>_</code> variable to force the input to be an expression.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> ast = <span class="keyword">new</span> Block [
|
||||
<span class="keyword">new</span> Assign (<span class="keyword">new</span> Value <span class="keyword">new</span> Literal <span class="string">'_'</span>), ast, <span class="string">'='</span>
|
||||
]
|
||||
js = ast.compile bare: <span class="literal">yes</span>, locals: Object.keys(context)
|
||||
cb <span class="literal">null</span>, vm.runInContext(js, context, filename)
|
||||
<span class="keyword">catch</span> err
|
||||
cb prettyErrorMessage(err, filename, input, <span class="literal">yes</span>)
|
||||
|
||||
<span class="function"><span class="title">addMultilineHandler</span></span> = (repl) ->
|
||||
{rli, inputStream, outputStream} = repl
|
||||
|
||||
multiline =
|
||||
enabled: <span class="literal">off</span>
|
||||
initialPrompt: repl.prompt.replace <span class="regexp">/^[^> ]*/, (x) -> x.replace /./g</span>, <span class="string">'-'</span>
|
||||
prompt: repl.prompt.replace <span class="regexp">/^[^> ]*>?/, (x) -> x.replace /./g</span>, <span class="string">'.'</span>
|
||||
buffer: <span class="string">''</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-7">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-7">¶</a>
|
||||
</div>
|
||||
<p>Proxy node's line listener
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> nodeLineListener = rli.listeners(<span class="string">'line'</span>)[<span class="number">0</span>]
|
||||
rli.removeListener <span class="string">'line'</span>, nodeLineListener
|
||||
rli.<span class="literal">on</span> <span class="string">'line'</span>, (cmd) ->
|
||||
<span class="keyword">if</span> multiline.enabled
|
||||
multiline.buffer += <span class="string">"<span class="subst">#{cmd}</span>\n"</span>
|
||||
rli.setPrompt multiline.prompt
|
||||
rli.prompt <span class="literal">true</span>
|
||||
<span class="keyword">else</span>
|
||||
nodeLineListener cmd
|
||||
<span class="keyword">return</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
<p>Handle Ctrl-v
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> inputStream.<span class="literal">on</span> <span class="string">'keypress'</span>, (char, key) ->
|
||||
<span class="keyword">return</span> <span class="keyword">unless</span> key <span class="keyword">and</span> key.ctrl <span class="keyword">and</span> <span class="keyword">not</span> key.meta <span class="keyword">and</span> <span class="keyword">not</span> key.shift <span class="keyword">and</span> key.name <span class="keyword">is</span> <span class="string">'v'</span>
|
||||
<span class="keyword">if</span> multiline.enabled</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-9">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
</div>
|
||||
<p>allow arbitrarily switching between modes any time before multiple lines are entered
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="keyword">unless</span> multiline.buffer.match <span class="regexp">/\n/</span>
|
||||
multiline.enabled = <span class="keyword">not</span> multiline.enabled
|
||||
rli.setPrompt repl.prompt
|
||||
rli.prompt <span class="literal">true</span>
|
||||
<span class="keyword">return</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-10">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
</div>
|
||||
<p>no-op unless the current line is empty
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="keyword">return</span> <span class="keyword">if</span> rli.line? <span class="keyword">and</span> <span class="keyword">not</span> rli.line.match <span class="regexp">/^\s*$/</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-11">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
</div>
|
||||
<p>eval, print, loop
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> multiline.enabled = <span class="keyword">not</span> multiline.enabled
|
||||
rli.line = <span class="string">''</span>
|
||||
rli.cursor = <span class="number">0</span>
|
||||
rli.output.cursorTo <span class="number">0</span>
|
||||
rli.output.clearLine <span class="number">1</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-12">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
</div>
|
||||
<p>XXX: multiline hack
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> multiline.buffer = multiline.buffer.replace <span class="regexp">/\n/g</span>, <span class="string">'\uFF00'</span>
|
||||
rli.emit <span class="string">'line'</span>, multiline.buffer
|
||||
multiline.buffer = <span class="string">''</span>
|
||||
<span class="keyword">else</span>
|
||||
multiline.enabled = <span class="keyword">not</span> multiline.enabled
|
||||
rli.setPrompt multiline.initialPrompt
|
||||
rli.prompt <span class="literal">true</span>
|
||||
<span class="keyword">return</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-13">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-13">¶</a>
|
||||
</div>
|
||||
<p>Store and load command history from a file
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="function"><span class="title">addHistory</span></span> = (repl, filename, maxSize) ->
|
||||
lastLine = <span class="literal">null</span>
|
||||
<span class="keyword">try</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-14">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-14">¶</a>
|
||||
</div>
|
||||
<p>Get file info and at most maxSize of command history
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> stat = fs.statSync filename
|
||||
size = Math.min maxSize, stat.size</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-15">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
</div>
|
||||
<p>Read last <code>size</code> bytes from the file
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> readFd = fs.openSync filename, <span class="string">'r'</span>
|
||||
buffer = <span class="keyword">new</span> Buffer(size)
|
||||
fs.readSync readFd, buffer, <span class="number">0</span>, size, stat.size - size</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-16">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-16">¶</a>
|
||||
</div>
|
||||
<p>Set the history on the interpreter
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> repl.rli.history = buffer.toString().split(<span class="string">'\n'</span>).reverse()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-17">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-17">¶</a>
|
||||
</div>
|
||||
<p>If the history file was truncated we should pop off a potential partial line
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> repl.rli.history.pop() <span class="keyword">if</span> stat.size > maxSize</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-18">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
</div>
|
||||
<p>Shift off the final blank newline
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> repl.rli.history.shift() <span class="keyword">if</span> repl.rli.history[<span class="number">0</span>] <span class="keyword">is</span> <span class="string">''</span>
|
||||
repl.rli.historyIndex = -<span class="number">1</span>
|
||||
lastLine = repl.rli.history[<span class="number">0</span>]
|
||||
|
||||
fd = fs.openSync filename, <span class="string">'a'</span>
|
||||
|
||||
repl.rli.addListener <span class="string">'line'</span>, (code) ->
|
||||
<span class="keyword">if</span> code <span class="keyword">and</span> code.length <span class="keyword">and</span> code <span class="keyword">isnt</span> <span class="string">'.history'</span> <span class="keyword">and</span> lastLine <span class="keyword">isnt</span> code</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-19">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-19">¶</a>
|
||||
</div>
|
||||
<p>Save the latest command in the file
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> fs.write fd, <span class="string">"<span class="subst">#{code}</span>\n"</span>
|
||||
lastLine = code
|
||||
|
||||
repl.rli.<span class="literal">on</span> <span class="string">'exit'</span>, -> fs.close fd</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-20">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-20">¶</a>
|
||||
</div>
|
||||
<p>Add a command to show the history stack
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> repl.commands[<span class="string">'.history'</span>] =
|
||||
help: <span class="string">'Show command history'</span>
|
||||
action: ->
|
||||
repl.outputStream.write <span class="string">"<span class="subst">#{repl.rli.history[..].reverse().join '\n'}</span>\n"</span>
|
||||
repl.displayPrompt()
|
||||
|
||||
module.exports =
|
||||
start: (opts = {}) ->
|
||||
[major, minor, build] = process.versions.node.split(<span class="string">'.'</span>).map (n) -> parseInt(n)
|
||||
|
||||
<span class="keyword">if</span> major <span class="keyword">is</span> <span class="number">0</span> <span class="keyword">and</span> minor < <span class="number">8</span>
|
||||
console.warn <span class="string">"Node 0.8.0+ required for CoffeeScript REPL"</span>
|
||||
process.exit <span class="number">1</span>
|
||||
|
||||
opts = merge replDefaults, opts
|
||||
repl = nodeREPL.start opts
|
||||
repl.<span class="literal">on</span> <span class="string">'exit'</span>, -> repl.outputStream.write <span class="string">'\n'</span>
|
||||
addMultilineHandler repl
|
||||
addHistory repl, opts.historyFile, opts.historyMaxInputSize <span class="keyword">if</span> opts.historyFile
|
||||
repl</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,431 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>scope.litcoffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>scope.litcoffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
<p>The <strong>Scope</strong> class regulates lexical scoping within CoffeeScript. As you
|
||||
generate code, you create a tree of scopes in the same shape as the nested
|
||||
function bodies. Each scope knows about the variables declared within it,
|
||||
and has a reference to its parent enclosing scope. In this way, we know which
|
||||
variables are new and need to be declared with <code>var</code>, and which are shared
|
||||
with external scopes.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-2">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-2">¶</a>
|
||||
</div>
|
||||
<p>Import the helpers we plan to use.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
{extend, last} = require <span class="string">'./helpers'</span>
|
||||
|
||||
exports.Scope = <span class="class"><span class="keyword">class</span> <span class="title">Scope</span></span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-3">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-3">¶</a>
|
||||
</div>
|
||||
<p>The <code>root</code> is the top-level <strong>Scope</strong> object for a given file.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
<span class="property">@root</span>: <span class="literal">null</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-4">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-4">¶</a>
|
||||
</div>
|
||||
<p>Initialize a scope with its parent, for lookups up the chain,
|
||||
as well as a reference to the <strong>Block</strong> node it belongs to, which is
|
||||
where it should declare its variables, and a reference to the function that
|
||||
it belongs to.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
constructor: (<span class="property">@parent</span>, <span class="property">@expressions</span>, <span class="property">@method</span>) ->
|
||||
<span class="property">@variables</span> = [{name: <span class="string">'arguments'</span>, type: <span class="string">'arguments'</span>}]
|
||||
<span class="property">@positions</span> = {}
|
||||
Scope.root = <span class="keyword">this</span> <span class="keyword">unless</span> <span class="property">@parent</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-5">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-5">¶</a>
|
||||
</div>
|
||||
<p>Adds a new variable or overrides an existing one.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
add: (name, type, immediate) ->
|
||||
<span class="keyword">return</span> <span class="property">@parent</span>.add name, type, immediate <span class="keyword">if</span> <span class="property">@shared</span> <span class="keyword">and</span> <span class="keyword">not</span> immediate
|
||||
<span class="keyword">if</span> Object::hasOwnProperty.call <span class="property">@positions</span>, name
|
||||
<span class="property">@variables</span>[<span class="property">@positions</span>[name]].type = type
|
||||
<span class="keyword">else</span>
|
||||
<span class="property">@positions</span>[name] = <span class="property">@variables</span>.push({name, type}) - <span class="number">1</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-6">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-6">¶</a>
|
||||
</div>
|
||||
<p>When <code>super</code> is called, we need to find the name of the current method we're
|
||||
in, so that we know how to invoke the same method of the parent class. This
|
||||
can get complicated if super is being called from an inner function.
|
||||
<code>namedMethod</code> will walk up the scope tree until it either finds the first
|
||||
function object that has a name filled in, or bottoms out.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
namedMethod: ->
|
||||
<span class="keyword">return</span> <span class="property">@method</span> <span class="keyword">if</span> <span class="property">@method</span>?.name <span class="keyword">or</span> !<span class="property">@parent</span>
|
||||
<span class="property">@parent</span>.namedMethod()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-7">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-7">¶</a>
|
||||
</div>
|
||||
<p>Look up a variable name in lexical scope, and declare it if it does not
|
||||
already exist.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
find: (name) ->
|
||||
<span class="keyword">return</span> <span class="literal">yes</span> <span class="keyword">if</span> <span class="property">@check</span> name
|
||||
<span class="property">@add</span> name, <span class="string">'var'</span>
|
||||
<span class="literal">no</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
<p>Reserve a variable name as originating from a function parameter for this
|
||||
scope. No <code>var</code> required for internal references.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
parameter: (name) ->
|
||||
<span class="keyword">return</span> <span class="keyword">if</span> <span class="property">@shared</span> <span class="keyword">and</span> <span class="property">@parent</span>.check name, <span class="literal">yes</span>
|
||||
<span class="property">@add</span> name, <span class="string">'param'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-9">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
</div>
|
||||
<p>Just check to see if a variable has already been declared, without reserving,
|
||||
walks up to the root scope.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
check: (name) ->
|
||||
!!(<span class="property">@type</span>(name) <span class="keyword">or</span> <span class="property">@parent</span>?.check(name))</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-10">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
</div>
|
||||
<p>Generate a temporary variable name at the given index.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
temporary: (name, index) ->
|
||||
<span class="keyword">if</span> name.length > <span class="number">1</span>
|
||||
<span class="string">'_'</span> + name + <span class="keyword">if</span> index > <span class="number">1</span> <span class="keyword">then</span> index - <span class="number">1</span> <span class="keyword">else</span> <span class="string">''</span>
|
||||
<span class="keyword">else</span>
|
||||
<span class="string">'_'</span> + (index + parseInt name, <span class="number">36</span>).toString(<span class="number">36</span>).replace <span class="regexp">/\d/g</span>, <span class="string">'a'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-11">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
</div>
|
||||
<p>Gets the type of a variable.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
type: (name) ->
|
||||
<span class="keyword">return</span> v.type <span class="keyword">for</span> v <span class="keyword">in</span> <span class="property">@variables</span> <span class="keyword">when</span> v.name <span class="keyword">is</span> name
|
||||
<span class="literal">null</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-12">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
</div>
|
||||
<p>If we need to store an intermediate result, find an available name for a
|
||||
compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on...
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
freeVariable: (name, reserve=<span class="literal">true</span>) ->
|
||||
index = <span class="number">0</span>
|
||||
index++ <span class="keyword">while</span> <span class="property">@check</span>((temp = <span class="property">@temporary</span> name, index))
|
||||
<span class="property">@add</span> temp, <span class="string">'var'</span>, <span class="literal">yes</span> <span class="keyword">if</span> reserve
|
||||
temp</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-13">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-13">¶</a>
|
||||
</div>
|
||||
<p>Ensure that an assignment is made at the top of this scope
|
||||
(or at the top-level scope, if requested).
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
assign: (name, value) ->
|
||||
<span class="property">@add</span> name, {value, assigned: <span class="literal">yes</span>}, <span class="literal">yes</span>
|
||||
<span class="property">@hasAssignments</span> = <span class="literal">yes</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-14">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-14">¶</a>
|
||||
</div>
|
||||
<p>Does this scope have any declared variables?
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
hasDeclarations: ->
|
||||
!!<span class="property">@declaredVariables</span>().length</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-15">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
</div>
|
||||
<p>Return the list of variables first declared in this scope.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
declaredVariables: ->
|
||||
realVars = []
|
||||
tempVars = []
|
||||
<span class="keyword">for</span> v <span class="keyword">in</span> <span class="property">@variables</span> <span class="keyword">when</span> v.type <span class="keyword">is</span> <span class="string">'var'</span>
|
||||
(<span class="keyword">if</span> v.name.charAt(<span class="number">0</span>) <span class="keyword">is</span> <span class="string">'_'</span> <span class="keyword">then</span> tempVars <span class="keyword">else</span> realVars).push v.name
|
||||
realVars.sort().concat tempVars.sort()</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-16">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-16">¶</a>
|
||||
</div>
|
||||
<p>Return the list of assignments that are supposed to be made at the top
|
||||
of this scope.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
assignedVariables: ->
|
||||
<span class="string">"<span class="subst">#{v.name}</span> = <span class="subst">#{v.type.value}</span>"</span> <span class="keyword">for</span> v <span class="keyword">in</span> <span class="property">@variables</span> <span class="keyword">when</span> v.type.assigned</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,646 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>sourcemap.litcoffee</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
||||
<link rel="stylesheet" media="all" href="docco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="background"></div>
|
||||
|
||||
<ul id="jump_to">
|
||||
<li>
|
||||
<a class="large" href="javascript:void(0);">Jump To …</a>
|
||||
<a class="small" href="javascript:void(0);">+</a>
|
||||
<div id="jump_wrapper">
|
||||
<div id="jump_page">
|
||||
|
||||
|
||||
<a class="source" href="browser.html">
|
||||
browser.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="cake.html">
|
||||
cake.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="coffee-script.html">
|
||||
coffee-script.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="command.html">
|
||||
command.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="grammar.html">
|
||||
grammar.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="helpers.html">
|
||||
helpers.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="index.html">
|
||||
index.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="lexer.html">
|
||||
lexer.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="nodes.html">
|
||||
nodes.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="optparse.html">
|
||||
optparse.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="repl.html">
|
||||
repl.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="rewriter.html">
|
||||
rewriter.coffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="scope.html">
|
||||
scope.litcoffee
|
||||
</a>
|
||||
|
||||
|
||||
<a class="source" href="sourcemap.html">
|
||||
sourcemap.litcoffee
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="sections">
|
||||
|
||||
<li id="title">
|
||||
<div class="annotation">
|
||||
<h1>sourcemap.litcoffee</h1>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
<li id="section-1">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-1">¶</a>
|
||||
</div>
|
||||
<p>Source maps allow JavaScript runtimes to match running JavaScript back to
|
||||
the original source code that corresponds to it. This can be minified
|
||||
JavaScript, but in our case, we're concerned with mapping pretty-printed
|
||||
JavaScript back to CoffeeScript.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-2">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-2">¶</a>
|
||||
</div>
|
||||
<p>In order to produce maps, we must keep track of positions (line number, column number)
|
||||
that originated every node in the syntax tree, and be able to generate a
|
||||
<a href="https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit">map file</a>
|
||||
— which is a compact, VLQ-encoded representation of the JSON serialization
|
||||
of this information — to write out alongside the generated JavaScript.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-3">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap for-h2">
|
||||
<a class="pilcrow" href="#section-3">¶</a>
|
||||
</div>
|
||||
<h2>LineMap</h2>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-4">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-4">¶</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-5">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-5">¶</a>
|
||||
</div>
|
||||
<p>A <strong>LineMap</strong> object keeps track of information about original line and column
|
||||
positions for a single line of output JavaScript code.
|
||||
<strong>SourceMaps</strong> are implemented in terms of <strong>LineMaps</strong>.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
<span class="class"><span class="keyword">class</span> <span class="title">LineMap</span></span>
|
||||
constructor: (<span class="property">@line</span>) ->
|
||||
<span class="property">@columns</span> = []
|
||||
|
||||
add: (column, [sourceLine, sourceColumn], options={}) ->
|
||||
<span class="keyword">return</span> <span class="keyword">if</span> <span class="property">@columns</span>[column] <span class="keyword">and</span> options.noReplace
|
||||
<span class="property">@columns</span>[column] = {line: <span class="property">@line</span>, column, sourceLine, sourceColumn}
|
||||
|
||||
sourceLocation: (column) ->
|
||||
column-- <span class="keyword">until</span> (mapping = <span class="property">@columns</span>[column]) <span class="keyword">or</span> (column <= <span class="number">0</span>)
|
||||
mapping <span class="keyword">and</span> [mapping.sourceLine, mapping.sourceColumn]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-6">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap for-h2">
|
||||
<a class="pilcrow" href="#section-6">¶</a>
|
||||
</div>
|
||||
<h2>SourceMap</h2>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-7">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-7">¶</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
<p>Maps locations in a single generated JavaScript file back to locations in
|
||||
the original CoffeeScript source file.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-9">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
</div>
|
||||
<p>This is intentionally agnostic towards how a source map might be represented on
|
||||
disk. Once the compiler is ready to produce a "v3"-style source map, we can walk
|
||||
through the arrays of line and column buffer to produce it.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
<span class="class"><span class="keyword">class</span> <span class="title">SourceMap</span></span>
|
||||
constructor: ->
|
||||
<span class="property">@lines</span> = []</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-10">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
</div>
|
||||
<p>Adds a mapping to this SourceMap. <code>sourceLocation</code> and <code>generatedLocation</code>
|
||||
are both <code>[line, column]</code> arrays. If <code>options.noReplace</code> is true, then if there
|
||||
is already a mapping for the specified <code>line</code> and <code>column</code>, this will have no
|
||||
effect.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
add: (sourceLocation, generatedLocation, options = {}) ->
|
||||
[line, column] = generatedLocation
|
||||
lineMap = (<span class="property">@lines</span>[line] <span class="keyword">or</span>= <span class="keyword">new</span> LineMap(line))
|
||||
lineMap.add column, sourceLocation, options</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-11">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
</div>
|
||||
<p>Look up the original position of a given <code>line</code> and <code>column</code> in the generated
|
||||
code.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
sourceLocation: ([line, column]) ->
|
||||
line-- <span class="keyword">until</span> (lineMap = <span class="property">@lines</span>[line]) <span class="keyword">or</span> (line <= <span class="number">0</span>)
|
||||
lineMap <span class="keyword">and</span> lineMap.sourceLocation column</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-12">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap for-h2">
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
</div>
|
||||
<h2>V3 SourceMap Generation</h2>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-13">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-13">¶</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-14">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-14">¶</a>
|
||||
</div>
|
||||
<p>Builds up a V3 source map, returning the generated JSON as a string.
|
||||
<code>options.sourceRoot</code> may be used to specify the sourceRoot written to the source
|
||||
map. Also, <code>options.sourceFiles</code> and <code>options.generatedFile</code> may be passed to
|
||||
set "sources" and "file", respectively.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
generate: (options = {}, code = <span class="literal">null</span>) ->
|
||||
writingline = <span class="number">0</span>
|
||||
lastColumn = <span class="number">0</span>
|
||||
lastSourceLine = <span class="number">0</span>
|
||||
lastSourceColumn = <span class="number">0</span>
|
||||
needComma = <span class="literal">no</span>
|
||||
buffer = <span class="string">""</span>
|
||||
|
||||
<span class="keyword">for</span> lineMap, lineNumber <span class="keyword">in</span> <span class="property">@lines</span> <span class="keyword">when</span> lineMap
|
||||
<span class="keyword">for</span> mapping <span class="keyword">in</span> lineMap.columns <span class="keyword">when</span> mapping
|
||||
<span class="keyword">while</span> writingline < mapping.line
|
||||
lastColumn = <span class="number">0</span>
|
||||
needComma = <span class="literal">no</span>
|
||||
buffer += <span class="string">";"</span>
|
||||
writingline++</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-15">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
</div>
|
||||
<p>Write a comma if we've already written a segment on this line.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
<span class="keyword">if</span> needComma
|
||||
buffer += <span class="string">","</span>
|
||||
needComma = <span class="literal">no</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-16">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-16">¶</a>
|
||||
</div>
|
||||
<p>Write the next segment. Segments can be 1, 4, or 5 values. If just one, then it
|
||||
is a generated column which doesn't match anything in the source code.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-17">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-17">¶</a>
|
||||
</div>
|
||||
<p>The starting column in the generated source, relative to any previous recorded
|
||||
column for the current line:
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
buffer += <span class="property">@encodeVlq</span> mapping.column - lastColumn
|
||||
lastColumn = mapping.column</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-18">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
</div>
|
||||
<p>The index into the list of sources:
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
buffer += <span class="property">@encodeVlq</span> <span class="number">0</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-19">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-19">¶</a>
|
||||
</div>
|
||||
<p>The starting line in the original source, relative to the previous source line.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
buffer += <span class="property">@encodeVlq</span> mapping.sourceLine - lastSourceLine
|
||||
lastSourceLine = mapping.sourceLine</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-20">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-20">¶</a>
|
||||
</div>
|
||||
<p>The starting column in the original source, relative to the previous column.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
buffer += <span class="property">@encodeVlq</span> mapping.sourceColumn - lastSourceColumn
|
||||
lastSourceColumn = mapping.sourceColumn
|
||||
needComma = <span class="literal">yes</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-21">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-21">¶</a>
|
||||
</div>
|
||||
<p>Produce the canonical JSON object format for a "v3" source map.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
v3 =
|
||||
version: <span class="number">3</span>
|
||||
file: options.generatedFile <span class="keyword">or</span> <span class="string">''</span>
|
||||
sourceRoot: options.sourceRoot <span class="keyword">or</span> <span class="string">''</span>
|
||||
sources: options.sourceFiles <span class="keyword">or</span> [<span class="string">''</span>]
|
||||
names: []
|
||||
mappings: buffer
|
||||
|
||||
v3.sourcesContent = [code] <span class="keyword">if</span> options.inline
|
||||
|
||||
JSON.stringify v3, <span class="literal">null</span>, <span class="number">2</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-22">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap for-h2">
|
||||
<a class="pilcrow" href="#section-22">¶</a>
|
||||
</div>
|
||||
<h2>Base64 VLQ Encoding</h2>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-23">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-23">¶</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-24">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-24">¶</a>
|
||||
</div>
|
||||
<p>Note that SourceMap VLQ encoding is "backwards". MIDI-style VLQ encoding puts
|
||||
the most-significant-bit (MSB) from the original value into the MSB of the VLQ
|
||||
encoded value (see <a href="http://en.wikipedia.org/wiki/File:Uintvar_coding.svg">Wikipedia</a>).
|
||||
SourceMap VLQ does things the other way around, with the least significat four
|
||||
bits of the original value encoded into the first byte of the VLQ encoded value.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
VLQ_SHIFT = <span class="number">5</span>
|
||||
VLQ_CONTINUATION_BIT = <span class="number">1</span> << VLQ_SHIFT <span class="comment"># 0010 0000</span>
|
||||
VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - <span class="number">1</span> <span class="comment"># 0001 1111</span>
|
||||
|
||||
encodeVlq: (value) ->
|
||||
answer = <span class="string">''</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-25">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-25">¶</a>
|
||||
</div>
|
||||
<p>Least significant bit represents the sign.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> signBit = <span class="keyword">if</span> value < <span class="number">0</span> <span class="keyword">then</span> <span class="number">1</span> <span class="keyword">else</span> <span class="number">0</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-26">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-26">¶</a>
|
||||
</div>
|
||||
<p>The next bits are the actual value.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> valueToEncode = (Math.abs(value) << <span class="number">1</span>) + signBit</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-27">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-27">¶</a>
|
||||
</div>
|
||||
<p>Make sure we encode at least one character, even if valueToEncode is 0.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="keyword">while</span> valueToEncode <span class="keyword">or</span> <span class="keyword">not</span> answer
|
||||
nextChunk = valueToEncode & VLQ_VALUE_MASK
|
||||
valueToEncode = valueToEncode >> VLQ_SHIFT
|
||||
nextChunk |= VLQ_CONTINUATION_BIT <span class="keyword">if</span> valueToEncode
|
||||
answer += <span class="property">@encodeBase64</span> nextChunk
|
||||
|
||||
answer</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-28">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap for-h2">
|
||||
<a class="pilcrow" href="#section-28">¶</a>
|
||||
</div>
|
||||
<h2>Regular Base64 Encoding</h2>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-29">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-29">¶</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
BASE64_CHARS = <span class="string">'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'</span>
|
||||
|
||||
encodeBase64: (value) ->
|
||||
BASE64_CHARS[value] <span class="keyword">or</span> <span class="keyword">throw</span> <span class="keyword">new</span> Error <span class="string">"Cannot Base64 encode value: <span class="subst">#{value}</span>"</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-30">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-30">¶</a>
|
||||
</div>
|
||||
<p>Our API for source maps is just the <code>SourceMap</code> class.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre>
|
||||
module.exports = SourceMap</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -2,5 +2,3 @@
|
||||
SkinnyMochaHalfCaffScript Compiler v1.0
|
||||
Released under the MIT License
|
||||
###
|
||||
|
||||
|
||||
@@ -6,4 +6,4 @@ task 'build:parser', 'rebuild the Jison parser', (options) ->
|
||||
require 'jison'
|
||||
code = require('./lib/grammar').parser.generate()
|
||||
dir = options.output or 'lib'
|
||||
fs.writeFile "#{dir}/parser.js", code
|
||||
fs.writeFile "#{dir}/parser.js", code
|
||||
@@ -4,5 +4,3 @@ $ 'body'
|
||||
.fadeIn 'fast'
|
||||
.addClass '.active'
|
||||
.css 'background', 'white'
|
||||
|
||||
|
||||
@@ -19,7 +19,3 @@ tom = new Horse "Tommy the Palomino"
|
||||
|
||||
sam.move()
|
||||
tom.move()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
cholesterol = 127
|
||||
|
||||
healthy = 200 > cholesterol > 60
|
||||
|
||||
|
||||
@@ -7,6 +7,3 @@ else
|
||||
showIt()
|
||||
|
||||
date = if friday then sue else jill
|
||||
|
||||
|
||||
|
||||
5
documentation/examples/constructor_destructuring.coffee
Normal file
@@ -0,0 +1,5 @@
|
||||
class Person
|
||||
constructor: (options) ->
|
||||
{@name, @age, @height = 'average'} = options
|
||||
|
||||
tim = new Person name: 'Tim', age: 4
|
||||
@@ -1,8 +1,2 @@
|
||||
fill = (container, liquid = "coffee") ->
|
||||
"Filling the #{container} with #{liquid}..."
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
for filename in list
|
||||
do (filename) ->
|
||||
fs.readFile filename, (err, contents) ->
|
||||
compile filename, contents.toString()
|
||||
compile filename, contents.toString()
|
||||
@@ -1,6 +1,3 @@
|
||||
hi = `function() {
|
||||
return [document.title, "Hello JavaScript"].join(": ");
|
||||
}`
|
||||
|
||||
|
||||
|
||||
5
documentation/examples/embedded_block.coffee
Normal file
@@ -0,0 +1,5 @@
|
||||
```
|
||||
function time() {
|
||||
return `The time is ${new Date().toLocaleTimeString()}`;
|
||||
}
|
||||
```
|
||||
3
documentation/examples/embedded_escaped.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
markdown = `function () {
|
||||
return \`In Markdown, write code like \\\`this\\\`\`;
|
||||
}`
|
||||
@@ -4,10 +4,3 @@ speed = 0
|
||||
speed ?= 15
|
||||
|
||||
footprints = yeti ? "bear"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,3 @@ text = "Every literary critic believes he will
|
||||
outwit history and have the last word"
|
||||
|
||||
[first, ..., last] = text.split " "
|
||||
|
||||
|
||||
|
||||
@@ -6,4 +6,4 @@ grade = (student) ->
|
||||
else
|
||||
"C"
|
||||
|
||||
eldest = if 24 > 21 then "Liz" else "Ike"
|
||||
eldest = if 24 > 21 then "Liz" else "Ike"
|
||||
@@ -1,3 +1 @@
|
||||
six = (one = 1) + (two = 2) + (three = 3)
|
||||
|
||||
|
||||
3
documentation/examples/expressions_comprehension.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# The first ten global properties.
|
||||
|
||||
globals = (name for name of window)[0...10]
|
||||
@@ -4,4 +4,3 @@ alert(
|
||||
catch error
|
||||
"And the error is ... #{error}"
|
||||
)
|
||||
|
||||
6
documentation/examples/fat_arrow.coffee
Normal file
@@ -0,0 +1,6 @@
|
||||
Account = (customer, cart) ->
|
||||
@customer = customer
|
||||
@cart = cart
|
||||
|
||||
$('.shopping_cart').on 'click', (event) =>
|
||||
@customer.purchase @cart
|
||||
13
documentation/examples/generator_iteration.coffee
Normal file
@@ -0,0 +1,13 @@
|
||||
fibonacci = ->
|
||||
[previous, current] = [1, 1]
|
||||
loop
|
||||
[previous, current] = [current, previous + current]
|
||||
yield current
|
||||
return
|
||||
|
||||
getFibonacciNumbers = (length) ->
|
||||
results = [1]
|
||||
for n from fibonacci()
|
||||
results.push n
|
||||
break if results.length is length
|
||||
results
|
||||
8
documentation/examples/generators.coffee
Normal file
@@ -0,0 +1,8 @@
|
||||
perfectSquares = ->
|
||||
num = 0
|
||||
loop
|
||||
num += 1
|
||||
yield num * num
|
||||
return
|
||||
|
||||
window.ps or= perfectSquares()
|
||||
@@ -3,4 +3,3 @@ html = """
|
||||
cup of coffeescript
|
||||
</strong>
|
||||
"""
|
||||
|
||||
@@ -7,5 +7,3 @@ OPERATOR = /// ^ (
|
||||
| \?\. # soak access
|
||||
| \.{2,3} # range or splat
|
||||
) ///
|
||||
|
||||
|
||||
@@ -2,8 +2,3 @@ author = "Wittgenstein"
|
||||
quote = "A picture is a fact. -- #{ author }"
|
||||
|
||||
sentence = "#{ 22 / 7 } is a decent approximation of π"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
22
documentation/examples/modules.coffee
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'local-file.coffee'
|
||||
import 'coffee-script'
|
||||
|
||||
import _ from 'underscore'
|
||||
import * as underscore from 'underscore'
|
||||
|
||||
import { now } from 'underscore'
|
||||
import { now as currentTimestamp } from 'underscore'
|
||||
import { first, last } from 'underscore'
|
||||
import utilityBelt, { each } from 'underscore'
|
||||
|
||||
export default Math
|
||||
export square = (x) -> x * x
|
||||
export class Mathematics
|
||||
least: (x, y) -> if x < y then x else y
|
||||
|
||||
export { sqrt }
|
||||
export { sqrt as squareRoot }
|
||||
export { Mathematics as default, sqrt as squareRoot }
|
||||
|
||||
export * from 'underscore'
|
||||
export { max, min } from 'underscore'
|
||||
4
documentation/examples/modulo.coffee
Normal file
@@ -0,0 +1,4 @@
|
||||
-7 % 5 == -2 # The remainder of 7 / 5
|
||||
-7 %% 5 == 3 # n %% 5 is always between 0 and 4
|
||||
|
||||
tabs.selectTabAtIndex((tabs.currentIndex - count) %% tabs.length)
|
||||