Chromium Code Reviews| Index: runtime/vm/object.cc |
| diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
| index 8ba182a30b55d34f06cab4fbc87dfe6df5d1c068..ac251452b19e38ee3daaffc6689360b7f793a690 100644 |
| --- a/runtime/vm/object.cc |
| +++ b/runtime/vm/object.cc |
| @@ -5443,6 +5443,13 @@ RawString* Function::QualifiedUserVisibleName() const { |
| } |
| +RawString* Function::GenerateSource() { |
|
hausner
2013/11/05 22:30:05
I suggest making this a bit more smart. If we do h
|
| + const Script& func_script = Script::Handle(script()); |
| + const TokenStream& token_stream = TokenStream::Handle(func_script.tokens()); |
| + return token_stream.GenerateSource(token_pos(), end_token_pos()); |
| +} |
| + |
| + |
| // Construct fingerprint from token stream. The token stream contains also |
| // arguments. |
| int32_t Function::SourceFingerprint() const { |
| @@ -6250,8 +6257,9 @@ void TokenStream::SetPrivateKey(const String& value) const { |
| } |
| -RawString* TokenStream::GenerateSource() const { |
| - Iterator iterator(*this, 0, Iterator::kAllTokens); |
| +RawString* TokenStream::GenerateSource(intptr_t start_tok_pos, |
| + intptr_t end_tok_pos) const { |
| + Iterator iterator(*this, start_tok_pos, Iterator::kAllTokens); |
| const ExternalTypedData& data = ExternalTypedData::Handle(GetStream()); |
| const GrowableObjectArray& literals = |
| GrowableObjectArray::Handle(GrowableObjectArray::New(data.Length())); |
| @@ -6267,6 +6275,10 @@ RawString* TokenStream::GenerateSource() const { |
| int indent = 0; |
| while (curr != Token::kEOS) { |
| + if ((end_tok_pos > 0) && (iterator.CurrentPosition() > end_tok_pos)) { |
|
hausner
2013/11/05 22:30:05
Is end_token_pos inclusive or exclusive? Typically
|
| + // We've reached the end of the token stream we want. |
| + break; |
| + } |
| // Remember current values for this token. |
| obj = iterator.CurrentToken(); |
| literal = iterator.MakeLiteralToken(obj); |