Destructor. Assumes already cleaned up children. Private: use Decref() instead of delete to destroy Regexps. Can't call Decref on the sub-Regexps here because that could cause arbitrarily deep recursion, so required Decref() to have handled them for us.
| 44 | // that could cause arbitrarily deep recursion, so |
| 45 | // required Decref() to have handled them for us. |
| 46 | Regexp::~Regexp() { |
| 47 | if (nsub_ > 0) |
| 48 | LOG(DFATAL) << "Regexp not destroyed."; |
| 49 | |
| 50 | switch (op_) { |
| 51 | default: |
| 52 | break; |
| 53 | case kRegexpCapture: |
| 54 | delete name_; |
| 55 | break; |
| 56 | case kRegexpLiteralString: |
| 57 | delete[] runes_; |
| 58 | break; |
| 59 | case kRegexpCharClass: |
| 60 | if (cc_) |
| 61 | cc_->Delete(); |
| 62 | delete ccb_; |
| 63 | break; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | // If it's possible to destroy this regexp without recurring, |
| 68 | // do so and return true. Else return false. |