Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(875)

Side by Side Diff: src/ast.h

Issue 18096: Experimental: merge from bleeding_edge. Merge up to and including... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/assembler-ia32-inl.h ('k') | src/ast.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 class ThisFunction: public Expression { 1213 class ThisFunction: public Expression {
1214 public: 1214 public:
1215 virtual void Accept(AstVisitor* v); 1215 virtual void Accept(AstVisitor* v);
1216 }; 1216 };
1217 1217
1218 1218
1219 // ---------------------------------------------------------------------------- 1219 // ----------------------------------------------------------------------------
1220 // Regular expressions 1220 // Regular expressions
1221 1221
1222 1222
1223 class RegExpVisitor BASE_EMBEDDED {
1224 public:
1225 virtual ~RegExpVisitor() { }
1226 #define MAKE_CASE(Name) \
1227 virtual void* Visit##Name(RegExp##Name*, void* data) = 0;
1228 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE)
1229 #undef MAKE_CASE
1230 };
1231
1232
1223 class RegExpTree: public ZoneObject { 1233 class RegExpTree: public ZoneObject {
1224 public: 1234 public:
1225 static const int kInfinity = kMaxInt; 1235 static const int kInfinity = kMaxInt;
1226 virtual ~RegExpTree() { } 1236 virtual ~RegExpTree() { }
1227 virtual void* Accept(RegExpVisitor* visitor, void* data) = 0; 1237 virtual void* Accept(RegExpVisitor* visitor, void* data) = 0;
1228 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 1238 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
1229 RegExpNode* on_success) = 0; 1239 RegExpNode* on_success) = 0;
1230 virtual bool IsTextElement() { return false; } 1240 virtual bool IsTextElement() { return false; }
1231 virtual int min_match() = 0; 1241 virtual int min_match() = 0;
1232 virtual int max_match() = 0; 1242 virtual int max_match() = 0;
1243 // Returns the interval of registers used for captures within this
1244 // expression.
1245 virtual Interval CaptureRegisters() { return Interval::Empty(); }
1233 virtual void AppendToText(RegExpText* text); 1246 virtual void AppendToText(RegExpText* text);
1234 SmartPointer<const char> ToString(); 1247 SmartPointer<const char> ToString();
1235 #define MAKE_ASTYPE(Name) \ 1248 #define MAKE_ASTYPE(Name) \
1236 virtual RegExp##Name* As##Name(); \ 1249 virtual RegExp##Name* As##Name(); \
1237 virtual bool Is##Name(); 1250 virtual bool Is##Name();
1238 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_ASTYPE) 1251 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_ASTYPE)
1239 #undef MAKE_ASTYPE 1252 #undef MAKE_ASTYPE
1240 }; 1253 };
1241 1254
1242 1255
1243 class RegExpDisjunction: public RegExpTree { 1256 class RegExpDisjunction: public RegExpTree {
1244 public: 1257 public:
1245 explicit RegExpDisjunction(ZoneList<RegExpTree*>* alternatives); 1258 explicit RegExpDisjunction(ZoneList<RegExpTree*>* alternatives);
1246 virtual void* Accept(RegExpVisitor* visitor, void* data); 1259 virtual void* Accept(RegExpVisitor* visitor, void* data);
1247 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 1260 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
1248 RegExpNode* on_success); 1261 RegExpNode* on_success);
1249 virtual RegExpDisjunction* AsDisjunction(); 1262 virtual RegExpDisjunction* AsDisjunction();
1263 virtual Interval CaptureRegisters();
1250 virtual bool IsDisjunction(); 1264 virtual bool IsDisjunction();
1251 virtual int min_match() { return min_match_; } 1265 virtual int min_match() { return min_match_; }
1252 virtual int max_match() { return max_match_; } 1266 virtual int max_match() { return max_match_; }
1253 ZoneList<RegExpTree*>* alternatives() { return alternatives_; } 1267 ZoneList<RegExpTree*>* alternatives() { return alternatives_; }
1254 private: 1268 private:
1255 ZoneList<RegExpTree*>* alternatives_; 1269 ZoneList<RegExpTree*>* alternatives_;
1256 int min_match_; 1270 int min_match_;
1257 int max_match_; 1271 int max_match_;
1258 }; 1272 };
1259 1273
1260 1274
1261 class RegExpAlternative: public RegExpTree { 1275 class RegExpAlternative: public RegExpTree {
1262 public: 1276 public:
1263 explicit RegExpAlternative(ZoneList<RegExpTree*>* nodes); 1277 explicit RegExpAlternative(ZoneList<RegExpTree*>* nodes);
1264 virtual void* Accept(RegExpVisitor* visitor, void* data); 1278 virtual void* Accept(RegExpVisitor* visitor, void* data);
1265 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 1279 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
1266 RegExpNode* on_success); 1280 RegExpNode* on_success);
1267 virtual RegExpAlternative* AsAlternative(); 1281 virtual RegExpAlternative* AsAlternative();
1282 virtual Interval CaptureRegisters();
1268 virtual bool IsAlternative(); 1283 virtual bool IsAlternative();
1269 virtual int min_match() { return min_match_; } 1284 virtual int min_match() { return min_match_; }
1270 virtual int max_match() { return max_match_; } 1285 virtual int max_match() { return max_match_; }
1271 ZoneList<RegExpTree*>* nodes() { return nodes_; } 1286 ZoneList<RegExpTree*>* nodes() { return nodes_; }
1272 private: 1287 private:
1273 ZoneList<RegExpTree*>* nodes_; 1288 ZoneList<RegExpTree*>* nodes_;
1274 int min_match_; 1289 int min_match_;
1275 int max_match_; 1290 int max_match_;
1276 }; 1291 };
1277 1292
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 virtual void* Accept(RegExpVisitor* visitor, void* data); 1437 virtual void* Accept(RegExpVisitor* visitor, void* data);
1423 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 1438 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
1424 RegExpNode* on_success); 1439 RegExpNode* on_success);
1425 static RegExpNode* ToNode(int min, 1440 static RegExpNode* ToNode(int min,
1426 int max, 1441 int max,
1427 bool is_greedy, 1442 bool is_greedy,
1428 RegExpTree* body, 1443 RegExpTree* body,
1429 RegExpCompiler* compiler, 1444 RegExpCompiler* compiler,
1430 RegExpNode* on_success); 1445 RegExpNode* on_success);
1431 virtual RegExpQuantifier* AsQuantifier(); 1446 virtual RegExpQuantifier* AsQuantifier();
1447 virtual Interval CaptureRegisters();
1432 virtual bool IsQuantifier(); 1448 virtual bool IsQuantifier();
1433 virtual int min_match() { return min_match_; } 1449 virtual int min_match() { return min_match_; }
1434 virtual int max_match() { return max_match_; } 1450 virtual int max_match() { return max_match_; }
1435 int min() { return min_; } 1451 int min() { return min_; }
1436 int max() { return max_; } 1452 int max() { return max_; }
1437 bool is_greedy() { return is_greedy_; } 1453 bool is_greedy() { return is_greedy_; }
1438 RegExpTree* body() { return body_; } 1454 RegExpTree* body() { return body_; }
1439 private: 1455 private:
1440 int min_; 1456 int min_;
1441 int max_; 1457 int max_;
(...skipping 15 matching lines...) Expand all
1457 explicit RegExpCapture(RegExpTree* body, int index) 1473 explicit RegExpCapture(RegExpTree* body, int index)
1458 : body_(body), index_(index), available_(CAPTURE_AVAILABLE) { } 1474 : body_(body), index_(index), available_(CAPTURE_AVAILABLE) { }
1459 virtual void* Accept(RegExpVisitor* visitor, void* data); 1475 virtual void* Accept(RegExpVisitor* visitor, void* data);
1460 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 1476 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
1461 RegExpNode* on_success); 1477 RegExpNode* on_success);
1462 static RegExpNode* ToNode(RegExpTree* body, 1478 static RegExpNode* ToNode(RegExpTree* body,
1463 int index, 1479 int index,
1464 RegExpCompiler* compiler, 1480 RegExpCompiler* compiler,
1465 RegExpNode* on_success); 1481 RegExpNode* on_success);
1466 virtual RegExpCapture* AsCapture(); 1482 virtual RegExpCapture* AsCapture();
1483 virtual Interval CaptureRegisters();
1467 virtual bool IsCapture(); 1484 virtual bool IsCapture();
1468 virtual int min_match() { return body_->min_match(); } 1485 virtual int min_match() { return body_->min_match(); }
1469 virtual int max_match() { return body_->max_match(); } 1486 virtual int max_match() { return body_->max_match(); }
1470 RegExpTree* body() { return body_; } 1487 RegExpTree* body() { return body_; }
1471 int index() { return index_; } 1488 int index() { return index_; }
1472 inline CaptureAvailability available() { return available_; } 1489 inline CaptureAvailability available() { return available_; }
1473 inline void set_available(CaptureAvailability availability) { 1490 inline void set_available(CaptureAvailability availability) {
1474 available_ = availability; 1491 available_ = availability;
1475 } 1492 }
1476 static int StartRegister(int index) { return index * 2; } 1493 static int StartRegister(int index) { return index * 2; }
1477 static int EndRegister(int index) { return index * 2 + 1; } 1494 static int EndRegister(int index) { return index * 2 + 1; }
1478 private: 1495 private:
1479 RegExpTree* body_; 1496 RegExpTree* body_;
1480 int index_; 1497 int index_;
1481 CaptureAvailability available_; 1498 CaptureAvailability available_;
1482 }; 1499 };
1483 1500
1484 1501
1485 class RegExpLookahead: public RegExpTree { 1502 class RegExpLookahead: public RegExpTree {
1486 public: 1503 public:
1487 RegExpLookahead(RegExpTree* body, bool is_positive) 1504 RegExpLookahead(RegExpTree* body, bool is_positive)
1488 : body_(body), 1505 : body_(body),
1489 is_positive_(is_positive) { } 1506 is_positive_(is_positive) { }
1490 virtual void* Accept(RegExpVisitor* visitor, void* data); 1507 virtual void* Accept(RegExpVisitor* visitor, void* data);
1491 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 1508 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
1492 RegExpNode* on_success); 1509 RegExpNode* on_success);
1493 virtual RegExpLookahead* AsLookahead(); 1510 virtual RegExpLookahead* AsLookahead();
1511 virtual Interval CaptureRegisters();
1494 virtual bool IsLookahead(); 1512 virtual bool IsLookahead();
1495 virtual int min_match() { return 0; } 1513 virtual int min_match() { return 0; }
1496 virtual int max_match() { return 0; } 1514 virtual int max_match() { return 0; }
1497 RegExpTree* body() { return body_; } 1515 RegExpTree* body() { return body_; }
1498 bool is_positive() { return is_positive_; } 1516 bool is_positive() { return is_positive_; }
1499 private: 1517 private:
1500 RegExpTree* body_; 1518 RegExpTree* body_;
1501 bool is_positive_; 1519 bool is_positive_;
1502 }; 1520 };
1503 1521
1504 1522
1505 class RegExpBackReference: public RegExpTree { 1523 class RegExpBackReference: public RegExpTree {
1506 public: 1524 public:
1507 explicit RegExpBackReference(RegExpCapture* capture) 1525 explicit RegExpBackReference(RegExpCapture* capture)
1508 : capture_(capture) { } 1526 : capture_(capture) { }
1509 virtual void* Accept(RegExpVisitor* visitor, void* data); 1527 virtual void* Accept(RegExpVisitor* visitor, void* data);
1510 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 1528 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
1511 RegExpNode* on_success); 1529 RegExpNode* on_success);
1512 virtual RegExpBackReference* AsBackReference(); 1530 virtual RegExpBackReference* AsBackReference();
1513 virtual bool IsBackReference(); 1531 virtual bool IsBackReference();
1514 virtual int min_match() { return capture_->min_match(); } 1532 virtual int min_match() { return 0; }
1515 virtual int max_match() { return capture_->max_match(); } 1533 virtual int max_match() { return capture_->max_match(); }
1516 int index() { return capture_->index(); } 1534 int index() { return capture_->index(); }
1517 RegExpCapture* capture() { return capture_; } 1535 RegExpCapture* capture() { return capture_; }
1518 private: 1536 private:
1519 RegExpCapture* capture_; 1537 RegExpCapture* capture_;
1520 }; 1538 };
1521 1539
1522 1540
1523 class RegExpEmpty: public RegExpTree { 1541 class RegExpEmpty: public RegExpTree {
1524 public: 1542 public:
1525 RegExpEmpty() { } 1543 RegExpEmpty() { }
1526 virtual void* Accept(RegExpVisitor* visitor, void* data); 1544 virtual void* Accept(RegExpVisitor* visitor, void* data);
1527 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 1545 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
1528 RegExpNode* on_success); 1546 RegExpNode* on_success);
1529 virtual RegExpEmpty* AsEmpty(); 1547 virtual RegExpEmpty* AsEmpty();
1530 virtual bool IsEmpty(); 1548 virtual bool IsEmpty();
1531 virtual int min_match() { return 0; } 1549 virtual int min_match() { return 0; }
1532 virtual int max_match() { return 0; } 1550 virtual int max_match() { return 0; }
1533 static RegExpEmpty* GetInstance() { return &kInstance; } 1551 static RegExpEmpty* GetInstance() { return &kInstance; }
1534 private: 1552 private:
1535 static RegExpEmpty kInstance; 1553 static RegExpEmpty kInstance;
1536 }; 1554 };
1537 1555
1538 1556
1539 class RegExpVisitor BASE_EMBEDDED {
1540 public:
1541 virtual ~RegExpVisitor() { }
1542 #define MAKE_CASE(Name) \
1543 virtual void* Visit##Name(RegExp##Name*, void* data) = 0;
1544 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE)
1545 #undef MAKE_CASE
1546 };
1547
1548
1549 // ---------------------------------------------------------------------------- 1557 // ----------------------------------------------------------------------------
1550 // Basic visitor 1558 // Basic visitor
1551 // - leaf node visitors are abstract. 1559 // - leaf node visitors are abstract.
1552 1560
1553 class AstVisitor BASE_EMBEDDED { 1561 class AstVisitor BASE_EMBEDDED {
1554 public: 1562 public:
1555 AstVisitor() : stack_overflow_(false) { } 1563 AstVisitor() : stack_overflow_(false) { }
1556 virtual ~AstVisitor() { } 1564 virtual ~AstVisitor() { }
1557 1565
1558 // Dispatch 1566 // Dispatch
(...skipping 25 matching lines...) Expand all
1584 #undef DEF_VISIT 1592 #undef DEF_VISIT
1585 1593
1586 private: 1594 private:
1587 bool stack_overflow_; 1595 bool stack_overflow_;
1588 }; 1596 };
1589 1597
1590 1598
1591 } } // namespace v8::internal 1599 } } // namespace v8::internal
1592 1600
1593 #endif // V8_AST_H_ 1601 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « src/assembler-ia32-inl.h ('k') | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698