mobile_template 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +28 -0
- data/Rakefile +3 -0
- data/bin/mobile_template +71 -0
- data/lib/mobile_template/version.rb +4 -0
- data/lib/mobile_template.rb +5 -0
- data/mobile_template.gemspec +21 -0
- data/templates/assets/Gemfile +4 -0
- data/templates/assets/config.rb +96 -0
- data/templates/assets/config.ru +4 -0
- data/templates/assets/source/images/vendor/ajax-loader.gif +0 -0
- data/templates/assets/source/images/vendor/ajax-loader.png +0 -0
- data/templates/assets/source/images/vendor/icons-18-black.png +0 -0
- data/templates/assets/source/images/vendor/icons-18-white.png +0 -0
- data/templates/assets/source/images/vendor/icons-36-black.png +0 -0
- data/templates/assets/source/images/vendor/icons-36-white.png +0 -0
- data/templates/assets/source/index.html.erb +2 -0
- data/templates/assets/source/javascripts/app/index.js.coffee +2 -0
- data/templates/assets/source/javascripts/application.js.coffee +5 -0
- data/templates/assets/source/javascripts/vendor/cordova.js +4841 -0
- data/templates/assets/source/javascripts/vendor/jquery.js +9267 -0
- data/templates/assets/source/javascripts/vendor/jquery.mobile.js +7410 -0
- data/templates/assets/source/layout.erb +24 -0
- data/templates/assets/source/stylesheets/application.css.scss +2 -0
- data/templates/assets/source/stylesheets/vendor/jquery.mobile.css.scss +1872 -0
- data/templates/cordova_android/.gitignore +18 -0
- data/templates/cordova_android/LICENSE +202 -0
- data/templates/cordova_android/NOTICE +5 -0
- data/templates/cordova_android/README.md +95 -0
- data/templates/cordova_android/VERSION +1 -0
- data/templates/cordova_android/bin/BOOM +4 -0
- data/templates/cordova_android/bin/autotest +2 -0
- data/templates/cordova_android/bin/bench +29 -0
- data/templates/cordova_android/bin/create +46 -0
- data/templates/cordova_android/bin/create.bat +1 -0
- data/templates/cordova_android/bin/create.js +88 -0
- data/templates/cordova_android/bin/create.xml +79 -0
- data/templates/cordova_android/bin/node_modules/.bin/cake +7 -0
- data/templates/cordova_android/bin/node_modules/.bin/coffee +7 -0
- data/templates/cordova_android/bin/node_modules/.bin/nodeunit +120 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/.npmignore +11 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/LICENSE +22 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/README +48 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/Rakefile +78 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/bin/cake +7 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/bin/coffee +7 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/extras/jsl.conf +44 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/browser.js +75 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/cake.js +76 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/coffee-script.js +135 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/command.js +301 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/grammar.js +591 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/helpers.js +66 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/index.js +8 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/lexer.js +656 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/nodes.js +2289 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/optparse.js +111 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/parser.js +676 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/repl.js +123 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/rewriter.js +363 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/scope.js +120 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/package.json +27 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/.gitignore +5 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/.npmignore +3 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/CONTRIBUTORS.md +60 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/LICENSE +19 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/Makefile +126 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/README.md +432 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/bin/nodeunit +120 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/bin/nodeunit.json +10 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/async.js +623 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/console.log.js +55 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/ejs.js +125 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/json2.js +483 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/nodeunit.js +1757 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/suite1.js +12 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/suite2.js +13 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/test.html +16 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/img/example_fail.png +0 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/img/example_pass.png +0 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/index.js +3 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/assert.js +316 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/core.js +260 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/nodeunit.js +82 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/browser.js +119 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/default.js +123 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/html.js +107 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/index.js +9 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/junit.js +183 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/minimal.js +112 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/skip_passed.js +105 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/track.js +48 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/types.js +187 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/utils.js +209 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/man1/nodeunit.1 +95 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/nodelint.cfg +4 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/package.json +56 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/junit.xml.ejs +19 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/license.js +11 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/nodeunit.css +70 -0
- data/templates/cordova_android/bin/templates/project/.cordova/android/readme.md +1 -0
- data/templates/cordova_android/bin/templates/project/.cordova/readme.md +3 -0
- data/templates/cordova_android/bin/templates/project/cordova/create +36 -0
- data/templates/cordova_android/bin/templates/project/cordova/debug +9 -0
- data/templates/cordova_android/bin/templates/project/cordova/emulate +12 -0
- data/templates/cordova_android/bin/templates/project/cordova/log +3 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/Activity.java +16 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/AndroidManifest.xml +50 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/index.html +42 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/main.js +146 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/master.css +96 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/drawable/icon.png +0 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/xml/cordova.xml +5 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/xml/plugins.xml +19 -0
- data/templates/cordova_android/bin/test +26 -0
- data/templates/cordova_android/bin/tests/autotest.coffee +4 -0
- data/templates/cordova_android/bin/tests/create.coffee +21 -0
- data/templates/cordova_android/bin/tests/debug.coffee +0 -0
- data/templates/cordova_android/bin/tests/test.coffee +0 -0
- data/templates/cordova_android/framework/.classpath +8 -0
- data/templates/cordova_android/framework/.project +33 -0
- data/templates/cordova_android/framework/AndroidManifest.xml +68 -0
- data/templates/cordova_android/framework/ant.properties +34 -0
- data/templates/cordova_android/framework/assets/js/accelerometer.js +137 -0
- data/templates/cordova_android/framework/assets/js/app.js +89 -0
- data/templates/cordova_android/framework/assets/js/battery.js +134 -0
- data/templates/cordova_android/framework/assets/js/camera.js +168 -0
- data/templates/cordova_android/framework/assets/js/capture.js +203 -0
- data/templates/cordova_android/framework/assets/js/compass.js +168 -0
- data/templates/cordova_android/framework/assets/js/contact.js +310 -0
- data/templates/cordova_android/framework/assets/js/cordova.android.js +4841 -0
- data/templates/cordova_android/framework/assets/js/cordova.js.base +924 -0
- data/templates/cordova_android/framework/assets/js/crypto.js +54 -0
- data/templates/cordova_android/framework/assets/js/device.js +83 -0
- data/templates/cordova_android/framework/assets/js/file.js +1082 -0
- data/templates/cordova_android/framework/assets/js/filetransfer.js +125 -0
- data/templates/cordova_android/framework/assets/js/geolocation.js +209 -0
- data/templates/cordova_android/framework/assets/js/header.txt +19 -0
- data/templates/cordova_android/framework/assets/js/media.js +233 -0
- data/templates/cordova_android/framework/assets/js/network.js +100 -0
- data/templates/cordova_android/framework/assets/js/notification.js +133 -0
- data/templates/cordova_android/framework/assets/js/position.js +100 -0
- data/templates/cordova_android/framework/assets/js/storage.js +439 -0
- data/templates/cordova_android/framework/assets/www/index.html +27 -0
- data/templates/cordova_android/framework/build.xml +216 -0
- data/templates/cordova_android/framework/libs/commons-codec-1.3.jar +0 -0
- data/templates/cordova_android/framework/proguard-project.txt +20 -0
- data/templates/cordova_android/framework/project.properties +14 -0
- data/templates/cordova_android/framework/res/drawable/icon.png +0 -0
- data/templates/cordova_android/framework/res/drawable/splash.png +0 -0
- data/templates/cordova_android/framework/res/layout/main.xml +29 -0
- data/templates/cordova_android/framework/res/values/strings.xml +23 -0
- data/templates/cordova_android/framework/res/xml/cordova.xml +37 -0
- data/templates/cordova_android/framework/res/xml/plugins.xml +37 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/IPlugin.java +27 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/LOG.java +28 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PhonegapActivity.java +28 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/Plugin.java +27 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PluginManager.java +35 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PluginResult.java +53 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AccelListener.java +311 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/App.java +198 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AudioHandler.java +364 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AudioPlayer.java +450 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AuthenticationToken.java +69 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/BatteryListener.java +156 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CallbackServer.java +431 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CameraLauncher.java +500 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Capture.java +400 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CompassListener.java +308 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessor.java +198 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessorSdk5.java +1934 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactManager.java +113 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CordovaChromeClient.java +314 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CordovaWebViewClient.java +306 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Device.java +219 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/DirectoryManager.java +161 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/DroidGap.java +1417 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ExifHelper.java +165 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileTransfer.java +458 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileUploadResult.java +63 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileUtils.java +1048 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GeoBroker.java +165 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GeoListener.java +133 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GpsListener.java +163 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/HttpHandler.java +80 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java +104 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/NetworkListener.java +153 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/NetworkManager.java +248 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Notification.java +366 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/PreferenceNode.java +34 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/PreferenceSet.java +62 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/StandAlone.java +35 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Storage.java +239 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/TempListener.java +112 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/CordovaInterface.java +145 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/IPlugin.java +116 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/LOG.java +234 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/Plugin.java +210 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginManager.java +359 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginResult.java +119 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/EncodingException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/FileExistsException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/InvalidModificationException.java +29 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/NoModificationAllowedException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/TypeMismatchException.java +29 -0
- data/templates/cordova_android/framework/test/org/apache/cordova/PreferenceNodeTest.java +53 -0
- data/templates/cordova_android/framework/test/org/apache/cordova/PreferenceSetTest.java +73 -0
- metadata +279 -0
@@ -0,0 +1,123 @@
|
|
1
|
+
(function() {
|
2
|
+
var ACCESSOR, CoffeeScript, Module, REPL_PROMPT, REPL_PROMPT_CONTINUATION, SIMPLEVAR, Script, autocomplete, backlog, completeAttribute, completeVariable, enableColours, error, g, getCompletions, inspect, nonContextGlobals, readline, repl, run, sandbox, stdin, stdout, _i, _len;
|
3
|
+
CoffeeScript = require('./coffee-script');
|
4
|
+
readline = require('readline');
|
5
|
+
inspect = require('util').inspect;
|
6
|
+
Script = require('vm').Script;
|
7
|
+
Module = require('module');
|
8
|
+
REPL_PROMPT = 'coffee> ';
|
9
|
+
REPL_PROMPT_CONTINUATION = '......> ';
|
10
|
+
enableColours = false;
|
11
|
+
if (process.platform !== 'win32') {
|
12
|
+
enableColours = !process.env.NODE_DISABLE_COLORS;
|
13
|
+
}
|
14
|
+
stdin = process.openStdin();
|
15
|
+
stdout = process.stdout;
|
16
|
+
error = function(err) {
|
17
|
+
return stdout.write((err.stack || err.toString()) + '\n\n');
|
18
|
+
};
|
19
|
+
backlog = '';
|
20
|
+
sandbox = Script.createContext();
|
21
|
+
nonContextGlobals = ['Buffer', 'console', 'process', 'setInterval', 'clearInterval', 'setTimeout', 'clearTimeout'];
|
22
|
+
for (_i = 0, _len = nonContextGlobals.length; _i < _len; _i++) {
|
23
|
+
g = nonContextGlobals[_i];
|
24
|
+
sandbox[g] = global[g];
|
25
|
+
}
|
26
|
+
sandbox.global = sandbox.root = sandbox.GLOBAL = sandbox;
|
27
|
+
run = function(buffer) {
|
28
|
+
var code, returnValue, _;
|
29
|
+
if (!buffer.toString().trim() && !backlog) {
|
30
|
+
repl.prompt();
|
31
|
+
return;
|
32
|
+
}
|
33
|
+
code = backlog += buffer;
|
34
|
+
if (code[code.length - 1] === '\\') {
|
35
|
+
backlog = "" + backlog.slice(0, -1) + "\n";
|
36
|
+
repl.setPrompt(REPL_PROMPT_CONTINUATION);
|
37
|
+
repl.prompt();
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
repl.setPrompt(REPL_PROMPT);
|
41
|
+
backlog = '';
|
42
|
+
try {
|
43
|
+
_ = sandbox._;
|
44
|
+
returnValue = CoffeeScript.eval("_=(" + code + "\n)", {
|
45
|
+
sandbox: sandbox,
|
46
|
+
filename: 'repl',
|
47
|
+
modulename: 'repl'
|
48
|
+
});
|
49
|
+
if (returnValue === void 0) {
|
50
|
+
sandbox._ = _;
|
51
|
+
} else {
|
52
|
+
process.stdout.write(inspect(returnValue, false, 2, enableColours) + '\n');
|
53
|
+
}
|
54
|
+
} catch (err) {
|
55
|
+
error(err);
|
56
|
+
}
|
57
|
+
return repl.prompt();
|
58
|
+
};
|
59
|
+
ACCESSOR = /\s*([\w\.]+)(?:\.(\w*))$/;
|
60
|
+
SIMPLEVAR = /\s*(\w*)$/i;
|
61
|
+
autocomplete = function(text) {
|
62
|
+
return completeAttribute(text) || completeVariable(text) || [[], text];
|
63
|
+
};
|
64
|
+
completeAttribute = function(text) {
|
65
|
+
var all, completions, match, obj, prefix, val;
|
66
|
+
if (match = text.match(ACCESSOR)) {
|
67
|
+
all = match[0], obj = match[1], prefix = match[2];
|
68
|
+
try {
|
69
|
+
val = Script.runInContext(obj, sandbox);
|
70
|
+
} catch (error) {
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
completions = getCompletions(prefix, Object.getOwnPropertyNames(val));
|
74
|
+
return [completions, prefix];
|
75
|
+
}
|
76
|
+
};
|
77
|
+
completeVariable = function(text) {
|
78
|
+
var completions, free, possibilities, vars, _ref;
|
79
|
+
if (free = (_ref = text.match(SIMPLEVAR)) != null ? _ref[1] : void 0) {
|
80
|
+
vars = Script.runInContext('Object.getOwnPropertyNames(this)', sandbox);
|
81
|
+
possibilities = vars.concat(CoffeeScript.RESERVED);
|
82
|
+
completions = getCompletions(free, possibilities);
|
83
|
+
return [completions, free];
|
84
|
+
}
|
85
|
+
};
|
86
|
+
getCompletions = function(prefix, candidates) {
|
87
|
+
var el, _j, _len2, _results;
|
88
|
+
_results = [];
|
89
|
+
for (_j = 0, _len2 = candidates.length; _j < _len2; _j++) {
|
90
|
+
el = candidates[_j];
|
91
|
+
if (el.indexOf(prefix) === 0) {
|
92
|
+
_results.push(el);
|
93
|
+
}
|
94
|
+
}
|
95
|
+
return _results;
|
96
|
+
};
|
97
|
+
process.on('uncaughtException', error);
|
98
|
+
if (readline.createInterface.length < 3) {
|
99
|
+
repl = readline.createInterface(stdin, autocomplete);
|
100
|
+
stdin.on('data', function(buffer) {
|
101
|
+
return repl.write(buffer);
|
102
|
+
});
|
103
|
+
} else {
|
104
|
+
repl = readline.createInterface(stdin, stdout, autocomplete);
|
105
|
+
}
|
106
|
+
repl.on('attemptClose', function() {
|
107
|
+
if (backlog) {
|
108
|
+
backlog = '';
|
109
|
+
process.stdout.write('\n');
|
110
|
+
repl.setPrompt(REPL_PROMPT);
|
111
|
+
return repl.prompt();
|
112
|
+
} else {
|
113
|
+
return repl.close();
|
114
|
+
}
|
115
|
+
});
|
116
|
+
repl.on('close', function() {
|
117
|
+
process.stdout.write('\n');
|
118
|
+
return stdin.destroy();
|
119
|
+
});
|
120
|
+
repl.on('line', run);
|
121
|
+
repl.setPrompt(REPL_PROMPT);
|
122
|
+
repl.prompt();
|
123
|
+
}).call(this);
|
@@ -0,0 +1,363 @@
|
|
1
|
+
(function() {
|
2
|
+
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, left, rite, _i, _len, _ref;
|
3
|
+
var __indexOf = Array.prototype.indexOf || function(item) {
|
4
|
+
for (var i = 0, l = this.length; i < l; i++) {
|
5
|
+
if (this[i] === item) return i;
|
6
|
+
}
|
7
|
+
return -1;
|
8
|
+
}, __slice = Array.prototype.slice;
|
9
|
+
exports.Rewriter = (function() {
|
10
|
+
function Rewriter() {}
|
11
|
+
Rewriter.prototype.rewrite = function(tokens) {
|
12
|
+
this.tokens = tokens;
|
13
|
+
this.removeLeadingNewlines();
|
14
|
+
this.removeMidExpressionNewlines();
|
15
|
+
this.closeOpenCalls();
|
16
|
+
this.closeOpenIndexes();
|
17
|
+
this.addImplicitIndentation();
|
18
|
+
this.tagPostfixConditionals();
|
19
|
+
this.addImplicitBraces();
|
20
|
+
this.addImplicitParentheses();
|
21
|
+
this.ensureBalance(BALANCED_PAIRS);
|
22
|
+
this.rewriteClosingParens();
|
23
|
+
return this.tokens;
|
24
|
+
};
|
25
|
+
Rewriter.prototype.scanTokens = function(block) {
|
26
|
+
var i, token, tokens;
|
27
|
+
tokens = this.tokens;
|
28
|
+
i = 0;
|
29
|
+
while (token = tokens[i]) {
|
30
|
+
i += block.call(this, token, i, tokens);
|
31
|
+
}
|
32
|
+
return true;
|
33
|
+
};
|
34
|
+
Rewriter.prototype.detectEnd = function(i, condition, action) {
|
35
|
+
var levels, token, tokens, _ref, _ref2;
|
36
|
+
tokens = this.tokens;
|
37
|
+
levels = 0;
|
38
|
+
while (token = tokens[i]) {
|
39
|
+
if (levels === 0 && condition.call(this, token, i)) {
|
40
|
+
return action.call(this, token, i);
|
41
|
+
}
|
42
|
+
if (!token || levels < 0) {
|
43
|
+
return action.call(this, token, i - 1);
|
44
|
+
}
|
45
|
+
if (_ref = token[0], __indexOf.call(EXPRESSION_START, _ref) >= 0) {
|
46
|
+
levels += 1;
|
47
|
+
} else if (_ref2 = token[0], __indexOf.call(EXPRESSION_END, _ref2) >= 0) {
|
48
|
+
levels -= 1;
|
49
|
+
}
|
50
|
+
i += 1;
|
51
|
+
}
|
52
|
+
return i - 1;
|
53
|
+
};
|
54
|
+
Rewriter.prototype.removeLeadingNewlines = function() {
|
55
|
+
var i, tag, _len, _ref;
|
56
|
+
_ref = this.tokens;
|
57
|
+
for (i = 0, _len = _ref.length; i < _len; i++) {
|
58
|
+
tag = _ref[i][0];
|
59
|
+
if (tag !== 'TERMINATOR') {
|
60
|
+
break;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
if (i) {
|
64
|
+
return this.tokens.splice(0, i);
|
65
|
+
}
|
66
|
+
};
|
67
|
+
Rewriter.prototype.removeMidExpressionNewlines = function() {
|
68
|
+
return this.scanTokens(function(token, i, tokens) {
|
69
|
+
var _ref;
|
70
|
+
if (!(token[0] === 'TERMINATOR' && (_ref = this.tag(i + 1), __indexOf.call(EXPRESSION_CLOSE, _ref) >= 0))) {
|
71
|
+
return 1;
|
72
|
+
}
|
73
|
+
tokens.splice(i, 1);
|
74
|
+
return 0;
|
75
|
+
});
|
76
|
+
};
|
77
|
+
Rewriter.prototype.closeOpenCalls = function() {
|
78
|
+
var action, condition;
|
79
|
+
condition = function(token, i) {
|
80
|
+
var _ref;
|
81
|
+
return ((_ref = token[0]) === ')' || _ref === 'CALL_END') || token[0] === 'OUTDENT' && this.tag(i - 1) === ')';
|
82
|
+
};
|
83
|
+
action = function(token, i) {
|
84
|
+
return this.tokens[token[0] === 'OUTDENT' ? i - 1 : i][0] = 'CALL_END';
|
85
|
+
};
|
86
|
+
return this.scanTokens(function(token, i) {
|
87
|
+
if (token[0] === 'CALL_START') {
|
88
|
+
this.detectEnd(i + 1, condition, action);
|
89
|
+
}
|
90
|
+
return 1;
|
91
|
+
});
|
92
|
+
};
|
93
|
+
Rewriter.prototype.closeOpenIndexes = function() {
|
94
|
+
var action, condition;
|
95
|
+
condition = function(token, i) {
|
96
|
+
var _ref;
|
97
|
+
return (_ref = token[0]) === ']' || _ref === 'INDEX_END';
|
98
|
+
};
|
99
|
+
action = function(token, i) {
|
100
|
+
return token[0] = 'INDEX_END';
|
101
|
+
};
|
102
|
+
return this.scanTokens(function(token, i) {
|
103
|
+
if (token[0] === 'INDEX_START') {
|
104
|
+
this.detectEnd(i + 1, condition, action);
|
105
|
+
}
|
106
|
+
return 1;
|
107
|
+
});
|
108
|
+
};
|
109
|
+
Rewriter.prototype.addImplicitBraces = function() {
|
110
|
+
var action, condition, stack, start, startIndent;
|
111
|
+
stack = [];
|
112
|
+
start = null;
|
113
|
+
startIndent = 0;
|
114
|
+
condition = function(token, i) {
|
115
|
+
var one, tag, three, two, _ref, _ref2;
|
116
|
+
_ref = this.tokens.slice(i + 1, (i + 3 + 1) || 9e9), one = _ref[0], two = _ref[1], three = _ref[2];
|
117
|
+
if ('HERECOMMENT' === (one != null ? one[0] : void 0)) {
|
118
|
+
return false;
|
119
|
+
}
|
120
|
+
tag = token[0];
|
121
|
+
return ((tag === 'TERMINATOR' || tag === 'OUTDENT') && !((two != null ? two[0] : void 0) === ':' || (one != null ? one[0] : void 0) === '@' && (three != null ? three[0] : void 0) === ':')) || (tag === ',' && one && ((_ref2 = one[0]) !== 'IDENTIFIER' && _ref2 !== 'NUMBER' && _ref2 !== 'STRING' && _ref2 !== '@' && _ref2 !== 'TERMINATOR' && _ref2 !== 'OUTDENT'));
|
122
|
+
};
|
123
|
+
action = function(token, i) {
|
124
|
+
var tok;
|
125
|
+
tok = ['}', '}', token[2]];
|
126
|
+
tok.generated = true;
|
127
|
+
return this.tokens.splice(i, 0, tok);
|
128
|
+
};
|
129
|
+
return this.scanTokens(function(token, i, tokens) {
|
130
|
+
var ago, idx, tag, tok, value, _ref, _ref2;
|
131
|
+
if (_ref = (tag = token[0]), __indexOf.call(EXPRESSION_START, _ref) >= 0) {
|
132
|
+
stack.push([(tag === 'INDENT' && this.tag(i - 1) === '{' ? '{' : tag), i]);
|
133
|
+
return 1;
|
134
|
+
}
|
135
|
+
if (__indexOf.call(EXPRESSION_END, tag) >= 0) {
|
136
|
+
start = stack.pop();
|
137
|
+
return 1;
|
138
|
+
}
|
139
|
+
if (!(tag === ':' && ((ago = this.tag(i - 2)) === ':' || ((_ref2 = stack[stack.length - 1]) != null ? _ref2[0] : void 0) !== '{'))) {
|
140
|
+
return 1;
|
141
|
+
}
|
142
|
+
stack.push(['{']);
|
143
|
+
idx = ago === '@' ? i - 2 : i - 1;
|
144
|
+
while (this.tag(idx - 2) === 'HERECOMMENT') {
|
145
|
+
idx -= 2;
|
146
|
+
}
|
147
|
+
value = new String('{');
|
148
|
+
value.generated = true;
|
149
|
+
tok = ['{', value, token[2]];
|
150
|
+
tok.generated = true;
|
151
|
+
tokens.splice(idx, 0, tok);
|
152
|
+
this.detectEnd(i + 2, condition, action);
|
153
|
+
return 2;
|
154
|
+
});
|
155
|
+
};
|
156
|
+
Rewriter.prototype.addImplicitParentheses = function() {
|
157
|
+
var action, noCall;
|
158
|
+
noCall = false;
|
159
|
+
action = function(token, i) {
|
160
|
+
var idx;
|
161
|
+
idx = token[0] === 'OUTDENT' ? i + 1 : i;
|
162
|
+
return this.tokens.splice(idx, 0, ['CALL_END', ')', token[2]]);
|
163
|
+
};
|
164
|
+
return this.scanTokens(function(token, i, tokens) {
|
165
|
+
var callObject, current, next, prev, seenControl, seenSingle, tag, _ref, _ref2, _ref3;
|
166
|
+
tag = token[0];
|
167
|
+
if (tag === 'CLASS' || tag === 'IF') {
|
168
|
+
noCall = true;
|
169
|
+
}
|
170
|
+
_ref = tokens.slice(i - 1, (i + 1 + 1) || 9e9), prev = _ref[0], current = _ref[1], next = _ref[2];
|
171
|
+
callObject = !noCall && tag === 'INDENT' && next && next.generated && next[0] === '{' && prev && (_ref2 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref2) >= 0);
|
172
|
+
seenSingle = false;
|
173
|
+
seenControl = false;
|
174
|
+
if (__indexOf.call(LINEBREAKS, tag) >= 0) {
|
175
|
+
noCall = false;
|
176
|
+
}
|
177
|
+
if (prev && !prev.spaced && tag === '?') {
|
178
|
+
token.call = true;
|
179
|
+
}
|
180
|
+
if (token.fromThen) {
|
181
|
+
return 1;
|
182
|
+
}
|
183
|
+
if (!(callObject || (prev != null ? prev.spaced : void 0) && (prev.call || (_ref3 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref3) >= 0)) && (__indexOf.call(IMPLICIT_CALL, tag) >= 0 || !(token.spaced || token.newLine) && __indexOf.call(IMPLICIT_UNSPACED_CALL, tag) >= 0))) {
|
184
|
+
return 1;
|
185
|
+
}
|
186
|
+
tokens.splice(i, 0, ['CALL_START', '(', token[2]]);
|
187
|
+
this.detectEnd(i + 1, function(token, i) {
|
188
|
+
var post, _ref4;
|
189
|
+
tag = token[0];
|
190
|
+
if (!seenSingle && token.fromThen) {
|
191
|
+
return true;
|
192
|
+
}
|
193
|
+
if (tag === 'IF' || tag === 'ELSE' || tag === 'CATCH' || tag === '->' || tag === '=>') {
|
194
|
+
seenSingle = true;
|
195
|
+
}
|
196
|
+
if (tag === 'IF' || tag === 'ELSE' || tag === 'SWITCH' || tag === 'TRY') {
|
197
|
+
seenControl = true;
|
198
|
+
}
|
199
|
+
if ((tag === '.' || tag === '?.' || tag === '::') && this.tag(i - 1) === 'OUTDENT') {
|
200
|
+
return true;
|
201
|
+
}
|
202
|
+
return !token.generated && this.tag(i - 1) !== ',' && (__indexOf.call(IMPLICIT_END, tag) >= 0 || (tag === 'INDENT' && !seenControl)) && (tag !== 'INDENT' || (this.tag(i - 2) !== 'CLASS' && (_ref4 = this.tag(i - 1), __indexOf.call(IMPLICIT_BLOCK, _ref4) < 0) && !((post = this.tokens[i + 1]) && post.generated && post[0] === '{')));
|
203
|
+
}, action);
|
204
|
+
if (prev[0] === '?') {
|
205
|
+
prev[0] = 'FUNC_EXIST';
|
206
|
+
}
|
207
|
+
return 2;
|
208
|
+
});
|
209
|
+
};
|
210
|
+
Rewriter.prototype.addImplicitIndentation = function() {
|
211
|
+
return this.scanTokens(function(token, i, tokens) {
|
212
|
+
var action, condition, indent, outdent, starter, tag, _ref, _ref2;
|
213
|
+
tag = token[0];
|
214
|
+
if (tag === 'TERMINATOR' && this.tag(i + 1) === 'THEN') {
|
215
|
+
tokens.splice(i, 1);
|
216
|
+
return 0;
|
217
|
+
}
|
218
|
+
if (tag === 'ELSE' && this.tag(i - 1) !== 'OUTDENT') {
|
219
|
+
tokens.splice.apply(tokens, [i, 0].concat(__slice.call(this.indentation(token))));
|
220
|
+
return 2;
|
221
|
+
}
|
222
|
+
if (tag === 'CATCH' && ((_ref = this.tag(i + 2)) === 'OUTDENT' || _ref === 'TERMINATOR' || _ref === 'FINALLY')) {
|
223
|
+
tokens.splice.apply(tokens, [i + 2, 0].concat(__slice.call(this.indentation(token))));
|
224
|
+
return 4;
|
225
|
+
}
|
226
|
+
if (__indexOf.call(SINGLE_LINERS, tag) >= 0 && this.tag(i + 1) !== 'INDENT' && !(tag === 'ELSE' && this.tag(i + 1) === 'IF')) {
|
227
|
+
starter = tag;
|
228
|
+
_ref2 = this.indentation(token), indent = _ref2[0], outdent = _ref2[1];
|
229
|
+
if (starter === 'THEN') {
|
230
|
+
indent.fromThen = true;
|
231
|
+
}
|
232
|
+
indent.generated = outdent.generated = true;
|
233
|
+
tokens.splice(i + 1, 0, indent);
|
234
|
+
condition = function(token, i) {
|
235
|
+
var _ref3;
|
236
|
+
return token[1] !== ';' && (_ref3 = token[0], __indexOf.call(SINGLE_CLOSERS, _ref3) >= 0) && !(token[0] === 'ELSE' && (starter !== 'IF' && starter !== 'THEN'));
|
237
|
+
};
|
238
|
+
action = function(token, i) {
|
239
|
+
return this.tokens.splice((this.tag(i - 1) === ',' ? i - 1 : i), 0, outdent);
|
240
|
+
};
|
241
|
+
this.detectEnd(i + 2, condition, action);
|
242
|
+
if (tag === 'THEN') {
|
243
|
+
tokens.splice(i, 1);
|
244
|
+
}
|
245
|
+
return 1;
|
246
|
+
}
|
247
|
+
return 1;
|
248
|
+
});
|
249
|
+
};
|
250
|
+
Rewriter.prototype.tagPostfixConditionals = function() {
|
251
|
+
var condition;
|
252
|
+
condition = function(token, i) {
|
253
|
+
var _ref;
|
254
|
+
return (_ref = token[0]) === 'TERMINATOR' || _ref === 'INDENT';
|
255
|
+
};
|
256
|
+
return this.scanTokens(function(token, i) {
|
257
|
+
var original;
|
258
|
+
if (token[0] !== 'IF') {
|
259
|
+
return 1;
|
260
|
+
}
|
261
|
+
original = token;
|
262
|
+
this.detectEnd(i + 1, condition, function(token, i) {
|
263
|
+
if (token[0] !== 'INDENT') {
|
264
|
+
return original[0] = 'POST_' + original[0];
|
265
|
+
}
|
266
|
+
});
|
267
|
+
return 1;
|
268
|
+
});
|
269
|
+
};
|
270
|
+
Rewriter.prototype.ensureBalance = function(pairs) {
|
271
|
+
var close, level, levels, open, openLine, tag, token, _i, _j, _len, _len2, _ref, _ref2;
|
272
|
+
levels = {};
|
273
|
+
openLine = {};
|
274
|
+
_ref = this.tokens;
|
275
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
276
|
+
token = _ref[_i];
|
277
|
+
tag = token[0];
|
278
|
+
for (_j = 0, _len2 = pairs.length; _j < _len2; _j++) {
|
279
|
+
_ref2 = pairs[_j], open = _ref2[0], close = _ref2[1];
|
280
|
+
levels[open] |= 0;
|
281
|
+
if (tag === open) {
|
282
|
+
if (levels[open]++ === 0) {
|
283
|
+
openLine[open] = token[2];
|
284
|
+
}
|
285
|
+
} else if (tag === close && --levels[open] < 0) {
|
286
|
+
throw Error("too many " + token[1] + " on line " + (token[2] + 1));
|
287
|
+
}
|
288
|
+
}
|
289
|
+
}
|
290
|
+
for (open in levels) {
|
291
|
+
level = levels[open];
|
292
|
+
if (level > 0) {
|
293
|
+
throw Error("unclosed " + open + " on line " + (openLine[open] + 1));
|
294
|
+
}
|
295
|
+
}
|
296
|
+
return this;
|
297
|
+
};
|
298
|
+
Rewriter.prototype.rewriteClosingParens = function() {
|
299
|
+
var debt, key, stack;
|
300
|
+
stack = [];
|
301
|
+
debt = {};
|
302
|
+
for (key in INVERSES) {
|
303
|
+
debt[key] = 0;
|
304
|
+
}
|
305
|
+
return this.scanTokens(function(token, i, tokens) {
|
306
|
+
var inv, match, mtag, oppos, tag, val, _ref;
|
307
|
+
if (_ref = (tag = token[0]), __indexOf.call(EXPRESSION_START, _ref) >= 0) {
|
308
|
+
stack.push(token);
|
309
|
+
return 1;
|
310
|
+
}
|
311
|
+
if (__indexOf.call(EXPRESSION_END, tag) < 0) {
|
312
|
+
return 1;
|
313
|
+
}
|
314
|
+
if (debt[inv = INVERSES[tag]] > 0) {
|
315
|
+
debt[inv] -= 1;
|
316
|
+
tokens.splice(i, 1);
|
317
|
+
return 0;
|
318
|
+
}
|
319
|
+
match = stack.pop();
|
320
|
+
mtag = match[0];
|
321
|
+
oppos = INVERSES[mtag];
|
322
|
+
if (tag === oppos) {
|
323
|
+
return 1;
|
324
|
+
}
|
325
|
+
debt[mtag] += 1;
|
326
|
+
val = [oppos, mtag === 'INDENT' ? match[1] : oppos];
|
327
|
+
if (this.tag(i + 2) === mtag) {
|
328
|
+
tokens.splice(i + 3, 0, val);
|
329
|
+
stack.push(match);
|
330
|
+
} else {
|
331
|
+
tokens.splice(i, 0, val);
|
332
|
+
}
|
333
|
+
return 1;
|
334
|
+
});
|
335
|
+
};
|
336
|
+
Rewriter.prototype.indentation = function(token) {
|
337
|
+
return [['INDENT', 2, token[2]], ['OUTDENT', 2, token[2]]];
|
338
|
+
};
|
339
|
+
Rewriter.prototype.tag = function(i) {
|
340
|
+
var _ref;
|
341
|
+
return (_ref = this.tokens[i]) != null ? _ref[0] : void 0;
|
342
|
+
};
|
343
|
+
return Rewriter;
|
344
|
+
})();
|
345
|
+
BALANCED_PAIRS = [['(', ')'], ['[', ']'], ['{', '}'], ['INDENT', 'OUTDENT'], ['CALL_START', 'CALL_END'], ['PARAM_START', 'PARAM_END'], ['INDEX_START', 'INDEX_END']];
|
346
|
+
INVERSES = {};
|
347
|
+
EXPRESSION_START = [];
|
348
|
+
EXPRESSION_END = [];
|
349
|
+
for (_i = 0, _len = BALANCED_PAIRS.length; _i < _len; _i++) {
|
350
|
+
_ref = BALANCED_PAIRS[_i], left = _ref[0], rite = _ref[1];
|
351
|
+
EXPRESSION_START.push(INVERSES[rite] = left);
|
352
|
+
EXPRESSION_END.push(INVERSES[left] = rite);
|
353
|
+
}
|
354
|
+
EXPRESSION_CLOSE = ['CATCH', 'WHEN', 'ELSE', 'FINALLY'].concat(EXPRESSION_END);
|
355
|
+
IMPLICIT_FUNC = ['IDENTIFIER', 'SUPER', ')', 'CALL_END', ']', 'INDEX_END', '@', 'THIS'];
|
356
|
+
IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'CLASS', 'IF', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'UNARY', 'SUPER', '@', '->', '=>', '[', '(', '{', '--', '++'];
|
357
|
+
IMPLICIT_UNSPACED_CALL = ['+', '-'];
|
358
|
+
IMPLICIT_BLOCK = ['->', '=>', '{', '[', ','];
|
359
|
+
IMPLICIT_END = ['POST_IF', 'FOR', 'WHILE', 'UNTIL', 'WHEN', 'BY', 'LOOP', 'TERMINATOR'];
|
360
|
+
SINGLE_LINERS = ['ELSE', '->', '=>', 'TRY', 'FINALLY', 'THEN'];
|
361
|
+
SINGLE_CLOSERS = ['TERMINATOR', 'CATCH', 'FINALLY', 'ELSE', 'OUTDENT', 'LEADING_WHEN'];
|
362
|
+
LINEBREAKS = ['TERMINATOR', 'INDENT', 'OUTDENT'];
|
363
|
+
}).call(this);
|
@@ -0,0 +1,120 @@
|
|
1
|
+
(function() {
|
2
|
+
var Scope, extend, last, _ref;
|
3
|
+
_ref = require('./helpers'), extend = _ref.extend, last = _ref.last;
|
4
|
+
exports.Scope = Scope = (function() {
|
5
|
+
Scope.root = null;
|
6
|
+
function Scope(parent, expressions, method) {
|
7
|
+
this.parent = parent;
|
8
|
+
this.expressions = expressions;
|
9
|
+
this.method = method;
|
10
|
+
this.variables = [
|
11
|
+
{
|
12
|
+
name: 'arguments',
|
13
|
+
type: 'arguments'
|
14
|
+
}
|
15
|
+
];
|
16
|
+
this.positions = {};
|
17
|
+
if (!this.parent) {
|
18
|
+
Scope.root = this;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
Scope.prototype.add = function(name, type, immediate) {
|
22
|
+
var pos;
|
23
|
+
if (this.shared && !immediate) {
|
24
|
+
return this.parent.add(name, type, immediate);
|
25
|
+
}
|
26
|
+
if (typeof (pos = this.positions[name]) === 'number') {
|
27
|
+
return this.variables[pos].type = type;
|
28
|
+
} else {
|
29
|
+
return this.positions[name] = this.variables.push({
|
30
|
+
name: name,
|
31
|
+
type: type
|
32
|
+
}) - 1;
|
33
|
+
}
|
34
|
+
};
|
35
|
+
Scope.prototype.find = function(name, options) {
|
36
|
+
if (this.check(name, options)) {
|
37
|
+
return true;
|
38
|
+
}
|
39
|
+
this.add(name, 'var');
|
40
|
+
return false;
|
41
|
+
};
|
42
|
+
Scope.prototype.parameter = function(name) {
|
43
|
+
if (this.shared && this.parent.check(name, true)) {
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
return this.add(name, 'param');
|
47
|
+
};
|
48
|
+
Scope.prototype.check = function(name, immediate) {
|
49
|
+
var found, _ref2;
|
50
|
+
found = !!this.type(name);
|
51
|
+
if (found || immediate) {
|
52
|
+
return found;
|
53
|
+
}
|
54
|
+
return !!((_ref2 = this.parent) != null ? _ref2.check(name) : void 0);
|
55
|
+
};
|
56
|
+
Scope.prototype.temporary = function(name, index) {
|
57
|
+
if (name.length > 1) {
|
58
|
+
return '_' + name + (index > 1 ? index : '');
|
59
|
+
} else {
|
60
|
+
return '_' + (index + parseInt(name, 36)).toString(36).replace(/\d/g, 'a');
|
61
|
+
}
|
62
|
+
};
|
63
|
+
Scope.prototype.type = function(name) {
|
64
|
+
var v, _i, _len, _ref2;
|
65
|
+
_ref2 = this.variables;
|
66
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
67
|
+
v = _ref2[_i];
|
68
|
+
if (v.name === name) {
|
69
|
+
return v.type;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
return null;
|
73
|
+
};
|
74
|
+
Scope.prototype.freeVariable = function(type) {
|
75
|
+
var index, temp;
|
76
|
+
index = 0;
|
77
|
+
while (this.check((temp = this.temporary(type, index)))) {
|
78
|
+
index++;
|
79
|
+
}
|
80
|
+
this.add(temp, 'var', true);
|
81
|
+
return temp;
|
82
|
+
};
|
83
|
+
Scope.prototype.assign = function(name, value) {
|
84
|
+
this.add(name, {
|
85
|
+
value: value,
|
86
|
+
assigned: true
|
87
|
+
});
|
88
|
+
return this.hasAssignments = true;
|
89
|
+
};
|
90
|
+
Scope.prototype.hasDeclarations = function() {
|
91
|
+
return !!this.declaredVariables().length;
|
92
|
+
};
|
93
|
+
Scope.prototype.declaredVariables = function() {
|
94
|
+
var realVars, tempVars, v, _i, _len, _ref2;
|
95
|
+
realVars = [];
|
96
|
+
tempVars = [];
|
97
|
+
_ref2 = this.variables;
|
98
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
99
|
+
v = _ref2[_i];
|
100
|
+
if (v.type === 'var') {
|
101
|
+
(v.name.charAt(0) === '_' ? tempVars : realVars).push(v.name);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
return realVars.sort().concat(tempVars.sort());
|
105
|
+
};
|
106
|
+
Scope.prototype.assignedVariables = function() {
|
107
|
+
var v, _i, _len, _ref2, _results;
|
108
|
+
_ref2 = this.variables;
|
109
|
+
_results = [];
|
110
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
111
|
+
v = _ref2[_i];
|
112
|
+
if (v.type.assigned) {
|
113
|
+
_results.push("" + v.name + " = " + v.type.value);
|
114
|
+
}
|
115
|
+
}
|
116
|
+
return _results;
|
117
|
+
};
|
118
|
+
return Scope;
|
119
|
+
})();
|
120
|
+
}).call(this);
|
@@ -0,0 +1,27 @@
|
|
1
|
+
{
|
2
|
+
"name": "coffee-script",
|
3
|
+
"description": "Unfancy JavaScript",
|
4
|
+
"keywords": ["javascript", "language", "coffeescript", "compiler"],
|
5
|
+
"author": "Jeremy Ashkenas",
|
6
|
+
"version": "1.1.2",
|
7
|
+
"licenses": [{
|
8
|
+
"type": "MIT",
|
9
|
+
"url": "http://github.com/jashkenas/coffee-script/raw/master/LICENSE"
|
10
|
+
}],
|
11
|
+
"engines": {
|
12
|
+
"node": ">=0.2.5"
|
13
|
+
},
|
14
|
+
"directories" : {
|
15
|
+
"lib" : "./lib"
|
16
|
+
},
|
17
|
+
"main" : "./lib/coffee-script",
|
18
|
+
"bin": {
|
19
|
+
"coffee": "./bin/coffee",
|
20
|
+
"cake": "./bin/cake"
|
21
|
+
},
|
22
|
+
"homepage": "http://coffeescript.org",
|
23
|
+
"repository": {
|
24
|
+
"type": "git",
|
25
|
+
"url": "git://github.com/jashkenas/coffee-script.git"
|
26
|
+
}
|
27
|
+
}
|