| 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 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 // is infinite in practice. | 1334 // is infinite in practice. |
| 1335 static const int kInfinity = (1 << 30); | 1335 static const int kInfinity = (1 << 30); |
| 1336 private: | 1336 private: |
| 1337 int min_; | 1337 int min_; |
| 1338 int max_; | 1338 int max_; |
| 1339 bool is_greedy_; | 1339 bool is_greedy_; |
| 1340 RegExpTree* body_; | 1340 RegExpTree* body_; |
| 1341 }; | 1341 }; |
| 1342 | 1342 |
| 1343 | 1343 |
| 1344 enum CaptureAvailability { |
| 1345 CAPTURE_AVAILABLE, CAPTURE_UNREACHABLE, CAPTURE_PERMANENTLY_UNREACHABLE }; |
| 1346 |
| 1344 class RegExpCapture: public RegExpTree { | 1347 class RegExpCapture: public RegExpTree { |
| 1345 public: | 1348 public: |
| 1346 explicit RegExpCapture(RegExpTree* body, int index) | 1349 explicit RegExpCapture(RegExpTree* body, int index) |
| 1347 : body_(body), index_(index) { } | 1350 : body_(body), index_(index), available_(CAPTURE_AVAILABLE) { } |
| 1348 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1351 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1349 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 1352 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1350 RegExpNode* on_success, | 1353 RegExpNode* on_success, |
| 1351 RegExpNode* on_failure); | 1354 RegExpNode* on_failure); |
| 1352 static RegExpNode* ToNode(RegExpTree* body, | 1355 static RegExpNode* ToNode(RegExpTree* body, |
| 1353 int index, | 1356 int index, |
| 1354 RegExpCompiler* compiler, | 1357 RegExpCompiler* compiler, |
| 1355 RegExpNode* on_success, | 1358 RegExpNode* on_success, |
| 1356 RegExpNode* on_failure); | 1359 RegExpNode* on_failure); |
| 1357 virtual RegExpCapture* AsCapture(); | 1360 virtual RegExpCapture* AsCapture(); |
| 1358 RegExpTree* body() { return body_; } | 1361 RegExpTree* body() { return body_; } |
| 1359 int index() { return index_; } | 1362 int index() { return index_; } |
| 1363 inline CaptureAvailability available() { return available_; } |
| 1364 inline void set_available(CaptureAvailability availability) { |
| 1365 available_ = availability; |
| 1366 } |
| 1360 static int StartRegister(int index) { return index * 2; } | 1367 static int StartRegister(int index) { return index * 2; } |
| 1361 static int EndRegister(int index) { return index * 2 + 1; } | 1368 static int EndRegister(int index) { return index * 2 + 1; } |
| 1362 private: | 1369 private: |
| 1363 RegExpTree* body_; | 1370 RegExpTree* body_; |
| 1364 int index_; | 1371 int index_; |
| 1372 CaptureAvailability available_; |
| 1365 }; | 1373 }; |
| 1366 | 1374 |
| 1367 | 1375 |
| 1368 class RegExpLookahead: public RegExpTree { | 1376 class RegExpLookahead: public RegExpTree { |
| 1369 public: | 1377 public: |
| 1370 RegExpLookahead(RegExpTree* body, bool is_positive) | 1378 RegExpLookahead(RegExpTree* body, bool is_positive) |
| 1371 : body_(body), | 1379 : body_(body), |
| 1372 is_positive_(is_positive) { } | 1380 is_positive_(is_positive) { } |
| 1373 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1381 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1374 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 1382 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1375 RegExpNode* on_success, | 1383 RegExpNode* on_success, |
| 1376 RegExpNode* on_failure); | 1384 RegExpNode* on_failure); |
| 1377 virtual RegExpLookahead* AsLookahead(); | 1385 virtual RegExpLookahead* AsLookahead(); |
| 1378 RegExpTree* body() { return body_; } | 1386 RegExpTree* body() { return body_; } |
| 1379 bool is_positive() { return is_positive_; } | 1387 bool is_positive() { return is_positive_; } |
| 1380 private: | 1388 private: |
| 1381 RegExpTree* body_; | 1389 RegExpTree* body_; |
| 1382 bool is_positive_; | 1390 bool is_positive_; |
| 1383 }; | 1391 }; |
| 1384 | 1392 |
| 1385 | 1393 |
| 1386 class RegExpBackreference: public RegExpTree { | 1394 class RegExpBackreference: public RegExpTree { |
| 1387 public: | 1395 public: |
| 1388 explicit RegExpBackreference(int index) : index_(index) { } | 1396 explicit RegExpBackreference(RegExpCapture* capture) |
| 1397 : capture_(capture) { } |
| 1389 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1398 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1390 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 1399 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1391 RegExpNode* on_success, | 1400 RegExpNode* on_success, |
| 1392 RegExpNode* on_failure); | 1401 RegExpNode* on_failure); |
| 1393 virtual RegExpBackreference* AsBackreference(); | 1402 virtual RegExpBackreference* AsBackreference(); |
| 1394 int index() { return index_; } | 1403 int index() { return capture_->index(); } |
| 1404 RegExpCapture* capture() { return capture_; } |
| 1395 private: | 1405 private: |
| 1396 int index_; | 1406 RegExpCapture* capture_; |
| 1397 }; | 1407 }; |
| 1398 | 1408 |
| 1399 | 1409 |
| 1400 class RegExpEmpty: public RegExpTree { | 1410 class RegExpEmpty: public RegExpTree { |
| 1401 public: | 1411 public: |
| 1402 RegExpEmpty() { } | 1412 RegExpEmpty() { } |
| 1403 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1413 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1404 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 1414 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1405 RegExpNode* on_success, | 1415 RegExpNode* on_success, |
| 1406 RegExpNode* on_failure); | 1416 RegExpNode* on_failure); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1459 #undef DEF_VISIT | 1469 #undef DEF_VISIT |
| 1460 | 1470 |
| 1461 private: | 1471 private: |
| 1462 bool stack_overflow_; | 1472 bool stack_overflow_; |
| 1463 }; | 1473 }; |
| 1464 | 1474 |
| 1465 | 1475 |
| 1466 } } // namespace v8::internal | 1476 } } // namespace v8::internal |
| 1467 | 1477 |
| 1468 #endif // V8_AST_H_ | 1478 #endif // V8_AST_H_ |
| OLD | NEW |