summaryrefslogtreecommitdiff
path: root/js/src/shell
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-24 12:23:14 +0100
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-24 12:23:14 +0100
commit2bb0252ab48a97a72c33cef9cbe54e86563f15c9 (patch)
tree1b792a95a2ddaed8f3a16e7367b72fff73a51a51 /js/src/shell
parent4b487efb58bfba4c3f67d898e86b9f6daaab59b2 (diff)
downloaduxp-2bb0252ab48a97a72c33cef9cbe54e86563f15c9.tar.gz
Bug 1147371: Implement IteratorClose for array destructuring
Issue #74
Diffstat (limited to 'js/src/shell')
-rw-r--r--js/src/shell/js.cpp35
1 files changed, 25 insertions, 10 deletions
diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp
index 294dd935df..6fe01de22b 100644
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -2585,12 +2585,28 @@ Notes(JSContext* cx, unsigned argc, Value* vp)
return true;
}
-JS_STATIC_ASSERT(JSTRY_CATCH == 0);
-JS_STATIC_ASSERT(JSTRY_FINALLY == 1);
-JS_STATIC_ASSERT(JSTRY_FOR_IN == 2);
+static const char*
+TryNoteName(JSTryNoteKind kind)
+{
+ switch (kind) {
+ case JSTRY_CATCH:
+ return "catch";
+ case JSTRY_FINALLY:
+ return "finally";
+ case JSTRY_FOR_IN:
+ return "for-in";
+ case JSTRY_FOR_OF:
+ return "for-of";
+ case JSTRY_LOOP:
+ return "loop";
+ case JSTRY_ITERCLOSE:
+ return "iterclose";
+ case JSTRY_DESTRUCTURING_ITERCLOSE:
+ return "dstr-iterclose";
+ }
-static const char* const TryNoteNames[] = { "catch", "finally", "for-in", "for-of", "loop",
- "iterclose" };
+ MOZ_CRASH("Bad JSTryNoteKind");
+}
static MOZ_MUST_USE bool
TryNotes(JSContext* cx, HandleScript script, Sprinter* sp)
@@ -2598,17 +2614,16 @@ TryNotes(JSContext* cx, HandleScript script, Sprinter* sp)
if (!script->hasTrynotes())
return true;
- if (sp->put("\nException table:\nkind stack start end\n") < 0)
+ if (sp->put("\nException table:\nkind stack start end\n") < 0)
return false;
JSTryNote* tn = script->trynotes()->vector;
JSTryNote* tnlimit = tn + script->trynotes()->length;
do {
- MOZ_ASSERT(tn->kind < ArrayLength(TryNoteNames));
uint32_t startOff = script->pcToOffset(script->main()) + tn->start;
- if (!sp->jsprintf(" %-9s %6u %8u %8u\n",
- TryNoteNames[tn->kind], tn->stackDepth,
- startOff, startOff + tn->length))
+ if (!sp->jsprintf(" %-14s %6u %8u %8u\n",
+ TryNoteName(static_cast<JSTryNoteKind>(tn->kind)),
+ tn->stackDepth, startOff, startOff + tn->length))
{
return false;
}