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

Unified Diff: runtime/vm/regexp_parser.cc

Issue 539153002: Port and integrate the irregexp engine from V8 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Port remaining V8 regexp tests and fix exposed bugs. Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/regexp_parser.cc
diff --git a/runtime/vm/regexp_parser.cc b/runtime/vm/regexp_parser.cc
index 30acc5515c173fe3ff820751917c39a634058086..1b2df30ede8e0f975d76892182c6bad062b08fdf 100644
--- a/runtime/vm/regexp_parser.cc
+++ b/runtime/vm/regexp_parser.cc
@@ -249,6 +249,32 @@ void RegExpParser::Reset(intptr_t pos) {
}
+bool RegExpParser::ParseFunction(ParsedFunction *parsed_function) {
+ Isolate* isolate = parsed_function->isolate();
+ JSRegExp& regexp = JSRegExp::Handle(parsed_function->function().regexp());
+
+ const String& pattern = String::Handle(regexp.pattern());
+ const bool multiline = regexp.is_multi_line();
+
+ RegExpCompileData* compile_data = new(isolate) RegExpCompileData();
+ if (!RegExpParser::ParseRegExp(pattern, multiline, compile_data)) {
+ // Parsing failures are handled in the JSRegExp factory constructor.
+ UNREACHABLE();
+ }
+
+ regexp.set_num_bracket_expressions(compile_data->capture_count);
+ if (compile_data->simple) {
+ regexp.set_is_simple();
+ } else {
+ regexp.set_is_complex();
+ }
+
+ parsed_function->SetRegExpCompileData(compile_data);
+
+ return true;
+}
+
+
bool RegExpParser::ParseRegExp(const String& input,
bool multiline,
RegExpCompileData* result) {
@@ -266,10 +292,15 @@ bool RegExpParser::ParseRegExp(const String& input,
result->capture_count = capture_count;
} else {
ASSERT(!result->error.IsNull());
-
- // TODO(jgruber): Throw a format exception once we are ready to replace
- // jscre. For now, we ignore the error set by LongJump.
Isolate::Current()->object_store()->clear_sticky_error();
+
+ // Throw a FormatException on parsing failures.
+ const String& message = String::Handle(
+ String::Concat(result->error, input));
+ const Array& args = Array::Handle(Array::New(1));
+ args.SetAt(0, message);
+
+ Exceptions::ThrowByType(Exceptions::kFormat, args);
}
return !parser.failed();
}

Powered by Google App Engine
This is Rietveld 408576698