| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #ifndef V8_AST_H_ | 28 #ifndef V8_AST_H_ |
| 29 #define V8_AST_H_ | 29 #define V8_AST_H_ |
| 30 | 30 |
| 31 #include "execution.h" | 31 #include "execution.h" |
| 32 #include "factory.h" | 32 #include "factory.h" |
| 33 #include "runtime.h" | 33 #include "runtime.h" |
| 34 #include "token.h" | 34 #include "token.h" |
| 35 #include "variables.h" | 35 #include "variables.h" |
| 36 #include "macro-assembler.h" | 36 #include "macro-assembler.h" |
| 37 #include "jsregexp.h" |
| 37 | 38 |
| 38 namespace v8 { namespace internal { | 39 namespace v8 { namespace internal { |
| 39 | 40 |
| 40 // The abstract syntax tree is an intermediate, light-weight | 41 // The abstract syntax tree is an intermediate, light-weight |
| 41 // representation of the parsed JavaScript code suitable for | 42 // representation of the parsed JavaScript code suitable for |
| 42 // compilation to native code. | 43 // compilation to native code. |
| 43 | 44 |
| 44 // Nodes are allocated in a separate zone, which allows faster | 45 // Nodes are allocated in a separate zone, which allows faster |
| 45 // allocation and constant-time deallocation of the entire syntax | 46 // allocation and constant-time deallocation of the entire syntax |
| 46 // tree. | 47 // tree. |
| (...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1251 }; | 1252 }; |
| 1252 explicit RegExpAssertion(Type type) : type_(type) { } | 1253 explicit RegExpAssertion(Type type) : type_(type) { } |
| 1253 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1254 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1254 virtual RegExpAssertion* AsAssertion(); | 1255 virtual RegExpAssertion* AsAssertion(); |
| 1255 Type type() { return type_; } | 1256 Type type() { return type_; } |
| 1256 private: | 1257 private: |
| 1257 Type type_; | 1258 Type type_; |
| 1258 }; | 1259 }; |
| 1259 | 1260 |
| 1260 | 1261 |
| 1261 class CharacterRange { | |
| 1262 public: | |
| 1263 // For compatibility with the CHECK_OK macro | |
| 1264 CharacterRange(void* null) { ASSERT_EQ(NULL, null); } //NOLINT | |
| 1265 CharacterRange(uc32 from, uc32 to, bool is_character_class) | |
| 1266 : from_(from), | |
| 1267 to_(to), | |
| 1268 is_character_class_(is_character_class) { | |
| 1269 // Assert that truncating doesn't throw away information. | |
| 1270 ASSERT_EQ(from, from_); | |
| 1271 ASSERT_EQ(to_, to); | |
| 1272 } | |
| 1273 static inline CharacterRange CharacterClass(uc32 tag) { | |
| 1274 return CharacterRange(tag, tag, true); | |
| 1275 } | |
| 1276 static inline CharacterRange Singleton(uc32 value) { | |
| 1277 return CharacterRange(value, value, false); | |
| 1278 } | |
| 1279 static inline CharacterRange Range(uc32 from, uc32 to) { | |
| 1280 return CharacterRange(from, to, false); | |
| 1281 } | |
| 1282 unsigned from() { return from_; } | |
| 1283 unsigned to() { return to_; } | |
| 1284 bool is_character_class() { return is_character_class_; } | |
| 1285 bool IsSingleton() { return (from_ == to_) && !is_character_class(); } | |
| 1286 private: | |
| 1287 unsigned from_ : 16; | |
| 1288 unsigned to_ : 16; | |
| 1289 bool is_character_class_ : 1; | |
| 1290 }; | |
| 1291 | |
| 1292 | |
| 1293 STATIC_CHECK(sizeof(CharacterRange) == 2 * sizeof(int)); // NOLINT | |
| 1294 | |
| 1295 | |
| 1296 class RegExpCharacterClass: public RegExpTree { | 1262 class RegExpCharacterClass: public RegExpTree { |
| 1297 public: | 1263 public: |
| 1298 explicit RegExpCharacterClass(CharacterRange range) | |
| 1299 : ranges_(new ZoneList<CharacterRange>(1)), | |
| 1300 is_negated_(false) { | |
| 1301 ranges_->Add(range); | |
| 1302 } | |
| 1303 RegExpCharacterClass(ZoneList<CharacterRange>* ranges, bool is_negated) | 1264 RegExpCharacterClass(ZoneList<CharacterRange>* ranges, bool is_negated) |
| 1304 : ranges_(ranges), | 1265 : ranges_(ranges), |
| 1305 is_negated_(is_negated) { } | 1266 is_negated_(is_negated) { } |
| 1306 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1267 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1307 virtual RegExpCharacterClass* AsCharacterClass(); | 1268 virtual RegExpCharacterClass* AsCharacterClass(); |
| 1308 ZoneList<CharacterRange>* ranges() { return ranges_; } | 1269 ZoneList<CharacterRange>* ranges() { return ranges_; } |
| 1309 bool is_negated() { return is_negated_; } | 1270 bool is_negated() { return is_negated_; } |
| 1310 private: | 1271 private: |
| 1311 ZoneList<CharacterRange>* ranges_; | 1272 ZoneList<CharacterRange>* ranges_; |
| 1312 bool is_negated_; | 1273 bool is_negated_; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 #undef DEF_VISIT | 1406 #undef DEF_VISIT |
| 1446 | 1407 |
| 1447 private: | 1408 private: |
| 1448 bool stack_overflow_; | 1409 bool stack_overflow_; |
| 1449 }; | 1410 }; |
| 1450 | 1411 |
| 1451 | 1412 |
| 1452 } } // namespace v8::internal | 1413 } } // namespace v8::internal |
| 1453 | 1414 |
| 1454 #endif // V8_AST_H_ | 1415 #endif // V8_AST_H_ |
| OLD | NEW |