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

Unified Diff: runtime/vm/parser.cc

Issue 2904793002: Allow setting breakpoints in literal function initializers of fields. (Closed)
Patch Set: Add comments Created 3 years, 7 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
« runtime/vm/debugger_test.cc ('K') | « runtime/vm/parser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index 95f0e1c290ee2c188f7f05025f11b27c79d3ba45..3e714a0fd893677b6f2d36496f89c5a1184e2890 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -983,6 +983,43 @@ void Parser::ParseClass(const Class& cls) {
}
+bool Parser::FieldHasFunctionLiteralInitializer(const Field& field,
+ TokenPosition* start,
+ TokenPosition* end) {
+ if (!field.has_initializer()) {
+ return false;
+ }
+ Thread* thread = Thread::Current();
+ Zone* zone = thread->zone();
+ const Class& cls = Class::Handle(zone, field.Owner());
+ const Script& script = Script::Handle(zone, cls.script());
+ const Library& lib = Library::Handle(zone, cls.library());
+ Parser parser(script, lib, field.token_pos());
+ return parser.GetFunctionLiteralInitializerRange(field, start, end);
+}
+
+bool Parser::GetFunctionLiteralInitializerRange(const Field& field,
+ TokenPosition* start,
+ TokenPosition* end) {
+ ASSERT(field.has_initializer());
+ // Since |field| has an initializer, skip until '='.
+ while (CurrentToken() != Token::kASSIGN) {
+ ConsumeToken();
+ }
+ // Skip past the '=' as well.
+ ConsumeToken();
+
+ *start = TokenPos();
+ if (IsFunctionLiteral()) {
+ SkipExpr();
+ *end = PrevTokenPos();
+ return true;
+ }
+
+ return false;
+}
+
+
RawObject* Parser::ParseFunctionParameters(const Function& func) {
ASSERT(!func.IsNull());
LongJumpScope jump;
@@ -8197,7 +8234,6 @@ AstNode* Parser::ParseFunctionStatement(bool is_literal) {
ASSERT(innermost_function_.raw() == function.raw());
innermost_function_ = function.parent_function();
-
return is_literal ? closure : new (Z) StoreLocalNode(
function_pos, function_variable, closure);
}
« runtime/vm/debugger_test.cc ('K') | « runtime/vm/parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698