Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / coffee-script / lib / coffee-script / coffee-script.js
1 // Generated by CoffeeScript 1.8.0
2 (function() {
3   var Lexer, SourceMap, compile, ext, formatSourcePosition, fs, getSourceMap, helpers, lexer, parser, path, sourceMaps, vm, withPrettyErrors, _base, _i, _len, _ref,
4     __hasProp = {}.hasOwnProperty,
5     __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; };
6
7   fs = require('fs');
8
9   vm = require('vm');
10
11   path = require('path');
12
13   Lexer = require('./lexer').Lexer;
14
15   parser = require('./parser').parser;
16
17   helpers = require('./helpers');
18
19   SourceMap = require('./sourcemap');
20
21   exports.VERSION = '1.8.0';
22
23   exports.FILE_EXTENSIONS = ['.coffee', '.litcoffee', '.coffee.md'];
24
25   exports.helpers = helpers;
26
27   withPrettyErrors = function(fn) {
28     return function(code, options) {
29       var err;
30       if (options == null) {
31         options = {};
32       }
33       try {
34         return fn.call(this, code, options);
35       } catch (_error) {
36         err = _error;
37         throw helpers.updateSyntaxError(err, code, options.filename);
38       }
39     };
40   };
41
42   exports.compile = compile = withPrettyErrors(function(code, options) {
43     var answer, currentColumn, currentLine, extend, fragment, fragments, header, js, map, merge, newLines, _i, _len;
44     merge = helpers.merge, extend = helpers.extend;
45     options = extend({}, options);
46     if (options.sourceMap) {
47       map = new SourceMap;
48     }
49     fragments = parser.parse(lexer.tokenize(code, options)).compileToFragments(options);
50     currentLine = 0;
51     if (options.header) {
52       currentLine += 1;
53     }
54     if (options.shiftLine) {
55       currentLine += 1;
56     }
57     currentColumn = 0;
58     js = "";
59     for (_i = 0, _len = fragments.length; _i < _len; _i++) {
60       fragment = fragments[_i];
61       if (options.sourceMap) {
62         if (fragment.locationData) {
63           map.add([fragment.locationData.first_line, fragment.locationData.first_column], [currentLine, currentColumn], {
64             noReplace: true
65           });
66         }
67         newLines = helpers.count(fragment.code, "\n");
68         currentLine += newLines;
69         if (newLines) {
70           currentColumn = fragment.code.length - (fragment.code.lastIndexOf("\n") + 1);
71         } else {
72           currentColumn += fragment.code.length;
73         }
74       }
75       js += fragment.code;
76     }
77     if (options.header) {
78       header = "Generated by CoffeeScript " + this.VERSION;
79       js = "// " + header + "\n" + js;
80     }
81     if (options.sourceMap) {
82       answer = {
83         js: js
84       };
85       answer.sourceMap = map;
86       answer.v3SourceMap = map.generate(options, code);
87       return answer;
88     } else {
89       return js;
90     }
91   });
92
93   exports.tokens = withPrettyErrors(function(code, options) {
94     return lexer.tokenize(code, options);
95   });
96
97   exports.nodes = withPrettyErrors(function(source, options) {
98     if (typeof source === 'string') {
99       return parser.parse(lexer.tokenize(source, options));
100     } else {
101       return parser.parse(source);
102     }
103   });
104
105   exports.run = function(code, options) {
106     var answer, dir, mainModule, _ref;
107     if (options == null) {
108       options = {};
109     }
110     mainModule = require.main;
111     mainModule.filename = process.argv[1] = options.filename ? fs.realpathSync(options.filename) : '.';
112     mainModule.moduleCache && (mainModule.moduleCache = {});
113     dir = options.filename ? path.dirname(fs.realpathSync(options.filename)) : fs.realpathSync('.');
114     mainModule.paths = require('module')._nodeModulePaths(dir);
115     if (!helpers.isCoffee(mainModule.filename) || require.extensions) {
116       answer = compile(code, options);
117       code = (_ref = answer.js) != null ? _ref : answer;
118     }
119     return mainModule._compile(code, mainModule.filename);
120   };
121
122   exports["eval"] = function(code, options) {
123     var Module, Script, js, k, o, r, sandbox, v, _i, _len, _module, _ref, _ref1, _require;
124     if (options == null) {
125       options = {};
126     }
127     if (!(code = code.trim())) {
128       return;
129     }
130     Script = vm.Script;
131     if (Script) {
132       if (options.sandbox != null) {
133         if (options.sandbox instanceof Script.createContext().constructor) {
134           sandbox = options.sandbox;
135         } else {
136           sandbox = Script.createContext();
137           _ref = options.sandbox;
138           for (k in _ref) {
139             if (!__hasProp.call(_ref, k)) continue;
140             v = _ref[k];
141             sandbox[k] = v;
142           }
143         }
144         sandbox.global = sandbox.root = sandbox.GLOBAL = sandbox;
145       } else {
146         sandbox = global;
147       }
148       sandbox.__filename = options.filename || 'eval';
149       sandbox.__dirname = path.dirname(sandbox.__filename);
150       if (!(sandbox !== global || sandbox.module || sandbox.require)) {
151         Module = require('module');
152         sandbox.module = _module = new Module(options.modulename || 'eval');
153         sandbox.require = _require = function(path) {
154           return Module._load(path, _module, true);
155         };
156         _module.filename = sandbox.__filename;
157         _ref1 = Object.getOwnPropertyNames(require);
158         for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
159           r = _ref1[_i];
160           if (r !== 'paths') {
161             _require[r] = require[r];
162           }
163         }
164         _require.paths = _module.paths = Module._nodeModulePaths(process.cwd());
165         _require.resolve = function(request) {
166           return Module._resolveFilename(request, _module);
167         };
168       }
169     }
170     o = {};
171     for (k in options) {
172       if (!__hasProp.call(options, k)) continue;
173       v = options[k];
174       o[k] = v;
175     }
176     o.bare = true;
177     js = compile(code, o);
178     if (sandbox === global) {
179       return vm.runInThisContext(js);
180     } else {
181       return vm.runInContext(js, sandbox);
182     }
183   };
184
185   exports.register = function() {
186     return require('./register');
187   };
188
189   if (require.extensions) {
190     _ref = this.FILE_EXTENSIONS;
191     for (_i = 0, _len = _ref.length; _i < _len; _i++) {
192       ext = _ref[_i];
193       if ((_base = require.extensions)[ext] == null) {
194         _base[ext] = function() {
195           throw new Error("Use CoffeeScript.register() or require the coffee-script/register module to require " + ext + " files.");
196         };
197       }
198     }
199   }
200
201   exports._compileFile = function(filename, sourceMap) {
202     var answer, err, raw, stripped;
203     if (sourceMap == null) {
204       sourceMap = false;
205     }
206     raw = fs.readFileSync(filename, 'utf8');
207     stripped = raw.charCodeAt(0) === 0xFEFF ? raw.substring(1) : raw;
208     try {
209       answer = compile(stripped, {
210         filename: filename,
211         sourceMap: sourceMap,
212         literate: helpers.isLiterate(filename)
213       });
214     } catch (_error) {
215       err = _error;
216       throw helpers.updateSyntaxError(err, stripped, filename);
217     }
218     return answer;
219   };
220
221   lexer = new Lexer;
222
223   parser.lexer = {
224     lex: function() {
225       var tag, token;
226       token = this.tokens[this.pos++];
227       if (token) {
228         tag = token[0], this.yytext = token[1], this.yylloc = token[2];
229         this.errorToken = token.origin || token;
230         this.yylineno = this.yylloc.first_line;
231       } else {
232         tag = '';
233       }
234       return tag;
235     },
236     setInput: function(tokens) {
237       this.tokens = tokens;
238       return this.pos = 0;
239     },
240     upcomingInput: function() {
241       return "";
242     }
243   };
244
245   parser.yy = require('./nodes');
246
247   parser.yy.parseError = function(message, _arg) {
248     var errorLoc, errorTag, errorText, errorToken, token, tokens, _ref1;
249     token = _arg.token;
250     _ref1 = parser.lexer, errorToken = _ref1.errorToken, tokens = _ref1.tokens;
251     errorTag = errorToken[0], errorText = errorToken[1], errorLoc = errorToken[2];
252     errorText = errorToken === tokens[tokens.length - 1] ? 'end of input' : errorTag === 'INDENT' || errorTag === 'OUTDENT' ? 'indentation' : helpers.nameWhitespaceCharacter(errorText);
253     return helpers.throwSyntaxError("unexpected " + errorText, errorLoc);
254   };
255
256   formatSourcePosition = function(frame, getSourceMapping) {
257     var as, column, fileLocation, fileName, functionName, isConstructor, isMethodCall, line, methodName, source, tp, typeName;
258     fileName = void 0;
259     fileLocation = '';
260     if (frame.isNative()) {
261       fileLocation = "native";
262     } else {
263       if (frame.isEval()) {
264         fileName = frame.getScriptNameOrSourceURL();
265         if (!fileName) {
266           fileLocation = "" + (frame.getEvalOrigin()) + ", ";
267         }
268       } else {
269         fileName = frame.getFileName();
270       }
271       fileName || (fileName = "<anonymous>");
272       line = frame.getLineNumber();
273       column = frame.getColumnNumber();
274       source = getSourceMapping(fileName, line, column);
275       fileLocation = source ? "" + fileName + ":" + source[0] + ":" + source[1] : "" + fileName + ":" + line + ":" + column;
276     }
277     functionName = frame.getFunctionName();
278     isConstructor = frame.isConstructor();
279     isMethodCall = !(frame.isToplevel() || isConstructor);
280     if (isMethodCall) {
281       methodName = frame.getMethodName();
282       typeName = frame.getTypeName();
283       if (functionName) {
284         tp = as = '';
285         if (typeName && functionName.indexOf(typeName)) {
286           tp = "" + typeName + ".";
287         }
288         if (methodName && functionName.indexOf("." + methodName) !== functionName.length - methodName.length - 1) {
289           as = " [as " + methodName + "]";
290         }
291         return "" + tp + functionName + as + " (" + fileLocation + ")";
292       } else {
293         return "" + typeName + "." + (methodName || '<anonymous>') + " (" + fileLocation + ")";
294       }
295     } else if (isConstructor) {
296       return "new " + (functionName || '<anonymous>') + " (" + fileLocation + ")";
297     } else if (functionName) {
298       return "" + functionName + " (" + fileLocation + ")";
299     } else {
300       return fileLocation;
301     }
302   };
303
304   sourceMaps = {};
305
306   getSourceMap = function(filename) {
307     var answer, _ref1;
308     if (sourceMaps[filename]) {
309       return sourceMaps[filename];
310     }
311     if (_ref1 = path != null ? path.extname(filename) : void 0, __indexOf.call(exports.FILE_EXTENSIONS, _ref1) < 0) {
312       return;
313     }
314     answer = exports._compileFile(filename, true);
315     return sourceMaps[filename] = answer.sourceMap;
316   };
317
318   Error.prepareStackTrace = function(err, stack) {
319     var frame, frames, getSourceMapping;
320     getSourceMapping = function(filename, line, column) {
321       var answer, sourceMap;
322       sourceMap = getSourceMap(filename);
323       if (sourceMap) {
324         answer = sourceMap.sourceLocation([line - 1, column - 1]);
325       }
326       if (answer) {
327         return [answer[0] + 1, answer[1] + 1];
328       } else {
329         return null;
330       }
331     };
332     frames = (function() {
333       var _j, _len1, _results;
334       _results = [];
335       for (_j = 0, _len1 = stack.length; _j < _len1; _j++) {
336         frame = stack[_j];
337         if (frame.getFunction() === exports.run) {
338           break;
339         }
340         _results.push("  at " + (formatSourcePosition(frame, getSourceMapping)));
341       }
342       return _results;
343     })();
344     return "" + (err.toString()) + "\n" + (frames.join('\n')) + "\n";
345   };
346
347 }).call(this);