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

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

Issue 259393002: Enums cleanup. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 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 | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | 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 3655 matching lines...) Expand 10 before | Expand all | Expand 10 after
3666 } 3666 }
3667 for (intptr_t i = 0, j = prefix_length; i < accessor_name_len; i++, j++) { 3667 for (intptr_t i = 0, j = prefix_length; i < accessor_name_len; i++, j++) {
3668 if (name.CharAt(j) != accessor_name.CharAt(i)) { 3668 if (name.CharAt(j) != accessor_name.CharAt(i)) {
3669 return false; 3669 return false;
3670 } 3670 }
3671 } 3671 }
3672 return true; 3672 return true;
3673 } 3673 }
3674 3674
3675 3675
3676 RawFunction* Class::CheckFunctionType(const Function& func, intptr_t type) { 3676 RawFunction* Class::CheckFunctionType(const Function& func, MemberKind kind) {
3677 if (type == kInstance) { 3677 if (kind == kInstance) {
3678 if (func.IsDynamicFunction()) { 3678 if (func.IsDynamicFunction()) {
3679 return func.raw(); 3679 return func.raw();
3680 } 3680 }
3681 } else if (type == kStatic) { 3681 } else if (kind == kStatic) {
3682 if (func.IsStaticFunction()) { 3682 if (func.IsStaticFunction()) {
3683 return func.raw(); 3683 return func.raw();
3684 } 3684 }
3685 } else if (type == kConstructor) { 3685 } else if (kind == kConstructor) {
3686 if (func.IsConstructor()) { 3686 if (func.IsConstructor()) {
3687 ASSERT(!func.is_static()); 3687 ASSERT(!func.is_static());
3688 return func.raw(); 3688 return func.raw();
3689 } 3689 }
3690 } else if (type == kFactory) { 3690 } else if (kind == kFactory) {
3691 if (func.IsFactory()) { 3691 if (func.IsFactory()) {
3692 ASSERT(func.is_static()); 3692 ASSERT(func.is_static());
3693 return func.raw(); 3693 return func.raw();
3694 } 3694 }
3695 } else if (type == kAny) { 3695 } else if (kind == kAny) {
3696 return func.raw(); 3696 return func.raw();
3697 } 3697 }
3698 return Function::null(); 3698 return Function::null();
3699 } 3699 }
3700 3700
3701 3701
3702 RawFunction* Class::LookupFunction(const String& name, intptr_t type) const { 3702 RawFunction* Class::LookupFunction(const String& name, MemberKind kind) const {
3703 Isolate* isolate = Isolate::Current(); 3703 Isolate* isolate = Isolate::Current();
3704 if (EnsureIsFinalized(isolate) != Error::null()) { 3704 if (EnsureIsFinalized(isolate) != Error::null()) {
3705 return Function::null(); 3705 return Function::null();
3706 } 3706 }
3707 REUSABLE_ARRAY_HANDLESCOPE(isolate); 3707 REUSABLE_ARRAY_HANDLESCOPE(isolate);
3708 REUSABLE_FUNCTION_HANDLESCOPE(isolate); 3708 REUSABLE_FUNCTION_HANDLESCOPE(isolate);
3709 Array& funcs = isolate->ArrayHandle(); 3709 Array& funcs = isolate->ArrayHandle();
3710 funcs ^= functions(); 3710 funcs ^= functions();
3711 ASSERT(!funcs.IsNull()); 3711 ASSERT(!funcs.IsNull());
3712 const intptr_t len = funcs.Length(); 3712 const intptr_t len = funcs.Length();
3713 Function& function = isolate->FunctionHandle(); 3713 Function& function = isolate->FunctionHandle();
3714 if (name.IsSymbol()) { 3714 if (name.IsSymbol()) {
3715 // Quick Symbol compare. 3715 // Quick Symbol compare.
3716 NoGCScope no_gc; 3716 NoGCScope no_gc;
3717 for (intptr_t i = 0; i < len; i++) { 3717 for (intptr_t i = 0; i < len; i++) {
3718 function ^= funcs.At(i); 3718 function ^= funcs.At(i);
3719 if (function.name() == name.raw()) { 3719 if (function.name() == name.raw()) {
3720 return CheckFunctionType(function, type); 3720 return CheckFunctionType(function, kind);
3721 } 3721 }
3722 } 3722 }
3723 } else { 3723 } else {
3724 REUSABLE_STRING_HANDLESCOPE(isolate); 3724 REUSABLE_STRING_HANDLESCOPE(isolate);
3725 String& function_name = isolate->StringHandle(); 3725 String& function_name = isolate->StringHandle();
3726 for (intptr_t i = 0; i < len; i++) { 3726 for (intptr_t i = 0; i < len; i++) {
3727 function ^= funcs.At(i); 3727 function ^= funcs.At(i);
3728 function_name ^= function.name(); 3728 function_name ^= function.name();
3729 if (function_name.Equals(name)) { 3729 if (function_name.Equals(name)) {
3730 return CheckFunctionType(function, type); 3730 return CheckFunctionType(function, kind);
3731 } 3731 }
3732 } 3732 }
3733 } 3733 }
3734 // No function found. 3734 // No function found.
3735 return Function::null(); 3735 return Function::null();
3736 } 3736 }
3737 3737
3738 3738
3739 RawFunction* Class::LookupFunctionAllowPrivate(const String& name, 3739 RawFunction* Class::LookupFunctionAllowPrivate(const String& name,
3740 intptr_t type) const { 3740 MemberKind kind) const {
3741 Isolate* isolate = Isolate::Current(); 3741 Isolate* isolate = Isolate::Current();
3742 if (EnsureIsFinalized(isolate) != Error::null()) { 3742 if (EnsureIsFinalized(isolate) != Error::null()) {
3743 return Function::null(); 3743 return Function::null();
3744 } 3744 }
3745 REUSABLE_ARRAY_HANDLESCOPE(isolate); 3745 REUSABLE_ARRAY_HANDLESCOPE(isolate);
3746 REUSABLE_FUNCTION_HANDLESCOPE(isolate); 3746 REUSABLE_FUNCTION_HANDLESCOPE(isolate);
3747 REUSABLE_STRING_HANDLESCOPE(isolate); 3747 REUSABLE_STRING_HANDLESCOPE(isolate);
3748 Array& funcs = isolate->ArrayHandle(); 3748 Array& funcs = isolate->ArrayHandle();
3749 funcs ^= functions(); 3749 funcs ^= functions();
3750 ASSERT(!funcs.IsNull()); 3750 ASSERT(!funcs.IsNull());
3751 const intptr_t len = funcs.Length(); 3751 const intptr_t len = funcs.Length();
3752 Function& function = isolate->FunctionHandle(); 3752 Function& function = isolate->FunctionHandle();
3753 String& function_name = isolate->StringHandle(); 3753 String& function_name = isolate->StringHandle();
3754 for (intptr_t i = 0; i < len; i++) { 3754 for (intptr_t i = 0; i < len; i++) {
3755 function ^= funcs.At(i); 3755 function ^= funcs.At(i);
3756 function_name ^= function.name(); 3756 function_name ^= function.name();
3757 if (String::EqualsIgnoringPrivateKey(function_name, name)) { 3757 if (String::EqualsIgnoringPrivateKey(function_name, name)) {
3758 return CheckFunctionType(function, type); 3758 return CheckFunctionType(function, kind);
3759 } 3759 }
3760 } 3760 }
3761 // No function found. 3761 // No function found.
3762 return Function::null(); 3762 return Function::null();
3763 } 3763 }
3764 3764
3765 3765
3766 RawFunction* Class::LookupGetterFunction(const String& name) const { 3766 RawFunction* Class::LookupGetterFunction(const String& name) const {
3767 return LookupAccessorFunction(kGetterPrefix, kGetterPrefixLength, name); 3767 return LookupAccessorFunction(kGetterPrefix, kGetterPrefixLength, name);
3768 } 3768 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
3835 RawField* Class::LookupStaticField(const String& name) const { 3835 RawField* Class::LookupStaticField(const String& name) const {
3836 return LookupField(name, kStatic); 3836 return LookupField(name, kStatic);
3837 } 3837 }
3838 3838
3839 3839
3840 RawField* Class::LookupField(const String& name) const { 3840 RawField* Class::LookupField(const String& name) const {
3841 return LookupField(name, kAny); 3841 return LookupField(name, kAny);
3842 } 3842 }
3843 3843
3844 3844
3845 RawField* Class::LookupField(const String& name, intptr_t type) const { 3845 RawField* Class::LookupField(const String& name, MemberKind kind) const {
3846 Isolate* isolate = Isolate::Current(); 3846 Isolate* isolate = Isolate::Current();
3847 if (EnsureIsFinalized(isolate) != Error::null()) { 3847 if (EnsureIsFinalized(isolate) != Error::null()) {
3848 return Field::null(); 3848 return Field::null();
3849 } 3849 }
3850 REUSABLE_ARRAY_HANDLESCOPE(isolate); 3850 REUSABLE_ARRAY_HANDLESCOPE(isolate);
3851 REUSABLE_FIELD_HANDLESCOPE(isolate); 3851 REUSABLE_FIELD_HANDLESCOPE(isolate);
3852 REUSABLE_STRING_HANDLESCOPE(isolate); 3852 REUSABLE_STRING_HANDLESCOPE(isolate);
3853 Array& flds = isolate->ArrayHandle(); 3853 Array& flds = isolate->ArrayHandle();
3854 flds ^= fields(); 3854 flds ^= fields();
3855 ASSERT(!flds.IsNull()); 3855 ASSERT(!flds.IsNull());
3856 intptr_t len = flds.Length(); 3856 intptr_t len = flds.Length();
3857 Field& field = isolate->FieldHandle(); 3857 Field& field = isolate->FieldHandle();
3858 String& field_name = isolate->StringHandle(); 3858 String& field_name = isolate->StringHandle();
3859 for (intptr_t i = 0; i < len; i++) { 3859 for (intptr_t i = 0; i < len; i++) {
3860 field ^= flds.At(i); 3860 field ^= flds.At(i);
3861 field_name ^= field.name(); 3861 field_name ^= field.name();
3862 if (String::EqualsIgnoringPrivateKey(field_name, name)) { 3862 if (String::EqualsIgnoringPrivateKey(field_name, name)) {
3863 if (type == kInstance) { 3863 if (kind == kInstance) {
3864 if (!field.is_static()) { 3864 if (!field.is_static()) {
3865 return field.raw(); 3865 return field.raw();
3866 } 3866 }
3867 } else if (type == kStatic) { 3867 } else if (kind == kStatic) {
3868 if (field.is_static()) { 3868 if (field.is_static()) {
3869 return field.raw(); 3869 return field.raw();
3870 } 3870 }
3871 } else if (type == kAny) { 3871 } else if (kind == kAny) {
3872 return field.raw(); 3872 return field.raw();
3873 } 3873 }
3874 return Field::null(); 3874 return Field::null();
3875 } 3875 }
3876 } 3876 }
3877 // No field found. 3877 // No field found.
3878 return Field::null(); 3878 return Field::null();
3879 } 3879 }
3880 3880
3881 3881
(...skipping 14787 matching lines...) Expand 10 before | Expand all | Expand 10 after
18669 return tag_label.ToCString(); 18669 return tag_label.ToCString();
18670 } 18670 }
18671 18671
18672 18672
18673 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 18673 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
18674 Instance::PrintJSONImpl(stream, ref); 18674 Instance::PrintJSONImpl(stream, ref);
18675 } 18675 }
18676 18676
18677 18677
18678 } // namespace dart 18678 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698