mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
removing export of RESERVED ... more progress.
This commit is contained in:
parent
76a25dc797
commit
9167b3aca1
2 changed files with 44 additions and 43 deletions
|
@ -1,40 +1,39 @@
|
|||
// Generated by CoffeeScript 1.3.3
|
||||
(function() {
|
||||
var Lexer, RESERVED, compile, fs, lexer, parser, path, stripBOM, vm, _ref,
|
||||
var Lexer, compile, ext, extensions, fs, lexer, loadFile, parser, path, vm, _i, _len,
|
||||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
|
||||
__hasProp = {}.hasOwnProperty;
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
path = require('path');
|
||||
|
||||
_ref = require('./lexer'), Lexer = _ref.Lexer, RESERVED = _ref.RESERVED;
|
||||
Lexer = require('./lexer').Lexer;
|
||||
|
||||
parser = require('./parser').parser;
|
||||
|
||||
vm = require('vm');
|
||||
|
||||
stripBOM = function(content) {
|
||||
if (content.charCodeAt(0) === 0xFEFF) {
|
||||
return content.substring(1);
|
||||
} else {
|
||||
return content;
|
||||
}
|
||||
extensions = ['.coffee', '.litcoffee'];
|
||||
|
||||
loadFile = function(module, filename) {
|
||||
var raw, stripped;
|
||||
raw = fs.readFileSync(filename, 'utf8');
|
||||
stripped = raw.charCodeAt(0) === 0xFEFF ? raw.substring(1) : raw;
|
||||
return module._compile(compile(stripped, {
|
||||
filename: filename
|
||||
}), filename);
|
||||
};
|
||||
|
||||
if (require.extensions) {
|
||||
require.extensions['.coffee'] = function(module, filename) {
|
||||
var content;
|
||||
content = compile(stripBOM(fs.readFileSync(filename, 'utf8')), {
|
||||
filename: filename
|
||||
});
|
||||
return module._compile(content, filename);
|
||||
};
|
||||
for (_i = 0, _len = extensions.length; _i < _len; _i++) {
|
||||
ext = extensions[_i];
|
||||
require.extensions[ext] = loadFile;
|
||||
}
|
||||
}
|
||||
|
||||
exports.VERSION = '1.3.3';
|
||||
|
||||
exports.RESERVED = RESERVED;
|
||||
|
||||
exports.helpers = require('./helpers');
|
||||
|
||||
exports.compile = compile = function(code, options) {
|
||||
|
@ -71,7 +70,7 @@
|
|||
};
|
||||
|
||||
exports.run = function(code, options) {
|
||||
var mainModule;
|
||||
var mainModule, _ref;
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
|
@ -79,7 +78,7 @@
|
|||
mainModule.filename = process.argv[1] = options.filename ? fs.realpathSync(options.filename) : '.';
|
||||
mainModule.moduleCache && (mainModule.moduleCache = {});
|
||||
mainModule.paths = require('module')._nodeModulePaths(path.dirname(fs.realpathSync(options.filename)));
|
||||
if (path.extname(mainModule.filename) !== '.coffee' || require.extensions) {
|
||||
if ((_ref = path.extname(mainModule.filename), __indexOf.call(extensions, _ref) < 0) || require.extensions) {
|
||||
return mainModule._compile(compile(code, options), mainModule.filename);
|
||||
} else {
|
||||
return mainModule._compile(code, mainModule.filename);
|
||||
|
@ -87,7 +86,7 @@
|
|||
};
|
||||
|
||||
exports["eval"] = function(code, options) {
|
||||
var Module, Script, js, k, o, r, sandbox, v, _i, _len, _module, _ref1, _ref2, _require;
|
||||
var Module, Script, js, k, o, r, sandbox, v, _j, _len1, _module, _ref, _ref1, _require;
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
|
@ -101,10 +100,10 @@
|
|||
sandbox = options.sandbox;
|
||||
} else {
|
||||
sandbox = Script.createContext();
|
||||
_ref1 = options.sandbox;
|
||||
for (k in _ref1) {
|
||||
if (!__hasProp.call(_ref1, k)) continue;
|
||||
v = _ref1[k];
|
||||
_ref = options.sandbox;
|
||||
for (k in _ref) {
|
||||
if (!__hasProp.call(_ref, k)) continue;
|
||||
v = _ref[k];
|
||||
sandbox[k] = v;
|
||||
}
|
||||
}
|
||||
|
@ -121,9 +120,9 @@
|
|||
return Module._load(path, _module, true);
|
||||
};
|
||||
_module.filename = sandbox.__filename;
|
||||
_ref2 = Object.getOwnPropertyNames(require);
|
||||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
||||
r = _ref2[_i];
|
||||
_ref1 = Object.getOwnPropertyNames(require);
|
||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||
r = _ref1[_j];
|
||||
if (r !== 'paths') {
|
||||
_require[r] = require[r];
|
||||
}
|
||||
|
@ -153,8 +152,8 @@
|
|||
|
||||
parser.lexer = {
|
||||
lex: function() {
|
||||
var tag, _ref1;
|
||||
_ref1 = this.tokens[this.pos++] || [''], tag = _ref1[0], this.yytext = _ref1[1], this.yylineno = _ref1[2];
|
||||
var tag, _ref;
|
||||
_ref = this.tokens[this.pos++] || [''], tag = _ref[0], this.yytext = _ref[1], this.yylineno = _ref[2];
|
||||
return tag;
|
||||
},
|
||||
setInput: function(tokens) {
|
||||
|
|
|
@ -8,24 +8,26 @@
|
|||
|
||||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
{Lexer,RESERVED} = require './lexer'
|
||||
{Lexer} = require './lexer'
|
||||
{parser} = require './parser'
|
||||
vm = require 'vm'
|
||||
|
||||
stripBOM = (content) ->
|
||||
if content.charCodeAt(0) is 0xFEFF then content.substring 1 else content
|
||||
# The file extensions that are considered to be CoffeeScript.
|
||||
extensions = ['.coffee', '.litcoffee']
|
||||
|
||||
# Load and run a CoffeeScript file for Node, stripping any `BOM`s.
|
||||
loadFile = (module, filename) ->
|
||||
raw = fs.readFileSync filename, 'utf8'
|
||||
stripped = if raw.charCodeAt(0) is 0xFEFF then raw.substring 1 else raw
|
||||
module._compile compile(stripped, {filename}), filename
|
||||
|
||||
if require.extensions
|
||||
require.extensions['.coffee'] = (module, filename) ->
|
||||
content = compile stripBOM(fs.readFileSync filename, 'utf8'), {filename}
|
||||
module._compile content, filename
|
||||
for ext in extensions
|
||||
require.extensions[ext] = loadFile
|
||||
|
||||
# The current CoffeeScript version number.
|
||||
exports.VERSION = '1.3.3'
|
||||
|
||||
# Words that cannot be used as identifiers in CoffeeScript code
|
||||
exports.RESERVED = RESERVED
|
||||
|
||||
# Expose helpers for testing.
|
||||
exports.helpers = require './helpers'
|
||||
|
||||
|
@ -71,7 +73,7 @@ exports.run = (code, options = {}) ->
|
|||
mainModule.paths = require('module')._nodeModulePaths path.dirname fs.realpathSync options.filename
|
||||
|
||||
# Compile.
|
||||
if path.extname(mainModule.filename) isnt '.coffee' or require.extensions
|
||||
if (path.extname(mainModule.filename) not in extensions) or require.extensions
|
||||
mainModule._compile compile(code, options), mainModule.filename
|
||||
else
|
||||
mainModule._compile code, mainModule.filename
|
||||
|
|
Loading…
Reference in a new issue