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

Side by Side Diff: runtime/vm/parser.cc

Issue 11231074: Change signature of noSuchMethod to take an InvocationMirror. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: One more test expectation Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/parser.h ('k') | runtime/vm/stack_frame_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/parser.h" 5 #include "vm/parser.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 String& name = String::Handle(class_name.raw()); 1306 String& name = String::Handle(class_name.raw());
1307 if (class_name.CharAt(0) == Scanner::kPrivateIdentifierStart) { 1307 if (class_name.CharAt(0) == Scanner::kPrivateIdentifierStart) {
1308 // Private identifiers are mangled on a per script basis. 1308 // Private identifiers are mangled on a per script basis.
1309 name = String::Concat(name, String::Handle(core_lib.private_key())); 1309 name = String::Concat(name, String::Handle(core_lib.private_key()));
1310 name = Symbols::New(name); 1310 name = Symbols::New(name);
1311 } 1311 }
1312 return core_lib.LookupClass(name); 1312 return core_lib.LookupClass(name);
1313 } 1313 }
1314 1314
1315 1315
1316 StaticCallNode* Parser::BuildInvocationMirrorAllocation(
1317 intptr_t call_pos,
1318 const String& function_name,
1319 const ArgumentListNode& function_args) {
1320 const intptr_t args_pos = function_args.token_pos();
1321 // Build arguments to the call to the static
1322 // InvocationMirror._allocateInvocationMirror method.
1323 ArgumentListNode* arguments = new ArgumentListNode(args_pos);
1324 // The first argument is the original function name.
1325 arguments->Add(new LiteralNode(args_pos, function_name));
1326 // The second argument is an array containing the original function arguments.
1327 ArrayNode* args_array = new ArrayNode(
1328 args_pos, Type::ZoneHandle(Type::ListInterface()));
1329 for (intptr_t i = 1; i < function_args.length(); i++) {
1330 args_array->AddElement(function_args.NodeAt(i));
1331 }
1332 arguments->Add(args_array);
1333 // Lookup the static InvocationMirror._allocateInvocationMirror method.
1334 const Class& mirror_class = Class::Handle(
1335 LookupCoreClass(String::Handle(Symbols::InvocationMirror())));
1336 ASSERT(!mirror_class.IsNull());
1337 const String& allocation_function_name =
1338 String::Handle(Symbols::AllocateInvocationMirror());
1339 const Function& allocation_function = Function::ZoneHandle(
1340 mirror_class.LookupStaticFunction(allocation_function_name));
1341 ASSERT(!allocation_function.IsNull());
1342 return new StaticCallNode(call_pos, allocation_function, arguments);
1343 }
1344
1345
1316 ArgumentListNode* Parser::BuildNoSuchMethodArguments( 1346 ArgumentListNode* Parser::BuildNoSuchMethodArguments(
1347 intptr_t call_pos,
1317 const String& function_name, 1348 const String& function_name,
1318 const ArgumentListNode& function_args) { 1349 const ArgumentListNode& function_args) {
1319 ASSERT(function_args.length() >= 1); // The receiver is the first argument. 1350 ASSERT(function_args.length() >= 1); // The receiver is the first argument.
1320 const intptr_t args_pos = function_args.token_pos(); 1351 const intptr_t args_pos = function_args.token_pos();
1321 ArgumentListNode* arguments = new ArgumentListNode(args_pos); 1352 ArgumentListNode* arguments = new ArgumentListNode(args_pos);
1322 arguments->Add(function_args.NodeAt(0)); 1353 arguments->Add(function_args.NodeAt(0));
1323 // The second argument is the original function name. 1354 // The second argument is the invocation mirror.
1324 // TODO(regis): This will change once mirrors are supported. 1355 arguments->Add(BuildInvocationMirrorAllocation(
1325 arguments->Add(new LiteralNode(args_pos, function_name)); 1356 call_pos, function_name, function_args));
1326 // The third argument is an array containing the original function arguments.
1327 ArrayNode* args_array = new ArrayNode(
1328 args_pos, Type::ZoneHandle(Type::ListInterface()));
1329 for (intptr_t i = 1; i < function_args.length(); i++) {
1330 args_array->AddElement(function_args.NodeAt(i));
1331 }
1332 arguments->Add(args_array);
1333 return arguments; 1357 return arguments;
1334 } 1358 }
1335 1359
1336 1360
1337 AstNode* Parser::ParseSuperCall(const String& function_name) { 1361 AstNode* Parser::ParseSuperCall(const String& function_name) {
1338 TRACE_PARSER("ParseSuperCall"); 1362 TRACE_PARSER("ParseSuperCall");
1339 ASSERT(CurrentToken() == Token::kLPAREN); 1363 ASSERT(CurrentToken() == Token::kLPAREN);
1340 const intptr_t supercall_pos = TokenPos(); 1364 const intptr_t supercall_pos = TokenPos();
1341 1365
1342 const bool kResolveGetter = true; 1366 const bool kResolveGetter = true;
(...skipping 15 matching lines...) Expand all
1358 super_class, 1382 super_class,
1359 function_name); 1383 function_name);
1360 EnsureExpressionTemp(); 1384 EnsureExpressionTemp();
1361 return new ClosureCallNode(supercall_pos, closure, arguments); 1385 return new ClosureCallNode(supercall_pos, closure, arguments);
1362 } 1386 }
1363 // 'this' parameter is the first argument to super call. 1387 // 'this' parameter is the first argument to super call.
1364 AstNode* receiver = LoadReceiver(supercall_pos); 1388 AstNode* receiver = LoadReceiver(supercall_pos);
1365 arguments->Add(receiver); 1389 arguments->Add(receiver);
1366 ParseActualParameters(arguments, kAllowConst); 1390 ParseActualParameters(arguments, kAllowConst);
1367 if (is_no_such_method) { 1391 if (is_no_such_method) {
1368 arguments = BuildNoSuchMethodArguments(function_name, *arguments); 1392 arguments = BuildNoSuchMethodArguments(
1393 supercall_pos, function_name, *arguments);
1369 } 1394 }
1370 return new StaticCallNode(supercall_pos, super_function, arguments); 1395 return new StaticCallNode(supercall_pos, super_function, arguments);
1371 } 1396 }
1372 1397
1373 1398
1374 // Simple test if a node is side effect free. 1399 // Simple test if a node is side effect free.
1375 static bool IsSimpleLocalOrLiteralNode(AstNode* node) { 1400 static bool IsSimpleLocalOrLiteralNode(AstNode* node) {
1376 if (node->IsLiteralNode()) { 1401 if (node->IsLiteralNode()) {
1377 return true; 1402 return true;
1378 } 1403 }
(...skipping 18 matching lines...) Expand all
1397 const Function& super_operator = Function::ZoneHandle( 1422 const Function& super_operator = Function::ZoneHandle(
1398 GetSuperFunction(super_pos, 1423 GetSuperFunction(super_pos,
1399 operator_function_name, 1424 operator_function_name,
1400 kResolveGetter, 1425 kResolveGetter,
1401 &is_no_such_method)); 1426 &is_no_such_method));
1402 ArgumentListNode* op_arguments = new ArgumentListNode(super_pos); 1427 ArgumentListNode* op_arguments = new ArgumentListNode(super_pos);
1403 AstNode* receiver = LoadReceiver(super_pos); 1428 AstNode* receiver = LoadReceiver(super_pos);
1404 op_arguments->Add(receiver); 1429 op_arguments->Add(receiver);
1405 CheckFunctionIsCallable(super_pos, super_operator); 1430 CheckFunctionIsCallable(super_pos, super_operator);
1406 if (is_no_such_method) { 1431 if (is_no_such_method) {
1407 op_arguments = BuildNoSuchMethodArguments(operator_function_name, 1432 op_arguments = BuildNoSuchMethodArguments(
1408 *op_arguments); 1433 super_pos, operator_function_name, *op_arguments);
1409 } 1434 }
1410 super_op = new StaticCallNode(super_pos, super_operator, op_arguments); 1435 super_op = new StaticCallNode(super_pos, super_operator, op_arguments);
1411 } else { 1436 } else {
1412 ErrorMsg(super_pos, "illegal super operator call"); 1437 ErrorMsg(super_pos, "illegal super operator call");
1413 } 1438 }
1414 return super_op; 1439 return super_op;
1415 } 1440 }
1416 1441
1417 1442
1418 AstNode* Parser::ParseSuperOperator() { 1443 AstNode* Parser::ParseSuperOperator() {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 ASSERT(Token::Precedence(op) >= Token::Precedence(Token::kBIT_OR)); 1479 ASSERT(Token::Precedence(op) >= Token::Precedence(Token::kBIT_OR));
1455 AstNode* other_operand = ParseBinaryExpr(Token::Precedence(op) + 1); 1480 AstNode* other_operand = ParseBinaryExpr(Token::Precedence(op) + 1);
1456 1481
1457 ArgumentListNode* op_arguments = new ArgumentListNode(operator_pos); 1482 ArgumentListNode* op_arguments = new ArgumentListNode(operator_pos);
1458 AstNode* receiver = LoadReceiver(operator_pos); 1483 AstNode* receiver = LoadReceiver(operator_pos);
1459 op_arguments->Add(receiver); 1484 op_arguments->Add(receiver);
1460 op_arguments->Add(other_operand); 1485 op_arguments->Add(other_operand);
1461 1486
1462 CheckFunctionIsCallable(operator_pos, super_operator); 1487 CheckFunctionIsCallable(operator_pos, super_operator);
1463 if (is_no_such_method) { 1488 if (is_no_such_method) {
1464 op_arguments = BuildNoSuchMethodArguments(operator_function_name, 1489 op_arguments = BuildNoSuchMethodArguments(
1465 *op_arguments); 1490 operator_pos, operator_function_name, *op_arguments);
1466 } 1491 }
1467 super_op = new StaticCallNode(operator_pos, super_operator, op_arguments); 1492 super_op = new StaticCallNode(operator_pos, super_operator, op_arguments);
1468 if (negate_result) { 1493 if (negate_result) {
1469 super_op = new UnaryOpNode(operator_pos, Token::kNOT, super_op); 1494 super_op = new UnaryOpNode(operator_pos, Token::kNOT, super_op);
1470 } 1495 }
1471 } 1496 }
1472 return super_op; 1497 return super_op;
1473 } 1498 }
1474 1499
1475 1500
(...skipping 8362 matching lines...) Expand 10 before | Expand all | Expand 10 after
9838 void Parser::SkipQualIdent() { 9863 void Parser::SkipQualIdent() {
9839 ASSERT(IsIdentifier()); 9864 ASSERT(IsIdentifier());
9840 ConsumeToken(); 9865 ConsumeToken();
9841 if (CurrentToken() == Token::kPERIOD) { 9866 if (CurrentToken() == Token::kPERIOD) {
9842 ConsumeToken(); // Consume the kPERIOD token. 9867 ConsumeToken(); // Consume the kPERIOD token.
9843 ExpectIdentifier("identifier expected after '.'"); 9868 ExpectIdentifier("identifier expected after '.'");
9844 } 9869 }
9845 } 9870 }
9846 9871
9847 } // namespace dart 9872 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/parser.h ('k') | runtime/vm/stack_frame_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698