Index: runtime/vm/object.cc |
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
index 77dab5ded8929b88f2c51f8a2fce2d788425ec97..f1f2289b6119e85f7f598c850b9010ba5f3dc39e 100644 |
--- a/runtime/vm/object.cc |
+++ b/runtime/vm/object.cc |
@@ -5447,6 +5447,13 @@ RawString* Function::QualifiedUserVisibleName() const { |
} |
+RawString* Function::GetSource() { |
+ const Script& func_script = Script::Handle(script()); |
+ // Without the + 1 the final "}" is not included. |
+ return func_script.GetSnippet(token_pos(), end_token_pos() + 1); |
+} |
+ |
+ |
// Construct fingerprint from token stream. The token stream contains also |
// arguments. |
int32_t Function::SourceFingerprint() const { |
@@ -6968,6 +6975,16 @@ RawString* Script::GetLine(intptr_t line_number) const { |
} |
+RawString* Script::GetSnippet(intptr_t from_token_pos, |
+ intptr_t to_token_pos) const { |
+ intptr_t from_line, from_column; |
+ intptr_t to_line, to_column; |
+ GetTokenLocation(from_token_pos, &from_line, &from_column); |
+ GetTokenLocation(to_token_pos, &to_line, &to_column); |
+ return GetSnippet(from_line, from_column, to_line, to_column); |
+} |
+ |
+ |
RawString* Script::GetSnippet(intptr_t from_line, |
intptr_t from_column, |
intptr_t to_line, |