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

Unified Diff: runtime/vm/parser.cc

Issue 15979010: Fix two bugs in the Dart VM's super-noSuchMethod invocation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 23536)
+++ runtime/vm/parser.cc (working copy)
@@ -109,10 +109,17 @@
}
-LocalVariable* ParsedFunction::CreateExpressionTempVar(intptr_t token_pos) {
- return new LocalVariable(token_pos,
- Symbols::ExprTemp(),
- Type::ZoneHandle(Type::DynamicType()));
+LocalVariable* ParsedFunction::EnsureExpressionTemp() {
+ if (!has_expression_temp_var()) {
+ LocalVariable* temp =
+ new LocalVariable(function_.token_pos(),
+ Symbols::ExprTemp(),
+ Type::ZoneHandle(Type::DynamicType()));
+ ASSERT(temp != NULL);
+ set_expression_temp_var(temp);
+ }
+ ASSERT(has_expression_temp_var());
+ return expression_temp_var();
}
@@ -1401,7 +1408,8 @@
StaticCallNode* Parser::BuildInvocationMirrorAllocation(
intptr_t call_pos,
const String& function_name,
- const ArgumentListNode& function_args) {
+ const ArgumentListNode& function_args,
+ const LocalVariable* temp_for_last_arg) {
const intptr_t args_pos = function_args.token_pos();
// Build arguments to the call to the static
// InvocationMirror._allocateInvocationMirror method.
@@ -1418,7 +1426,18 @@
ArrayNode* args_array =
new ArrayNode(args_pos, Type::ZoneHandle(Type::ArrayType()));
for (intptr_t i = 0; i < function_args.length(); i++) {
- args_array->AddElement(function_args.NodeAt(i));
+ AstNode* arg = function_args.NodeAt(i);
+ if ((temp_for_last_arg != NULL) && (i == function_args.length() - 1)) {
+ args_array->AddElement(
+ new CommaNode(arg->token_pos(),
+ new StoreLocalNode(arg->token_pos(),
+ temp_for_last_arg,
+ arg),
+ new LoadLocalNode(arg->token_pos(),
+ temp_for_last_arg)));
+ } else {
+ args_array->AddElement(function_args.NodeAt(i));
+ }
}
arguments->Add(args_array);
// Lookup the static InvocationMirror._allocateInvocationMirror method.
@@ -1436,14 +1455,15 @@
ArgumentListNode* Parser::BuildNoSuchMethodArguments(
intptr_t call_pos,
const String& function_name,
- const ArgumentListNode& function_args) {
+ const ArgumentListNode& function_args,
+ const LocalVariable* temp_for_last_arg) {
ASSERT(function_args.length() >= 1); // The receiver is the first argument.
const intptr_t args_pos = function_args.token_pos();
ArgumentListNode* arguments = new ArgumentListNode(args_pos);
arguments->Add(function_args.NodeAt(0));
// The second argument is the invocation mirror.
arguments->Add(BuildInvocationMirrorAllocation(
- call_pos, function_name, function_args));
+ call_pos, function_name, function_args, temp_for_last_arg));
return arguments;
}
@@ -6881,21 +6901,9 @@
}
-const LocalVariable* Parser::GetIncrementTempLocal() {
- if (!parsed_function()->has_expression_temp_var()) {
- LocalVariable* temp = ParsedFunction::CreateExpressionTempVar(
- current_function().token_pos());
- ASSERT(temp != NULL);
- parsed_function()->set_expression_temp_var(temp);
- }
- ASSERT(parsed_function()->has_expression_temp_var());
- return parsed_function()->expression_temp_var();
-}
-
-
void Parser::EnsureExpressionTemp() {
// Temporary used later by the flow_graph_builder.
- GetIncrementTempLocal();
+ parsed_function()->EnsureExpressionTemp();
}
« runtime/vm/compiler.cc ('K') | « runtime/vm/parser.h ('k') | runtime/vm/unit_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698