summaryrefslogtreecommitdiffstats
path: root/js/src/jspubtd.h
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jspubtd.h')
-rw-r--r--js/src/jspubtd.h34
1 files changed, 33 insertions, 1 deletions
diff --git a/js/src/jspubtd.h b/js/src/jspubtd.h
index c3c5d38bd6..64f2329c69 100644
--- a/js/src/jspubtd.h
+++ b/js/src/jspubtd.h
@@ -11,6 +11,8 @@
* JS public API typedefs.
*/
+#include "mozilla/Assertions.h" // MOZ_ASSERT_UNREACHABLE
+
#include "jstypes.h"
#include "js/ProtoKey.h"
@@ -39,7 +41,7 @@ enum JSType {
JSTYPE_NUMBER, /* number */
JSTYPE_BOOLEAN, /* boolean */
JSTYPE_SYMBOL, /* symbol */
- JSTYPE_BIGINT, /* BigInt */
+ JSTYPE_BIGINT, /* bigint */
#ifdef ENABLE_RECORD_TUPLE
JSTYPE_RECORD, /* record */
JSTYPE_TUPLE, /* tuple */
@@ -47,6 +49,36 @@ enum JSType {
JSTYPE_LIMIT
};
+inline const char* JSTypeToString(JSType type) {
+ switch (type) {
+ case JSTYPE_UNDEFINED:
+ return "undefined";
+ case JSTYPE_OBJECT:
+ return "object";
+ case JSTYPE_FUNCTION:
+ return "function";
+ case JSTYPE_STRING:
+ return "string";
+ case JSTYPE_NUMBER:
+ return "number";
+ case JSTYPE_BOOLEAN:
+ return "boolean";
+ case JSTYPE_SYMBOL:
+ return "symbol";
+ case JSTYPE_BIGINT:
+ return "bigint";
+#ifdef ENABLE_RECORD_TUPLE
+ case JSTYPE_RECORD:
+ return "record";
+ case JSTYPE_TUPLE:
+ return "tuple";
+#endif
+ default:
+ MOZ_ASSERT_UNREACHABLE("Unknown JSType");
+ }
+ return "";
+}
+
/* Dense index into cached prototypes and class atoms for standard objects. */
enum JSProtoKey {
#define PROTOKEY_AND_INITIALIZER(name, clasp) JSProto_##name,