| Index: vm/object.cc
|
| ===================================================================
|
| --- vm/object.cc (revision 3423)
|
| +++ vm/object.cc (working copy)
|
| @@ -33,6 +33,11 @@
|
| DEFINE_FLAG(bool, generate_gdb_symbols, false,
|
| "Generate symbols of generated dart functions for debugging with GDB");
|
|
|
| +static const char* kGetterPrefix = "get:";
|
| +static const intptr_t kGetterPrefixLength = strlen(kGetterPrefix);
|
| +static const char* kSetterPrefix = "set:";
|
| +static const intptr_t kSetterPrefixLength = strlen(kSetterPrefix);
|
| +
|
| cpp_vtable Object::handle_vtable_ = 0;
|
| cpp_vtable Smi::handle_vtable_ = 0;
|
|
|
| @@ -1516,6 +1521,30 @@
|
| }
|
|
|
|
|
| +static bool MatchesAccessorName(const String& name,
|
| + const char* prefix,
|
| + intptr_t prefix_length,
|
| + const String& accessor_name) {
|
| + intptr_t name_len = name.Length();
|
| + intptr_t accessor_name_len = accessor_name.Length();
|
| +
|
| + if (name_len != (accessor_name_len + prefix_length)) {
|
| + return false;
|
| + }
|
| + for (intptr_t i = 0; i < prefix_length; i++) {
|
| + if (name.CharAt(i) != prefix[i]) {
|
| + return false;
|
| + }
|
| + }
|
| + for (intptr_t i = 0, j = prefix_length; i < accessor_name_len; i++, j++) {
|
| + if (name.CharAt(j) != accessor_name.CharAt(i)) {
|
| + return false;
|
| + }
|
| + }
|
| + return true;
|
| +}
|
| +
|
| +
|
| static bool MatchesPrivateName(const String& name, const String& private_name) {
|
| intptr_t name_len = name.Length();
|
| intptr_t private_len = private_name.Length();
|
| @@ -1558,6 +1587,37 @@
|
| }
|
|
|
|
|
| +RawFunction* Class::LookupGetterFunction(const String& name) const {
|
| + return LookupAccessorFunction(kGetterPrefix, kGetterPrefixLength, name);
|
| +}
|
| +
|
| +
|
| +RawFunction* Class::LookupSetterFunction(const String& name) const {
|
| + return LookupAccessorFunction(kSetterPrefix, kSetterPrefixLength, name);
|
| +}
|
| +
|
| +
|
| +RawFunction* Class::LookupAccessorFunction(const char* prefix,
|
| + intptr_t prefix_length,
|
| + const String& name) const {
|
| + Isolate* isolate = Isolate::Current();
|
| + Array& funcs = Array::Handle(isolate, functions());
|
| + Function& function = Function::Handle(isolate, Function::null());
|
| + String& function_name = String::Handle(isolate, String::null());
|
| + intptr_t len = funcs.Length();
|
| + for (intptr_t i = 0; i < len; i++) {
|
| + function ^= funcs.At(i);
|
| + function_name ^= function.name();
|
| + if (MatchesAccessorName(function_name, prefix, prefix_length, name)) {
|
| + return function.raw();
|
| + }
|
| + }
|
| +
|
| + // No function found.
|
| + return Function::null();
|
| +}
|
| +
|
| +
|
| RawFunction* Class::LookupFunctionAtToken(intptr_t token_index) const {
|
| // TODO(hausner): we can shortcut the negative case if we knew the
|
| // beginning and end token position of the class.
|
| @@ -3494,33 +3554,47 @@
|
|
|
| RawString* Field::GetterName(const String& field_name) {
|
| String& str = String::Handle();
|
| - str = String::New("get:");
|
| + str = String::New(kGetterPrefix);
|
| str = String::Concat(str, field_name);
|
| + return str.raw();
|
| +}
|
| +
|
| +
|
| +RawString* Field::GetterSymbol(const String& field_name) {
|
| + String& str = String::Handle();
|
| + str = Field::GetterName(field_name);
|
| return String::NewSymbol(str);
|
| }
|
|
|
|
|
| RawString* Field::SetterName(const String& field_name) {
|
| String& str = String::Handle();
|
| - str = String::New("set:");
|
| + str = String::New(kSetterPrefix);
|
| str = String::Concat(str, field_name);
|
| + return str.raw();
|
| +}
|
| +
|
| +
|
| +RawString* Field::SetterSymbol(const String& field_name) {
|
| + String& str = String::Handle();
|
| + str = Field::SetterName(field_name);
|
| return String::NewSymbol(str);
|
| }
|
|
|
|
|
| RawString* Field::NameFromGetter(const String& getter_name) {
|
| String& str = String::Handle();
|
| - str = String::New("get:");
|
| + str = String::New(kGetterPrefix);
|
| str = String::SubString(getter_name, str.Length());
|
| - return String::NewSymbol(str);
|
| + return str.raw();
|
| }
|
|
|
|
|
| RawString* Field::NameFromSetter(const String& setter_name) {
|
| String& str = String::Handle();
|
| - str = String::New("set:");
|
| + str = String::New(kSetterPrefix);
|
| str = String::SubString(setter_name, str.Length());
|
| - return String::NewSymbol(str);
|
| + return str.raw();
|
| }
|
|
|
|
|
| @@ -6606,12 +6680,12 @@
|
| intptr_t hash = Hash(characters, len);
|
|
|
| const Array& symbol_table =
|
| - Array::Handle(isolate->object_store()->symbol_table());
|
| + Array::Handle(isolate, isolate->object_store()->symbol_table());
|
| // Last element of the array is the number of used elements.
|
| intptr_t table_size = symbol_table.Length() - 1;
|
| intptr_t index = hash % table_size;
|
|
|
| - String& symbol = String::Handle();
|
| + String& symbol = String::Handle(isolate, String::null());
|
| symbol ^= symbol_table.At(index);
|
| while (!symbol.IsNull() && !symbol.Equals(characters, len)) {
|
| index = (index + 1) % table_size; // Move to next element.
|
|
|