| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 V(Slot) \ | 75 V(Slot) \ |
| 76 V(VariableProxy) \ | 76 V(VariableProxy) \ |
| 77 V(Literal) \ | 77 V(Literal) \ |
| 78 V(RegExpLiteral) \ | 78 V(RegExpLiteral) \ |
| 79 V(ObjectLiteral) \ | 79 V(ObjectLiteral) \ |
| 80 V(ArrayLiteral) \ | 80 V(ArrayLiteral) \ |
| 81 V(Assignment) \ | 81 V(Assignment) \ |
| 82 V(Throw) \ | 82 V(Throw) \ |
| 83 V(Property) \ | 83 V(Property) \ |
| 84 V(Call) \ | 84 V(Call) \ |
| 85 V(CallEval) \ | 85 V(CallEval) \ |
| 86 V(CallNew) \ | 86 V(CallNew) \ |
| 87 V(CallRuntime) \ | 87 V(CallRuntime) \ |
| 88 V(UnaryOperation) \ | 88 V(UnaryOperation) \ |
| 89 V(CountOperation) \ | 89 V(CountOperation) \ |
| 90 V(BinaryOperation) \ | 90 V(BinaryOperation) \ |
| 91 V(CompareOperation) \ | 91 V(CompareOperation) \ |
| 92 V(ThisFunction) | 92 V(ThisFunction) |
| 93 | 93 |
| 94 | 94 |
| 95 // Forward declarations | 95 // Forward declarations |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 | 406 |
| 407 Expression* expression() { return expression_; } | 407 Expression* expression() { return expression_; } |
| 408 | 408 |
| 409 private: | 409 private: |
| 410 Expression* expression_; | 410 Expression* expression_; |
| 411 }; | 411 }; |
| 412 | 412 |
| 413 | 413 |
| 414 class WithEnterStatement: public Statement { | 414 class WithEnterStatement: public Statement { |
| 415 public: | 415 public: |
| 416 explicit WithEnterStatement(Expression* expression) | 416 explicit WithEnterStatement(Expression* expression, bool is_catch_block) |
| 417 : expression_(expression) { } | 417 : expression_(expression), is_catch_block_(is_catch_block) { } |
| 418 | 418 |
| 419 virtual void Accept(AstVisitor* v); | 419 virtual void Accept(AstVisitor* v); |
| 420 | 420 |
| 421 Expression* expression() const { return expression_; } | 421 Expression* expression() const { return expression_; } |
| 422 | 422 |
| 423 bool is_catch_block() const { return is_catch_block_; } |
| 424 |
| 423 private: | 425 private: |
| 424 Expression* expression_; | 426 Expression* expression_; |
| 427 bool is_catch_block_; |
| 425 }; | 428 }; |
| 426 | 429 |
| 427 | 430 |
| 428 class WithExitStatement: public Statement { | 431 class WithExitStatement: public Statement { |
| 429 public: | 432 public: |
| 430 WithExitStatement() { } | 433 WithExitStatement() { } |
| 431 | 434 |
| 432 virtual void Accept(AstVisitor* v); | 435 virtual void Accept(AstVisitor* v); |
| 433 }; | 436 }; |
| 434 | 437 |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 virtual void Accept(AstVisitor* v); | 1215 virtual void Accept(AstVisitor* v); |
| 1213 }; | 1216 }; |
| 1214 | 1217 |
| 1215 | 1218 |
| 1216 // ---------------------------------------------------------------------------- | 1219 // ---------------------------------------------------------------------------- |
| 1217 // Regular expressions | 1220 // Regular expressions |
| 1218 | 1221 |
| 1219 | 1222 |
| 1220 class RegExpTree: public ZoneObject { | 1223 class RegExpTree: public ZoneObject { |
| 1221 public: | 1224 public: |
| 1225 static const int kInfinity = kMaxInt; |
| 1222 virtual ~RegExpTree() { } | 1226 virtual ~RegExpTree() { } |
| 1223 virtual void* Accept(RegExpVisitor* visitor, void* data) = 0; | 1227 virtual void* Accept(RegExpVisitor* visitor, void* data) = 0; |
| 1224 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 1228 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1225 RegExpNode* on_success) = 0; | 1229 RegExpNode* on_success) = 0; |
| 1226 virtual bool IsTextElement() { return false; } | 1230 virtual bool IsTextElement() { return false; } |
| 1231 virtual int min_match() = 0; |
| 1232 virtual int max_match() = 0; |
| 1227 virtual void AppendToText(RegExpText* text); | 1233 virtual void AppendToText(RegExpText* text); |
| 1228 SmartPointer<const char> ToString(); | 1234 SmartPointer<const char> ToString(); |
| 1229 #define MAKE_ASTYPE(Name) \ | 1235 #define MAKE_ASTYPE(Name) \ |
| 1230 virtual RegExp##Name* As##Name(); \ | 1236 virtual RegExp##Name* As##Name(); \ |
| 1231 virtual bool Is##Name(); | 1237 virtual bool Is##Name(); |
| 1232 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_ASTYPE) | 1238 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_ASTYPE) |
| 1233 #undef MAKE_ASTYPE | 1239 #undef MAKE_ASTYPE |
| 1234 }; | 1240 }; |
| 1235 | 1241 |
| 1236 | 1242 |
| 1237 class RegExpDisjunction: public RegExpTree { | 1243 class RegExpDisjunction: public RegExpTree { |
| 1238 public: | 1244 public: |
| 1239 explicit RegExpDisjunction(ZoneList<RegExpTree*>* alternatives) | 1245 explicit RegExpDisjunction(ZoneList<RegExpTree*>* alternatives); |
| 1240 : alternatives_(alternatives) { } | |
| 1241 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1246 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1242 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 1247 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1243 RegExpNode* on_success); | 1248 RegExpNode* on_success); |
| 1244 virtual RegExpDisjunction* AsDisjunction(); | 1249 virtual RegExpDisjunction* AsDisjunction(); |
| 1245 virtual bool IsDisjunction(); | 1250 virtual bool IsDisjunction(); |
| 1251 virtual int min_match() { return min_match_; } |
| 1252 virtual int max_match() { return max_match_; } |
| 1246 ZoneList<RegExpTree*>* alternatives() { return alternatives_; } | 1253 ZoneList<RegExpTree*>* alternatives() { return alternatives_; } |
| 1247 private: | 1254 private: |
| 1248 ZoneList<RegExpTree*>* alternatives_; | 1255 ZoneList<RegExpTree*>* alternatives_; |
| 1256 int min_match_; |
| 1257 int max_match_; |
| 1249 }; | 1258 }; |
| 1250 | 1259 |
| 1251 | 1260 |
| 1252 class RegExpAlternative: public RegExpTree { | 1261 class RegExpAlternative: public RegExpTree { |
| 1253 public: | 1262 public: |
| 1254 explicit RegExpAlternative(ZoneList<RegExpTree*>* nodes) : nodes_(nodes) { } | 1263 explicit RegExpAlternative(ZoneList<RegExpTree*>* nodes); |
| 1255 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1264 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1256 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 1265 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1257 RegExpNode* on_success); | 1266 RegExpNode* on_success); |
| 1258 virtual RegExpAlternative* AsAlternative(); | 1267 virtual RegExpAlternative* AsAlternative(); |
| 1259 virtual bool IsAlternative(); | 1268 virtual bool IsAlternative(); |
| 1269 virtual int min_match() { return min_match_; } |
| 1270 virtual int max_match() { return max_match_; } |
| 1260 ZoneList<RegExpTree*>* nodes() { return nodes_; } | 1271 ZoneList<RegExpTree*>* nodes() { return nodes_; } |
| 1261 private: | 1272 private: |
| 1262 ZoneList<RegExpTree*>* nodes_; | 1273 ZoneList<RegExpTree*>* nodes_; |
| 1263 }; | 1274 int min_match_; |
| 1264 | 1275 int max_match_; |
| 1265 | |
| 1266 class RegExpText: public RegExpTree { | |
| 1267 public: | |
| 1268 RegExpText() : elements_(2) { } | |
| 1269 virtual void* Accept(RegExpVisitor* visitor, void* data); | |
| 1270 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | |
| 1271 RegExpNode* on_success); | |
| 1272 virtual RegExpText* AsText(); | |
| 1273 virtual bool IsText(); | |
| 1274 virtual bool IsTextElement() { return true; } | |
| 1275 virtual void AppendToText(RegExpText* text); | |
| 1276 void AddElement(TextElement elm) { elements_.Add(elm); } | |
| 1277 ZoneList<TextElement>* elements() { return &elements_; } | |
| 1278 private: | |
| 1279 ZoneList<TextElement> elements_; | |
| 1280 }; | 1276 }; |
| 1281 | 1277 |
| 1282 | 1278 |
| 1283 class RegExpAssertion: public RegExpTree { | 1279 class RegExpAssertion: public RegExpTree { |
| 1284 public: | 1280 public: |
| 1285 enum Type { | 1281 enum Type { |
| 1286 START_OF_LINE, | 1282 START_OF_LINE, |
| 1287 START_OF_INPUT, | 1283 START_OF_INPUT, |
| 1288 END_OF_LINE, | 1284 END_OF_LINE, |
| 1289 END_OF_INPUT, | 1285 END_OF_INPUT, |
| 1290 BOUNDARY, | 1286 BOUNDARY, |
| 1291 NON_BOUNDARY | 1287 NON_BOUNDARY |
| 1292 }; | 1288 }; |
| 1293 explicit RegExpAssertion(Type type) : type_(type) { } | 1289 explicit RegExpAssertion(Type type) : type_(type) { } |
| 1294 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1290 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1295 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 1291 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1296 RegExpNode* on_success); | 1292 RegExpNode* on_success); |
| 1297 virtual RegExpAssertion* AsAssertion(); | 1293 virtual RegExpAssertion* AsAssertion(); |
| 1298 virtual bool IsAssertion(); | 1294 virtual bool IsAssertion(); |
| 1295 virtual int min_match() { return 0; } |
| 1296 virtual int max_match() { return 0; } |
| 1299 Type type() { return type_; } | 1297 Type type() { return type_; } |
| 1300 private: | 1298 private: |
| 1301 Type type_; | 1299 Type type_; |
| 1302 }; | 1300 }; |
| 1303 | 1301 |
| 1304 | 1302 |
| 1305 class RegExpCharacterClass: public RegExpTree { | 1303 class RegExpCharacterClass: public RegExpTree { |
| 1306 public: | 1304 public: |
| 1307 RegExpCharacterClass(ZoneList<CharacterRange>* ranges, bool is_negated) | 1305 RegExpCharacterClass(ZoneList<CharacterRange>* ranges, bool is_negated) |
| 1308 : ranges_(ranges), | 1306 : ranges_(ranges), |
| 1309 is_negated_(is_negated) { } | 1307 is_negated_(is_negated) { } |
| 1310 explicit RegExpCharacterClass(uc16 type) | 1308 explicit RegExpCharacterClass(uc16 type) |
| 1311 : ranges_(new ZoneList<CharacterRange>(2)), | 1309 : ranges_(new ZoneList<CharacterRange>(2)), |
| 1312 is_negated_(false) { | 1310 is_negated_(false) { |
| 1313 CharacterRange::AddClassEscape(type, ranges_); | 1311 CharacterRange::AddClassEscape(type, ranges_); |
| 1314 } | 1312 } |
| 1315 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1313 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1316 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 1314 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1317 RegExpNode* on_success); | 1315 RegExpNode* on_success); |
| 1318 virtual RegExpCharacterClass* AsCharacterClass(); | 1316 virtual RegExpCharacterClass* AsCharacterClass(); |
| 1319 virtual bool IsCharacterClass(); | 1317 virtual bool IsCharacterClass(); |
| 1320 virtual bool IsTextElement() { return true; } | 1318 virtual bool IsTextElement() { return true; } |
| 1319 virtual int min_match() { return 1; } |
| 1320 virtual int max_match() { return 1; } |
| 1321 virtual void AppendToText(RegExpText* text); | 1321 virtual void AppendToText(RegExpText* text); |
| 1322 ZoneList<CharacterRange>* ranges() { return ranges_; } | 1322 ZoneList<CharacterRange>* ranges() { return ranges_; } |
| 1323 bool is_negated() { return is_negated_; } | 1323 bool is_negated() { return is_negated_; } |
| 1324 private: | 1324 private: |
| 1325 ZoneList<CharacterRange>* ranges_; | 1325 ZoneList<CharacterRange>* ranges_; |
| 1326 bool is_negated_; | 1326 bool is_negated_; |
| 1327 }; | 1327 }; |
| 1328 | 1328 |
| 1329 | 1329 |
| 1330 class RegExpAtom: public RegExpTree { | 1330 class RegExpAtom: public RegExpTree { |
| 1331 public: | 1331 public: |
| 1332 explicit RegExpAtom(Vector<const uc16> data) : data_(data) { } | 1332 explicit RegExpAtom(Vector<const uc16> data) : data_(data) { } |
| 1333 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1333 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1334 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 1334 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1335 RegExpNode* on_success); | 1335 RegExpNode* on_success); |
| 1336 virtual RegExpAtom* AsAtom(); | 1336 virtual RegExpAtom* AsAtom(); |
| 1337 virtual bool IsAtom(); | 1337 virtual bool IsAtom(); |
| 1338 virtual bool IsTextElement() { return true; } | 1338 virtual bool IsTextElement() { return true; } |
| 1339 virtual int min_match() { return data_.length(); } |
| 1340 virtual int max_match() { return data_.length(); } |
| 1339 virtual void AppendToText(RegExpText* text); | 1341 virtual void AppendToText(RegExpText* text); |
| 1340 Vector<const uc16> data() { return data_; } | 1342 Vector<const uc16> data() { return data_; } |
| 1343 int length() { return data_.length(); } |
| 1341 private: | 1344 private: |
| 1342 Vector<const uc16> data_; | 1345 Vector<const uc16> data_; |
| 1343 }; | 1346 }; |
| 1344 | 1347 |
| 1345 | 1348 |
| 1349 class RegExpText: public RegExpTree { |
| 1350 public: |
| 1351 RegExpText() : elements_(2), length_(0) {} |
| 1352 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1353 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1354 RegExpNode* on_success); |
| 1355 virtual RegExpText* AsText(); |
| 1356 virtual bool IsText(); |
| 1357 virtual bool IsTextElement() { return true; } |
| 1358 virtual int min_match() { return length_; } |
| 1359 virtual int max_match() { return length_; } |
| 1360 virtual void AppendToText(RegExpText* text); |
| 1361 void AddElement(TextElement elm) { |
| 1362 elements_.Add(elm); |
| 1363 length_ += elm.length(); |
| 1364 }; |
| 1365 ZoneList<TextElement>* elements() { return &elements_; } |
| 1366 private: |
| 1367 ZoneList<TextElement> elements_; |
| 1368 int length_; |
| 1369 }; |
| 1370 |
| 1371 |
| 1346 class RegExpQuantifier: public RegExpTree { | 1372 class RegExpQuantifier: public RegExpTree { |
| 1347 public: | 1373 public: |
| 1348 RegExpQuantifier(int min, int max, bool is_greedy, RegExpTree* body) | 1374 RegExpQuantifier(int min, int max, bool is_greedy, RegExpTree* body) |
| 1349 : min_(min), | 1375 : min_(min), |
| 1350 max_(max), | 1376 max_(max), |
| 1351 is_greedy_(is_greedy), | 1377 is_greedy_(is_greedy), |
| 1352 body_(body) { } | 1378 body_(body), |
| 1379 min_match_(min * body->min_match()) { |
| 1380 if (max > 0 && body->max_match() > kInfinity / max) { |
| 1381 max_match_ = kInfinity; |
| 1382 } else { |
| 1383 max_match_ = max * body->max_match(); |
| 1384 } |
| 1385 } |
| 1353 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1386 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1354 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 1387 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1355 RegExpNode* on_success); | 1388 RegExpNode* on_success); |
| 1356 static RegExpNode* ToNode(int min, | 1389 static RegExpNode* ToNode(int min, |
| 1357 int max, | 1390 int max, |
| 1358 bool is_greedy, | 1391 bool is_greedy, |
| 1359 RegExpTree* body, | 1392 RegExpTree* body, |
| 1360 RegExpCompiler* compiler, | 1393 RegExpCompiler* compiler, |
| 1361 RegExpNode* on_success); | 1394 RegExpNode* on_success); |
| 1362 virtual RegExpQuantifier* AsQuantifier(); | 1395 virtual RegExpQuantifier* AsQuantifier(); |
| 1363 virtual bool IsQuantifier(); | 1396 virtual bool IsQuantifier(); |
| 1397 virtual int min_match() { return min_match_; } |
| 1398 virtual int max_match() { return max_match_; } |
| 1364 int min() { return min_; } | 1399 int min() { return min_; } |
| 1365 int max() { return max_; } | 1400 int max() { return max_; } |
| 1366 bool is_greedy() { return is_greedy_; } | 1401 bool is_greedy() { return is_greedy_; } |
| 1367 RegExpTree* body() { return body_; } | 1402 RegExpTree* body() { return body_; } |
| 1368 // We just use a very large integer value as infinity because 2^30 | |
| 1369 // is infinite in practice. | |
| 1370 static const int kInfinity = (1 << 30); | |
| 1371 private: | 1403 private: |
| 1372 int min_; | 1404 int min_; |
| 1373 int max_; | 1405 int max_; |
| 1374 bool is_greedy_; | 1406 bool is_greedy_; |
| 1375 RegExpTree* body_; | 1407 RegExpTree* body_; |
| 1408 int min_match_; |
| 1409 int max_match_; |
| 1376 }; | 1410 }; |
| 1377 | 1411 |
| 1378 | 1412 |
| 1379 enum CaptureAvailability { | 1413 enum CaptureAvailability { |
| 1380 CAPTURE_AVAILABLE, | 1414 CAPTURE_AVAILABLE, |
| 1381 CAPTURE_UNREACHABLE, | 1415 CAPTURE_UNREACHABLE, |
| 1382 CAPTURE_PERMANENTLY_UNREACHABLE | 1416 CAPTURE_PERMANENTLY_UNREACHABLE |
| 1383 }; | 1417 }; |
| 1384 | 1418 |
| 1385 class RegExpCapture: public RegExpTree { | 1419 class RegExpCapture: public RegExpTree { |
| 1386 public: | 1420 public: |
| 1387 explicit RegExpCapture(RegExpTree* body, int index) | 1421 explicit RegExpCapture(RegExpTree* body, int index) |
| 1388 : body_(body), index_(index), available_(CAPTURE_AVAILABLE) { } | 1422 : body_(body), index_(index), available_(CAPTURE_AVAILABLE) { } |
| 1389 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1423 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1390 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 1424 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1391 RegExpNode* on_success); | 1425 RegExpNode* on_success); |
| 1392 static RegExpNode* ToNode(RegExpTree* body, | 1426 static RegExpNode* ToNode(RegExpTree* body, |
| 1393 int index, | 1427 int index, |
| 1394 RegExpCompiler* compiler, | 1428 RegExpCompiler* compiler, |
| 1395 RegExpNode* on_success); | 1429 RegExpNode* on_success); |
| 1396 virtual RegExpCapture* AsCapture(); | 1430 virtual RegExpCapture* AsCapture(); |
| 1397 virtual bool IsCapture(); | 1431 virtual bool IsCapture(); |
| 1432 virtual int min_match() { return body_->min_match(); } |
| 1433 virtual int max_match() { return body_->max_match(); } |
| 1398 RegExpTree* body() { return body_; } | 1434 RegExpTree* body() { return body_; } |
| 1399 int index() { return index_; } | 1435 int index() { return index_; } |
| 1400 inline CaptureAvailability available() { return available_; } | 1436 inline CaptureAvailability available() { return available_; } |
| 1401 inline void set_available(CaptureAvailability availability) { | 1437 inline void set_available(CaptureAvailability availability) { |
| 1402 available_ = availability; | 1438 available_ = availability; |
| 1403 } | 1439 } |
| 1404 static int StartRegister(int index) { return index * 2; } | 1440 static int StartRegister(int index) { return index * 2; } |
| 1405 static int EndRegister(int index) { return index * 2 + 1; } | 1441 static int EndRegister(int index) { return index * 2 + 1; } |
| 1406 private: | 1442 private: |
| 1407 RegExpTree* body_; | 1443 RegExpTree* body_; |
| 1408 int index_; | 1444 int index_; |
| 1409 CaptureAvailability available_; | 1445 CaptureAvailability available_; |
| 1410 }; | 1446 }; |
| 1411 | 1447 |
| 1412 | 1448 |
| 1413 class RegExpLookahead: public RegExpTree { | 1449 class RegExpLookahead: public RegExpTree { |
| 1414 public: | 1450 public: |
| 1415 RegExpLookahead(RegExpTree* body, bool is_positive) | 1451 RegExpLookahead(RegExpTree* body, bool is_positive) |
| 1416 : body_(body), | 1452 : body_(body), |
| 1417 is_positive_(is_positive) { } | 1453 is_positive_(is_positive) { } |
| 1418 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1454 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1419 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 1455 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1420 RegExpNode* on_success); | 1456 RegExpNode* on_success); |
| 1421 virtual RegExpLookahead* AsLookahead(); | 1457 virtual RegExpLookahead* AsLookahead(); |
| 1422 virtual bool IsLookahead(); | 1458 virtual bool IsLookahead(); |
| 1459 virtual int min_match() { return 0; } |
| 1460 virtual int max_match() { return 0; } |
| 1423 RegExpTree* body() { return body_; } | 1461 RegExpTree* body() { return body_; } |
| 1424 bool is_positive() { return is_positive_; } | 1462 bool is_positive() { return is_positive_; } |
| 1425 private: | 1463 private: |
| 1426 RegExpTree* body_; | 1464 RegExpTree* body_; |
| 1427 bool is_positive_; | 1465 bool is_positive_; |
| 1428 }; | 1466 }; |
| 1429 | 1467 |
| 1430 | 1468 |
| 1431 class RegExpBackReference: public RegExpTree { | 1469 class RegExpBackReference: public RegExpTree { |
| 1432 public: | 1470 public: |
| 1433 explicit RegExpBackReference(RegExpCapture* capture) | 1471 explicit RegExpBackReference(RegExpCapture* capture) |
| 1434 : capture_(capture) { } | 1472 : capture_(capture) { } |
| 1435 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1473 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1436 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 1474 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1437 RegExpNode* on_success); | 1475 RegExpNode* on_success); |
| 1438 virtual RegExpBackReference* AsBackReference(); | 1476 virtual RegExpBackReference* AsBackReference(); |
| 1439 virtual bool IsBackReference(); | 1477 virtual bool IsBackReference(); |
| 1478 virtual int min_match() { return capture_->min_match(); } |
| 1479 virtual int max_match() { return capture_->max_match(); } |
| 1440 int index() { return capture_->index(); } | 1480 int index() { return capture_->index(); } |
| 1441 RegExpCapture* capture() { return capture_; } | 1481 RegExpCapture* capture() { return capture_; } |
| 1442 private: | 1482 private: |
| 1443 RegExpCapture* capture_; | 1483 RegExpCapture* capture_; |
| 1444 }; | 1484 }; |
| 1445 | 1485 |
| 1446 | 1486 |
| 1447 class RegExpEmpty: public RegExpTree { | 1487 class RegExpEmpty: public RegExpTree { |
| 1448 public: | 1488 public: |
| 1449 RegExpEmpty() { } | 1489 RegExpEmpty() { } |
| 1450 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1490 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1451 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 1491 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1452 RegExpNode* on_success); | 1492 RegExpNode* on_success); |
| 1453 virtual RegExpEmpty* AsEmpty(); | 1493 virtual RegExpEmpty* AsEmpty(); |
| 1454 virtual bool IsEmpty(); | 1494 virtual bool IsEmpty(); |
| 1495 virtual int min_match() { return 0; } |
| 1496 virtual int max_match() { return 0; } |
| 1455 static RegExpEmpty* GetInstance() { return &kInstance; } | 1497 static RegExpEmpty* GetInstance() { return &kInstance; } |
| 1456 private: | 1498 private: |
| 1457 static RegExpEmpty kInstance; | 1499 static RegExpEmpty kInstance; |
| 1458 }; | 1500 }; |
| 1459 | 1501 |
| 1460 | 1502 |
| 1461 class RegExpVisitor BASE_EMBEDDED { | 1503 class RegExpVisitor BASE_EMBEDDED { |
| 1462 public: | 1504 public: |
| 1463 virtual ~RegExpVisitor() { } | 1505 virtual ~RegExpVisitor() { } |
| 1464 #define MAKE_CASE(Name) \ | 1506 #define MAKE_CASE(Name) \ |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1506 #undef DEF_VISIT | 1548 #undef DEF_VISIT |
| 1507 | 1549 |
| 1508 private: | 1550 private: |
| 1509 bool stack_overflow_; | 1551 bool stack_overflow_; |
| 1510 }; | 1552 }; |
| 1511 | 1553 |
| 1512 | 1554 |
| 1513 } } // namespace v8::internal | 1555 } } // namespace v8::internal |
| 1514 | 1556 |
| 1515 #endif // V8_AST_H_ | 1557 #endif // V8_AST_H_ |
| OLD | NEW |