OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 | 313 |
314 unsigned id() const { return id_; } | 314 unsigned id() const { return id_; } |
315 unsigned test_id() const { return test_id_; } | 315 unsigned test_id() const { return test_id_; } |
316 | 316 |
317 private: | 317 private: |
318 unsigned id_; | 318 unsigned id_; |
319 unsigned test_id_; | 319 unsigned test_id_; |
320 }; | 320 }; |
321 | 321 |
322 | 322 |
323 /** | |
324 * A sentinel used during pre parsing that represents some expression | |
325 * that is a valid left hand side without having to actually build | |
326 * the expression. | |
327 */ | |
328 class ValidLeftHandSideSentinel: public Expression { | |
329 public: | |
330 explicit ValidLeftHandSideSentinel(Isolate* isolate) : Expression(isolate) {} | |
331 virtual bool IsValidLeftHandSide() { return true; } | |
332 virtual void Accept(AstVisitor* v) { UNREACHABLE(); } | |
333 virtual bool IsInlineable() const; | |
334 }; | |
335 | |
336 | |
337 class BreakableStatement: public Statement { | 323 class BreakableStatement: public Statement { |
338 public: | 324 public: |
339 enum Type { | 325 enum Type { |
340 TARGET_FOR_ANONYMOUS, | 326 TARGET_FOR_ANONYMOUS, |
341 TARGET_FOR_NAMED_ONLY | 327 TARGET_FOR_NAMED_ONLY |
342 }; | 328 }; |
343 | 329 |
344 // The labels associated with this statement. May be NULL; | 330 // The labels associated with this statement. May be NULL; |
345 // if it is != NULL, guaranteed to contain at least one entry. | 331 // if it is != NULL, guaranteed to contain at least one entry. |
346 ZoneStringList* labels() const { return labels_; } | 332 ZoneStringList* labels() const { return labels_; } |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 bool is_this_; | 1153 bool is_this_; |
1168 bool inside_with_; | 1154 bool inside_with_; |
1169 bool is_trivial_; | 1155 bool is_trivial_; |
1170 int position_; | 1156 int position_; |
1171 | 1157 |
1172 VariableProxy(Isolate* isolate, | 1158 VariableProxy(Isolate* isolate, |
1173 Handle<String> name, | 1159 Handle<String> name, |
1174 bool is_this, | 1160 bool is_this, |
1175 bool inside_with, | 1161 bool inside_with, |
1176 int position = RelocInfo::kNoPosition); | 1162 int position = RelocInfo::kNoPosition); |
1177 VariableProxy(Isolate* isolate, bool is_this); | |
1178 | 1163 |
1179 friend class Scope; | 1164 friend class Scope; |
1180 }; | 1165 }; |
1181 | 1166 |
1182 | 1167 |
1183 class VariableProxySentinel: public VariableProxy { | |
1184 public: | |
1185 virtual bool IsValidLeftHandSide() { return !is_this(); } | |
1186 | |
1187 private: | |
1188 VariableProxySentinel(Isolate* isolate, bool is_this) | |
1189 : VariableProxy(isolate, is_this) { } | |
1190 | |
1191 friend class AstSentinels; | |
1192 }; | |
1193 | |
1194 | |
1195 class Slot: public Expression { | 1168 class Slot: public Expression { |
1196 public: | 1169 public: |
1197 enum Type { | 1170 enum Type { |
1198 // A slot in the parameter section on the stack. index() is | 1171 // A slot in the parameter section on the stack. index() is |
1199 // the parameter index, counting left-to-right, starting at 0. | 1172 // the parameter index, counting left-to-right, starting at 0. |
1200 PARAMETER, | 1173 PARAMETER, |
1201 | 1174 |
1202 // A slot in the local section on the stack. index() is | 1175 // A slot in the local section on the stack. index() is |
1203 // the variable index in the stack frame, starting at 0. | 1176 // the variable index in the stack frame, starting at 0. |
1204 LOCAL, | 1177 LOCAL, |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1342 CheckType check_type_; | 1315 CheckType check_type_; |
1343 SmallMapList receiver_types_; | 1316 SmallMapList receiver_types_; |
1344 Handle<JSFunction> target_; | 1317 Handle<JSFunction> target_; |
1345 Handle<JSObject> holder_; | 1318 Handle<JSObject> holder_; |
1346 Handle<JSGlobalPropertyCell> cell_; | 1319 Handle<JSGlobalPropertyCell> cell_; |
1347 | 1320 |
1348 int return_id_; | 1321 int return_id_; |
1349 }; | 1322 }; |
1350 | 1323 |
1351 | 1324 |
1352 class AstSentinels { | |
1353 public: | |
1354 ~AstSentinels() { } | |
1355 | |
1356 // Returns a property singleton property access on 'this'. Used | |
1357 // during preparsing. | |
1358 Property* this_property() { return &this_property_; } | |
1359 VariableProxySentinel* this_proxy() { return &this_proxy_; } | |
1360 VariableProxySentinel* identifier_proxy() { return &identifier_proxy_; } | |
1361 ValidLeftHandSideSentinel* valid_left_hand_side_sentinel() { | |
1362 return &valid_left_hand_side_sentinel_; | |
1363 } | |
1364 Call* call_sentinel() { return &call_sentinel_; } | |
1365 EmptyStatement* empty_statement() { return &empty_statement_; } | |
1366 | |
1367 private: | |
1368 AstSentinels(); | |
1369 VariableProxySentinel this_proxy_; | |
1370 VariableProxySentinel identifier_proxy_; | |
1371 ValidLeftHandSideSentinel valid_left_hand_side_sentinel_; | |
1372 Property this_property_; | |
1373 Call call_sentinel_; | |
1374 EmptyStatement empty_statement_; | |
1375 | |
1376 friend class Isolate; | |
1377 | |
1378 DISALLOW_COPY_AND_ASSIGN(AstSentinels); | |
1379 }; | |
1380 | |
1381 | |
1382 class CallNew: public Expression { | 1325 class CallNew: public Expression { |
1383 public: | 1326 public: |
1384 CallNew(Isolate* isolate, | 1327 CallNew(Isolate* isolate, |
1385 Expression* expression, | 1328 Expression* expression, |
1386 ZoneList<Expression*>* arguments, | 1329 ZoneList<Expression*>* arguments, |
1387 int pos) | 1330 int pos) |
1388 : Expression(isolate), | 1331 : Expression(isolate), |
1389 expression_(expression), | 1332 expression_(expression), |
1390 arguments_(arguments), | 1333 arguments_(arguments), |
1391 pos_(pos) { } | 1334 pos_(pos) { } |
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2265 | 2208 |
2266 private: | 2209 private: |
2267 Isolate* isolate_; | 2210 Isolate* isolate_; |
2268 bool stack_overflow_; | 2211 bool stack_overflow_; |
2269 }; | 2212 }; |
2270 | 2213 |
2271 | 2214 |
2272 } } // namespace v8::internal | 2215 } } // namespace v8::internal |
2273 | 2216 |
2274 #endif // V8_AST_H_ | 2217 #endif // V8_AST_H_ |
OLD | NEW |