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

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

Issue 977283002: Display call site data for functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« runtime/vm/object.cc ('K') | « runtime/vm/parser.h ('k') | no next file » | 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 "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/ast_transformer.h" 9 #include "vm/ast_transformer.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 10507 matching lines...) Expand 10 before | Expand all | Expand 10 after
10518 // javascript warnings are desired and identical is not invoked from a patch 10518 // javascript warnings are desired and identical is not invoked from a patch
10519 // source. 10519 // source.
10520 if (!FLAG_warn_on_javascript_compatibility || is_patch_source()) { 10520 if (!FLAG_warn_on_javascript_compatibility || is_patch_source()) {
10521 ASSERT(num_arguments == 2); 10521 ASSERT(num_arguments == 2);
10522 return new(Z) ComparisonNode(ident_pos, 10522 return new(Z) ComparisonNode(ident_pos,
10523 Token::kEQ_STRICT, 10523 Token::kEQ_STRICT,
10524 arguments->NodeAt(0), 10524 arguments->NodeAt(0),
10525 arguments->NodeAt(1)); 10525 arguments->NodeAt(1));
10526 } 10526 }
10527 } 10527 }
10528 return new(Z) StaticCallNode(call_pos, func, arguments); 10528 return new(Z) StaticCallNode(ident_pos, func, arguments);
10529 } 10529 }
10530 10530
10531 10531
10532 AstNode* Parser::ParseInstanceCall(AstNode* receiver, const String& func_name) { 10532 AstNode* Parser::ParseInstanceCall(AstNode* receiver,
10533 const String& func_name,
10534 intptr_t ident_pos) {
10533 TRACE_PARSER("ParseInstanceCall"); 10535 TRACE_PARSER("ParseInstanceCall");
10534 const intptr_t call_pos = TokenPos();
10535 CheckToken(Token::kLPAREN); 10536 CheckToken(Token::kLPAREN);
10536 ArgumentListNode* arguments = ParseActualParameters(NULL, kAllowConst); 10537 ArgumentListNode* arguments = ParseActualParameters(NULL, kAllowConst);
10537 return new(Z) InstanceCallNode(call_pos, receiver, func_name, arguments); 10538 return new(Z) InstanceCallNode(ident_pos, receiver, func_name, arguments);
10538 } 10539 }
10539 10540
10540 10541
10541 AstNode* Parser::ParseClosureCall(AstNode* closure) { 10542 AstNode* Parser::ParseClosureCall(AstNode* closure) {
10542 TRACE_PARSER("ParseClosureCall"); 10543 TRACE_PARSER("ParseClosureCall");
10543 const intptr_t call_pos = TokenPos(); 10544 const intptr_t call_pos = TokenPos();
10544 ASSERT(CurrentToken() == Token::kLPAREN); 10545 ASSERT(CurrentToken() == Token::kLPAREN);
10545 ArgumentListNode* arguments = ParseActualParameters(NULL, kAllowConst); 10546 ArgumentListNode* arguments = ParseActualParameters(NULL, kAllowConst);
10546 return BuildClosureCall(call_pos, closure, arguments); 10547 return BuildClosureCall(call_pos, closure, arguments);
10547 } 10548 }
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
10727 const intptr_t ident_pos = TokenPos(); 10728 const intptr_t ident_pos = TokenPos();
10728 String* ident = ExpectIdentifier("identifier expected"); 10729 String* ident = ExpectIdentifier("identifier expected");
10729 if (CurrentToken() == Token::kLPAREN) { 10730 if (CurrentToken() == Token::kLPAREN) {
10730 // Identifier followed by a opening paren: method call. 10731 // Identifier followed by a opening paren: method call.
10731 if (left->IsPrimaryNode() && 10732 if (left->IsPrimaryNode() &&
10732 left->AsPrimaryNode()->primary().IsClass()) { 10733 left->AsPrimaryNode()->primary().IsClass()) {
10733 // Static method call prefixed with class name. 10734 // Static method call prefixed with class name.
10734 const Class& cls = Class::Cast(left->AsPrimaryNode()->primary()); 10735 const Class& cls = Class::Cast(left->AsPrimaryNode()->primary());
10735 selector = ParseStaticCall(cls, *ident, ident_pos); 10736 selector = ParseStaticCall(cls, *ident, ident_pos);
10736 } else { 10737 } else {
10737 selector = ParseInstanceCall(left, *ident); 10738 selector = ParseInstanceCall(left, *ident, ident_pos);
10738 } 10739 }
10739 } else { 10740 } else {
10740 // Field access. 10741 // Field access.
10741 Class& cls = Class::Handle(Z); 10742 Class& cls = Class::Handle(Z);
10742 if (left->IsPrimaryNode()) { 10743 if (left->IsPrimaryNode()) {
10743 PrimaryNode* primary_node = left->AsPrimaryNode(); 10744 PrimaryNode* primary_node = left->AsPrimaryNode();
10744 if (primary_node->primary().IsClass()) { 10745 if (primary_node->primary().IsClass()) {
10745 // If the primary node referred to a class we are loading a 10746 // If the primary node referred to a class we are loading a
10746 // qualified static field. 10747 // qualified static field.
10747 cls ^= primary_node->primary().raw(); 10748 cls ^= primary_node->primary().raw();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
10821 Class& cls = Class::Handle(Z, func.Owner()); 10822 Class& cls = Class::Handle(Z, func.Owner());
10822 selector = ParseStaticCall(cls, func_name, primary_pos); 10823 selector = ParseStaticCall(cls, func_name, primary_pos);
10823 } else { 10824 } else {
10824 // Dynamic function call on implicit "this" parameter. 10825 // Dynamic function call on implicit "this" parameter.
10825 if (current_function().is_static()) { 10826 if (current_function().is_static()) {
10826 ReportError(primary_pos, 10827 ReportError(primary_pos,
10827 "cannot access instance method '%s' " 10828 "cannot access instance method '%s' "
10828 "from static function", 10829 "from static function",
10829 func_name.ToCString()); 10830 func_name.ToCString());
10830 } 10831 }
10831 selector = ParseInstanceCall(LoadReceiver(primary_pos), func_name); 10832 selector = ParseInstanceCall(LoadReceiver(primary_pos),
10833 func_name,
10834 primary_pos);
10832 } 10835 }
10833 } else if (primary_node->primary().IsString()) { 10836 } else if (primary_node->primary().IsString()) {
10834 // Primary is an unresolved name. 10837 // Primary is an unresolved name.
10835 if (primary_node->IsSuper()) { 10838 if (primary_node->IsSuper()) {
10836 ReportError(primary_pos, "illegal use of super"); 10839 ReportError(primary_pos, "illegal use of super");
10837 } 10840 }
10838 String& name = String::CheckedZoneHandle( 10841 String& name = String::CheckedZoneHandle(
10839 primary_node->primary().raw()); 10842 primary_node->primary().raw());
10840 if (current_function().is_static()) { 10843 if (current_function().is_static()) {
10841 selector = ThrowNoSuchMethodError(primary_pos, 10844 selector = ThrowNoSuchMethodError(primary_pos,
10842 current_class(), 10845 current_class(),
10843 name, 10846 name,
10844 NULL, // No arguments. 10847 NULL, // No arguments.
10845 InvocationMirror::kStatic, 10848 InvocationMirror::kStatic,
10846 InvocationMirror::kMethod, 10849 InvocationMirror::kMethod,
10847 NULL); // No existing function. 10850 NULL); // No existing function.
10848 } else { 10851 } else {
10849 // Treat as call to unresolved (instance) method. 10852 // Treat as call to unresolved (instance) method.
10850 selector = ParseInstanceCall(LoadReceiver(primary_pos), name); 10853 selector = ParseInstanceCall(LoadReceiver(primary_pos),
10854 name,
10855 primary_pos);
10851 } 10856 }
10852 } else if (primary_node->primary().IsTypeParameter()) { 10857 } else if (primary_node->primary().IsTypeParameter()) {
10853 const String& name = String::ZoneHandle(Z, 10858 const String& name = String::ZoneHandle(Z,
10854 TypeParameter::Cast(primary_node->primary()).name()); 10859 TypeParameter::Cast(primary_node->primary()).name());
10855 if (current_function().is_static()) { 10860 if (current_function().is_static()) {
10856 // Treat as this.T(), because T is in scope. 10861 // Treat as this.T(), because T is in scope.
10857 ReportError(primary_pos, 10862 ReportError(primary_pos,
10858 "cannot access type parameter '%s' " 10863 "cannot access type parameter '%s' "
10859 "from static function", 10864 "from static function",
10860 name.ToCString()); 10865 name.ToCString());
10861 } else { 10866 } else {
10862 // Treat as call to unresolved (instance) method. 10867 // Treat as call to unresolved (instance) method.
10863 selector = ParseInstanceCall(LoadReceiver(primary_pos), name); 10868 selector = ParseInstanceCall(LoadReceiver(primary_pos),
10869 name,
10870 primary_pos);
10864 } 10871 }
10865 } else if (primary_node->primary().IsClass()) { 10872 } else if (primary_node->primary().IsClass()) {
10866 const Class& type_class = Class::Cast(primary_node->primary()); 10873 const Class& type_class = Class::Cast(primary_node->primary());
10867 AbstractType& type = Type::ZoneHandle(Z, Type::New( 10874 AbstractType& type = Type::ZoneHandle(Z, Type::New(
10868 type_class, TypeArguments::Handle(Z), primary_pos)); 10875 type_class, TypeArguments::Handle(Z), primary_pos));
10869 type ^= ClassFinalizer::FinalizeType( 10876 type ^= ClassFinalizer::FinalizeType(
10870 current_class(), type, ClassFinalizer::kCanonicalize); 10877 current_class(), type, ClassFinalizer::kCanonicalize);
10871 // Type may be malbounded, but not malformed. 10878 // Type may be malbounded, but not malformed.
10872 ASSERT(!type.IsMalformed()); 10879 ASSERT(!type.IsMalformed());
10873 selector = new(Z) TypeNode(primary_pos, type); 10880 selector = new(Z) TypeNode(primary_pos, type);
(...skipping 2316 matching lines...) Expand 10 before | Expand all | Expand 10 after
13190 void Parser::SkipQualIdent() { 13197 void Parser::SkipQualIdent() {
13191 ASSERT(IsIdentifier()); 13198 ASSERT(IsIdentifier());
13192 ConsumeToken(); 13199 ConsumeToken();
13193 if (CurrentToken() == Token::kPERIOD) { 13200 if (CurrentToken() == Token::kPERIOD) {
13194 ConsumeToken(); // Consume the kPERIOD token. 13201 ConsumeToken(); // Consume the kPERIOD token.
13195 ExpectIdentifier("identifier expected after '.'"); 13202 ExpectIdentifier("identifier expected after '.'");
13196 } 13203 }
13197 } 13204 }
13198 13205
13199 } // namespace dart 13206 } // namespace dart
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698