| 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 "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 4437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4448 ParseLibraryImportExport(); | 4448 ParseLibraryImportExport(); |
| 4449 metadata_pos = TokenPos(); | 4449 metadata_pos = TokenPos(); |
| 4450 SkipMetadata(); | 4450 SkipMetadata(); |
| 4451 } | 4451 } |
| 4452 // Core lib has not been explicitly imported, so we implicitly | 4452 // Core lib has not been explicitly imported, so we implicitly |
| 4453 // import it here. | 4453 // import it here. |
| 4454 if (!library_.ImportsCorelib()) { | 4454 if (!library_.ImportsCorelib()) { |
| 4455 Library& core_lib = Library::Handle(Library::CoreLibrary()); | 4455 Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| 4456 ASSERT(!core_lib.IsNull()); | 4456 ASSERT(!core_lib.IsNull()); |
| 4457 const Namespace& core_ns = Namespace::Handle( | 4457 const Namespace& core_ns = Namespace::Handle( |
| 4458 Namespace::New(core_lib, Array::null_object(), Array::null_object())); | 4458 Namespace::New(core_lib, Object::null_array(), Object::null_array())); |
| 4459 library_.AddImport(core_ns); | 4459 library_.AddImport(core_ns); |
| 4460 } | 4460 } |
| 4461 while (CurrentToken() == Token::kPART) { | 4461 while (CurrentToken() == Token::kPART) { |
| 4462 ParseLibraryPart(); | 4462 ParseLibraryPart(); |
| 4463 metadata_pos = TokenPos(); | 4463 metadata_pos = TokenPos(); |
| 4464 SkipMetadata(); | 4464 SkipMetadata(); |
| 4465 } | 4465 } |
| 4466 SetPosition(metadata_pos); | 4466 SetPosition(metadata_pos); |
| 4467 } | 4467 } |
| 4468 | 4468 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4503 Class& toplevel_class = Class::Handle( | 4503 Class& toplevel_class = Class::Handle( |
| 4504 Class::New(Symbols::TopLevel(), script_, TokenPos())); | 4504 Class::New(Symbols::TopLevel(), script_, TokenPos())); |
| 4505 toplevel_class.set_library(library_); | 4505 toplevel_class.set_library(library_); |
| 4506 | 4506 |
| 4507 if (is_library_source() || is_patch_source()) { | 4507 if (is_library_source() || is_patch_source()) { |
| 4508 ParseLibraryDefinition(); | 4508 ParseLibraryDefinition(); |
| 4509 } else if (is_part_source()) { | 4509 } else if (is_part_source()) { |
| 4510 ParsePartHeader(); | 4510 ParsePartHeader(); |
| 4511 } | 4511 } |
| 4512 | 4512 |
| 4513 const Class& cls = Class::Handle(isolate); |
| 4513 while (true) { | 4514 while (true) { |
| 4514 set_current_class(Class::null_object()); // No current class. | 4515 set_current_class(cls); // No current class. |
| 4515 SkipMetadata(); | 4516 SkipMetadata(); |
| 4516 if (CurrentToken() == Token::kCLASS) { | 4517 if (CurrentToken() == Token::kCLASS) { |
| 4517 ParseClassDeclaration(pending_classes); | 4518 ParseClassDeclaration(pending_classes); |
| 4518 } else if ((CurrentToken() == Token::kTYPEDEF) && | 4519 } else if ((CurrentToken() == Token::kTYPEDEF) && |
| 4519 (LookaheadToken(1) != Token::kLPAREN)) { | 4520 (LookaheadToken(1) != Token::kLPAREN)) { |
| 4520 set_current_class(toplevel_class); | 4521 set_current_class(toplevel_class); |
| 4521 ParseTypedef(pending_classes); | 4522 ParseTypedef(pending_classes); |
| 4522 } else if ((CurrentToken() == Token::kABSTRACT) && | 4523 } else if ((CurrentToken() == Token::kABSTRACT) && |
| 4523 (LookaheadToken(1) == Token::kCLASS)) { | 4524 (LookaheadToken(1) == Token::kCLASS)) { |
| 4524 ParseClassDeclaration(pending_classes); | 4525 ParseClassDeclaration(pending_classes); |
| (...skipping 3568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8093 ASSERT(func.kind() == RawFunction::kConstImplicitGetter); | 8094 ASSERT(func.kind() == RawFunction::kConstImplicitGetter); |
| 8094 Object& const_value = Object::Handle( | 8095 Object& const_value = Object::Handle( |
| 8095 DartEntry::InvokeFunction(func, Object::empty_array())); | 8096 DartEntry::InvokeFunction(func, Object::empty_array())); |
| 8096 if (const_value.IsError()) { | 8097 if (const_value.IsError()) { |
| 8097 const Error& error = Error::Cast(const_value); | 8098 const Error& error = Error::Cast(const_value); |
| 8098 if (error.IsUnhandledException()) { | 8099 if (error.IsUnhandledException()) { |
| 8099 // An exception may not occur in every parse attempt, i.e., the | 8100 // An exception may not occur in every parse attempt, i.e., the |
| 8100 // generated AST is not deterministic. Therefore mark the function as | 8101 // generated AST is not deterministic. Therefore mark the function as |
| 8101 // not optimizable. | 8102 // not optimizable. |
| 8102 current_function().set_is_optimizable(false); | 8103 current_function().set_is_optimizable(false); |
| 8103 field.set_value(Instance::null_object()); | 8104 field.set_value(Object::null_instance()); |
| 8104 // It is a compile-time error if evaluation of a compile-time constant | 8105 // It is a compile-time error if evaluation of a compile-time constant |
| 8105 // would raise an exception. | 8106 // would raise an exception. |
| 8106 AppendErrorMsg(error, TokenPos(), | 8107 AppendErrorMsg(error, TokenPos(), |
| 8107 "error initializing const field '%s'", | 8108 "error initializing const field '%s'", |
| 8108 String::Handle(field.name()).ToCString()); | 8109 String::Handle(field.name()).ToCString()); |
| 8109 } else { | 8110 } else { |
| 8110 Isolate::Current()->long_jump_base()->Jump(1, error); | 8111 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 8111 } | 8112 } |
| 8112 } | 8113 } |
| 8113 ASSERT(const_value.IsNull() || const_value.IsInstance()); | 8114 ASSERT(const_value.IsNull() || const_value.IsInstance()); |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8677 return Type::DynamicType(); | 8678 return Type::DynamicType(); |
| 8678 } | 8679 } |
| 8679 AbstractType& type = AbstractType::Handle( | 8680 AbstractType& type = AbstractType::Handle( |
| 8680 Type::New(type_class, type_arguments, type_name.ident_pos)); | 8681 Type::New(type_class, type_arguments, type_name.ident_pos)); |
| 8681 // In production mode, malformed type arguments are mapped to dynamic. | 8682 // In production mode, malformed type arguments are mapped to dynamic. |
| 8682 // In checked mode, a type with malformed type arguments is malformed. | 8683 // In checked mode, a type with malformed type arguments is malformed. |
| 8683 if (FLAG_enable_type_checks && !malformed_error.IsNull()) { | 8684 if (FLAG_enable_type_checks && !malformed_error.IsNull()) { |
| 8684 Type& parameterized_type = Type::Handle(); | 8685 Type& parameterized_type = Type::Handle(); |
| 8685 parameterized_type ^= type.raw(); | 8686 parameterized_type ^= type.raw(); |
| 8686 parameterized_type.set_type_class(Class::Handle(Object::dynamic_class())); | 8687 parameterized_type.set_type_class(Class::Handle(Object::dynamic_class())); |
| 8687 parameterized_type.set_arguments( | 8688 parameterized_type.set_arguments(Object::null_abstract_type_arguments()); |
| 8688 AbstractTypeArguments::null_object()); | |
| 8689 parameterized_type.set_malformed_error(malformed_error); | 8689 parameterized_type.set_malformed_error(malformed_error); |
| 8690 } | 8690 } |
| 8691 if (finalization >= ClassFinalizer::kTryResolve) { | 8691 if (finalization >= ClassFinalizer::kTryResolve) { |
| 8692 ResolveTypeFromClass(current_class(), finalization, &type); | 8692 ResolveTypeFromClass(current_class(), finalization, &type); |
| 8693 if (finalization >= ClassFinalizer::kCanonicalize) { | 8693 if (finalization >= ClassFinalizer::kCanonicalize) { |
| 8694 type ^= ClassFinalizer::FinalizeType(current_class(), type, finalization); | 8694 type ^= ClassFinalizer::FinalizeType(current_class(), type, finalization); |
| 8695 } | 8695 } |
| 8696 } | 8696 } |
| 8697 return type.raw(); | 8697 return type.raw(); |
| 8698 } | 8698 } |
| (...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9968 void Parser::SkipQualIdent() { | 9968 void Parser::SkipQualIdent() { |
| 9969 ASSERT(IsIdentifier()); | 9969 ASSERT(IsIdentifier()); |
| 9970 ConsumeToken(); | 9970 ConsumeToken(); |
| 9971 if (CurrentToken() == Token::kPERIOD) { | 9971 if (CurrentToken() == Token::kPERIOD) { |
| 9972 ConsumeToken(); // Consume the kPERIOD token. | 9972 ConsumeToken(); // Consume the kPERIOD token. |
| 9973 ExpectIdentifier("identifier expected after '.'"); | 9973 ExpectIdentifier("identifier expected after '.'"); |
| 9974 } | 9974 } |
| 9975 } | 9975 } |
| 9976 | 9976 |
| 9977 } // namespace dart | 9977 } // namespace dart |
| OLD | NEW |