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

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

Issue 116343004: Some cleanups (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 12 months 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 | « no previous file | no next file » | 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) 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 "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 1857 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 } 1868 }
1869 } 1869 }
1870 closure = Function::null(); 1870 closure = Function::null();
1871 if (best_fit_index >= 0) { 1871 if (best_fit_index >= 0) {
1872 closure ^= closures.At(best_fit_index); 1872 closure ^= closures.At(best_fit_index);
1873 } 1873 }
1874 return closure.raw(); 1874 return closure.raw();
1875 } 1875 }
1876 1876
1877 intptr_t Class::FindClosureIndex(intptr_t token_pos) const { 1877 intptr_t Class::FindClosureIndex(intptr_t token_pos) const {
1878 if (raw_ptr()->closure_functions_ == GrowableObjectArray::null()) { 1878 if (closures() == GrowableObjectArray::null()) {
1879 return -1; 1879 return -1;
1880 } 1880 }
1881 Isolate* isolate = Isolate::Current(); 1881 Isolate* isolate = Isolate::Current();
1882 ReusableHandleScope reused_handles(isolate); 1882 ReusableHandleScope reused_handles(isolate);
1883 const GrowableObjectArray& closures = 1883 const GrowableObjectArray& closures_array =
1884 GrowableObjectArray::Handle(isolate, raw_ptr()->closure_functions_); 1884 GrowableObjectArray::Handle(isolate, closures());
1885 Function& closure = reused_handles.FunctionHandle(); 1885 Function& closure = reused_handles.FunctionHandle();
1886 intptr_t num_closures = closures.Length(); 1886 intptr_t num_closures = closures_array.Length();
1887 intptr_t best_fit_token_pos = -1; 1887 intptr_t best_fit_token_pos = -1;
1888 intptr_t best_fit_index = -1; 1888 intptr_t best_fit_index = -1;
1889 for (intptr_t i = 0; i < num_closures; i++) { 1889 for (intptr_t i = 0; i < num_closures; i++) {
1890 closure ^= closures.At(i); 1890 closure ^= closures_array.At(i);
1891 ASSERT(!closure.IsNull()); 1891 ASSERT(!closure.IsNull());
1892 if ((closure.token_pos() <= token_pos) && 1892 if ((closure.token_pos() <= token_pos) &&
1893 (token_pos <= closure.end_token_pos()) && 1893 (token_pos <= closure.end_token_pos()) &&
1894 (best_fit_token_pos < closure.token_pos())) { 1894 (best_fit_token_pos < closure.token_pos())) {
1895 best_fit_index = i; 1895 best_fit_index = i;
1896 best_fit_token_pos = closure.token_pos(); 1896 best_fit_token_pos = closure.token_pos();
1897 } 1897 }
1898 } 1898 }
1899 return best_fit_index; 1899 return best_fit_index;
1900 } 1900 }
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
2465 String& needle_name = String::Handle(isolate); 2465 String& needle_name = String::Handle(isolate);
2466 needle_name ^= needle.name(); 2466 needle_name ^= needle.name();
2467 const intptr_t len = fields_array.Length(); 2467 const intptr_t len = fields_array.Length();
2468 for (intptr_t i = 0; i < len; i++) { 2468 for (intptr_t i = 0; i < len; i++) {
2469 field ^= fields_array.At(i); 2469 field ^= fields_array.At(i);
2470 field_name ^= field.name(); 2470 field_name ^= field.name();
2471 if (field_name.Equals(needle_name)) { 2471 if (field_name.Equals(needle_name)) {
2472 return i; 2472 return i;
2473 } 2473 }
2474 } 2474 }
2475 // No field found found. 2475 // No field found.
2476 return -1; 2476 return -1;
2477 } 2477 }
2478 2478
2479 2479
2480 template <class FakeInstance> 2480 template <class FakeInstance>
2481 RawClass* Class::New(intptr_t index) { 2481 RawClass* Class::New(intptr_t index) {
2482 ASSERT(Object::class_class() != Class::null()); 2482 ASSERT(Object::class_class() != Class::null());
2483 Class& result = Class::Handle(); 2483 Class& result = Class::Handle();
2484 { 2484 {
2485 RawObject* raw = Object::Allocate(Class::kClassId, 2485 RawObject* raw = Object::Allocate(Class::kClassId,
(...skipping 12063 matching lines...) Expand 10 before | Expand all | Expand 10 after
14549 return dststr.raw(); 14549 return dststr.raw();
14550 } 14550 }
14551 14551
14552 14552
14553 RawString* String::DecodeURI(const String& str) { 14553 RawString* String::DecodeURI(const String& str) {
14554 // URI encoding is only specified for one byte strings. 14554 // URI encoding is only specified for one byte strings.
14555 ASSERT(str.IsOneByteString() || str.IsExternalOneByteString()); 14555 ASSERT(str.IsOneByteString() || str.IsExternalOneByteString());
14556 CodePointIterator cpi(str); 14556 CodePointIterator cpi(str);
14557 intptr_t num_escapes = 0; 14557 intptr_t num_escapes = 0;
14558 intptr_t len = str.Length(); 14558 intptr_t len = str.Length();
14559 bool valid = true;
14560 { 14559 {
14561 CodePointIterator cpi(str); 14560 CodePointIterator cpi(str);
14562 while (valid && cpi.Next()) { 14561 while (cpi.Next()) {
14563 int32_t code_point = cpi.Current(); 14562 int32_t code_point = cpi.Current();
14564 if (IsPercent(code_point)) { 14563 if (IsPercent(code_point)) {
14565 // Verify that the two characters following the % are hex digits. 14564 // Verify that the two characters following the % are hex digits.
14566 if (!cpi.Next()) { 14565 if (!cpi.Next()) {
14567 valid = false; 14566 return str.raw();
14568 break;
14569 } 14567 }
14570 int32_t code_point = cpi.Current(); 14568 int32_t code_point = cpi.Current();
14571 if (!IsHexCharacter(code_point)) { 14569 if (!IsHexCharacter(code_point)) {
14572 valid = false; 14570 return str.raw();
14573 break;
14574 } 14571 }
14575 if (!cpi.Next()) { 14572 if (!cpi.Next()) {
14576 valid = false; 14573 return str.raw();
14577 break;
14578 } 14574 }
14579 code_point = cpi.Current(); 14575 code_point = cpi.Current();
14580 if (!IsHexCharacter(code_point)) { 14576 if (!IsHexCharacter(code_point)) {
14581 valid = false; 14577 return str.raw();
14582 break;
14583 } 14578 }
14584 num_escapes += 2; 14579 num_escapes += 2;
14585 } 14580 }
14586 } 14581 }
14587 } 14582 }
14588 if (!valid) {
14589 // Invalid, return original string.
14590 return str.raw();
14591 }
14592 ASSERT(len - num_escapes > 0); 14583 ASSERT(len - num_escapes > 0);
14593 const String& dststr = String::Handle( 14584 const String& dststr = String::Handle(
14594 OneByteString::New(len - num_escapes, Heap::kNew)); 14585 OneByteString::New(len - num_escapes, Heap::kNew));
14595 { 14586 {
14596 intptr_t index = 0; 14587 intptr_t index = 0;
14597 CodePointIterator cpi(str); 14588 CodePointIterator cpi(str);
14598 while (cpi.Next()) { 14589 while (cpi.Next()) {
14599 int32_t code_point = cpi.Current(); 14590 int32_t code_point = cpi.Current();
14600 if (IsPercent(code_point)) { 14591 if (IsPercent(code_point)) {
14601 cpi.Next(); 14592 cpi.Next();
(...skipping 2189 matching lines...) Expand 10 before | Expand all | Expand 10 after
16791 return "_MirrorReference"; 16782 return "_MirrorReference";
16792 } 16783 }
16793 16784
16794 16785
16795 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 16786 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
16796 Instance::PrintToJSONStream(stream, ref); 16787 Instance::PrintToJSONStream(stream, ref);
16797 } 16788 }
16798 16789
16799 16790
16800 } // namespace dart 16791 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698