DEFINE_bool(irregexp, false, "new regular expression code")
DEFINE_bool(trace_regexps, false, "trace Irregexp execution")
DEFINE_bool(trace_regexp_bytecodes, false, "trace Irregexp bytecode execution")
-DEFINE_bool(attempt_case_independent, false, "attempt to run Irregexp case independent")
DEFINE_bool(irregexp_native, false, "use native code Irregexp implementation (IA32 only)")
+DEFINE_bool(disable_jscre, false, "abort if JSCRE is used. Only useful with --irregexp")
// Testing flags test/cctest/test-{flags,api,serialization}.cc
DEFINE_bool(testing_bool_flag, true, "testing_bool_flag")
&node,
flags.is_ignore_case());
if (irregexp_data.is_null()) {
+ if (FLAG_disable_jscre) {
+ UNIMPLEMENTED();
+ }
result = JscrePrepare(re, pattern, flags);
} else {
result = IrregexpPrepare(re, pattern, flags, irregexp_data);
Handle<Object> index) {
switch (regexp->TypeTag()) {
case JSRegExp::JSCRE:
+ if (FLAG_disable_jscre) {
+ UNIMPLEMENTED();
+ }
return JscreExec(regexp, subject, index);
case JSRegExp::ATOM:
return AtomExec(regexp, subject, index);
Handle<String> subject) {
switch (regexp->TypeTag()) {
case JSRegExp::JSCRE:
+ if (FLAG_disable_jscre) {
+ UNIMPLEMENTED();
+ }
return JscreExecGlobal(regexp, subject);
case JSRegExp::ATOM:
return AtomExecGlobal(regexp, subject);
inline void IncrementRecursionDepth() { recursion_depth_++; }
inline void DecrementRecursionDepth() { recursion_depth_--; }
- inline bool is_case_independent() { return is_case_independent_; }
+ inline bool ignore_case() { return ignore_case_; }
private:
EndNode* accept_;
List<RegExpNode*>* work_list_;
int recursion_depth_;
RegExpMacroAssembler* macro_assembler_;
- bool is_case_independent_;
+ bool ignore_case_;
};
: next_register_(2 * (capture_count + 1)),
work_list_(NULL),
recursion_depth_(0),
- is_case_independent_(ignore_case) {
+ ignore_case_(ignore_case) {
accept_ = new EndNode(EndNode::ACCEPT);
backtrack_ = new EndNode(EndNode::BACKTRACK);
}
RegExpMacroAssembler* macro_assembler,
RegExpNode* start,
int capture_count) {
- if (!FLAG_attempt_case_independent && is_case_independent_) {
- return Handle<FixedArray>::null();
- }
macro_assembler_ = macro_assembler;
List <RegExpNode*> work_list(0);
work_list_ = &work_list;
TextElement elm = elms_->at(i);
if (elm.type == TextElement::ATOM) {
Vector<const uc16> quarks = elm.data.u_atom->data();
- if (compiler->is_case_independent()) {
+ if (compiler->ignore_case()) {
EmitAtomNonLetters(macro_assembler,
elm,
quarks,
}
}
// Second, handle case independent letter matches if any.
- if (compiler->is_case_independent()) {
+ if (compiler->ignore_case()) {
cp_offset = 0;
for (int i = 0; i < element_count; i++) {
TextElement elm = elms_->at(i);
}
+void TextNode::MakeCaseIndependent() {
+ int element_count = elms_->length();
+ for (int i = 0; i < element_count; i++) {
+ TextElement elm = elms_->at(i);
+ if (elm.type == TextElement::CHAR_CLASS) {
+ RegExpCharacterClass* cc = elm.data.u_char_class;
+ ZoneList<CharacterRange>* ranges = cc->ranges();
+ int range_count = ranges->length();
+ for (int i = 0; i < range_count; i++) {
+ ranges->at(i).AddCaseEquivalents(ranges);
+ }
+ }
+ }
+}
+
+
bool ChoiceNode::Emit(RegExpCompiler* compiler) {
int choice_count = alternatives_->length();
RegExpMacroAssembler* macro_assembler = compiler->macro_assembler();
macro->IfRegisterLT(start_reg_, 0, on_success()->label());
macro->IfRegisterLT(end_reg_, 0, on_success()->label());
ASSERT_EQ(start_reg_ + 1, end_reg_);
- if (compiler->is_case_independent()) {
- macro->CheckNotBackReferenceCaseIndependent(start_reg_,
- on_failure_->label());
+ if (compiler->ignore_case()) {
+ macro->CheckNotBackReferenceIgnoreCase(start_reg_, on_failure_->label());
} else {
macro->CheckNotBackReference(start_reg_, on_failure_->label());
}
void Analysis::VisitText(TextNode* that) {
+ if (ignore_case_) {
+ that->MakeCaseIndependent();
+ }
EnsureAnalyzed(that->on_success());
EnsureAnalyzed(that->on_failure());
}
captured_body,
compiler.backtrack());
if (node_return != NULL) *node_return = node;
- Analysis analysis;
+ Analysis analysis(ignore_case);
analysis.EnsureAnalyzed(node);
if (!FLAG_irregexp) {