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

Side by Side Diff: vm/object.cc

Issue 9616044: Adds new apis Dart_GetField/Dart_SetField. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 9 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
« include/dart_api.h ('K') | « vm/object.h ('k') | 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 "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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 object_store->set_object_class(cls); 563 object_store->set_object_class(cls);
564 cls.set_name(String::Handle(String::NewSymbol("Object"))); 564 cls.set_name(String::Handle(String::NewSymbol("Object")));
565 cls.set_script(script); 565 cls.set_script(script);
566 core_lib.AddClass(cls); 566 core_lib.AddClass(cls);
567 pending_classes.Add(&Class::ZoneHandle(cls.raw())); 567 pending_classes.Add(&Class::ZoneHandle(cls.raw()));
568 type = Type::NewNonParameterizedType(cls); 568 type = Type::NewNonParameterizedType(cls);
569 object_store->set_object_type(type); 569 object_store->set_object_type(type);
570 570
571 cls = Class::New<InternalByteArray>(); 571 cls = Class::New<InternalByteArray>();
572 object_store->set_internal_byte_array_class(cls); 572 object_store->set_internal_byte_array_class(cls);
573 cls.set_name(String::Handle(core_lib.PrivateName("_InternalByteArray"))); 573 String& public_class_name = String::Handle();
574 public_class_name = String::New("_InternalByteArray");
575 cls.set_name(String::Handle(core_lib.PrivateName(public_class_name)));
574 cls.set_script(script); 576 cls.set_script(script);
575 core_lib.AddClass(cls); 577 core_lib.AddClass(cls);
576 578
577 cls = Class::New<ExternalByteArray>(); 579 cls = Class::New<ExternalByteArray>();
578 object_store->set_external_byte_array_class(cls); 580 object_store->set_external_byte_array_class(cls);
579 cls.set_name(String::Handle(core_lib.PrivateName("_ExternalByteArray"))); 581 public_class_name = String::New("_ExternalByteArray");
582 cls.set_name(String::Handle(core_lib.PrivateName(public_class_name)));
580 cls.set_script(script); 583 cls.set_script(script);
581 core_lib.AddClass(cls); 584 core_lib.AddClass(cls);
582 585
583 // Set the super type of class Stacktrace to Object type so that the 586 // Set the super type of class Stacktrace to Object type so that the
584 // 'toString' method is implemented. 587 // 'toString' method is implemented.
585 cls = object_store->stacktrace_class(); 588 cls = object_store->stacktrace_class();
586 cls.set_super_type(type); 589 cls.set_super_type(type);
587 590
588 cls = CreateAndRegisterInterface("Function", script, core_lib); 591 cls = CreateAndRegisterInterface("Function", script, core_lib);
589 pending_classes.Add(&Class::ZoneHandle(cls.raw())); 592 pending_classes.Add(&Class::ZoneHandle(cls.raw()));
(...skipping 3867 matching lines...) Expand 10 before | Expand all | Expand 10 after
4457 if (entry_name.Equals(name)) { 4460 if (entry_name.Equals(name)) {
4458 return entry.raw(); 4461 return entry.raw();
4459 } 4462 }
4460 index = (index + 1) % dict_size; 4463 index = (index + 1) % dict_size;
4461 entry = dict.At(index); 4464 entry = dict.At(index);
4462 } 4465 }
4463 return Class::null(); 4466 return Class::null();
4464 } 4467 }
4465 4468
4466 4469
4470 RawField* Library::LookupLocalField(const String& name) const {
4471 Isolate* isolate = Isolate::Current();
4472 Field& field = Field::Handle(isolate, Field::null());
4473 Object& obj = Object::Handle(isolate, Object::null());
4474 obj = LookupLocalObject(name);
4475 if (obj.IsNull()) {
4476 String& private_name = String::Handle(isolate, PrivateName(name));
4477 obj = LookupLocalObject(private_name);
4478 }
4479 if (!obj.IsNull()) {
4480 if (obj.IsField()) {
4481 field ^= obj.raw();
4482 return field.raw();
4483 }
4484 }
4485
4486 // No field found.
4487 return Field::null();
4488 }
4489
4490
4491 RawFunction* Library::LookupLocalFunction(const String& name) const {
4492 Isolate* isolate = Isolate::Current();
4493 Function& function = Function::Handle(isolate, Function::null());
4494 Object& obj = Object::Handle(isolate, Object::null());
4495 obj = LookupLocalObject(name);
4496 if (obj.IsNull()) {
4497 String& private_name = String::Handle(isolate, PrivateName(name));
4498 obj = LookupLocalObject(private_name);
4499 }
4500 if (!obj.IsNull()) {
4501 if (obj.IsFunction()) {
4502 function ^= obj.raw();
4503 return function.raw();
4504 }
4505 }
4506
4507 // No function found.
4508 return Function::null();
4509 }
4510
4511
4467 RawObject* Library::LookupObjectFiltered(const String& name, 4512 RawObject* Library::LookupObjectFiltered(const String& name,
4468 const Library& filter_lib) const { 4513 const Library& filter_lib) const {
4469 // First check if name is found in the local scope of the library. 4514 // First check if name is found in the local scope of the library.
4470 Object& obj = Object::Handle(LookupLocalObject(name)); 4515 Object& obj = Object::Handle(LookupLocalObject(name));
4471 if (!obj.IsNull()) { 4516 if (!obj.IsNull()) {
4472 return obj.raw(); 4517 return obj.raw();
4473 } 4518 }
4474 // Now check if name is found in the top level scope of any imported libs. 4519 // Now check if name is found in the top level scope of any imported libs.
4475 const Array& imports = Array::Handle(this->imports()); 4520 const Array& imports = Array::Handle(this->imports());
4476 Library& import_lib = Library::Handle(); 4521 Library& import_lib = Library::Handle();
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
4872 lib_key = lib_url.Hash(); 4917 lib_key = lib_url.Hash();
4873 if (lib_key == key) { 4918 if (lib_key == key) {
4874 return true; 4919 return true;
4875 } 4920 }
4876 lib = lib.next_registered(); 4921 lib = lib.next_registered();
4877 } 4922 }
4878 return false; 4923 return false;
4879 } 4924 }
4880 4925
4881 4926
4882 RawString* Library::PrivateName(const char* name) { 4927 RawString* Library::PrivateName(const String& name) const {
4883 ASSERT(name[0] == '_'); 4928 // TODO(turnidge): Should check for prefix of "_", "get:_", or "set:_" here.
Ivan Posva 2012/03/07 20:02:58 ASSERT(name.CharAt(0) == '_');
turnidge 2012/03/07 21:17:12 Done...
4884 ASSERT(strchr(name, '@') == NULL); 4929 // ASSERT(strchr(name, '@') == NULL);
4885 String& str = String::Handle(); 4930 String& str = String::Handle();
4886 str = String::New(name); 4931 str ^= name.raw();
4887 str = String::Concat(str, String::Handle(this->private_key())); 4932 str = String::Concat(str, String::Handle(this->private_key()));
4888 str = String::NewSymbol(str); 4933 str = String::NewSymbol(str);
4889 return str.raw(); 4934 return str.raw();
4890 } 4935 }
4891 4936
4892 4937
4893 void Library::Register() const { 4938 void Library::Register() const {
4894 ASSERT(Library::LookupLibrary(String::Handle(url())) == Library::null()); 4939 ASSERT(Library::LookupLibrary(String::Handle(url())) == Library::null());
4895 raw_ptr()->next_registered_ = 4940 raw_ptr()->next_registered_ =
4896 Isolate::Current()->object_store()->registered_libraries(); 4941 Isolate::Current()->object_store()->registered_libraries();
(...skipping 3627 matching lines...) Expand 10 before | Expand all | Expand 10 after
8524 result.set_num_args_tested(num_args_tested); 8569 result.set_num_args_tested(num_args_tested);
8525 // Number of array elements in one test entry (num_args_tested + 1) 8570 // Number of array elements in one test entry (num_args_tested + 1)
8526 intptr_t len = result.TestEntryLength(); 8571 intptr_t len = result.TestEntryLength();
8527 // IC data array must be null terminated (sentinel entry). 8572 // IC data array must be null terminated (sentinel entry).
8528 Array& ic_data = Array::Handle(Array::New(len, Heap::kOld)); 8573 Array& ic_data = Array::Handle(Array::New(len, Heap::kOld));
8529 result.set_ic_data(ic_data); 8574 result.set_ic_data(ic_data);
8530 return result.raw(); 8575 return result.raw();
8531 } 8576 }
8532 8577
8533 } // namespace dart 8578 } // namespace dart
OLDNEW
« include/dart_api.h ('K') | « vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698