OLD | NEW |
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 2330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2341 const Class& super_class = Class::Handle(Z, cls.SuperClass()); | 2341 const Class& super_class = Class::Handle(Z, cls.SuperClass()); |
2342 // Omit the implicit super() if there is no super class (i.e. | 2342 // Omit the implicit super() if there is no super class (i.e. |
2343 // we're not compiling class Object), or if the super class is an | 2343 // we're not compiling class Object), or if the super class is an |
2344 // artificially generated "wrapper class" that has no constructor. | 2344 // artificially generated "wrapper class" that has no constructor. |
2345 if (super_class.IsNull() || | 2345 if (super_class.IsNull() || |
2346 (super_class.num_native_fields() > 0 && | 2346 (super_class.num_native_fields() > 0 && |
2347 Class::Handle(Z, super_class.SuperClass()).IsObjectClass())) { | 2347 Class::Handle(Z, super_class.SuperClass()).IsObjectClass())) { |
2348 return; | 2348 return; |
2349 } | 2349 } |
2350 String& super_ctor_name = String::Handle(Z, super_class.Name()); | 2350 String& super_ctor_name = String::Handle(Z, super_class.Name()); |
2351 super_ctor_name = String::Concat(super_ctor_name, Symbols::Dot()); | 2351 super_ctor_name = Symbols::FromConcat(super_ctor_name, Symbols::Dot()); |
2352 | 2352 |
2353 ArgumentListNode* arguments = new ArgumentListNode(supercall_pos); | 2353 ArgumentListNode* arguments = new ArgumentListNode(supercall_pos); |
2354 // Implicit 'this' parameter is the first argument. | 2354 // Implicit 'this' parameter is the first argument. |
2355 AstNode* implicit_argument = new LoadLocalNode(supercall_pos, receiver); | 2355 AstNode* implicit_argument = new LoadLocalNode(supercall_pos, receiver); |
2356 arguments->Add(implicit_argument); | 2356 arguments->Add(implicit_argument); |
2357 // Implicit construction phase parameter is second argument. | 2357 // Implicit construction phase parameter is second argument. |
2358 arguments->Add(phase_parameter); | 2358 arguments->Add(phase_parameter); |
2359 | 2359 |
2360 // If this is a super call in a forwarding constructor, add the user- | 2360 // If this is a super call in a forwarding constructor, add the user- |
2361 // defined arguments to the super call and adjust the the super | 2361 // defined arguments to the super call and adjust the the super |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2402 | 2402 |
2403 AstNode* Parser::ParseSuperInitializer(const Class& cls, | 2403 AstNode* Parser::ParseSuperInitializer(const Class& cls, |
2404 LocalVariable* receiver) { | 2404 LocalVariable* receiver) { |
2405 TRACE_PARSER("ParseSuperInitializer"); | 2405 TRACE_PARSER("ParseSuperInitializer"); |
2406 ASSERT(CurrentToken() == Token::kSUPER); | 2406 ASSERT(CurrentToken() == Token::kSUPER); |
2407 const intptr_t supercall_pos = TokenPos(); | 2407 const intptr_t supercall_pos = TokenPos(); |
2408 ConsumeToken(); | 2408 ConsumeToken(); |
2409 const Class& super_class = Class::Handle(Z, cls.SuperClass()); | 2409 const Class& super_class = Class::Handle(Z, cls.SuperClass()); |
2410 ASSERT(!super_class.IsNull()); | 2410 ASSERT(!super_class.IsNull()); |
2411 String& ctor_name = String::Handle(Z, super_class.Name()); | 2411 String& ctor_name = String::Handle(Z, super_class.Name()); |
2412 ctor_name = String::Concat(ctor_name, Symbols::Dot()); | 2412 ctor_name = Symbols::FromConcat(ctor_name, Symbols::Dot()); |
2413 if (CurrentToken() == Token::kPERIOD) { | 2413 if (CurrentToken() == Token::kPERIOD) { |
2414 ConsumeToken(); | 2414 ConsumeToken(); |
2415 ctor_name = String::Concat(ctor_name, | 2415 ctor_name = Symbols::FromConcat( |
2416 *ExpectIdentifier("constructor name expected")); | 2416 ctor_name, *ExpectIdentifier("constructor name expected")); |
2417 } | 2417 } |
2418 CheckToken(Token::kLPAREN, "parameter list expected"); | 2418 CheckToken(Token::kLPAREN, "parameter list expected"); |
2419 | 2419 |
2420 ArgumentListNode* arguments = new ArgumentListNode(supercall_pos); | 2420 ArgumentListNode* arguments = new ArgumentListNode(supercall_pos); |
2421 // 'this' parameter is the first argument to super class constructor. | 2421 // 'this' parameter is the first argument to super class constructor. |
2422 AstNode* implicit_argument = new LoadLocalNode(supercall_pos, receiver); | 2422 AstNode* implicit_argument = new LoadLocalNode(supercall_pos, receiver); |
2423 arguments->Add(implicit_argument); | 2423 arguments->Add(implicit_argument); |
2424 // Second implicit parameter is the construction phase. We optimistically | 2424 // Second implicit parameter is the construction phase. We optimistically |
2425 // assume that we can execute both the super initializer and the super | 2425 // assume that we can execute both the super initializer and the super |
2426 // constructor body. We may later change this to only execute the | 2426 // constructor body. We may later change this to only execute the |
(...skipping 2776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5203 ExpectIdentifier("name expected"); | 5203 ExpectIdentifier("name expected"); |
5204 } | 5204 } |
5205 SkipTypeArguments(); | 5205 SkipTypeArguments(); |
5206 } | 5206 } |
5207 } | 5207 } |
5208 | 5208 |
5209 | 5209 |
5210 void Parser::ParseTypeParameters(const Class& cls) { | 5210 void Parser::ParseTypeParameters(const Class& cls) { |
5211 TRACE_PARSER("ParseTypeParameters"); | 5211 TRACE_PARSER("ParseTypeParameters"); |
5212 if (CurrentToken() == Token::kLT) { | 5212 if (CurrentToken() == Token::kLT) { |
5213 GrowableArray<AbstractType*> type_parameters_array; | 5213 GrowableArray<AbstractType*> type_parameters_array(Z, 2); |
5214 intptr_t index = 0; | 5214 intptr_t index = 0; |
5215 TypeParameter& type_parameter = TypeParameter::Handle(Z); | 5215 TypeParameter& type_parameter = TypeParameter::Handle(Z); |
5216 TypeParameter& existing_type_parameter = TypeParameter::Handle(Z); | 5216 TypeParameter& existing_type_parameter = TypeParameter::Handle(Z); |
5217 String& existing_type_parameter_name = String::Handle(Z); | 5217 String& existing_type_parameter_name = String::Handle(Z); |
5218 AbstractType& type_parameter_bound = Type::Handle(Z); | 5218 AbstractType& type_parameter_bound = Type::Handle(Z); |
5219 do { | 5219 do { |
5220 ConsumeToken(); | 5220 ConsumeToken(); |
5221 const intptr_t metadata_pos = SkipMetadata(); | 5221 const intptr_t metadata_pos = SkipMetadata(); |
5222 const intptr_t type_parameter_pos = TokenPos(); | 5222 const intptr_t type_parameter_pos = TokenPos(); |
5223 const intptr_t declaration_pos = (metadata_pos > 0) ? metadata_pos | 5223 const intptr_t declaration_pos = (metadata_pos > 0) ? metadata_pos |
(...skipping 8961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14185 void Parser::SkipQualIdent() { | 14185 void Parser::SkipQualIdent() { |
14186 ASSERT(IsIdentifier()); | 14186 ASSERT(IsIdentifier()); |
14187 ConsumeToken(); | 14187 ConsumeToken(); |
14188 if (CurrentToken() == Token::kPERIOD) { | 14188 if (CurrentToken() == Token::kPERIOD) { |
14189 ConsumeToken(); // Consume the kPERIOD token. | 14189 ConsumeToken(); // Consume the kPERIOD token. |
14190 ExpectIdentifier("identifier expected after '.'"); | 14190 ExpectIdentifier("identifier expected after '.'"); |
14191 } | 14191 } |
14192 } | 14192 } |
14193 | 14193 |
14194 } // namespace dart | 14194 } // namespace dart |
OLD | NEW |