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

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

Issue 15930003: - Allocate symbols for 'get:' and 'set:' (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | « no previous file | runtime/vm/parser.cc » ('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 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 StorePointer(&raw_ptr()->library_, value.raw()); 1551 StorePointer(&raw_ptr()->library_, value.raw());
1552 } 1552 }
1553 1553
1554 1554
1555 void Class::set_type_parameters(const TypeArguments& value) const { 1555 void Class::set_type_parameters(const TypeArguments& value) const {
1556 StorePointer(&raw_ptr()->type_parameters_, value.raw()); 1556 StorePointer(&raw_ptr()->type_parameters_, value.raw());
1557 } 1557 }
1558 1558
1559 1559
1560 intptr_t Class::NumTypeParameters() const { 1560 intptr_t Class::NumTypeParameters() const {
1561 if (type_parameters() == TypeArguments::null()) {
1562 return 0;
1563 }
1561 const TypeArguments& type_params = TypeArguments::Handle(type_parameters()); 1564 const TypeArguments& type_params = TypeArguments::Handle(type_parameters());
1562 if (type_params.IsNull()) { 1565 return type_params.Length();
1563 return 0;
1564 } else {
1565 return type_params.Length();
1566 }
1567 } 1566 }
1568 1567
1569 1568
1570 intptr_t Class::NumTypeArguments() const { 1569 intptr_t Class::NumTypeArguments() const {
1571 // To work properly, this call requires the super class of this class to be 1570 // To work properly, this call requires the super class of this class to be
1572 // resolved, which is checked by the SuperClass() call. 1571 // resolved, which is checked by the SuperClass() call.
1573 Class& cls = Class::Handle(raw()); 1572 Class& cls = Class::Handle(raw());
1574 if (IsSignatureClass()) { 1573 if (IsSignatureClass()) {
1575 const Function& signature_fun = Function::Handle(signature_function()); 1574 const Function& signature_fun = Function::Handle(signature_function());
1576 if (!signature_fun.is_static() && 1575 if (!signature_fun.is_static() &&
1577 !signature_fun.HasInstantiatedSignature()) { 1576 !signature_fun.HasInstantiatedSignature()) {
1578 cls = signature_fun.Owner(); 1577 cls = signature_fun.Owner();
1579 } 1578 }
1580 } 1579 }
1581 intptr_t num_type_args = NumTypeParameters(); 1580 intptr_t num_type_args = NumTypeParameters();
1582 const Class& superclass = Class::Handle(cls.SuperClass()); 1581 cls = cls.SuperClass();
1583 // Object is its own super class during bootstrap. 1582 // Object is its own super class during bootstrap.
1584 if (!superclass.IsNull() && (superclass.raw() != raw())) { 1583 if (!cls.IsNull() && (cls.raw() != raw())) {
1585 num_type_args += superclass.NumTypeArguments(); 1584 num_type_args += cls.NumTypeArguments();
1586 } 1585 }
1587 return num_type_args; 1586 return num_type_args;
1588 } 1587 }
1589 1588
1590 1589
1591 bool Class::HasTypeArguments() const { 1590 bool Class::HasTypeArguments() const {
1592 if (!IsSignatureClass() && (is_finalized() || is_prefinalized())) { 1591 if (!IsSignatureClass() && (is_finalized() || is_prefinalized())) {
1593 // More efficient than calling NumTypeArguments(). 1592 // More efficient than calling NumTypeArguments().
1594 return type_arguments_field_offset() != kNoTypeArguments; 1593 return type_arguments_field_offset() != kNoTypeArguments;
1595 } else { 1594 } else {
(...skipping 2238 matching lines...) Expand 10 before | Expand all | Expand 10 after
3834 const Array& argument_names, 3833 const Array& argument_names,
3835 String* error_message) const { 3834 String* error_message) const {
3836 const int num_named_arguments = 3835 const int num_named_arguments =
3837 argument_names.IsNull() ? 0 : argument_names.Length(); 3836 argument_names.IsNull() ? 0 : argument_names.Length();
3838 if (!AreValidArgumentCounts(num_arguments, 3837 if (!AreValidArgumentCounts(num_arguments,
3839 num_named_arguments, 3838 num_named_arguments,
3840 error_message)) { 3839 error_message)) {
3841 return false; 3840 return false;
3842 } 3841 }
3843 // Verify that all argument names are valid parameter names. 3842 // Verify that all argument names are valid parameter names.
3844 String& argument_name = String::Handle(); 3843 Isolate* isolate = Isolate::Current();
3845 String& parameter_name = String::Handle(); 3844 String& argument_name = String::Handle(isolate);
3845 String& parameter_name = String::Handle(isolate);
3846 for (int i = 0; i < num_named_arguments; i++) { 3846 for (int i = 0; i < num_named_arguments; i++) {
3847 argument_name ^= argument_names.At(i); 3847 argument_name ^= argument_names.At(i);
3848 ASSERT(argument_name.IsSymbol()); 3848 ASSERT(argument_name.IsSymbol());
3849 bool found = false; 3849 bool found = false;
3850 const int num_positional_args = num_arguments - num_named_arguments; 3850 const int num_positional_args = num_arguments - num_named_arguments;
3851 const int num_parameters = NumParameters(); 3851 const int num_parameters = NumParameters();
3852 for (int j = num_positional_args; !found && (j < num_parameters); j++) { 3852 for (int j = num_positional_args; !found && (j < num_parameters); j++) {
3853 parameter_name = ParameterNameAt(j); 3853 parameter_name = ParameterNameAt(j);
3854 ASSERT(argument_name.IsSymbol()); 3854 ASSERT(argument_name.IsSymbol());
3855 if (argument_name.Equals(parameter_name)) { 3855 if (argument_name.Equals(parameter_name)) {
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
4665 return reinterpret_cast<RawRedirectionData*>(raw); 4665 return reinterpret_cast<RawRedirectionData*>(raw);
4666 } 4666 }
4667 4667
4668 4668
4669 const char* RedirectionData::ToCString() const { 4669 const char* RedirectionData::ToCString() const {
4670 return "RedirectionData class"; 4670 return "RedirectionData class";
4671 } 4671 }
4672 4672
4673 4673
4674 RawString* Field::GetterName(const String& field_name) { 4674 RawString* Field::GetterName(const String& field_name) {
4675 String& str = String::Handle(); 4675 return String::Concat(Symbols::GetterPrefix(), field_name);
4676 str = String::New(kGetterPrefix);
4677 str = String::Concat(str, field_name);
4678 return str.raw();
4679 } 4676 }
4680 4677
4681 4678
4682 RawString* Field::GetterSymbol(const String& field_name) { 4679 RawString* Field::GetterSymbol(const String& field_name) {
4683 const String& str = String::Handle(Field::GetterName(field_name)); 4680 const String& str = String::Handle(Field::GetterName(field_name));
4684 return Symbols::New(str); 4681 return Symbols::New(str);
4685 } 4682 }
4686 4683
4687 4684
4688 RawString* Field::SetterName(const String& field_name) { 4685 RawString* Field::SetterName(const String& field_name) {
4689 String& str = String::Handle(); 4686 return String::Concat(Symbols::SetterPrefix(), field_name);
4690 str = String::New(kSetterPrefix);
4691 str = String::Concat(str, field_name);
4692 return str.raw();
4693 } 4687 }
4694 4688
4695 4689
4696 RawString* Field::SetterSymbol(const String& field_name) { 4690 RawString* Field::SetterSymbol(const String& field_name) {
4697 const String& str = String::Handle(Field::SetterName(field_name)); 4691 const String& str = String::Handle(Field::SetterName(field_name));
4698 return Symbols::New(str); 4692 return Symbols::New(str);
4699 } 4693 }
4700 4694
4701 4695
4702 RawString* Field::NameFromGetter(const String& getter_name) { 4696 RawString* Field::NameFromGetter(const String& getter_name) {
4703 String& str = String::Handle(); 4697 return String::SubString(getter_name, strlen(kGetterPrefix));
4704 str = String::SubString(getter_name, strlen(kGetterPrefix));
4705 return str.raw();
4706 } 4698 }
4707 4699
4708 4700
4709 RawString* Field::NameFromSetter(const String& setter_name) { 4701 RawString* Field::NameFromSetter(const String& setter_name) {
4710 String& str = String::Handle(); 4702 return String::SubString(setter_name, strlen(kSetterPrefix));
4711 str = String::SubString(setter_name, strlen(kSetterPrefix));
4712 return str.raw();
4713 } 4703 }
4714 4704
4715 4705
4716 bool Field::IsGetterName(const String& function_name) { 4706 bool Field::IsGetterName(const String& function_name) {
4717 return function_name.StartsWith(String::Handle(String::New(kGetterPrefix))); 4707 return function_name.StartsWith(Symbols::GetterPrefix());
4718 } 4708 }
4719 4709
4720 4710
4721 bool Field::IsSetterName(const String& function_name) { 4711 bool Field::IsSetterName(const String& function_name) {
4722 return function_name.StartsWith(String::Handle(String::New(kSetterPrefix))); 4712 return function_name.StartsWith(Symbols::SetterPrefix());
4723 } 4713 }
4724 4714
4725 4715
4726 void Field::set_name(const String& value) const { 4716 void Field::set_name(const String& value) const {
4727 ASSERT(value.IsSymbol()); 4717 ASSERT(value.IsSymbol());
4728 StorePointer(&raw_ptr()->name_, value.raw()); 4718 StorePointer(&raw_ptr()->name_, value.raw());
4729 } 4719 }
4730 4720
4731 4721
4732 RawClass* Field::owner() const { 4722 RawClass* Field::owner() const {
(...skipping 1589 matching lines...) Expand 10 before | Expand all | Expand 10 after
6322 return Library::null(); 6312 return Library::null();
6323 } 6313 }
6324 return import.library(); 6314 return import.library();
6325 } 6315 }
6326 6316
6327 6317
6328 RawNamespace* Library::ImportAt(intptr_t index) const { 6318 RawNamespace* Library::ImportAt(intptr_t index) const {
6329 if ((index < 0) || index >= num_imports()) { 6319 if ((index < 0) || index >= num_imports()) {
6330 return Namespace::null(); 6320 return Namespace::null();
6331 } 6321 }
6322 Namespace& import = Namespace::Handle();
Ivan Posva 2013/05/23 22:30:17 ?
siva 2013/05/23 22:39:31 Restored.
6332 const Array& import_list = Array::Handle(imports()); 6323 const Array& import_list = Array::Handle(imports());
6333 Namespace& import = Namespace::Handle();
6334 import ^= import_list.At(index); 6324 import ^= import_list.At(index);
6335 return import.raw(); 6325 return import.raw();
6336 } 6326 }
6337 6327
6338 6328
6339 bool Library::ImportsCorelib() const { 6329 bool Library::ImportsCorelib() const {
6340 Isolate* isolate = Isolate::Current(); 6330 Isolate* isolate = Isolate::Current();
6341 Library& imported = Library::Handle(isolate); 6331 Library& imported = Library::Handle(isolate);
6342 intptr_t count = num_imports(); 6332 intptr_t count = num_imports();
6343 for (int i = 0; i < count; i++) { 6333 for (int i = 0; i < count; i++) {
(...skipping 6897 matching lines...) Expand 10 before | Expand all | Expand 10 after
13241 } 13231 }
13242 return result.raw(); 13232 return result.raw();
13243 } 13233 }
13244 13234
13245 13235
13246 const char* WeakProperty::ToCString() const { 13236 const char* WeakProperty::ToCString() const {
13247 return "_WeakProperty"; 13237 return "_WeakProperty";
13248 } 13238 }
13249 13239
13250 } // namespace dart 13240 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698