summaryrefslogtreecommitdiffstats
path: root/js/src/jscntxt.cpp
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2019-06-09 14:38:36 -0400
committerGaming4JC <g4jc@hyperbola.info>2019-07-18 22:38:32 -0400
commitf4552af8bc9419c5f2860385de14e28a6805ea7e (patch)
treec8a8c738e0681578ab0a7bbe2382bfbc9a27ee5f /js/src/jscntxt.cpp
parentda77e2c04cf4d408a3d0dca153c8a27ec3de2951 (diff)
downloadUXP-f4552af8bc9419c5f2860385de14e28a6805ea7e.tar
UXP-f4552af8bc9419c5f2860385de14e28a6805ea7e.tar.gz
UXP-f4552af8bc9419c5f2860385de14e28a6805ea7e.tar.lz
UXP-f4552af8bc9419c5f2860385de14e28a6805ea7e.tar.xz
UXP-f4552af8bc9419c5f2860385de14e28a6805ea7e.zip
1283712 - Part 5: Support notes in Debugger.
Diffstat (limited to 'js/src/jscntxt.cpp')
-rw-r--r--js/src/jscntxt.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/js/src/jscntxt.cpp b/js/src/jscntxt.cpp
index b113a0e1f..441b006d6 100644
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -921,6 +921,52 @@ js::ReportValueErrorFlags(JSContext* cx, unsigned flags, const unsigned errorNum
return ok;
}
+JSObject*
+js::CreateErrorNotesArray(JSContext* cx, JSErrorReport* report)
+{
+ RootedArrayObject notesArray(cx, NewDenseEmptyArray(cx));
+ if (!notesArray)
+ return nullptr;
+
+ if (!report->notes)
+ return notesArray;
+
+ for (auto&& note : *report->notes) {
+ RootedPlainObject noteObj(cx, NewBuiltinClassInstance<PlainObject>(cx));
+ if (!noteObj)
+ return nullptr;
+
+ RootedString messageStr(cx, note->newMessageString(cx));
+ if (!messageStr)
+ return nullptr;
+ RootedValue messageVal(cx, StringValue(messageStr));
+ if (!DefineProperty(cx, noteObj, cx->names().message, messageVal))
+ return nullptr;
+
+ RootedValue filenameVal(cx);
+ if (note->filename) {
+ RootedString filenameStr(cx, NewStringCopyZ<CanGC>(cx, note->filename));
+ if (!filenameStr)
+ return nullptr;
+ filenameVal = StringValue(filenameStr);
+ }
+ if (!DefineProperty(cx, noteObj, cx->names().fileName, filenameVal))
+ return nullptr;
+
+ RootedValue linenoVal(cx, Int32Value(note->lineno));
+ if (!DefineProperty(cx, noteObj, cx->names().lineNumber, linenoVal))
+ return nullptr;
+ RootedValue columnVal(cx, Int32Value(note->column));
+ if (!DefineProperty(cx, noteObj, cx->names().columnNumber, columnVal))
+ return nullptr;
+
+ if (!NewbornArrayPush(cx, notesArray, ObjectValue(*noteObj)))
+ return nullptr;
+ }
+
+ return notesArray;
+}
+
const JSErrorFormatString js_ErrorFormatString[JSErr_Limit] = {
#define MSG_DEF(name, count, exception, format) \
{ #name, format, count, exception } ,