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

Side by Side Diff: runtime/vm/parser.cc

Issue 2904793002: Allow setting breakpoints in literal function initializers of fields. (Closed)
Patch Set: Add comments Created 3 years, 6 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 unified diff | Download patch
« runtime/vm/debugger_test.cc ('K') | « runtime/vm/parser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/parser.h" 5 #include "vm/parser.h"
6 #include "vm/flags.h" 6 #include "vm/flags.h"
7 7
8 #ifndef DART_PRECOMPILED_RUNTIME 8 #ifndef DART_PRECOMPILED_RUNTIME
9 9
10 #include "lib/invocation_mirror.h" 10 #include "lib/invocation_mirror.h"
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 const Script& script = Script::Handle(zone, cls.script()); 976 const Script& script = Script::Handle(zone, cls.script());
977 const Library& lib = Library::Handle(zone, cls.library()); 977 const Library& lib = Library::Handle(zone, cls.library());
978 Parser parser(script, lib, cls.token_pos()); 978 Parser parser(script, lib, cls.token_pos());
979 parser.ParseEnumDefinition(cls); 979 parser.ParseEnumDefinition(cls);
980 } 980 }
981 const int64_t num_tokes_after = STAT_VALUE(thread, num_tokens_consumed); 981 const int64_t num_tokes_after = STAT_VALUE(thread, num_tokens_consumed);
982 INC_STAT(thread, num_class_tokens, num_tokes_after - num_tokes_before); 982 INC_STAT(thread, num_class_tokens, num_tokes_after - num_tokes_before);
983 } 983 }
984 984
985 985
986 bool Parser::FieldHasFunctionLiteralInitializer(const Field& field,
987 TokenPosition* start,
988 TokenPosition* end) {
989 if (!field.has_initializer()) {
990 return false;
991 }
992 Thread* thread = Thread::Current();
993 Zone* zone = thread->zone();
994 const Class& cls = Class::Handle(zone, field.Owner());
995 const Script& script = Script::Handle(zone, cls.script());
996 const Library& lib = Library::Handle(zone, cls.library());
997 Parser parser(script, lib, field.token_pos());
998 return parser.GetFunctionLiteralInitializerRange(field, start, end);
999 }
1000
1001 bool Parser::GetFunctionLiteralInitializerRange(const Field& field,
1002 TokenPosition* start,
1003 TokenPosition* end) {
1004 ASSERT(field.has_initializer());
1005 // Since |field| has an initializer, skip until '='.
1006 while (CurrentToken() != Token::kASSIGN) {
1007 ConsumeToken();
1008 }
1009 // Skip past the '=' as well.
1010 ConsumeToken();
1011
1012 *start = TokenPos();
1013 if (IsFunctionLiteral()) {
1014 SkipExpr();
1015 *end = PrevTokenPos();
1016 return true;
1017 }
1018
1019 return false;
1020 }
1021
1022
986 RawObject* Parser::ParseFunctionParameters(const Function& func) { 1023 RawObject* Parser::ParseFunctionParameters(const Function& func) {
987 ASSERT(!func.IsNull()); 1024 ASSERT(!func.IsNull());
988 LongJumpScope jump; 1025 LongJumpScope jump;
989 if (setjmp(*jump.Set()) == 0) { 1026 if (setjmp(*jump.Set()) == 0) {
990 Thread* thread = Thread::Current(); 1027 Thread* thread = Thread::Current();
991 StackZone stack_zone(thread); 1028 StackZone stack_zone(thread);
992 Zone* zone = stack_zone.GetZone(); 1029 Zone* zone = stack_zone.GetZone();
993 const Script& script = Script::Handle(zone, func.script()); 1030 const Script& script = Script::Handle(zone, func.script());
994 const Class& owner = Class::Handle(zone, func.Owner()); 1031 const Class& owner = Class::Handle(zone, func.Owner());
995 ASSERT(!owner.IsNull()); 1032 ASSERT(!owner.IsNull());
(...skipping 7194 matching lines...) Expand 10 before | Expand all | Expand 10 after
8190 // The local scope of the parsed function can be pruned, since contained 8227 // The local scope of the parsed function can be pruned, since contained
8191 // variables are not relevant for the compilation of the enclosing function. 8228 // variables are not relevant for the compilation of the enclosing function.
8192 // This pruning is done by omitting to hook the local scope in its parent 8229 // This pruning is done by omitting to hook the local scope in its parent
8193 // scope in the constructor of LocalScope. 8230 // scope in the constructor of LocalScope.
8194 AstNode* closure = 8231 AstNode* closure =
8195 new (Z) ClosureNode(function_pos, function, NULL, 8232 new (Z) ClosureNode(function_pos, function, NULL,
8196 statements != NULL ? statements->scope() : NULL); 8233 statements != NULL ? statements->scope() : NULL);
8197 8234
8198 ASSERT(innermost_function_.raw() == function.raw()); 8235 ASSERT(innermost_function_.raw() == function.raw());
8199 innermost_function_ = function.parent_function(); 8236 innermost_function_ = function.parent_function();
8200
8201 return is_literal ? closure : new (Z) StoreLocalNode( 8237 return is_literal ? closure : new (Z) StoreLocalNode(
8202 function_pos, function_variable, closure); 8238 function_pos, function_variable, closure);
8203 } 8239 }
8204 8240
8205 8241
8206 // Returns true if the current and next tokens can be parsed as type 8242 // Returns true if the current and next tokens can be parsed as type
8207 // parameters. Current token position is not saved and restored. 8243 // parameters. Current token position is not saved and restored.
8208 bool Parser::TryParseTypeParameters() { 8244 bool Parser::TryParseTypeParameters() {
8209 ASSERT(CurrentToken() == Token::kLT); 8245 ASSERT(CurrentToken() == Token::kLT);
8210 int nesting_level = 0; 8246 int nesting_level = 0;
(...skipping 7044 matching lines...) Expand 10 before | Expand all | Expand 10 after
15255 const ArgumentListNode& function_args, 15291 const ArgumentListNode& function_args,
15256 const LocalVariable* temp_for_last_arg, 15292 const LocalVariable* temp_for_last_arg,
15257 bool is_super_invocation) { 15293 bool is_super_invocation) {
15258 UNREACHABLE(); 15294 UNREACHABLE();
15259 return NULL; 15295 return NULL;
15260 } 15296 }
15261 15297
15262 } // namespace dart 15298 } // namespace dart
15263 15299
15264 #endif // DART_PRECOMPILED_RUNTIME 15300 #endif // DART_PRECOMPILED_RUNTIME
OLDNEW
« 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