Без опису

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. // Generated by CoffeeScript 1.3.3
  2. (function() {
  3. var Lexer, RESERVED, compile, fs, lexer, parser, path, vm, _ref,
  4. __hasProp = {}.hasOwnProperty;
  5. fs = require('fs');
  6. path = require('path');
  7. _ref = require('./lexer'), Lexer = _ref.Lexer, RESERVED = _ref.RESERVED;
  8. parser = require('./parser').parser;
  9. vm = require('vm');
  10. if (require.extensions) {
  11. require.extensions['.coffee'] = function(module, filename) {
  12. var content;
  13. content = compile(fs.readFileSync(filename, 'utf8'), {
  14. filename: filename
  15. });
  16. return module._compile(content, filename);
  17. };
  18. } else if (require.registerExtension) {
  19. require.registerExtension('.coffee', function(content) {
  20. return compile(content);
  21. });
  22. }
  23. exports.VERSION = '1.3.3';
  24. exports.RESERVED = RESERVED;
  25. exports.helpers = require('./helpers');
  26. exports.compile = compile = function(code, options) {
  27. var header, js, merge;
  28. if (options == null) {
  29. options = {};
  30. }
  31. merge = exports.helpers.merge;
  32. try {
  33. js = (parser.parse(lexer.tokenize(code))).compile(options);
  34. if (!options.header) {
  35. return js;
  36. }
  37. } catch (err) {
  38. if (options.filename) {
  39. err.message = "In " + options.filename + ", " + err.message;
  40. }
  41. throw err;
  42. }
  43. header = "Generated by CoffeeScript " + this.VERSION;
  44. return "// " + header + "\n" + js;
  45. };
  46. exports.tokens = function(code, options) {
  47. return lexer.tokenize(code, options);
  48. };
  49. exports.nodes = function(source, options) {
  50. if (typeof source === 'string') {
  51. return parser.parse(lexer.tokenize(source, options));
  52. } else {
  53. return parser.parse(source);
  54. }
  55. };
  56. exports.run = function(code, options) {
  57. var mainModule;
  58. if (options == null) {
  59. options = {};
  60. }
  61. mainModule = require.main;
  62. mainModule.filename = process.argv[1] = options.filename ? fs.realpathSync(options.filename) : '.';
  63. mainModule.moduleCache && (mainModule.moduleCache = {});
  64. mainModule.paths = require('module')._nodeModulePaths(path.dirname(fs.realpathSync(options.filename)));
  65. if (path.extname(mainModule.filename) !== '.coffee' || require.extensions) {
  66. return mainModule._compile(compile(code, options), mainModule.filename);
  67. } else {
  68. return mainModule._compile(code, mainModule.filename);
  69. }
  70. };
  71. exports["eval"] = function(code, options) {
  72. var Module, Script, js, k, o, r, sandbox, v, _i, _len, _module, _ref1, _ref2, _require;
  73. if (options == null) {
  74. options = {};
  75. }
  76. if (!(code = code.trim())) {
  77. return;
  78. }
  79. Script = vm.Script;
  80. if (Script) {
  81. if (options.sandbox != null) {
  82. if (options.sandbox instanceof Script.createContext().constructor) {
  83. sandbox = options.sandbox;
  84. } else {
  85. sandbox = Script.createContext();
  86. _ref1 = options.sandbox;
  87. for (k in _ref1) {
  88. if (!__hasProp.call(_ref1, k)) continue;
  89. v = _ref1[k];
  90. sandbox[k] = v;
  91. }
  92. }
  93. sandbox.global = sandbox.root = sandbox.GLOBAL = sandbox;
  94. } else {
  95. sandbox = global;
  96. }
  97. sandbox.__filename = options.filename || 'eval';
  98. sandbox.__dirname = path.dirname(sandbox.__filename);
  99. if (!(sandbox !== global || sandbox.module || sandbox.require)) {
  100. Module = require('module');
  101. sandbox.module = _module = new Module(options.modulename || 'eval');
  102. sandbox.require = _require = function(path) {
  103. return Module._load(path, _module, true);
  104. };
  105. _module.filename = sandbox.__filename;
  106. _ref2 = Object.getOwnPropertyNames(require);
  107. for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
  108. r = _ref2[_i];
  109. if (r !== 'paths') {
  110. _require[r] = require[r];
  111. }
  112. }
  113. _require.paths = _module.paths = Module._nodeModulePaths(process.cwd());
  114. _require.resolve = function(request) {
  115. return Module._resolveFilename(request, _module);
  116. };
  117. }
  118. }
  119. o = {};
  120. for (k in options) {
  121. if (!__hasProp.call(options, k)) continue;
  122. v = options[k];
  123. o[k] = v;
  124. }
  125. o.bare = true;
  126. js = compile(code, o);
  127. if (sandbox === global) {
  128. return vm.runInThisContext(js);
  129. } else {
  130. return vm.runInContext(js, sandbox);
  131. }
  132. };
  133. lexer = new Lexer;
  134. parser.lexer = {
  135. lex: function() {
  136. var tag, _ref1;
  137. _ref1 = this.tokens[this.pos++] || [''], tag = _ref1[0], this.yytext = _ref1[1], this.yylineno = _ref1[2];
  138. return tag;
  139. },
  140. setInput: function(tokens) {
  141. this.tokens = tokens;
  142. return this.pos = 0;
  143. },
  144. upcomingInput: function() {
  145. return "";
  146. }
  147. };
  148. parser.yy = require('./nodes');
  149. }).call(this);