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

Unified Diff: runtime/vm/object.cc

Issue 2489723003: Run field initializers for new instance fields after a reload (Closed)
Patch Set: Created 4 years, 1 month 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/isolate_reload_test.cc ('K') | « runtime/vm/object.h ('k') | no next file » | 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 bf063f3ffe159961bc70fc0b7978785fd1a9ef6b..6c3389fe4e9b171d757f259a55c762f3cd50cdb3 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -3059,10 +3059,10 @@ static RawString* BuildClosureSource(const Array& formal_params,
}
-static RawFunction* EvaluateHelper(const Class& cls,
- const String& expr,
- const Array& param_names,
- bool is_static) {
+RawFunction* Function::EvaluateHelper(const Class& cls,
+ const String& expr,
+ const Array& param_names,
+ bool is_static) {
const String& func_src =
String::Handle(BuildClosureSource(param_names, expr));
Script& script = Script::Handle();
@@ -3099,7 +3099,8 @@ RawObject* Class::Evaluate(const String& expr,
}
const Function& eval_func =
- Function::Handle(EvaluateHelper(*this, expr, param_names, true));
+ Function::Handle(
+ Function::EvaluateHelper(*this, expr, param_names, true));
const Object& result =
Object::Handle(DartEntry::InvokeFunction(eval_func, param_values));
return result.raw();
@@ -7647,6 +7648,38 @@ RawField* Field::Clone(const Field& original) const {
}
+RawString* Field::InitializingExpression() const {
rmacnak 2016/11/09 00:36:32 Copying the initializer like this means any stackt
+ Thread* thread = Thread::Current();
+ Zone* zone = thread->zone();
+ const class Script& scr = Script::Handle(zone, Script());
+ ASSERT(!scr.IsNull());
+ const TokenStream& tkns = TokenStream::Handle(zone, scr.tokens());
+ if (tkns.IsNull()) {
+ ASSERT(Dart::snapshot_kind() == Snapshot::kAppNoJIT);
+ return String::null();
+ }
+ TokenStream::Iterator tkit(zone,
+ tkns,
+ token_pos());
+ ASSERT(Token::IsIdentifier(tkit.CurrentTokenKind()));
+#if defined(DEBUG)
+ const String& literal = String::Handle(zone, tkit.CurrentLiteral());
+ ASSERT(literal.raw() == name());
+#endif
+ tkit.Advance();
+ if (tkit.CurrentTokenKind() != Token::kASSIGN) {
+ return String::null();
+ }
+ tkit.Advance();
+ const TokenPosition start_of_expression = tkit.CurrentPosition();
+ while (tkit.CurrentTokenKind() != Token::kSEMICOLON) {
+ tkit.Advance();
+ }
+ const TokenPosition end_of_expression = tkit.CurrentPosition();
+ return scr.GetSnippet(start_of_expression, end_of_expression);
+}
+
+
RawString* Field::UserVisibleName() const {
if (FLAG_show_internal_names) {
return name();
@@ -9115,6 +9148,18 @@ RawString* Script::GetLine(intptr_t line_number, Heap::Space space) const {
}
+RawString* Script::GetSnippet(TokenPosition from, TokenPosition to) const {
+ intptr_t from_line;
+ intptr_t from_column;
+ intptr_t to_line;
+ intptr_t to_column;
+ GetTokenLocation(from, &from_line, &from_column);
+ GetTokenLocation(to, &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,
@@ -15465,7 +15510,8 @@ RawObject* Instance::Evaluate(const Class& method_cls,
const Array& param_names,
const Array& param_values) const {
const Function& eval_func =
- Function::Handle(EvaluateHelper(method_cls, expr, param_names, false));
+ Function::Handle(
+ Function::EvaluateHelper(method_cls, expr, param_names, false));
const Array& args = Array::Handle(Array::New(1 + param_values.Length()));
PassiveObject& param = PassiveObject::Handle();
args.SetAt(0, *this);
« runtime/vm/isolate_reload_test.cc ('K') | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698