| 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 #include "vm/flags.h" | 6 #include "vm/flags.h" | 
| 7 | 7 | 
| 8 #ifndef DART_PRECOMPILED_RUNTIME | 8 #ifndef DART_PRECOMPILED_RUNTIME | 
| 9 | 9 | 
| 10 #include "lib/invocation_mirror.h" | 10 #include "lib/invocation_mirror.h" | 
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 618 | 618 | 
| 619 | 619 | 
| 620 RawInteger* Parser::CurrentIntegerLiteral() const { | 620 RawInteger* Parser::CurrentIntegerLiteral() const { | 
| 621   literal_token_ ^= tokens_iterator_.CurrentToken(); | 621   literal_token_ ^= tokens_iterator_.CurrentToken(); | 
| 622   ASSERT(literal_token_.kind() == Token::kINTEGER); | 622   ASSERT(literal_token_.kind() == Token::kINTEGER); | 
| 623   RawInteger* ri = Integer::RawCast(literal_token_.value()); | 623   RawInteger* ri = Integer::RawCast(literal_token_.value()); | 
| 624   return ri; | 624   return ri; | 
| 625 } | 625 } | 
| 626 | 626 | 
| 627 | 627 | 
|  | 628 RawFraction* Parser::CurrentRationalLiteral() const { | 
|  | 629   literal_token_ ^= tokens_iterator_.CurrentToken(); | 
|  | 630   ASSERT(literal_token_.kind() == Token::kRATIONAL); | 
|  | 631   return Fraction::RawCast(literal_token_.value()); | 
|  | 632 } | 
|  | 633 | 
|  | 634 | 
| 628 struct ParamDesc { | 635 struct ParamDesc { | 
| 629   ParamDesc() | 636   ParamDesc() | 
| 630       : type(NULL), | 637       : type(NULL), | 
| 631         name_pos(TokenPosition::kNoSource), | 638         name_pos(TokenPosition::kNoSource), | 
| 632         name(NULL), | 639         name(NULL), | 
| 633         default_value(NULL), | 640         default_value(NULL), | 
| 634         metadata(NULL), | 641         metadata(NULL), | 
| 635         var(NULL), | 642         var(NULL), | 
| 636         is_final(false), | 643         is_final(false), | 
| 637         is_field_initializer(false), | 644         is_field_initializer(false), | 
| (...skipping 3879 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4517     cls ^= obj.raw(); | 4524     cls ^= obj.raw(); | 
| 4518     if (is_patch) { | 4525     if (is_patch) { | 
| 4519       // Preserve and reuse the original type parameters and bounds since the | 4526       // Preserve and reuse the original type parameters and bounds since the | 
| 4520       // ones defined in the patch class will not be finalized. | 4527       // ones defined in the patch class will not be finalized. | 
| 4521       orig_type_parameters = cls.type_parameters(); | 4528       orig_type_parameters = cls.type_parameters(); | 
| 4522       cls = Class::New(library_, class_name, script_, declaration_pos); | 4529       cls = Class::New(library_, class_name, script_, declaration_pos); | 
| 4523     } else { | 4530     } else { | 
| 4524       // Not patching a class, but it has been found. This must be one of the | 4531       // Not patching a class, but it has been found. This must be one of the | 
| 4525       // pre-registered classes from object.cc or a duplicate definition. | 4532       // pre-registered classes from object.cc or a duplicate definition. | 
| 4526       if (!(cls.is_prefinalized() || | 4533       if (!(cls.is_prefinalized() || | 
|  | 4534             cls.is_refinalize_after_patch() ||  // TODO(regis): Remove. | 
| 4527             RawObject::IsImplicitFieldClassId(cls.id()))) { | 4535             RawObject::IsImplicitFieldClassId(cls.id()))) { | 
| 4528         ReportError(classname_pos, "class '%s' is already defined", | 4536         ReportError(classname_pos, "class '%s' is already defined", | 
| 4529                     class_name.ToCString()); | 4537                     class_name.ToCString()); | 
| 4530       } | 4538       } | 
| 4531       // Pre-registered classes need their scripts connected at this time. | 4539       // Pre-registered classes need their scripts connected at this time. | 
| 4532       cls.set_script(script_); | 4540       cls.set_script(script_); | 
| 4533       cls.set_token_pos(declaration_pos); | 4541       cls.set_token_pos(declaration_pos); | 
| 4534     } | 4542     } | 
| 4535   } | 4543   } | 
| 4536   ASSERT(!cls.IsNull()); | 4544   ASSERT(!cls.IsNull()); | 
| (...skipping 3384 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 7921     // 'type' is not a type parameter (an unresolved type will not get resolved | 7929     // 'type' is not a type parameter (an unresolved type will not get resolved | 
| 7922     // to a type parameter later) and if 'type' has no type arguments, then it | 7930     // to a type parameter later) and if 'type' has no type arguments, then it | 
| 7923     // will be instantiated at class finalization time. Otherwise, we return | 7931     // will be instantiated at class finalization time. Otherwise, we return | 
| 7924     // false, since the type test would not be possible at finalization time for | 7932     // false, since the type test would not be possible at finalization time for | 
| 7925     // an uninstantiated type. | 7933     // an uninstantiated type. | 
| 7926     return false; | 7934     return false; | 
| 7927   } | 7935   } | 
| 7928   if (CurrentToken() == Token::kINTEGER) { | 7936   if (CurrentToken() == Token::kINTEGER) { | 
| 7929     *value = CurrentIntegerLiteral(); | 7937     *value = CurrentIntegerLiteral(); | 
| 7930     return true; | 7938     return true; | 
|  | 7939   } else if (CurrentToken() == Token::kRATIONAL) { | 
|  | 7940     *value = CurrentRationalLiteral(); | 
|  | 7941     return true; | 
| 7931   } else if (CurrentToken() == Token::kDOUBLE) { | 7942   } else if (CurrentToken() == Token::kDOUBLE) { | 
| 7932     *value = CurrentDoubleLiteral(); | 7943     *value = CurrentDoubleLiteral(); | 
| 7933     return true; | 7944     return true; | 
| 7934   } else if (CurrentToken() == Token::kSTRING) { | 7945   } else if (CurrentToken() == Token::kSTRING) { | 
| 7935     *value = CurrentLiteral()->raw(); | 7946     *value = CurrentLiteral()->raw(); | 
| 7936     return true; | 7947     return true; | 
| 7937   } else if (CurrentToken() == Token::kTRUE) { | 7948   } else if (CurrentToken() == Token::kTRUE) { | 
| 7938     *value = Bool::True().raw(); | 7949     *value = Bool::True().raw(); | 
| 7939     return true; | 7950     return true; | 
| 7940   } else if (CurrentToken() == Token::kFALSE) { | 7951   } else if (CurrentToken() == Token::kFALSE) { | 
| (...skipping 6135 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 14076     ConsumeToken(); | 14087     ConsumeToken(); | 
| 14077   } else if (token == Token::kNULL) { | 14088   } else if (token == Token::kNULL) { | 
| 14078     primary = new(Z) LiteralNode(TokenPos(), Object::null_instance()); | 14089     primary = new(Z) LiteralNode(TokenPos(), Object::null_instance()); | 
| 14079     ConsumeToken(); | 14090     ConsumeToken(); | 
| 14080   } else if (token == Token::kLPAREN) { | 14091   } else if (token == Token::kLPAREN) { | 
| 14081     ConsumeToken(); | 14092     ConsumeToken(); | 
| 14082     const bool saved_mode = SetAllowFunctionLiterals(true); | 14093     const bool saved_mode = SetAllowFunctionLiterals(true); | 
| 14083     primary = ParseExpr(kAllowConst, kConsumeCascades); | 14094     primary = ParseExpr(kAllowConst, kConsumeCascades); | 
| 14084     SetAllowFunctionLiterals(saved_mode); | 14095     SetAllowFunctionLiterals(saved_mode); | 
| 14085     ExpectToken(Token::kRPAREN); | 14096     ExpectToken(Token::kRPAREN); | 
|  | 14097   } else if (token == Token::kRATIONAL) { | 
|  | 14098     const Fraction& rational_value = | 
|  | 14099         Fraction::ZoneHandle(Z, CurrentRationalLiteral()); | 
|  | 14100     if (rational_value.IsNull()) { | 
|  | 14101       ReportError("invalid rational literal"); | 
|  | 14102     } | 
|  | 14103     primary = new(Z) LiteralNode(TokenPos(), rational_value); | 
|  | 14104     ConsumeToken(); | 
| 14086   } else if (token == Token::kDOUBLE) { | 14105   } else if (token == Token::kDOUBLE) { | 
| 14087     const Double& double_value = Double::ZoneHandle(Z, CurrentDoubleLiteral()); | 14106     const Double& double_value = Double::ZoneHandle(Z, CurrentDoubleLiteral()); | 
| 14088     if (double_value.IsNull()) { | 14107     if (double_value.IsNull()) { | 
| 14089       ReportError("invalid double literal"); | 14108       ReportError("invalid double literal"); | 
| 14090     } | 14109     } | 
| 14091     primary = new(Z) LiteralNode(TokenPos(), double_value); | 14110     primary = new(Z) LiteralNode(TokenPos(), double_value); | 
| 14092     ConsumeToken(); | 14111     ConsumeToken(); | 
| 14093   } else if (token == Token::kSTRING) { | 14112   } else if (token == Token::kSTRING) { | 
| 14094     primary = ParseStringLiteral(true); | 14113     primary = ParseStringLiteral(true); | 
| 14095   } else if (token == Token::kNEW) { | 14114   } else if (token == Token::kNEW) { | 
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 14369     SkipFunctionLiteral(); | 14388     SkipFunctionLiteral(); | 
| 14370     return; | 14389     return; | 
| 14371   } | 14390   } | 
| 14372   switch (CurrentToken()) { | 14391   switch (CurrentToken()) { | 
| 14373     case Token::kTHIS: | 14392     case Token::kTHIS: | 
| 14374     case Token::kSUPER: | 14393     case Token::kSUPER: | 
| 14375     case Token::kNULL: | 14394     case Token::kNULL: | 
| 14376     case Token::kTRUE: | 14395     case Token::kTRUE: | 
| 14377     case Token::kFALSE: | 14396     case Token::kFALSE: | 
| 14378     case Token::kINTEGER: | 14397     case Token::kINTEGER: | 
|  | 14398     case Token::kRATIONAL: | 
| 14379     case Token::kDOUBLE: | 14399     case Token::kDOUBLE: | 
| 14380       ConsumeToken(); | 14400       ConsumeToken(); | 
| 14381       break; | 14401       break; | 
| 14382     case Token::kIDENT: | 14402     case Token::kIDENT: | 
| 14383       ConsumeToken(); | 14403       ConsumeToken(); | 
| 14384       break; | 14404       break; | 
| 14385     case Token::kSTRING: | 14405     case Token::kSTRING: | 
| 14386       SkipStringLiteral(); | 14406       SkipStringLiteral(); | 
| 14387       break; | 14407       break; | 
| 14388     case Token::kLPAREN: | 14408     case Token::kLPAREN: | 
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 14640     const ArgumentListNode& function_args, | 14660     const ArgumentListNode& function_args, | 
| 14641     const LocalVariable* temp_for_last_arg, | 14661     const LocalVariable* temp_for_last_arg, | 
| 14642     bool is_super_invocation) { | 14662     bool is_super_invocation) { | 
| 14643   UNREACHABLE(); | 14663   UNREACHABLE(); | 
| 14644   return NULL; | 14664   return NULL; | 
| 14645 } | 14665 } | 
| 14646 | 14666 | 
| 14647 }  // namespace dart | 14667 }  // namespace dart | 
| 14648 | 14668 | 
| 14649 #endif  // DART_PRECOMPILED_RUNTIME | 14669 #endif  // DART_PRECOMPILED_RUNTIME | 
| OLD | NEW | 
|---|