|
|
|
|
| 1 |
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
1 |
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
| 2 |
* vim: set ts=8 sts=4 et sw=4 tw=99: |
2 |
* vim: set ts=8 sts=4 et sw=4 tw=99: |
| 3 |
* This Source Code Form is subject to the terms of the Mozilla Public |
3 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 4 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
4 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 |
|
6 |
|
| 7 |
/* JS reflection package. */ |
7 |
/* JS reflection package. */ |
| 8 |
|
8 |
|
| 9 |
#include "jsreflect.h" |
|
|
| 10 |
|
| 11 |
#include "mozilla/ArrayUtils.h" |
9 |
#include "mozilla/ArrayUtils.h" |
| 12 |
#include "mozilla/DebugOnly.h" |
10 |
#include "mozilla/DebugOnly.h" |
| 13 |
|
11 |
|
| 14 |
#include <stdlib.h> |
12 |
#include <stdlib.h> |
| 15 |
|
13 |
|
| 16 |
#include "jsarray.h" |
14 |
#include "jsarray.h" |
| 17 |
#include "jsatom.h" |
15 |
#include "jsatom.h" |
| 18 |
#include "jsobj.h" |
16 |
#include "jsobj.h" |
|
|
| 29 |
|
27 |
|
| 30 |
using namespace js; |
28 |
using namespace js; |
| 31 |
using namespace js::frontend; |
29 |
using namespace js::frontend; |
| 32 |
|
30 |
|
| 33 |
using JS::AutoValueArray; |
31 |
using JS::AutoValueArray; |
| 34 |
using mozilla::ArrayLength; |
32 |
using mozilla::ArrayLength; |
| 35 |
using mozilla::DebugOnly; |
33 |
using mozilla::DebugOnly; |
| 36 |
|
34 |
|
| 37 |
char const * const js::aopNames[] = { |
35 |
enum ASTType { |
|
|
36 |
AST_ERROR = -1, |
| 37 |
#define ASTDEF(ast, str, method) ast, |
| 38 |
#include "jsast.tbl" |
| 39 |
#undef ASTDEF |
| 40 |
AST_LIMIT |
| 41 |
}; |
| 42 |
|
| 43 |
enum AssignmentOperator { |
| 44 |
AOP_ERR = -1, |
| 45 |
|
| 46 |
/* assign */ |
| 47 |
AOP_ASSIGN = 0, |
| 48 |
/* operator-assign */ |
| 49 |
AOP_PLUS, AOP_MINUS, AOP_STAR, AOP_DIV, AOP_MOD, |
| 50 |
/* shift-assign */ |
| 51 |
AOP_LSH, AOP_RSH, AOP_URSH, |
| 52 |
/* binary */ |
| 53 |
AOP_BITOR, AOP_BITXOR, AOP_BITAND, |
| 54 |
|
| 55 |
AOP_LIMIT |
| 56 |
}; |
| 57 |
|
| 58 |
enum BinaryOperator { |
| 59 |
BINOP_ERR = -1, |
| 60 |
|
| 61 |
/* eq */ |
| 62 |
BINOP_EQ = 0, BINOP_NE, BINOP_STRICTEQ, BINOP_STRICTNE, |
| 63 |
/* rel */ |
| 64 |
BINOP_LT, BINOP_LE, BINOP_GT, BINOP_GE, |
| 65 |
/* shift */ |
| 66 |
BINOP_LSH, BINOP_RSH, BINOP_URSH, |
| 67 |
/* arithmetic */ |
| 68 |
BINOP_ADD, BINOP_SUB, BINOP_STAR, BINOP_DIV, BINOP_MOD, |
| 69 |
/* binary */ |
| 70 |
BINOP_BITOR, BINOP_BITXOR, BINOP_BITAND, |
| 71 |
/* misc */ |
| 72 |
BINOP_IN, BINOP_INSTANCEOF, |
| 73 |
|
| 74 |
BINOP_LIMIT |
| 75 |
}; |
| 76 |
|
| 77 |
enum UnaryOperator { |
| 78 |
UNOP_ERR = -1, |
| 79 |
|
| 80 |
UNOP_DELETE = 0, |
| 81 |
UNOP_NEG, |
| 82 |
UNOP_POS, |
| 83 |
UNOP_NOT, |
| 84 |
UNOP_BITNOT, |
| 85 |
UNOP_TYPEOF, |
| 86 |
UNOP_VOID, |
| 87 |
|
| 88 |
UNOP_LIMIT |
| 89 |
}; |
| 90 |
|
| 91 |
enum VarDeclKind { |
| 92 |
VARDECL_ERR = -1, |
| 93 |
VARDECL_VAR = 0, |
| 94 |
VARDECL_CONST, |
| 95 |
VARDECL_LET, |
| 96 |
VARDECL_LIMIT |
| 97 |
}; |
| 98 |
|
| 99 |
enum PropKind { |
| 100 |
PROP_ERR = -1, |
| 101 |
PROP_INIT = 0, |
| 102 |
PROP_GETTER, |
| 103 |
PROP_SETTER, |
| 104 |
PROP_MUTATEPROTO, |
| 105 |
PROP_LIMIT |
| 106 |
}; |
| 107 |
|
| 108 |
static char const * const aopNames[] = { |
| 38 |
"=", /* AOP_ASSIGN */ |
109 |
"=", /* AOP_ASSIGN */ |
| 39 |
"+=", /* AOP_PLUS */ |
110 |
"+=", /* AOP_PLUS */ |
| 40 |
"-=", /* AOP_MINUS */ |
111 |
"-=", /* AOP_MINUS */ |
| 41 |
"*=", /* AOP_STAR */ |
112 |
"*=", /* AOP_STAR */ |
| 42 |
"/=", /* AOP_DIV */ |
113 |
"/=", /* AOP_DIV */ |
| 43 |
"%=", /* AOP_MOD */ |
114 |
"%=", /* AOP_MOD */ |
| 44 |
"<<=", /* AOP_LSH */ |
115 |
"<<=", /* AOP_LSH */ |
| 45 |
">>=", /* AOP_RSH */ |
116 |
">>=", /* AOP_RSH */ |
| 46 |
">>>=", /* AOP_URSH */ |
117 |
">>>=", /* AOP_URSH */ |
| 47 |
"|=", /* AOP_BITOR */ |
118 |
"|=", /* AOP_BITOR */ |
| 48 |
"^=", /* AOP_BITXOR */ |
119 |
"^=", /* AOP_BITXOR */ |
| 49 |
"&=" /* AOP_BITAND */ |
120 |
"&=" /* AOP_BITAND */ |
| 50 |
}; |
121 |
}; |
| 51 |
|
122 |
|
| 52 |
char const * const js::binopNames[] = { |
123 |
static char const * const binopNames[] = { |
| 53 |
"==", /* BINOP_EQ */ |
124 |
"==", /* BINOP_EQ */ |
| 54 |
"!=", /* BINOP_NE */ |
125 |
"!=", /* BINOP_NE */ |
| 55 |
"===", /* BINOP_STRICTEQ */ |
126 |
"===", /* BINOP_STRICTEQ */ |
| 56 |
"!==", /* BINOP_STRICTNE */ |
127 |
"!==", /* BINOP_STRICTNE */ |
| 57 |
"<", /* BINOP_LT */ |
128 |
"<", /* BINOP_LT */ |
| 58 |
"<=", /* BINOP_LE */ |
129 |
"<=", /* BINOP_LE */ |
| 59 |
">", /* BINOP_GT */ |
130 |
">", /* BINOP_GT */ |
| 60 |
">=", /* BINOP_GE */ |
131 |
">=", /* BINOP_GE */ |
|
Lines 68-94
char const * const js::binopNames[] = {
|
Link Here
|
|---|
|
| 68 |
"%", /* BINOP_MOD */ |
139 |
"%", /* BINOP_MOD */ |
| 69 |
"|", /* BINOP_BITOR */ |
140 |
"|", /* BINOP_BITOR */ |
| 70 |
"^", /* BINOP_BITXOR */ |
141 |
"^", /* BINOP_BITXOR */ |
| 71 |
"&", /* BINOP_BITAND */ |
142 |
"&", /* BINOP_BITAND */ |
| 72 |
"in", /* BINOP_IN */ |
143 |
"in", /* BINOP_IN */ |
| 73 |
"instanceof", /* BINOP_INSTANCEOF */ |
144 |
"instanceof", /* BINOP_INSTANCEOF */ |
| 74 |
}; |
145 |
}; |
| 75 |
|
146 |
|
| 76 |
char const * const js::unopNames[] = { |
147 |
static char const * const unopNames[] = { |
| 77 |
"delete", /* UNOP_DELETE */ |
148 |
"delete", /* UNOP_DELETE */ |
| 78 |
"-", /* UNOP_NEG */ |
149 |
"-", /* UNOP_NEG */ |
| 79 |
"+", /* UNOP_POS */ |
150 |
"+", /* UNOP_POS */ |
| 80 |
"!", /* UNOP_NOT */ |
151 |
"!", /* UNOP_NOT */ |
| 81 |
"~", /* UNOP_BITNOT */ |
152 |
"~", /* UNOP_BITNOT */ |
| 82 |
"typeof", /* UNOP_TYPEOF */ |
153 |
"typeof", /* UNOP_TYPEOF */ |
| 83 |
"void" /* UNOP_VOID */ |
154 |
"void" /* UNOP_VOID */ |
| 84 |
}; |
155 |
}; |
| 85 |
|
156 |
|
| 86 |
char const * const js::nodeTypeNames[] = { |
157 |
static char const * const nodeTypeNames[] = { |
| 87 |
#define ASTDEF(ast, str, method) str, |
158 |
#define ASTDEF(ast, str, method) str, |
| 88 |
#include "jsast.tbl" |
159 |
#include "jsast.tbl" |
| 89 |
#undef ASTDEF |
160 |
#undef ASTDEF |
| 90 |
nullptr |
161 |
nullptr |
| 91 |
}; |
162 |
}; |
| 92 |
|
163 |
|
| 93 |
static char const * const callbackNames[] = { |
164 |
static char const * const callbackNames[] = { |
| 94 |
#define ASTDEF(ast, str, method) method, |
165 |
#define ASTDEF(ast, str, method) method, |