117 lines
4.1 KiB
JavaScript
117 lines
4.1 KiB
JavaScript
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
/** A container holding a script line. */
|
|
var ScriptLine =
|
|
/** The content (or value) of this line of source. */
|
|
function ScriptLine(lineNumber, content) {
|
|
var highlight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
|
|
_classCallCheck(this, ScriptLine);
|
|
|
|
this.lineNumber = lineNumber;
|
|
this.content = content;
|
|
this.highlight = highlight;
|
|
}
|
|
/** Whether or not this line should be highlighted. Particularly useful for error reporting with context. */
|
|
|
|
/** The line number of this line of source. */
|
|
;
|
|
|
|
/**
|
|
* A representation of a stack frame.
|
|
*/
|
|
|
|
|
|
var StackFrame = function () {
|
|
function StackFrame() {
|
|
var functionName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
var fileName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
var lineNumber = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
var columnNumber = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
var scriptCode = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
|
|
var sourceFunctionName = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
|
|
var sourceFileName = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
var sourceLineNumber = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
var sourceColumnNumber = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
|
|
var sourceScriptCode = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : null;
|
|
|
|
_classCallCheck(this, StackFrame);
|
|
|
|
this.functionName = functionName;
|
|
|
|
this.fileName = fileName;
|
|
this.lineNumber = lineNumber;
|
|
this.columnNumber = columnNumber;
|
|
|
|
this._originalFunctionName = sourceFunctionName;
|
|
this._originalFileName = sourceFileName;
|
|
this._originalLineNumber = sourceLineNumber;
|
|
this._originalColumnNumber = sourceColumnNumber;
|
|
|
|
this._scriptCode = scriptCode;
|
|
this._originalScriptCode = sourceScriptCode;
|
|
}
|
|
|
|
/**
|
|
* Returns the name of this function.
|
|
*/
|
|
|
|
|
|
_createClass(StackFrame, [{
|
|
key: 'getFunctionName',
|
|
value: function getFunctionName() {
|
|
return this.functionName;
|
|
}
|
|
|
|
/**
|
|
* Returns the source of the frame.
|
|
* This contains the file name, line number, and column number when available.
|
|
*/
|
|
|
|
}, {
|
|
key: 'getSource',
|
|
value: function getSource() {
|
|
var str = '';
|
|
if (this.fileName != null) {
|
|
str += this.fileName + ':';
|
|
}
|
|
if (this.lineNumber != null) {
|
|
str += this.lineNumber + ':';
|
|
}
|
|
if (this.columnNumber != null) {
|
|
str += this.columnNumber + ':';
|
|
}
|
|
return str.slice(0, -1);
|
|
}
|
|
|
|
/**
|
|
* Returns a pretty version of this stack frame.
|
|
*/
|
|
|
|
}, {
|
|
key: 'toString',
|
|
value: function toString() {
|
|
var f = this.getFunctionName();
|
|
if (f == null) {
|
|
return this.getSource();
|
|
}
|
|
return f + ' (' + this.getSource() + ')';
|
|
}
|
|
}]);
|
|
|
|
return StackFrame;
|
|
}();
|
|
|
|
export { StackFrame, ScriptLine };
|
|
export default StackFrame; |