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

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

Issue 8772009: Address Regis' comments, replace AbstractType with Type where possible. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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/raw_object.h » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 855 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 if (signature_class.IsNull()) { 866 if (signature_class.IsNull()) {
867 signature_class = Class::NewSignatureClass(signature, 867 signature_class = Class::NewSignatureClass(signature,
868 signature_function, 868 signature_function,
869 script_); 869 script_);
870 // Record the function signature class in the current library. 870 // Record the function signature class in the current library.
871 library_.AddClass(signature_class); 871 library_.AddClass(signature_class);
872 } else { 872 } else {
873 signature_function.set_signature_class(signature_class); 873 signature_function.set_signature_class(signature_class);
874 } 874 }
875 ASSERT(signature_function.signature_class() == signature_class.raw()); 875 ASSERT(signature_function.signature_class() == signature_class.raw());
876 AbstractType& signature_type = 876 Type& signature_type = Type::ZoneHandle(signature_class.SignatureType());
877 AbstractType::ZoneHandle(signature_class.SignatureType());
878 if (!is_top_level_ && !signature_type.IsFinalized()) { 877 if (!is_top_level_ && !signature_type.IsFinalized()) {
879 String& errmsg = String::Handle(); 878 String& errmsg = String::Handle();
880 signature_type = 879 signature_type =
881 ClassFinalizer::FinalizeAndCanonicalizeType(signature_type, 880 ClassFinalizer::FinalizeAndCanonicalizeType(signature_type,
882 &errmsg); 881 &errmsg);
883 if (!errmsg.IsNull()) { 882 if (!errmsg.IsNull()) {
884 ErrorMsg(errmsg.ToCString()); 883 ErrorMsg(errmsg.ToCString());
885 } 884 }
886 } 885 }
887 // The type of the parameter is now the signature type. 886 // The type of the parameter is now the signature type.
(...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after
2467 class_name.ToCString()); 2466 class_name.ToCString());
2468 } else if (cls.functions() != Array::Empty()) { 2467 } else if (cls.functions() != Array::Empty()) {
2469 ErrorMsg(classname_pos, "class '%s' is already defined", 2468 ErrorMsg(classname_pos, "class '%s' is already defined",
2470 class_name.ToCString()); 2469 class_name.ToCString());
2471 } 2470 }
2472 } 2471 }
2473 ASSERT(!cls.IsNull()); 2472 ASSERT(!cls.IsNull());
2474 ASSERT(cls.functions() == Array::Empty()); 2473 ASSERT(cls.functions() == Array::Empty());
2475 set_current_class(cls); 2474 set_current_class(cls);
2476 ParseTypeParameters(cls); 2475 ParseTypeParameters(cls);
2477 AbstractType& super_type = AbstractType::Handle(); 2476 Type& super_type = Type::Handle();
2478 if (CurrentToken() == Token::kEXTENDS) { 2477 if (CurrentToken() == Token::kEXTENDS) {
2479 ConsumeToken(); 2478 ConsumeToken();
2480 super_type = ParseType(kCanResolve); 2479 super_type ^= ParseType(kCanResolve);
2481 if (super_type.IsInterfaceType()) { 2480 if (super_type.IsInterfaceType()) {
2482 ErrorMsg("class '%s' may implement, but cannot extend interface '%s'", 2481 ErrorMsg("class '%s' may implement, but cannot extend interface '%s'",
2483 class_name.ToCString(), 2482 class_name.ToCString(),
2484 String::Handle(super_type.Name()).ToCString()); 2483 String::Handle(super_type.Name()).ToCString());
2485 } 2484 }
2486 } else { 2485 } else {
2487 // No extends clause: Implicitly extend Object. 2486 // No extends clause: Implicitly extend Object.
2488 super_type = Type::ObjectType(); 2487 super_type = Type::ObjectType();
2489 } 2488 }
2490 ASSERT(!super_type.IsNull()); 2489 ASSERT(!super_type.IsNull());
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after
3722 // Make sure that the instantiator is captured. 3721 // Make sure that the instantiator is captured.
3723 if ((signature_class.NumTypeParameters() > 0) && 3722 if ((signature_class.NumTypeParameters() > 0) &&
3724 (current_block_->scope->function_level() > 0)) { 3723 (current_block_->scope->function_level() > 0)) {
3725 CaptureReceiver(); 3724 CaptureReceiver();
3726 } 3725 }
3727 3726
3728 if (variable_name != NULL) { 3727 if (variable_name != NULL) {
3729 // Patch the function type now that the signature is known. 3728 // Patch the function type now that the signature is known.
3730 // We need to create a new type for proper finalization, since the existing 3729 // We need to create a new type for proper finalization, since the existing
3731 // type is already marked as finalized. 3730 // type is already marked as finalized.
3732 AbstractType& signature_type = 3731 Type& signature_type = Type::Handle(signature_class.SignatureType());
3733 AbstractType::Handle(signature_class.SignatureType());
3734 const TypeArguments& signature_type_arguments = TypeArguments::Handle( 3732 const TypeArguments& signature_type_arguments = TypeArguments::Handle(
3735 signature_type.arguments()); 3733 signature_type.arguments());
3736 3734
3737 // Since the signature type is cached by the signature class, it may have 3735 // Since the signature type is cached by the signature class, it may have
3738 // been finalized already. 3736 // been finalized already.
3739 if (!signature_type.IsFinalized()) { 3737 if (!signature_type.IsFinalized()) {
3740 String& errmsg = String::Handle(); 3738 String& errmsg = String::Handle();
3741 signature_type = 3739 signature_type =
3742 ClassFinalizer::FinalizeAndCanonicalizeType(signature_type, &errmsg); 3740 ClassFinalizer::FinalizeAndCanonicalizeType(signature_type, &errmsg);
3743 if (!errmsg.IsNull()) { 3741 if (!errmsg.IsNull()) {
(...skipping 2823 matching lines...) Expand 10 before | Expand all | Expand 10 after
6567 } 6565 }
6568 return type_parameter.raw(); 6566 return type_parameter.raw();
6569 } 6567 }
6570 } 6568 }
6571 } 6569 }
6572 // Try to resolve the type class. 6570 // Try to resolve the type class.
6573 type_class = LookupTypeClass(type_name, type_resolution); 6571 type_class = LookupTypeClass(type_name, type_resolution);
6574 } 6572 }
6575 TypeArguments& type_arguments = 6573 TypeArguments& type_arguments =
6576 TypeArguments::Handle(ParseTypeArguments(type_resolution)); 6574 TypeArguments::Handle(ParseTypeArguments(type_resolution));
6577 AbstractType& type = AbstractType::Handle( 6575 Type& type = Type::Handle(
6578 Type::NewParameterizedType(type_class, type_arguments)); 6576 Type::NewParameterizedType(type_class, type_arguments));
6579 if (type_resolution == kMustResolve) { 6577 if (type_resolution == kMustResolve) {
6580 ASSERT(type_class.IsClass()); // Must be resolved. 6578 ASSERT(type_class.IsClass()); // Must be resolved.
6581 String& errmsg = String::Handle(); 6579 String& errmsg = String::Handle();
6582 type = ClassFinalizer::FinalizeAndCanonicalizeType(type, &errmsg); 6580 type = ClassFinalizer::FinalizeAndCanonicalizeType(type, &errmsg);
6583 if (!errmsg.IsNull()) { 6581 if (!errmsg.IsNull()) {
6584 ErrorMsg(errmsg.ToCString()); 6582 ErrorMsg(errmsg.ToCString());
6585 } 6583 }
6586 } 6584 }
6587 return type.raw(); 6585 return type.raw();
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
7111 // argument vector to be passed. 7109 // argument vector to be passed.
7112 { 7110 {
7113 Class& signature_class = Class::Handle(); 7111 Class& signature_class = Class::Handle();
7114 if (constructor.IsFactory()) { 7112 if (constructor.IsFactory()) {
7115 signature_class = constructor.signature_class(); 7113 signature_class = constructor.signature_class();
7116 } else { 7114 } else {
7117 signature_class = constructor.owner(); 7115 signature_class = constructor.owner();
7118 ASSERT(signature_class.raw() == type_class.raw()); 7116 ASSERT(signature_class.raw() == type_class.raw());
7119 } 7117 }
7120 // TODO(regis): Temporary type should be allocated in new gen heap. 7118 // TODO(regis): Temporary type should be allocated in new gen heap.
7121 AbstractType& type = Type::Handle( 7119 Type& type = Type::Handle(
7122 Type::NewParameterizedType(signature_class, type_arguments)); 7120 Type::NewParameterizedType(signature_class, type_arguments));
7123 String& errmsg = String::Handle(); 7121 String& errmsg = String::Handle();
7124 type = ClassFinalizer::FinalizeAndCanonicalizeType(type, &errmsg); 7122 type = ClassFinalizer::FinalizeAndCanonicalizeType(type, &errmsg);
7125 if (!errmsg.IsNull()) { 7123 if (!errmsg.IsNull()) {
7126 ErrorMsg(errmsg.ToCString()); 7124 ErrorMsg(errmsg.ToCString());
7127 } 7125 }
7128 // The type argument vector may have been expanded with the type arguments 7126 // The type argument vector may have been expanded with the type arguments
7129 // of the super type when finalizing the type. 7127 // of the super type when finalizing the type.
7130 type_arguments = type.arguments(); 7128 type_arguments = type.arguments();
7131 } 7129 }
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
7593 } 7591 }
7594 7592
7595 7593
7596 void Parser::SkipNestedExpr() { 7594 void Parser::SkipNestedExpr() {
7597 const bool saved_mode = SetAllowFunctionLiterals(true); 7595 const bool saved_mode = SetAllowFunctionLiterals(true);
7598 SkipExpr(); 7596 SkipExpr();
7599 SetAllowFunctionLiterals(saved_mode); 7597 SetAllowFunctionLiterals(saved_mode);
7600 } 7598 }
7601 7599
7602 } // namespace dart 7600 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/parser.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698