aboutsummaryrefslogtreecommitdiff
path: root/src/compiler.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-04-18 19:22:09 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-04-18 19:22:09 -0700
commit1c11fdd98530b6d35e51c0eba14fb1f375d05229 (patch)
treebd471ce02003d0e1d16dfe773d1ed4d0acdcb499 /src/compiler.js
parentd6cff2177ec065aa14f228ab547abc29ef37b248 (diff)
parent327b6f859e95be71e5613f24cc1c9d4f4b97c15f (diff)
merge
Diffstat (limited to 'src/compiler.js')
-rw-r--r--src/compiler.js16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/compiler.js b/src/compiler.js
index 134ac5bd..4442e38e 100644
--- a/src/compiler.js
+++ b/src/compiler.js
@@ -8,7 +8,8 @@ try {
} catch(e) {}
-// The environment setup code appears here, in shell.js, in js_optimizer.js and in tests/hello_world.js because it can't be shared. Keep them in sync!
+// The environment setup code appears here, in js_optimizer.js and in tests/hello_world.js because it can't be shared. Keep them in sync!
+// It also appears, in modified form, in shell.js.
// *** Environment setup code ***
var arguments_ = [];
@@ -28,11 +29,14 @@ if (ENVIRONMENT_IS_NODE) {
};
var nodeFS = require('fs');
+ var nodePath = require('path');
read = function(filename) {
+ filename = nodePath['normalize'](filename);
var ret = nodeFS['readFileSync'](filename).toString();
- if (!ret && filename[0] != '/') {
- filename = __dirname.split('/').slice(0, -1).join('/') + '/src/' + filename;
+ // The path is absolute if the normalized version is the same as the resolved.
+ if (!ret && filename != nodePath['resolve'](filename)) {
+ filename = path.join(__dirname, '..', 'src', filename);
ret = nodeFS['readFileSync'](filename).toString();
}
return ret;
@@ -50,9 +54,9 @@ if (ENVIRONMENT_IS_NODE) {
this['read'] = function(f) { snarf(f) };
}
- if (!this['arguments']) {
+ if (typeof scriptArgs != 'undefined') {
arguments_ = scriptArgs;
- } else {
+ } else if (typeof arguments != 'undefined') {
arguments_ = arguments;
}
@@ -110,6 +114,7 @@ load('settings.js');
var settings_file = arguments_[0];
var ll_file = arguments_[1];
+additionalLibraries = Array.prototype.slice.call(arguments_, 2);
if (settings_file) {
var settings = JSON.parse(read(settings_file));
@@ -118,6 +123,7 @@ if (settings_file) {
}
}
+
if (CORRECT_SIGNS >= 2) {
CORRECT_SIGNS_LINES = set(CORRECT_SIGNS_LINES); // for fast checking
}