OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 reinterpret_cast<AccessorDescriptor*>( | 171 reinterpret_cast<AccessorDescriptor*>( |
172 Foreign::cast(structure)->foreign_address()); | 172 Foreign::cast(structure)->foreign_address()); |
173 MaybeObject* value = (callback->getter)(receiver, callback->data); | 173 MaybeObject* value = (callback->getter)(receiver, callback->data); |
174 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 174 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
175 return value; | 175 return value; |
176 } | 176 } |
177 | 177 |
178 // api style callbacks. | 178 // api style callbacks. |
179 if (structure->IsAccessorInfo()) { | 179 if (structure->IsAccessorInfo()) { |
180 AccessorInfo* data = AccessorInfo::cast(structure); | 180 AccessorInfo* data = AccessorInfo::cast(structure); |
| 181 if (!data->IsCompatibleReceiver(receiver)) { |
| 182 Handle<Object> name_handle(name); |
| 183 Handle<Object> receiver_handle(receiver); |
| 184 Handle<Object> args[2] = { name_handle, receiver_handle }; |
| 185 Handle<Object> error = |
| 186 isolate->factory()->NewTypeError("incompatible_method_receiver", |
| 187 HandleVector(args, |
| 188 ARRAY_SIZE(args))); |
| 189 return isolate->Throw(*error); |
| 190 } |
181 Object* fun_obj = data->getter(); | 191 Object* fun_obj = data->getter(); |
182 v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj); | 192 v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj); |
183 HandleScope scope(isolate); | 193 HandleScope scope(isolate); |
184 JSObject* self = JSObject::cast(receiver); | 194 JSObject* self = JSObject::cast(receiver); |
185 Handle<String> key(name); | 195 Handle<String> key(name); |
186 LOG(isolate, ApiNamedPropertyAccess("load", self, name)); | 196 LOG(isolate, ApiNamedPropertyAccess("load", self, name)); |
187 CustomArguments args(isolate, data->data(), self, this); | 197 CustomArguments args(isolate, data->data(), self, this); |
188 v8::AccessorInfo info(args.end()); | 198 v8::AccessorInfo info(args.end()); |
189 v8::Handle<v8::Value> result; | 199 v8::Handle<v8::Value> result; |
190 { | 200 { |
(...skipping 1786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1977 Foreign::cast(structure)->foreign_address()); | 1987 Foreign::cast(structure)->foreign_address()); |
1978 MaybeObject* obj = (callback->setter)(this, value, callback->data); | 1988 MaybeObject* obj = (callback->setter)(this, value, callback->data); |
1979 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 1989 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
1980 if (obj->IsFailure()) return obj; | 1990 if (obj->IsFailure()) return obj; |
1981 return *value_handle; | 1991 return *value_handle; |
1982 } | 1992 } |
1983 | 1993 |
1984 if (structure->IsAccessorInfo()) { | 1994 if (structure->IsAccessorInfo()) { |
1985 // api style callbacks | 1995 // api style callbacks |
1986 AccessorInfo* data = AccessorInfo::cast(structure); | 1996 AccessorInfo* data = AccessorInfo::cast(structure); |
| 1997 if (!data->IsCompatibleReceiver(this)) { |
| 1998 Handle<Object> name_handle(name); |
| 1999 Handle<Object> receiver_handle(this); |
| 2000 Handle<Object> args[2] = { name_handle, receiver_handle }; |
| 2001 Handle<Object> error = |
| 2002 isolate->factory()->NewTypeError("incompatible_method_receiver", |
| 2003 HandleVector(args, |
| 2004 ARRAY_SIZE(args))); |
| 2005 return isolate->Throw(*error); |
| 2006 } |
1987 Object* call_obj = data->setter(); | 2007 Object* call_obj = data->setter(); |
1988 v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj); | 2008 v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj); |
1989 if (call_fun == NULL) return value; | 2009 if (call_fun == NULL) return value; |
1990 Handle<String> key(name); | 2010 Handle<String> key(name); |
1991 LOG(isolate, ApiNamedPropertyAccess("store", this, name)); | 2011 LOG(isolate, ApiNamedPropertyAccess("store", this, name)); |
1992 CustomArguments args(isolate, data->data(), this, JSObject::cast(holder)); | 2012 CustomArguments args(isolate, data->data(), this, JSObject::cast(holder)); |
1993 v8::AccessorInfo info(args.end()); | 2013 v8::AccessorInfo info(args.end()); |
1994 { | 2014 { |
1995 // Leaving JavaScript. | 2015 // Leaving JavaScript. |
1996 VMState state(isolate, EXTERNAL); | 2016 VMState state(isolate, EXTERNAL); |
(...skipping 11300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13297 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13317 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13298 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13318 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13299 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13319 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13300 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13320 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13301 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13321 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13302 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13322 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13303 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13323 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13304 } | 13324 } |
13305 | 13325 |
13306 } } // namespace v8::internal | 13326 } } // namespace v8::internal |
OLD | NEW |