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/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 cls.set_script(script); | 433 cls.set_script(script); |
434 lib.AddClass(cls); | 434 lib.AddClass(cls); |
435 } | 435 } |
436 | 436 |
437 | 437 |
438 void Object::RegisterPrivateClass(const Class& cls, | 438 void Object::RegisterPrivateClass(const Class& cls, |
439 const char* public_class_name, | 439 const char* public_class_name, |
440 const Script& script, | 440 const Script& script, |
441 const Library& lib) { | 441 const Library& lib) { |
442 String& str = String::Handle(); | 442 String& str = String::Handle(); |
443 str ^= String::NewSymbol(public_class_name); | 443 str = String::NewSymbol(public_class_name); |
444 str ^= lib.PrivateName(str); | 444 str = lib.PrivateName(str); |
445 cls.set_name(str); | 445 cls.set_name(str); |
446 cls.set_script(script); | 446 cls.set_script(script); |
447 lib.AddClass(cls); | 447 lib.AddClass(cls); |
448 } | 448 } |
449 | 449 |
450 | 450 |
451 RawError* Object::Init(Isolate* isolate) { | 451 RawError* Object::Init(Isolate* isolate) { |
452 TIMERSCOPE(time_bootstrap); | 452 TIMERSCOPE(time_bootstrap); |
453 ObjectStore* object_store = isolate->object_store(); | 453 ObjectStore* object_store = isolate->object_store(); |
454 | 454 |
(...skipping 2222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2677 | 2677 |
2678 | 2678 |
2679 bool Type::IsIdentical(const AbstractType& other, | 2679 bool Type::IsIdentical(const AbstractType& other, |
2680 bool check_type_parameter_bounds) const { | 2680 bool check_type_parameter_bounds) const { |
2681 if (raw() == other.raw()) { | 2681 if (raw() == other.raw()) { |
2682 return true; | 2682 return true; |
2683 } | 2683 } |
2684 if (!other.IsType()) { | 2684 if (!other.IsType()) { |
2685 return false; | 2685 return false; |
2686 } | 2686 } |
2687 Type& other_type = Type::Handle(); | |
2688 other_type ^= other.raw(); | |
2689 // Both type classes may not be resolved yet. | 2687 // Both type classes may not be resolved yet. |
2690 String& name = String::Handle(TypeClassName()); | 2688 String& name = String::Handle(TypeClassName()); |
2691 String& other_name = String::Handle(other_type.TypeClassName()); | 2689 String& other_name = String::Handle(Type::Cast(other).TypeClassName()); |
2692 if (!name.Equals(other_name)) { | 2690 if (!name.Equals(other_name)) { |
2693 return false; | 2691 return false; |
2694 } | 2692 } |
2695 return AbstractTypeArguments::AreIdentical( | 2693 return AbstractTypeArguments::AreIdentical( |
2696 AbstractTypeArguments::Handle(arguments()), | 2694 AbstractTypeArguments::Handle(arguments()), |
2697 AbstractTypeArguments::Handle(other.arguments()), | 2695 AbstractTypeArguments::Handle(other.arguments()), |
2698 false); // Bounds are only checked at the top level. | 2696 false); // Bounds are only checked at the top level. |
2699 } | 2697 } |
2700 | 2698 |
2701 | 2699 |
(...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4406 String& str = String::Handle(isolate, String::null()); | 4404 String& str = String::Handle(isolate, String::null()); |
4407 const Array& symbols = Array::Handle(isolate, | 4405 const Array& symbols = Array::Handle(isolate, |
4408 object_store->keyword_symbols()); | 4406 object_store->keyword_symbols()); |
4409 ASSERT(!symbols.IsNull()); | 4407 ASSERT(!symbols.IsNull()); |
4410 str ^= symbols.At(kind - Token::kFirstKeyword); | 4408 str ^= symbols.At(kind - Token::kFirstKeyword); |
4411 ASSERT(!str.IsNull()); | 4409 ASSERT(!str.IsNull()); |
4412 return str.raw(); | 4410 return str.raw(); |
4413 } | 4411 } |
4414 return String::NewSymbol(Token::Str(kind)); | 4412 return String::NewSymbol(Token::Str(kind)); |
4415 } else { | 4413 } else { |
4416 LiteralToken& token = LiteralToken::Handle(); | 4414 // Must be a literal token. |
4417 token ^= obj.raw(); // Must be a literal token. | 4415 return LiteralToken::Cast(obj).literal(); |
4418 return token.literal(); | |
4419 } | 4416 } |
4420 } | 4417 } |
4421 | 4418 |
4422 | 4419 |
4423 RawString* TokenStream::GenerateSource() const { | 4420 RawString* TokenStream::GenerateSource() const { |
4424 GrowableObjectArray& literals = | 4421 GrowableObjectArray& literals = |
4425 GrowableObjectArray::Handle(GrowableObjectArray::New(Length())); | 4422 GrowableObjectArray::Handle(GrowableObjectArray::New(Length())); |
4426 String& literal = String::Handle(); | 4423 String& literal = String::Handle(); |
4427 String& blank = String::Handle(String::New(" ")); | 4424 String& blank = String::Handle(String::New(" ")); |
4428 String& newline = String::Handle(String::New("\n")); | 4425 String& newline = String::Handle(String::New("\n")); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4684 : DictionaryIterator(library) { | 4681 : DictionaryIterator(library) { |
4685 MoveToNextClass(); | 4682 MoveToNextClass(); |
4686 } | 4683 } |
4687 | 4684 |
4688 | 4685 |
4689 RawClass* ClassDictionaryIterator::GetNextClass() { | 4686 RawClass* ClassDictionaryIterator::GetNextClass() { |
4690 ASSERT(HasNext()); | 4687 ASSERT(HasNext()); |
4691 int ix = next_ix_++; | 4688 int ix = next_ix_++; |
4692 Object& obj = Object::Handle(array_.At(ix)); | 4689 Object& obj = Object::Handle(array_.At(ix)); |
4693 MoveToNextClass(); | 4690 MoveToNextClass(); |
4694 Class& cls = Class::Handle(); | 4691 return Class::Cast(obj).raw(); |
4695 cls ^= obj.raw(); | |
4696 return cls.raw(); | |
4697 } | 4692 } |
4698 | 4693 |
4699 | 4694 |
4700 void ClassDictionaryIterator::MoveToNextClass() { | 4695 void ClassDictionaryIterator::MoveToNextClass() { |
4701 Object& obj = Object::Handle(array_.At(next_ix_)); | 4696 Object& obj = Object::Handle(array_.At(next_ix_)); |
4702 while (!obj.IsClass() && HasNext()) { | 4697 while (!obj.IsClass() && HasNext()) { |
4703 next_ix_++; | 4698 next_ix_++; |
4704 obj = array_.At(next_ix_); | 4699 obj = array_.At(next_ix_); |
4705 } | 4700 } |
4706 } | 4701 } |
4707 | 4702 |
4708 | 4703 |
4709 LibraryPrefixIterator::LibraryPrefixIterator(const Library& library) | 4704 LibraryPrefixIterator::LibraryPrefixIterator(const Library& library) |
4710 : DictionaryIterator(library) { | 4705 : DictionaryIterator(library) { |
4711 Advance(); | 4706 Advance(); |
4712 } | 4707 } |
4713 | 4708 |
4714 | 4709 |
4715 RawLibraryPrefix* LibraryPrefixIterator::GetNext() { | 4710 RawLibraryPrefix* LibraryPrefixIterator::GetNext() { |
4716 ASSERT(HasNext()); | 4711 ASSERT(HasNext()); |
4717 int ix = next_ix_++; | 4712 int ix = next_ix_++; |
4718 Object& obj = Object::Handle(array_.At(ix)); | 4713 Object& obj = Object::Handle(array_.At(ix)); |
4719 Advance(); | 4714 Advance(); |
4720 LibraryPrefix& prefix = LibraryPrefix::Handle(); | 4715 return LibraryPrefix::Cast(obj).raw(); |
4721 prefix ^= obj.raw(); | |
4722 return prefix.raw(); | |
4723 } | 4716 } |
4724 | 4717 |
4725 | 4718 |
4726 void LibraryPrefixIterator::Advance() { | 4719 void LibraryPrefixIterator::Advance() { |
4727 Object& obj = Object::Handle(array_.At(next_ix_)); | 4720 Object& obj = Object::Handle(array_.At(next_ix_)); |
4728 while (!obj.IsLibraryPrefix() && HasNext()) { | 4721 while (!obj.IsLibraryPrefix() && HasNext()) { |
4729 next_ix_++; | 4722 next_ix_++; |
4730 obj = array_.At(next_ix_); | 4723 obj = array_.At(next_ix_); |
4731 } | 4724 } |
4732 } | 4725 } |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5112 if (!function.IsNull()) { | 5105 if (!function.IsNull()) { |
5113 return function.raw(); | 5106 return function.raw(); |
5114 } | 5107 } |
5115 } | 5108 } |
5116 return Function::null(); | 5109 return Function::null(); |
5117 } | 5110 } |
5118 | 5111 |
5119 | 5112 |
5120 RawFunction* Library::LookupLocalFunction(const String& name) const { | 5113 RawFunction* Library::LookupLocalFunction(const String& name) const { |
5121 Isolate* isolate = Isolate::Current(); | 5114 Isolate* isolate = Isolate::Current(); |
5122 Function& function = Function::Handle(isolate, Function::null()); | |
5123 Object& obj = Object::Handle(isolate, Object::null()); | 5115 Object& obj = Object::Handle(isolate, Object::null()); |
5124 obj = LookupLocalObject(name); | 5116 obj = LookupLocalObject(name); |
5125 if (obj.IsNull() && ShouldBePrivate(name)) { | 5117 if (obj.IsNull() && ShouldBePrivate(name)) { |
5126 String& private_name = String::Handle(isolate, PrivateName(name)); | 5118 String& private_name = String::Handle(isolate, PrivateName(name)); |
5127 obj = LookupLocalObject(private_name); | 5119 obj = LookupLocalObject(private_name); |
5128 } | 5120 } |
5129 if (!obj.IsNull()) { | 5121 if (obj.IsFunction()) { |
5130 if (obj.IsFunction()) { | 5122 return Function::Cast(obj).raw(); |
5131 function ^= obj.raw(); | |
5132 return function.raw(); | |
5133 } | |
5134 } | 5123 } |
5135 | 5124 |
5136 // No function found. | 5125 // No function found. |
5137 return Function::null(); | 5126 return Function::null(); |
5138 } | 5127 } |
5139 | 5128 |
5140 | 5129 |
5141 RawObject* Library::LookupObjectFiltered(const String& name, | 5130 RawObject* Library::LookupObjectFiltered(const String& name, |
5142 const Library& filter_lib) const { | 5131 const Library& filter_lib) const { |
5143 // First check if name is found in the local scope of the library. | 5132 // First check if name is found in the local scope of the library. |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5290 return Class::CheckedHandle(obj.raw()).raw(); | 5279 return Class::CheckedHandle(obj.raw()).raw(); |
5291 } | 5280 } |
5292 return Class::null(); | 5281 return Class::null(); |
5293 } | 5282 } |
5294 | 5283 |
5295 | 5284 |
5296 RawClass* Library::LookupClassAllowPrivate(const String& name) const { | 5285 RawClass* Library::LookupClassAllowPrivate(const String& name) const { |
5297 // See if the class is available in this library or in the top level | 5286 // See if the class is available in this library or in the top level |
5298 // scope of any imported library. | 5287 // scope of any imported library. |
5299 Isolate* isolate = Isolate::Current(); | 5288 Isolate* isolate = Isolate::Current(); |
5300 Class& cls = Class::Handle(isolate); | 5289 const Class& cls = Class::Handle(isolate, LookupClass(name)); |
5301 cls = LookupClass(name); | |
5302 if (!cls.IsNull()) { | 5290 if (!cls.IsNull()) { |
5303 return cls.raw(); | 5291 return cls.raw(); |
5304 } | 5292 } |
5305 | 5293 |
5306 // Now try to lookup the class using its private name, but only in | 5294 // Now try to lookup the class using its private name, but only in |
5307 // this library (not in imported libraries). | 5295 // this library (not in imported libraries). |
5308 if (ShouldBePrivate(name)) { | 5296 if (ShouldBePrivate(name)) { |
5309 String& private_name = String::Handle(isolate, PrivateName(name)); | 5297 String& private_name = String::Handle(isolate, PrivateName(name)); |
5310 const Object& obj = Object::Handle(LookupLocalObject(private_name)); | 5298 const Object& obj = Object::Handle(LookupLocalObject(private_name)); |
5311 if (!obj.IsNull()) { | 5299 if (obj.IsClass()) { |
5312 if (obj.IsClass()) { | 5300 return Class::Cast(obj).raw(); |
5313 cls ^= obj.raw(); | |
5314 return cls.raw(); | |
5315 } | |
5316 } | 5301 } |
5317 } | 5302 } |
5318 | 5303 |
5319 return Class::null(); | 5304 return Class::null(); |
5320 } | 5305 } |
5321 | 5306 |
5322 | 5307 |
5323 RawLibraryPrefix* Library::LookupLocalLibraryPrefix(const String& name) const { | 5308 RawLibraryPrefix* Library::LookupLocalLibraryPrefix(const String& name) const { |
5324 Object& obj = Object::Handle(LookupLocalObject(name)); | 5309 const Object& obj = Object::Handle(LookupLocalObject(name)); |
5325 if (!obj.IsNull() && obj.IsLibraryPrefix()) { | 5310 if (obj.IsLibraryPrefix()) { |
5326 return LibraryPrefix::CheckedHandle(obj.raw()).raw(); | 5311 return LibraryPrefix::Cast(obj).raw(); |
5327 } | 5312 } |
5328 return LibraryPrefix::null(); | 5313 return LibraryPrefix::null(); |
5329 } | 5314 } |
5330 | 5315 |
5331 | 5316 |
5332 void Library::AddAnonymousClass(const Class& cls) const { | 5317 void Library::AddAnonymousClass(const Class& cls) const { |
5333 intptr_t num_anonymous = this->raw_ptr()->num_anonymous_; | 5318 intptr_t num_anonymous = this->raw_ptr()->num_anonymous_; |
5334 Array& anon_array = Array::Handle(this->raw_ptr()->anonymous_classes_); | 5319 Array& anon_array = Array::Handle(this->raw_ptr()->anonymous_classes_); |
5335 if (num_anonymous == anon_array.Length()) { | 5320 if (num_anonymous == anon_array.Length()) { |
5336 intptr_t new_len = (num_anonymous == 0) ? 4 : num_anonymous * 2; | 5321 intptr_t new_len = (num_anonymous == 0) ? 4 : num_anonymous * 2; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5370 return lib.raw(); | 5355 return lib.raw(); |
5371 } | 5356 } |
5372 | 5357 |
5373 | 5358 |
5374 RawLibraryPrefix* Library::ImportPrefixAt(intptr_t index) const { | 5359 RawLibraryPrefix* Library::ImportPrefixAt(intptr_t index) const { |
5375 const Library& imported = Library::Handle(ImportAt(index)); | 5360 const Library& imported = Library::Handle(ImportAt(index)); |
5376 if (imported.IsNull()) { | 5361 if (imported.IsNull()) { |
5377 return LibraryPrefix::null(); | 5362 return LibraryPrefix::null(); |
5378 } | 5363 } |
5379 DictionaryIterator it(*this); | 5364 DictionaryIterator it(*this); |
5380 LibraryPrefix& lib_prefix = LibraryPrefix::Handle(); | |
5381 Object& obj = Object::Handle(); | 5365 Object& obj = Object::Handle(); |
5382 while (it.HasNext()) { | 5366 while (it.HasNext()) { |
5383 obj = it.GetNext(); | 5367 obj = it.GetNext(); |
5384 if (obj.IsLibraryPrefix()) { | 5368 if (obj.IsLibraryPrefix()) { |
5385 lib_prefix ^= obj.raw(); | 5369 const LibraryPrefix& lib_prefix = LibraryPrefix::Cast(obj); |
5386 if (lib_prefix.ContainsLibrary(imported)) { | 5370 if (lib_prefix.ContainsLibrary(imported)) { |
5387 return lib_prefix.raw(); | 5371 return lib_prefix.raw(); |
5388 } | 5372 } |
5389 } | 5373 } |
5390 } | 5374 } |
5391 return LibraryPrefix::null(); | 5375 return LibraryPrefix::null(); |
5392 } | 5376 } |
5393 | 5377 |
5394 | 5378 |
5395 void Library::AddImport(const Library& library) const { | 5379 void Library::AddImport(const Library& library) const { |
(...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7384 int Integer::CompareWith(const Integer& other) const { | 7368 int Integer::CompareWith(const Integer& other) const { |
7385 UNIMPLEMENTED(); | 7369 UNIMPLEMENTED(); |
7386 return 0; | 7370 return 0; |
7387 } | 7371 } |
7388 | 7372 |
7389 | 7373 |
7390 bool Smi::Equals(const Instance& other) const { | 7374 bool Smi::Equals(const Instance& other) const { |
7391 if (other.IsNull() || !other.IsSmi()) { | 7375 if (other.IsNull() || !other.IsSmi()) { |
7392 return false; | 7376 return false; |
7393 } | 7377 } |
7394 | 7378 return (this->Value() == Smi::Cast(other).Value()); |
7395 Smi& other_smi = Smi::Handle(); | |
7396 other_smi ^= other.raw(); | |
7397 return (this->Value() == other_smi.Value()); | |
7398 } | 7379 } |
7399 | 7380 |
7400 | 7381 |
7401 double Smi::AsDoubleValue() const { | 7382 double Smi::AsDoubleValue() const { |
7402 return static_cast<double>(this->Value()); | 7383 return static_cast<double>(this->Value()); |
7403 } | 7384 } |
7404 | 7385 |
7405 | 7386 |
7406 int64_t Smi::AsInt64Value() const { | 7387 int64_t Smi::AsInt64Value() const { |
7407 return this->Value(); | 7388 return this->Value(); |
7408 } | 7389 } |
7409 | 7390 |
7410 | 7391 |
7411 static bool FitsIntoSmi(const Integer& integer) { | 7392 static bool FitsIntoSmi(const Integer& integer) { |
7412 if (integer.IsSmi()) { | 7393 if (integer.IsSmi()) { |
7413 return true; | 7394 return true; |
7414 } | 7395 } |
7415 if (integer.IsMint()) { | 7396 if (integer.IsMint()) { |
7416 int64_t mint_value = integer.AsInt64Value(); | 7397 int64_t mint_value = integer.AsInt64Value(); |
7417 return Smi::IsValid64(mint_value); | 7398 return Smi::IsValid64(mint_value); |
7418 } | 7399 } |
7419 if (integer.IsBigint()) { | 7400 if (integer.IsBigint()) { |
7420 Bigint& big = Bigint::Handle(); | 7401 return BigintOperations::FitsIntoSmi(Bigint::Cast(integer)); |
7421 big ^= integer.raw(); | |
7422 return BigintOperations::FitsIntoSmi(big); | |
7423 } | 7402 } |
7424 UNREACHABLE(); | 7403 UNREACHABLE(); |
7425 return false; | 7404 return false; |
7426 } | 7405 } |
7427 | 7406 |
7428 | 7407 |
7429 int Smi::CompareWith(const Integer& other) const { | 7408 int Smi::CompareWith(const Integer& other) const { |
7430 if (other.IsSmi()) { | 7409 if (other.IsSmi()) { |
7431 Smi& smi = Smi::Handle(); | 7410 const Smi& other_smi = Smi::Cast(other); |
7432 smi ^= other.raw(); | 7411 if (this->Value() < other_smi.Value()) { |
7433 if (this->Value() < smi.Value()) { | |
7434 return -1; | 7412 return -1; |
7435 } else if (this->Value() > smi.Value()) { | 7413 } else if (this->Value() > other_smi.Value()) { |
7436 return 1; | 7414 return 1; |
7437 } else { | 7415 } else { |
7438 return 0; | 7416 return 0; |
7439 } | 7417 } |
7440 } | 7418 } |
7441 ASSERT(!FitsIntoSmi(other)); | 7419 ASSERT(!FitsIntoSmi(other)); |
7442 if (other.IsMint() || other.IsBigint()) { | 7420 if (other.IsMint() || other.IsBigint()) { |
7443 if (this->IsNegative() == other.IsNegative()) { | 7421 if (this->IsNegative() == other.IsNegative()) { |
7444 return this->IsNegative() ? 1 : -1; | 7422 return this->IsNegative() ? 1 : -1; |
7445 } | 7423 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7516 canonical_value.SetCanonical(); | 7494 canonical_value.SetCanonical(); |
7517 return canonical_value.raw(); | 7495 return canonical_value.raw(); |
7518 } | 7496 } |
7519 | 7497 |
7520 | 7498 |
7521 bool Mint::Equals(const Instance& other) const { | 7499 bool Mint::Equals(const Instance& other) const { |
7522 if (this->raw() == other.raw()) { | 7500 if (this->raw() == other.raw()) { |
7523 // Both handles point to the same raw instance. | 7501 // Both handles point to the same raw instance. |
7524 return true; | 7502 return true; |
7525 } | 7503 } |
7526 | |
7527 if (!other.IsMint() || other.IsNull()) { | 7504 if (!other.IsMint() || other.IsNull()) { |
7528 return false; | 7505 return false; |
7529 } | 7506 } |
7530 | 7507 return value() == Mint::Cast(other).value(); |
7531 Mint& other_mint = Mint::Handle(); | |
7532 other_mint ^= other.raw(); | |
7533 | |
7534 return value() == other_mint.value(); | |
7535 } | 7508 } |
7536 | 7509 |
7537 | 7510 |
7538 double Mint::AsDoubleValue() const { | 7511 double Mint::AsDoubleValue() const { |
7539 return static_cast<double>(this->value()); | 7512 return static_cast<double>(this->value()); |
7540 } | 7513 } |
7541 | 7514 |
7542 | 7515 |
7543 int64_t Mint::AsInt64Value() const { | 7516 int64_t Mint::AsInt64Value() const { |
7544 return this->value(); | 7517 return this->value(); |
7545 } | 7518 } |
7546 | 7519 |
7547 | 7520 |
7548 int Mint::CompareWith(const Integer& other) const { | 7521 int Mint::CompareWith(const Integer& other) const { |
7549 ASSERT(!FitsIntoSmi(*this)); | 7522 ASSERT(!FitsIntoSmi(*this)); |
7550 if (other.IsMint() || other.IsSmi()) { | 7523 if (other.IsMint() || other.IsSmi()) { |
7551 int64_t a = AsInt64Value(); | 7524 int64_t a = AsInt64Value(); |
7552 int64_t b = other.AsInt64Value(); | 7525 int64_t b = other.AsInt64Value(); |
7553 if (a < b) { | 7526 if (a < b) { |
7554 return -1; | 7527 return -1; |
7555 } else if (a > b) { | 7528 } else if (a > b) { |
7556 return 1; | 7529 return 1; |
7557 } else { | 7530 } else { |
7558 return 0; | 7531 return 0; |
7559 } | 7532 } |
7560 } | 7533 } |
7561 if (other.IsBigint()) { | 7534 if (other.IsBigint()) { |
7562 Bigint& bigi = Bigint::Handle(); | 7535 ASSERT(!BigintOperations::FitsIntoMint(Bigint::Cast(other))); |
7563 bigi ^= other.raw(); | |
7564 ASSERT(!BigintOperations::FitsIntoMint(bigi)); | |
7565 if (this->IsNegative() == other.IsNegative()) { | 7536 if (this->IsNegative() == other.IsNegative()) { |
7566 return this->IsNegative() ? 1 : -1; | 7537 return this->IsNegative() ? 1 : -1; |
7567 } | 7538 } |
7568 return this->IsNegative() ? -1 : 1; | 7539 return this->IsNegative() ? -1 : 1; |
7569 } | 7540 } |
7570 UNREACHABLE(); | 7541 UNREACHABLE(); |
7571 return 0; | 7542 return 0; |
7572 } | 7543 } |
7573 | 7544 |
7574 | 7545 |
(...skipping 22 matching lines...) Expand all Loading... |
7597 } | 7568 } |
7598 | 7569 |
7599 | 7570 |
7600 bool Double::Equals(const Instance& other) const { | 7571 bool Double::Equals(const Instance& other) const { |
7601 if (this->raw() == other.raw()) { | 7572 if (this->raw() == other.raw()) { |
7602 return true; // "===". | 7573 return true; // "===". |
7603 } | 7574 } |
7604 if (other.IsNull() || !other.IsDouble()) { | 7575 if (other.IsNull() || !other.IsDouble()) { |
7605 return false; | 7576 return false; |
7606 } | 7577 } |
7607 Double& other_dbl = Double::Handle(); | 7578 return EqualsToDouble(Double::Cast(other).value()); |
7608 other_dbl ^= other.raw(); | |
7609 return EqualsToDouble(other_dbl.value()); | |
7610 } | 7579 } |
7611 | 7580 |
7612 | 7581 |
7613 RawDouble* Double::New(double d, Heap::Space space) { | 7582 RawDouble* Double::New(double d, Heap::Space space) { |
7614 Isolate* isolate = Isolate::Current(); | 7583 Isolate* isolate = Isolate::Current(); |
7615 const Class& cls = | 7584 const Class& cls = |
7616 Class::Handle(isolate->object_store()->double_class()); | 7585 Class::Handle(isolate->object_store()->double_class()); |
7617 Double& result = Double::Handle(); | 7586 Double& result = Double::Handle(); |
7618 { | 7587 { |
7619 RawObject* raw = Object::Allocate(cls, Double::InstanceSize(), space); | 7588 RawObject* raw = Object::Allocate(cls, Double::InstanceSize(), space); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7710 bool Bigint::Equals(const Instance& other) const { | 7679 bool Bigint::Equals(const Instance& other) const { |
7711 if (this->raw() == other.raw()) { | 7680 if (this->raw() == other.raw()) { |
7712 // Both handles point to the same raw instance. | 7681 // Both handles point to the same raw instance. |
7713 return true; | 7682 return true; |
7714 } | 7683 } |
7715 | 7684 |
7716 if (!other.IsBigint() || other.IsNull()) { | 7685 if (!other.IsBigint() || other.IsNull()) { |
7717 return false; | 7686 return false; |
7718 } | 7687 } |
7719 | 7688 |
7720 Bigint& other_bgi = Bigint::Handle(); | 7689 const Bigint& other_bgi = Bigint::Cast(other); |
7721 other_bgi ^= other.raw(); | |
7722 | 7690 |
7723 intptr_t len = this->Length(); | 7691 intptr_t len = this->Length(); |
7724 if (len != other_bgi.Length()) { | 7692 if (len != other_bgi.Length()) { |
7725 return false; | 7693 return false; |
7726 } | 7694 } |
7727 | 7695 |
7728 for (intptr_t i = 0; i < len; i++) { | 7696 for (intptr_t i = 0; i < len; i++) { |
7729 if (this->GetChunkAt(i) != other_bgi.GetChunkAt(i)) { | 7697 if (this->GetChunkAt(i) != other_bgi.GetChunkAt(i)) { |
7730 return false; | 7698 return false; |
7731 } | 7699 } |
(...skipping 23 matching lines...) Expand all Loading... |
7755 } | 7723 } |
7756 return BigintOperations::ToMint(*this); | 7724 return BigintOperations::ToMint(*this); |
7757 } | 7725 } |
7758 | 7726 |
7759 | 7727 |
7760 // For positive values: Smi < Mint < Bigint. | 7728 // For positive values: Smi < Mint < Bigint. |
7761 int Bigint::CompareWith(const Integer& other) const { | 7729 int Bigint::CompareWith(const Integer& other) const { |
7762 ASSERT(!FitsIntoSmi(*this)); | 7730 ASSERT(!FitsIntoSmi(*this)); |
7763 ASSERT(!BigintOperations::FitsIntoMint(*this)); | 7731 ASSERT(!BigintOperations::FitsIntoMint(*this)); |
7764 if (other.IsBigint()) { | 7732 if (other.IsBigint()) { |
7765 Bigint& big = Bigint::Handle(); | 7733 return BigintOperations::Compare(*this, Bigint::Cast(other)); |
7766 big ^= other.raw(); | |
7767 return BigintOperations::Compare(*this, big); | |
7768 } | 7734 } |
7769 if (this->IsNegative() == other.IsNegative()) { | 7735 if (this->IsNegative() == other.IsNegative()) { |
7770 return this->IsNegative() ? -1 : 1; | 7736 return this->IsNegative() ? -1 : 1; |
7771 } | 7737 } |
7772 return this->IsNegative() ? -1 : 1; | 7738 return this->IsNegative() ? -1 : 1; |
7773 } | 7739 } |
7774 | 7740 |
7775 | 7741 |
7776 RawBigint* Bigint::Allocate(intptr_t length, Heap::Space space) { | 7742 RawBigint* Bigint::Allocate(intptr_t length, Heap::Space space) { |
7777 ASSERT(length >= 0); | 7743 ASSERT(length >= 0); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7889 bool String::Equals(const Instance& other) const { | 7855 bool String::Equals(const Instance& other) const { |
7890 if (this->raw() == other.raw()) { | 7856 if (this->raw() == other.raw()) { |
7891 // Both handles point to the same raw instance. | 7857 // Both handles point to the same raw instance. |
7892 return true; | 7858 return true; |
7893 } | 7859 } |
7894 | 7860 |
7895 if (!other.IsString() || other.IsNull()) { | 7861 if (!other.IsString() || other.IsNull()) { |
7896 return false; | 7862 return false; |
7897 } | 7863 } |
7898 | 7864 |
7899 String& other_string = String::Handle(); | 7865 const String& other_string = String::Cast(other); |
7900 other_string ^= other.raw(); | |
7901 if (this->HasHash() && other_string.HasHash() && | 7866 if (this->HasHash() && other_string.HasHash() && |
7902 (this->Hash() != other_string.Hash())) { | 7867 (this->Hash() != other_string.Hash())) { |
7903 // Both sides have a hash code and it does not match. | 7868 // Both sides have a hash code and it does not match. |
7904 return false; | 7869 return false; |
7905 } | 7870 } |
7906 | 7871 |
7907 intptr_t len = this->Length(); | 7872 intptr_t len = this->Length(); |
7908 if (len != other_string.Length()) { | 7873 if (len != other_string.Length()) { |
7909 // Lengths don't match. | 7874 // Lengths don't match. |
7910 return false; | 7875 return false; |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8166 } | 8131 } |
8167 | 8132 |
8168 | 8133 |
8169 void String::Copy(const String& dst, intptr_t dst_offset, | 8134 void String::Copy(const String& dst, intptr_t dst_offset, |
8170 const uint8_t* characters, | 8135 const uint8_t* characters, |
8171 intptr_t len) { | 8136 intptr_t len) { |
8172 ASSERT(dst_offset >= 0); | 8137 ASSERT(dst_offset >= 0); |
8173 ASSERT(len >= 0); | 8138 ASSERT(len >= 0); |
8174 ASSERT(len <= (dst.Length() - dst_offset)); | 8139 ASSERT(len <= (dst.Length() - dst_offset)); |
8175 if (dst.IsOneByteString()) { | 8140 if (dst.IsOneByteString()) { |
8176 OneByteString& onestr = OneByteString::Handle(); | 8141 const OneByteString& onestr = OneByteString::Cast(dst); |
8177 onestr ^= dst.raw(); | |
8178 NoGCScope no_gc; | 8142 NoGCScope no_gc; |
8179 if (len > 0) { | 8143 if (len > 0) { |
8180 memmove(onestr.CharAddr(dst_offset), characters, len); | 8144 memmove(onestr.CharAddr(dst_offset), characters, len); |
8181 } | 8145 } |
8182 } else if (dst.IsTwoByteString()) { | 8146 } else if (dst.IsTwoByteString()) { |
8183 TwoByteString& twostr = TwoByteString::Handle(); | 8147 const TwoByteString& twostr = TwoByteString::Cast(dst); |
8184 twostr ^= dst.raw(); | |
8185 NoGCScope no_gc; | 8148 NoGCScope no_gc; |
8186 for (intptr_t i = 0; i < len; ++i) { | 8149 for (intptr_t i = 0; i < len; ++i) { |
8187 *twostr.CharAddr(i + dst_offset) = characters[i]; | 8150 *twostr.CharAddr(i + dst_offset) = characters[i]; |
8188 } | 8151 } |
8189 } else { | 8152 } else { |
8190 ASSERT(dst.IsFourByteString()); | 8153 ASSERT(dst.IsFourByteString()); |
8191 FourByteString& fourstr = FourByteString::Handle(); | 8154 const FourByteString& fourstr = FourByteString::Cast(dst); |
8192 fourstr ^= dst.raw(); | |
8193 NoGCScope no_gc; | 8155 NoGCScope no_gc; |
8194 for (intptr_t i = 0; i < len; ++i) { | 8156 for (intptr_t i = 0; i < len; ++i) { |
8195 *fourstr.CharAddr(i + dst_offset) = characters[i]; | 8157 *fourstr.CharAddr(i + dst_offset) = characters[i]; |
8196 } | 8158 } |
8197 } | 8159 } |
8198 } | 8160 } |
8199 | 8161 |
8200 | 8162 |
8201 void String::Copy(const String& dst, intptr_t dst_offset, | 8163 void String::Copy(const String& dst, intptr_t dst_offset, |
8202 const uint16_t* characters, | 8164 const uint16_t* characters, |
8203 intptr_t len) { | 8165 intptr_t len) { |
8204 ASSERT(dst_offset >= 0); | 8166 ASSERT(dst_offset >= 0); |
8205 ASSERT(len >= 0); | 8167 ASSERT(len >= 0); |
8206 ASSERT(len <= (dst.Length() - dst_offset)); | 8168 ASSERT(len <= (dst.Length() - dst_offset)); |
8207 if (dst.IsOneByteString()) { | 8169 if (dst.IsOneByteString()) { |
8208 OneByteString& onestr = OneByteString::Handle(); | 8170 const OneByteString& onestr = OneByteString::Cast(dst); |
8209 onestr ^= dst.raw(); | |
8210 NoGCScope no_gc; | 8171 NoGCScope no_gc; |
8211 for (intptr_t i = 0; i < len; ++i) { | 8172 for (intptr_t i = 0; i < len; ++i) { |
8212 ASSERT(characters[i] <= 0xFF); | 8173 ASSERT(characters[i] <= 0xFF); |
8213 *onestr.CharAddr(i + dst_offset) = characters[i]; | 8174 *onestr.CharAddr(i + dst_offset) = characters[i]; |
8214 } | 8175 } |
8215 } else if (dst.IsTwoByteString()) { | 8176 } else if (dst.IsTwoByteString()) { |
8216 TwoByteString& twostr = TwoByteString::Handle(); | 8177 const TwoByteString& twostr = TwoByteString::Cast(dst); |
8217 twostr ^= dst.raw(); | |
8218 NoGCScope no_gc; | 8178 NoGCScope no_gc; |
8219 if (len > 0) { | 8179 if (len > 0) { |
8220 memmove(twostr.CharAddr(dst_offset), characters, len * 2); | 8180 memmove(twostr.CharAddr(dst_offset), characters, len * 2); |
8221 } | 8181 } |
8222 } else { | 8182 } else { |
8223 ASSERT(dst.IsFourByteString()); | 8183 ASSERT(dst.IsFourByteString()); |
8224 FourByteString& fourstr = FourByteString::Handle(); | 8184 const FourByteString& fourstr = FourByteString::Cast(dst); |
8225 fourstr ^= dst.raw(); | |
8226 NoGCScope no_gc; | 8185 NoGCScope no_gc; |
8227 for (intptr_t i = 0; i < len; ++i) { | 8186 for (intptr_t i = 0; i < len; ++i) { |
8228 *fourstr.CharAddr(i + dst_offset) = characters[i]; | 8187 *fourstr.CharAddr(i + dst_offset) = characters[i]; |
8229 } | 8188 } |
8230 } | 8189 } |
8231 } | 8190 } |
8232 | 8191 |
8233 | 8192 |
8234 void String::Copy(const String& dst, intptr_t dst_offset, | 8193 void String::Copy(const String& dst, intptr_t dst_offset, |
8235 const uint32_t* characters, | 8194 const uint32_t* characters, |
8236 intptr_t len) { | 8195 intptr_t len) { |
8237 ASSERT(dst_offset >= 0); | 8196 ASSERT(dst_offset >= 0); |
8238 ASSERT(len >= 0); | 8197 ASSERT(len >= 0); |
8239 ASSERT(len <= (dst.Length() - dst_offset)); | 8198 ASSERT(len <= (dst.Length() - dst_offset)); |
8240 if (dst.IsOneByteString()) { | 8199 if (dst.IsOneByteString()) { |
8241 OneByteString& onestr = OneByteString::Handle(); | 8200 const OneByteString& onestr = OneByteString::Cast(dst); |
8242 onestr ^= dst.raw(); | |
8243 NoGCScope no_gc; | 8201 NoGCScope no_gc; |
8244 for (intptr_t i = 0; i < len; ++i) { | 8202 for (intptr_t i = 0; i < len; ++i) { |
8245 ASSERT(characters[i] <= 0xFF); | 8203 ASSERT(characters[i] <= 0xFF); |
8246 *onestr.CharAddr(i + dst_offset) = characters[i]; | 8204 *onestr.CharAddr(i + dst_offset) = characters[i]; |
8247 } | 8205 } |
8248 } else if (dst.IsTwoByteString()) { | 8206 } else if (dst.IsTwoByteString()) { |
8249 TwoByteString& twostr = TwoByteString::Handle(); | 8207 const TwoByteString& twostr = TwoByteString::Cast(dst); |
8250 twostr ^= dst.raw(); | |
8251 NoGCScope no_gc; | 8208 NoGCScope no_gc; |
8252 for (intptr_t i = 0; i < len; ++i) { | 8209 for (intptr_t i = 0; i < len; ++i) { |
8253 ASSERT(characters[i] <= 0xFFFF); | 8210 ASSERT(characters[i] <= 0xFFFF); |
8254 *twostr.CharAddr(i + dst_offset) = characters[i]; | 8211 *twostr.CharAddr(i + dst_offset) = characters[i]; |
8255 } | 8212 } |
8256 } else { | 8213 } else { |
8257 ASSERT(dst.IsFourByteString()); | 8214 ASSERT(dst.IsFourByteString()); |
8258 FourByteString& fourstr = FourByteString::Handle(); | 8215 const FourByteString& fourstr = FourByteString::Cast(dst); |
8259 fourstr ^= dst.raw(); | |
8260 NoGCScope no_gc; | 8216 NoGCScope no_gc; |
8261 if (len > 0) { | 8217 if (len > 0) { |
8262 memmove(fourstr.CharAddr(dst_offset), characters, len * 4); | 8218 memmove(fourstr.CharAddr(dst_offset), characters, len * 4); |
8263 } | 8219 } |
8264 } | 8220 } |
8265 } | 8221 } |
8266 | 8222 |
8267 | 8223 |
8268 void String::Copy(const String& dst, intptr_t dst_offset, | 8224 void String::Copy(const String& dst, intptr_t dst_offset, |
8269 const String& src, intptr_t src_offset, | 8225 const String& src, intptr_t src_offset, |
8270 intptr_t len) { | 8226 intptr_t len) { |
8271 ASSERT(dst_offset >= 0); | 8227 ASSERT(dst_offset >= 0); |
8272 ASSERT(src_offset >= 0); | 8228 ASSERT(src_offset >= 0); |
8273 ASSERT(len >= 0); | 8229 ASSERT(len >= 0); |
8274 ASSERT(len <= (dst.Length() - dst_offset)); | 8230 ASSERT(len <= (dst.Length() - dst_offset)); |
8275 ASSERT(len <= (src.Length() - src_offset)); | 8231 ASSERT(len <= (src.Length() - src_offset)); |
8276 if (len > 0) { | 8232 if (len > 0) { |
8277 intptr_t char_size = src.CharSize(); | 8233 intptr_t char_size = src.CharSize(); |
8278 if (char_size == kOneByteChar) { | 8234 if (char_size == kOneByteChar) { |
8279 if (src.IsOneByteString()) { | 8235 if (src.IsOneByteString()) { |
8280 OneByteString& onestr = OneByteString::Handle(); | 8236 const OneByteString& onestr = OneByteString::Cast(src); |
8281 onestr ^= src.raw(); | |
8282 NoGCScope no_gc; | 8237 NoGCScope no_gc; |
8283 String::Copy(dst, dst_offset, onestr.CharAddr(0) + src_offset, len); | 8238 String::Copy(dst, dst_offset, onestr.CharAddr(0) + src_offset, len); |
8284 } else { | 8239 } else { |
8285 ASSERT(src.IsExternalOneByteString()); | 8240 ASSERT(src.IsExternalOneByteString()); |
8286 ExternalOneByteString& onestr = ExternalOneByteString::Handle(); | 8241 const ExternalOneByteString& onestr = ExternalOneByteString::Cast(src); |
8287 onestr ^= src.raw(); | |
8288 NoGCScope no_gc; | 8242 NoGCScope no_gc; |
8289 String::Copy(dst, dst_offset, onestr.CharAddr(0) + src_offset, len); | 8243 String::Copy(dst, dst_offset, onestr.CharAddr(0) + src_offset, len); |
8290 } | 8244 } |
8291 } else if (char_size == kTwoByteChar) { | 8245 } else if (char_size == kTwoByteChar) { |
8292 if (src.IsTwoByteString()) { | 8246 if (src.IsTwoByteString()) { |
8293 TwoByteString& twostr = TwoByteString::Handle(); | 8247 const TwoByteString& twostr = TwoByteString::Cast(src); |
8294 twostr ^= src.raw(); | |
8295 NoGCScope no_gc; | 8248 NoGCScope no_gc; |
8296 String::Copy(dst, dst_offset, twostr.CharAddr(0) + src_offset, len); | 8249 String::Copy(dst, dst_offset, twostr.CharAddr(0) + src_offset, len); |
8297 } else { | 8250 } else { |
8298 ASSERT(src.IsExternalTwoByteString()); | 8251 ASSERT(src.IsExternalTwoByteString()); |
8299 ExternalTwoByteString& twostr = ExternalTwoByteString::Handle(); | 8252 const ExternalTwoByteString& twostr = ExternalTwoByteString::Cast(src); |
8300 twostr ^= src.raw(); | |
8301 NoGCScope no_gc; | 8253 NoGCScope no_gc; |
8302 String::Copy(dst, dst_offset, twostr.CharAddr(0) + src_offset, len); | 8254 String::Copy(dst, dst_offset, twostr.CharAddr(0) + src_offset, len); |
8303 } | 8255 } |
8304 } else { | 8256 } else { |
8305 ASSERT(char_size == kFourByteChar); | 8257 ASSERT(char_size == kFourByteChar); |
8306 if (src.IsFourByteString()) { | 8258 if (src.IsFourByteString()) { |
8307 FourByteString& fourstr = FourByteString::Handle(); | 8259 const FourByteString& fourstr = FourByteString::Cast(src); |
8308 fourstr ^= src.raw(); | |
8309 NoGCScope no_gc; | 8260 NoGCScope no_gc; |
8310 String::Copy(dst, dst_offset, fourstr.CharAddr(0) + src_offset, len); | 8261 String::Copy(dst, dst_offset, fourstr.CharAddr(0) + src_offset, len); |
8311 } else { | 8262 } else { |
8312 ASSERT(src.IsExternalFourByteString()); | 8263 ASSERT(src.IsExternalFourByteString()); |
8313 ExternalFourByteString& fourstr = ExternalFourByteString::Handle(); | 8264 const ExternalFourByteString& fourstr = |
8314 fourstr ^= src.raw(); | 8265 ExternalFourByteString::Cast(src); |
8315 NoGCScope no_gc; | 8266 NoGCScope no_gc; |
8316 String::Copy(dst, dst_offset, fourstr.CharAddr(0) + src_offset, len); | 8267 String::Copy(dst, dst_offset, fourstr.CharAddr(0) + src_offset, len); |
8317 } | 8268 } |
8318 } | 8269 } |
8319 } | 8270 } |
8320 } | 8271 } |
8321 | 8272 |
8322 | 8273 |
8323 static void GrowSymbolTable(const Array& symbol_table, intptr_t table_size) { | 8274 static void GrowSymbolTable(const Array& symbol_table, intptr_t table_size) { |
8324 // TODO(iposva): Avoid exponential growth. | 8275 // TODO(iposva): Avoid exponential growth. |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9127 return false; | 9078 return false; |
9128 } | 9079 } |
9129 | 9080 |
9130 // Must have the same type arguments. | 9081 // Must have the same type arguments. |
9131 if (!AbstractTypeArguments::AreEqual( | 9082 if (!AbstractTypeArguments::AreEqual( |
9132 AbstractTypeArguments::Handle(GetTypeArguments()), | 9083 AbstractTypeArguments::Handle(GetTypeArguments()), |
9133 AbstractTypeArguments::Handle(other.GetTypeArguments()))) { | 9084 AbstractTypeArguments::Handle(other.GetTypeArguments()))) { |
9134 return false; | 9085 return false; |
9135 } | 9086 } |
9136 | 9087 |
9137 Array& other_arr = Array::Handle(); | 9088 const Array& other_arr = Array::Cast(other); |
9138 other_arr ^= other.raw(); | |
9139 | 9089 |
9140 intptr_t len = this->Length(); | 9090 intptr_t len = this->Length(); |
9141 if (len != other_arr.Length()) { | 9091 if (len != other_arr.Length()) { |
9142 return false; | 9092 return false; |
9143 } | 9093 } |
9144 | 9094 |
9145 for (intptr_t i = 0; i < len; i++) { | 9095 for (intptr_t i = 0; i < len; i++) { |
9146 if (this->At(i) != other_arr.At(i)) { | 9096 if (this->At(i) != other_arr.At(i)) { |
9147 return false; | 9097 return false; |
9148 } | 9098 } |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9342 // If both handles point to the same raw instance they are equal. | 9292 // If both handles point to the same raw instance they are equal. |
9343 if (this->raw() == other.raw()) { | 9293 if (this->raw() == other.raw()) { |
9344 return true; | 9294 return true; |
9345 } | 9295 } |
9346 | 9296 |
9347 // Other instance must be non null and a GrowableObjectArray. | 9297 // Other instance must be non null and a GrowableObjectArray. |
9348 if (!other.IsGrowableObjectArray() || other.IsNull()) { | 9298 if (!other.IsGrowableObjectArray() || other.IsNull()) { |
9349 return false; | 9299 return false; |
9350 } | 9300 } |
9351 | 9301 |
9352 GrowableObjectArray& other_arr = GrowableObjectArray::Handle(); | 9302 const GrowableObjectArray& other_arr = GrowableObjectArray::Cast(other); |
9353 other_arr ^= other.raw(); | |
9354 | 9303 |
9355 // The capacity and length of both objects must be equal. | 9304 // The capacity and length of both objects must be equal. |
9356 if (Capacity() != other_arr.Capacity() || Length() != other_arr.Length()) { | 9305 if (Capacity() != other_arr.Capacity() || Length() != other_arr.Length()) { |
9357 return false; | 9306 return false; |
9358 } | 9307 } |
9359 | 9308 |
9360 // Both must have the same type arguments. | 9309 // Both must have the same type arguments. |
9361 if (!AbstractTypeArguments::AreEqual( | 9310 if (!AbstractTypeArguments::AreEqual( |
9362 AbstractTypeArguments::Handle(GetTypeArguments()), | 9311 AbstractTypeArguments::Handle(GetTypeArguments()), |
9363 AbstractTypeArguments::Handle(other.GetTypeArguments()))) { | 9312 AbstractTypeArguments::Handle(other.GetTypeArguments()))) { |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10229 } | 10178 } |
10230 | 10179 |
10231 | 10180 |
10232 bool JSRegExp::Equals(const Instance& other) const { | 10181 bool JSRegExp::Equals(const Instance& other) const { |
10233 if (this->raw() == other.raw()) { | 10182 if (this->raw() == other.raw()) { |
10234 return true; // "===". | 10183 return true; // "===". |
10235 } | 10184 } |
10236 if (other.IsNull() || !other.IsJSRegExp()) { | 10185 if (other.IsNull() || !other.IsJSRegExp()) { |
10237 return false; | 10186 return false; |
10238 } | 10187 } |
10239 JSRegExp& other_js = JSRegExp::Handle(); | 10188 const JSRegExp& other_js = JSRegExp::Cast(other); |
10240 other_js ^= other.raw(); | |
10241 // Match the pattern. | 10189 // Match the pattern. |
10242 const String& str1 = String::Handle(pattern()); | 10190 const String& str1 = String::Handle(pattern()); |
10243 const String& str2 = String::Handle(other_js.pattern()); | 10191 const String& str2 = String::Handle(other_js.pattern()); |
10244 if (!str1.Equals(str2)) { | 10192 if (!str1.Equals(str2)) { |
10245 return false; | 10193 return false; |
10246 } | 10194 } |
10247 // Match the flags. | 10195 // Match the flags. |
10248 if ((is_global() != other_js.is_global()) || | 10196 if ((is_global() != other_js.is_global()) || |
10249 (is_ignore_case() != other_js.is_ignore_case()) || | 10197 (is_ignore_case() != other_js.is_ignore_case()) || |
10250 (is_multi_line() != other_js.is_multi_line())) { | 10198 (is_multi_line() != other_js.is_multi_line())) { |
10251 return false; | 10199 return false; |
10252 } | 10200 } |
10253 return true; | 10201 return true; |
10254 } | 10202 } |
10255 | 10203 |
10256 | 10204 |
10257 const char* JSRegExp::ToCString() const { | 10205 const char* JSRegExp::ToCString() const { |
10258 const String& str = String::Handle(pattern()); | 10206 const String& str = String::Handle(pattern()); |
10259 const char* format = "JSRegExp: pattern=%s flags=%s"; | 10207 const char* format = "JSRegExp: pattern=%s flags=%s"; |
10260 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 10208 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
10261 char* chars = reinterpret_cast<char*>( | 10209 char* chars = reinterpret_cast<char*>( |
10262 Isolate::Current()->current_zone()->Allocate(len + 1)); | 10210 Isolate::Current()->current_zone()->Allocate(len + 1)); |
10263 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 10211 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
10264 return chars; | 10212 return chars; |
10265 } | 10213 } |
10266 | 10214 |
10267 } // namespace dart | 10215 } // namespace dart |
OLD | NEW |