зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1847469 - Part 21: Use column number types in ErrorObject. r=iain
Differential Revision: https://phabricator.services.mozilla.com/D185759
This commit is contained in:
Родитель
ee81f946a2
Коммит
52394e4a4f
|
@ -352,9 +352,9 @@ bool js::ErrorToException(JSContext* cx, JSErrorReport* reportp,
|
|||
return false;
|
||||
}
|
||||
|
||||
ErrorObject* errObject = ErrorObject::create(
|
||||
cx, exnType, stack, fileName, sourceId, lineNumber,
|
||||
columnNumber.oneOriginValue(), std::move(report), messageStr, cause);
|
||||
ErrorObject* errObject =
|
||||
ErrorObject::create(cx, exnType, stack, fileName, sourceId, lineNumber,
|
||||
columnNumber, std::move(report), messageStr, cause);
|
||||
if (!errObject) {
|
||||
return false;
|
||||
}
|
||||
|
@ -741,7 +741,7 @@ JSObject* js::CopyErrorObject(JSContext* cx, Handle<ErrorObject*> err) {
|
|||
}
|
||||
uint32_t sourceId = err->sourceId();
|
||||
uint32_t lineNumber = err->lineNumber();
|
||||
uint32_t columnNumber = err->columnNumber();
|
||||
JS::ColumnNumberOneOrigin columnNumber = err->columnNumber();
|
||||
JSExnType errorType = err->type();
|
||||
|
||||
// Create the Error object.
|
||||
|
@ -768,9 +768,9 @@ JS_PUBLIC_API bool JS::CreateError(JSContext* cx, JSExnType type,
|
|||
}
|
||||
}
|
||||
|
||||
JSObject* obj = js::ErrorObject::create(
|
||||
cx, type, stack, fileName, 0, lineNumber, columnNumber.oneOriginValue(),
|
||||
std::move(rep), message, cause);
|
||||
JSObject* obj =
|
||||
js::ErrorObject::create(cx, type, stack, fileName, 0, lineNumber,
|
||||
columnNumber, std::move(rep), message, cause);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include "vm/ErrorObject.h"
|
||||
|
||||
#include "js/ColumnNumber.h" // JS::ColumnNumberOneOrigin
|
||||
|
||||
#include "vm/JSAtomState.h"
|
||||
#include "vm/JSContext.h"
|
||||
|
||||
|
@ -27,9 +29,10 @@ inline uint32_t js::ErrorObject::lineNumber() const {
|
|||
return val.isInt32() ? val.toInt32() : 0;
|
||||
}
|
||||
|
||||
inline uint32_t js::ErrorObject::columnNumber() const {
|
||||
inline JS::ColumnNumberOneOrigin js::ErrorObject::columnNumber() const {
|
||||
Value val = getReservedSlot(COLUMNNUMBER_SLOT);
|
||||
return val.isInt32() ? val.toInt32() : 0;
|
||||
return val.isInt32() ? JS::ColumnNumberOneOrigin(val.toInt32())
|
||||
: JS::ColumnNumberOneOrigin::zero();
|
||||
}
|
||||
|
||||
inline JSObject* js::ErrorObject::stack() const {
|
||||
|
|
|
@ -277,8 +277,7 @@ static ErrorObject* CreateErrorObject(JSContext* cx, const CallArgs& args,
|
|||
}
|
||||
|
||||
return ErrorObject::create(cx, exnType, stack, fileName, sourceId, lineNumber,
|
||||
columnNumber.oneOriginValue(), nullptr, message,
|
||||
cause, proto);
|
||||
columnNumber, nullptr, message, cause, proto);
|
||||
}
|
||||
|
||||
static bool Error(JSContext* cx, unsigned argc, Value* vp) {
|
||||
|
@ -448,7 +447,8 @@ bool js::ErrorObject::init(JSContext* cx, Handle<ErrorObject*> obj,
|
|||
JSExnType type, UniquePtr<JSErrorReport> errorReport,
|
||||
HandleString fileName, HandleObject stack,
|
||||
uint32_t sourceId, uint32_t lineNumber,
|
||||
uint32_t columnNumber, HandleString message,
|
||||
JS::ColumnNumberOneOrigin columnNumber,
|
||||
HandleString message,
|
||||
Handle<mozilla::Maybe<JS::Value>> cause) {
|
||||
MOZ_ASSERT(JSEXN_ERR <= type && type < JSEXN_ERROR_LIMIT);
|
||||
AssertObjectIsSavedFrameOrWrapper(cx, stack);
|
||||
|
@ -504,7 +504,8 @@ bool js::ErrorObject::init(JSContext* cx, Handle<ErrorObject*> obj,
|
|||
obj->setReservedSlot(ERROR_REPORT_SLOT, PrivateValue(report));
|
||||
obj->initReservedSlot(FILENAME_SLOT, StringValue(fileName));
|
||||
obj->initReservedSlot(LINENUMBER_SLOT, Int32Value(lineNumber));
|
||||
obj->initReservedSlot(COLUMNNUMBER_SLOT, Int32Value(columnNumber));
|
||||
obj->initReservedSlot(COLUMNNUMBER_SLOT,
|
||||
Int32Value(columnNumber.oneOriginValue()));
|
||||
if (message) {
|
||||
obj->initReservedSlot(MESSAGE_SLOT, StringValue(message));
|
||||
}
|
||||
|
@ -526,7 +527,7 @@ bool js::ErrorObject::init(JSContext* cx, Handle<ErrorObject*> obj,
|
|||
ErrorObject* js::ErrorObject::create(JSContext* cx, JSExnType errorType,
|
||||
HandleObject stack, HandleString fileName,
|
||||
uint32_t sourceId, uint32_t lineNumber,
|
||||
uint32_t columnNumber,
|
||||
JS::ColumnNumberOneOrigin columnNumber,
|
||||
UniquePtr<JSErrorReport> report,
|
||||
HandleString message,
|
||||
Handle<mozilla::Maybe<JS::Value>> cause,
|
||||
|
@ -585,7 +586,7 @@ JSErrorReport* js::ErrorObject::getOrCreateErrorReport(JSContext* cx) {
|
|||
// Coordinates.
|
||||
report.sourceId = sourceId();
|
||||
report.lineno = lineNumber();
|
||||
report.column = JS::ColumnNumberOneOrigin(columnNumber());
|
||||
report.column = columnNumber();
|
||||
|
||||
// Message. Note that |new Error()| will result in an undefined |message|
|
||||
// slot, so we need to explicitly substitute the empty string in that case.
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "NamespaceImports.h"
|
||||
|
||||
#include "js/Class.h"
|
||||
#include "js/ColumnNumber.h" // JS::ColumnNumberOneOrigin
|
||||
#include "js/ErrorReport.h"
|
||||
#include "js/RootingAPI.h"
|
||||
#include "js/TypeDecls.h"
|
||||
|
@ -35,7 +36,7 @@ class ErrorObject : public NativeObject {
|
|||
static bool init(JSContext* cx, Handle<ErrorObject*> obj, JSExnType type,
|
||||
UniquePtr<JSErrorReport> errorReport, HandleString fileName,
|
||||
HandleObject stack, uint32_t sourceId, uint32_t lineNumber,
|
||||
uint32_t columnNumber, HandleString message,
|
||||
JS::ColumnNumberOneOrigin columnNumber, HandleString message,
|
||||
Handle<mozilla::Maybe<JS::Value>> cause);
|
||||
|
||||
static const ClassSpec classSpecs[JSEXN_ERROR_LIMIT];
|
||||
|
@ -73,10 +74,10 @@ class ErrorObject : public NativeObject {
|
|||
// info. If |message| is non-null, then the error will have a .message
|
||||
// property with that value; otherwise the error will have no .message
|
||||
// property.
|
||||
// columnNumber is 1-origin.
|
||||
static ErrorObject* create(JSContext* cx, JSExnType type, HandleObject stack,
|
||||
HandleString fileName, uint32_t sourceId,
|
||||
uint32_t lineNumber, uint32_t columnNumber,
|
||||
uint32_t lineNumber,
|
||||
JS::ColumnNumberOneOrigin columnNumber,
|
||||
UniquePtr<JSErrorReport> report,
|
||||
HandleString message,
|
||||
Handle<mozilla::Maybe<JS::Value>> cause,
|
||||
|
@ -111,8 +112,8 @@ class ErrorObject : public NativeObject {
|
|||
// Line number (1-origin).
|
||||
inline uint32_t lineNumber() const;
|
||||
|
||||
// Column number in UTF-16 code units (1-origin).
|
||||
inline uint32_t columnNumber() const;
|
||||
// Column number in UTF-16 code units.
|
||||
inline JS::ColumnNumberOneOrigin columnNumber() const;
|
||||
|
||||
inline JSObject* stack() const;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#include "builtin/MapObject.h"
|
||||
#include "js/Array.h" // JS::GetArrayLength, JS::IsArrayObject
|
||||
#include "js/ArrayBuffer.h" // JS::{ArrayBufferHasData,DetachArrayBuffer,IsArrayBufferObject,New{,Mapped}ArrayBufferWithContents,ReleaseMappedArrayBufferContents}
|
||||
#include "js/ColumnNumber.h" // JS::TaggedColumnNumberOneOrigin
|
||||
#include "js/ColumnNumber.h" // JS::ColumnNumberOneOrigin, JS::TaggedColumnNumberOneOrigin
|
||||
#include "js/Date.h"
|
||||
#include "js/experimental/TypedData.h" // JS_NewDataView, JS_New{{Ui,I}nt{8,16,32},Float{32,64},Uint8Clamped,Big{Ui,I}nt64}ArrayWithBuffer
|
||||
#include "js/friend/ErrorMessages.h" // js::GetErrorMessage, JSMSG_*
|
||||
|
@ -1983,7 +1983,7 @@ bool JSStructuredCloneWriter::traverseError(HandleObject obj) {
|
|||
return false;
|
||||
}
|
||||
|
||||
val = Int32Value(unwrapped->columnNumber());
|
||||
val = Int32Value(*unwrapped->columnNumber().addressOfValueForTranscode());
|
||||
return writePrimitive(val);
|
||||
}
|
||||
|
||||
|
@ -3604,8 +3604,10 @@ JSObject* JSStructuredCloneReader::readErrorHeader(uint32_t type) {
|
|||
}
|
||||
RootedString fileName(cx, val.toString());
|
||||
|
||||
uint32_t lineNumber, columnNumber;
|
||||
if (!readUint32(&lineNumber) || !readUint32(&columnNumber)) {
|
||||
uint32_t lineNumber;
|
||||
JS::ColumnNumberOneOrigin columnNumber;
|
||||
if (!readUint32(&lineNumber) ||
|
||||
!readUint32(columnNumber.addressOfValueForTranscode())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "jit/JitContext.h"
|
||||
#include "jit/JitOptions.h"
|
||||
#include "jit/Simulator.h"
|
||||
#include "js/ColumnNumber.h" // JS::ColumnNumberOneOrigin
|
||||
#include "js/ForOfIterator.h"
|
||||
#include "js/friend/ErrorMessages.h" // js::GetErrorMessage, JSMSG_*
|
||||
#include "js/Printf.h"
|
||||
|
@ -4228,7 +4229,8 @@ static bool Reject(JSContext* cx, const CompileArgs& args,
|
|||
|
||||
RootedObject errorObj(
|
||||
cx, ErrorObject::create(cx, JSEXN_WASMCOMPILEERROR, stack, fileName, 0,
|
||||
line, 0, nullptr, message, cause));
|
||||
line, JS::ColumnNumberOneOrigin::zero(), nullptr,
|
||||
message, cause));
|
||||
if (!errorObj) {
|
||||
return false;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче