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

Unified Diff: runtime/vm/object.cc

Issue 361743002: observatory/vm: add support for computing/passing end tokens on classes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix polymer include and add deployed/ Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index d736ad7ab3a8567f345b4fd71b7e4779c389b9c5..d83e40d5d8664cf8b84c0b10c3e5e3b59e459d17 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -3252,6 +3252,32 @@ void Class::set_token_pos(intptr_t token_pos) const {
}
+intptr_t Class::ComputeEndTokenPos() const {
+ // Return the begin token for synthetic classes.
+ if (IsSignatureClass() || IsMixinApplication() || IsTopLevel()) {
+ return token_pos();
+ }
+ const Script& scr = Script::Handle(script());
+ ASSERT(!scr.IsNull());
+ const TokenStream& tkns = TokenStream::Handle(scr.tokens());
+ TokenStream::Iterator tkit(
+ tkns, token_pos(), TokenStream::Iterator::kNoNewlines);
+ intptr_t level = 0;
+ while (tkit.CurrentTokenKind() != Token::kEOS) {
+ if (tkit.CurrentTokenKind() == Token::kLBRACE) {
+ level++;
+ } else if (tkit.CurrentTokenKind() == Token::kRBRACE) {
+ if (--level == 0) {
+ return tkit.CurrentPosition();
+ }
+ }
+ tkit.Advance();
+ }
+ UNREACHABLE();
+ return 0;
+}
+
+
void Class::set_is_implemented() const {
set_state_bits(ImplementedBit::update(true, raw_ptr()->state_bits_));
}
@@ -4008,6 +4034,7 @@ void Class::PrintJSONImpl(JSONStream* stream, bool ref) const {
if (!script.IsNull()) {
jsobj.AddProperty("script", script);
jsobj.AddProperty("tokenPos", token_pos());
+ jsobj.AddProperty("endTokenPos", ComputeEndTokenPos());
}
{
JSONArray interfaces_array(&jsobj, "interfaces");
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698