ProxyObject.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. /*
  2. * Copyright (c) 2020, Matthew Olsson <matthewcolsson@gmail.com>
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice, this
  9. * list of conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  16. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  19. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  20. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  21. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  22. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  23. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  24. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #include <LibJS/Runtime/Accessor.h>
  27. #include <LibJS/Runtime/Array.h>
  28. #include <LibJS/Runtime/Error.h>
  29. #include <LibJS/Runtime/GlobalObject.h>
  30. #include <LibJS/Runtime/ProxyObject.h>
  31. namespace JS {
  32. bool static is_compatible_property_descriptor(bool is_extensible, PropertyDescriptor new_descriptor, Optional<PropertyDescriptor> current_descriptor_optional)
  33. {
  34. if (!current_descriptor_optional.has_value())
  35. return is_extensible;
  36. auto current_descriptor = current_descriptor_optional.value();
  37. if (new_descriptor.attributes.is_empty() && new_descriptor.value.is_empty() && !new_descriptor.getter && !new_descriptor.setter)
  38. return true;
  39. if (!current_descriptor.attributes.is_configurable()) {
  40. if (new_descriptor.attributes.is_configurable())
  41. return false;
  42. if (new_descriptor.attributes.has_enumerable() && new_descriptor.attributes.is_enumerable() != current_descriptor.attributes.is_enumerable())
  43. return false;
  44. }
  45. if (new_descriptor.is_generic_descriptor())
  46. return true;
  47. if (current_descriptor.is_data_descriptor() != new_descriptor.is_data_descriptor() && !current_descriptor.attributes.is_configurable())
  48. return false;
  49. if (current_descriptor.is_data_descriptor() && new_descriptor.is_data_descriptor() && !current_descriptor.attributes.is_configurable() && !current_descriptor.attributes.is_writable()) {
  50. if (new_descriptor.attributes.is_writable())
  51. return false;
  52. return new_descriptor.value.is_empty() && same_value(new_descriptor.value, current_descriptor.value);
  53. }
  54. return true;
  55. }
  56. ProxyObject* ProxyObject::create(GlobalObject& global_object, Object& target, Object& handler)
  57. {
  58. return global_object.heap().allocate<ProxyObject>(global_object, target, handler, *global_object.proxy_prototype());
  59. }
  60. ProxyObject::ProxyObject(Object& target, Object& handler, Object& prototype)
  61. : Function(prototype)
  62. , m_target(target)
  63. , m_handler(handler)
  64. {
  65. }
  66. ProxyObject::~ProxyObject()
  67. {
  68. }
  69. Object* ProxyObject::prototype()
  70. {
  71. if (m_is_revoked) {
  72. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyRevoked);
  73. return nullptr;
  74. }
  75. auto trap = m_handler.get("getPrototypeOf");
  76. if (vm().exception())
  77. return nullptr;
  78. if (trap.is_empty() || trap.is_undefined() || trap.is_null())
  79. return m_target.prototype();
  80. if (!trap.is_function()) {
  81. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyInvalidTrap, "getPrototypeOf");
  82. return nullptr;
  83. }
  84. auto trap_result = vm().call(trap.as_function(), Value(&m_handler), Value(&m_target));
  85. if (vm().exception())
  86. return nullptr;
  87. if (!trap_result.is_object() && !trap_result.is_null()) {
  88. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyGetPrototypeOfReturn);
  89. return nullptr;
  90. }
  91. if (m_target.is_extensible()) {
  92. if (vm().exception())
  93. return nullptr;
  94. if (trap_result.is_null())
  95. return nullptr;
  96. return &trap_result.as_object();
  97. }
  98. auto target_proto = m_target.prototype();
  99. if (vm().exception())
  100. return nullptr;
  101. if (!same_value(trap_result, Value(target_proto))) {
  102. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyGetPrototypeOfNonExtensible);
  103. return nullptr;
  104. }
  105. return &trap_result.as_object();
  106. }
  107. const Object* ProxyObject::prototype() const
  108. {
  109. if (m_is_revoked) {
  110. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyRevoked);
  111. return nullptr;
  112. }
  113. return const_cast<const Object*>(const_cast<ProxyObject*>(this)->prototype());
  114. }
  115. bool ProxyObject::set_prototype(Object* object)
  116. {
  117. if (m_is_revoked) {
  118. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyRevoked);
  119. return false;
  120. }
  121. auto trap = m_handler.get("setPrototypeOf");
  122. if (vm().exception())
  123. return false;
  124. if (trap.is_empty() || trap.is_undefined() || trap.is_null())
  125. return m_target.set_prototype(object);
  126. if (!trap.is_function()) {
  127. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyInvalidTrap, "setPrototypeOf");
  128. return false;
  129. }
  130. auto trap_result = vm().call(trap.as_function(), Value(&m_handler), Value(&m_target), Value(object)).to_boolean();
  131. if (vm().exception() || !trap_result)
  132. return false;
  133. if (m_target.is_extensible())
  134. return true;
  135. auto* target_proto = m_target.prototype();
  136. if (vm().exception())
  137. return false;
  138. if (!same_value(Value(object), Value(target_proto))) {
  139. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxySetPrototypeOfNonExtensible);
  140. return false;
  141. }
  142. return true;
  143. }
  144. bool ProxyObject::is_extensible() const
  145. {
  146. if (m_is_revoked) {
  147. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyRevoked);
  148. return false;
  149. }
  150. auto trap = m_handler.get("isExtensible");
  151. if (vm().exception())
  152. return false;
  153. if (trap.is_empty() || trap.is_undefined() || trap.is_null())
  154. return m_target.is_extensible();
  155. if (!trap.is_function()) {
  156. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyInvalidTrap, "isExtensible");
  157. return {};
  158. }
  159. auto trap_result = vm().call(trap.as_function(), Value(&m_handler), Value(&m_target)).to_boolean();
  160. if (vm().exception())
  161. return false;
  162. if (trap_result != m_target.is_extensible()) {
  163. if (!vm().exception())
  164. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyIsExtensibleReturn);
  165. return false;
  166. }
  167. return trap_result;
  168. }
  169. bool ProxyObject::prevent_extensions()
  170. {
  171. if (m_is_revoked) {
  172. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyRevoked);
  173. return false;
  174. }
  175. auto trap = m_handler.get("preventExtensions");
  176. if (vm().exception())
  177. return false;
  178. if (trap.is_empty() || trap.is_undefined() || trap.is_null())
  179. return m_target.prevent_extensions();
  180. if (!trap.is_function()) {
  181. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyInvalidTrap, "preventExtensions");
  182. return {};
  183. }
  184. auto trap_result = vm().call(trap.as_function(), Value(&m_handler), Value(&m_target)).to_boolean();
  185. if (vm().exception())
  186. return false;
  187. if (trap_result && m_target.is_extensible()) {
  188. if (!vm().exception())
  189. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyPreventExtensionsReturn);
  190. return false;
  191. }
  192. return trap_result;
  193. }
  194. Optional<PropertyDescriptor> ProxyObject::get_own_property_descriptor(const PropertyName& name) const
  195. {
  196. if (m_is_revoked) {
  197. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyRevoked);
  198. return {};
  199. }
  200. auto trap = m_handler.get("getOwnPropertyDescriptor");
  201. if (vm().exception())
  202. return {};
  203. if (trap.is_empty() || trap.is_undefined() || trap.is_null())
  204. return m_target.get_own_property_descriptor(name);
  205. if (!trap.is_function()) {
  206. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyInvalidTrap, "getOwnPropertyDescriptor");
  207. return {};
  208. }
  209. auto trap_result = vm().call(trap.as_function(), Value(&m_handler), Value(&m_target), js_string(vm(), name.to_string()));
  210. if (vm().exception())
  211. return {};
  212. if (!trap_result.is_object() && !trap_result.is_undefined()) {
  213. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyGetOwnDescriptorReturn);
  214. return {};
  215. }
  216. auto target_desc = m_target.get_own_property_descriptor(name);
  217. if (vm().exception())
  218. return {};
  219. if (trap_result.is_undefined()) {
  220. if (!target_desc.has_value())
  221. return {};
  222. if (!target_desc.value().attributes.is_configurable()) {
  223. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyGetOwnDescriptorNonConfigurable);
  224. return {};
  225. }
  226. if (!m_target.is_extensible()) {
  227. if (!vm().exception())
  228. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyGetOwnDescriptorUndefReturn);
  229. return {};
  230. }
  231. return {};
  232. }
  233. auto result_desc = PropertyDescriptor::from_dictionary(vm(), trap_result.as_object());
  234. if (vm().exception())
  235. return {};
  236. if (!is_compatible_property_descriptor(m_target.is_extensible(), result_desc, target_desc)) {
  237. if (!vm().exception())
  238. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyGetOwnDescriptorInvalidDescriptor);
  239. return {};
  240. }
  241. if (!result_desc.attributes.is_configurable() && (!target_desc.has_value() || target_desc.value().attributes.is_configurable())) {
  242. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyGetOwnDescriptorInvalidNonConfig);
  243. return {};
  244. }
  245. return result_desc;
  246. }
  247. bool ProxyObject::define_property(const StringOrSymbol& property_name, const Object& descriptor, bool throw_exceptions)
  248. {
  249. if (m_is_revoked) {
  250. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyRevoked);
  251. return false;
  252. }
  253. auto trap = m_handler.get("defineProperty");
  254. if (vm().exception())
  255. return false;
  256. if (trap.is_empty() || trap.is_undefined() || trap.is_null())
  257. return m_target.define_property(property_name, descriptor, throw_exceptions);
  258. if (!trap.is_function()) {
  259. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyInvalidTrap, "defineProperty");
  260. return false;
  261. }
  262. auto trap_result = vm().call(trap.as_function(), Value(&m_handler), Value(&m_target), property_name.to_value(vm()), Value(const_cast<Object*>(&descriptor))).to_boolean();
  263. if (vm().exception() || !trap_result)
  264. return false;
  265. auto target_desc = m_target.get_own_property_descriptor(property_name);
  266. if (vm().exception())
  267. return false;
  268. bool setting_config_false = false;
  269. if (descriptor.has_property("configurable") && !descriptor.get("configurable").to_boolean())
  270. setting_config_false = true;
  271. if (vm().exception())
  272. return false;
  273. if (!target_desc.has_value()) {
  274. if (!m_target.is_extensible()) {
  275. if (!vm().exception())
  276. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyDefinePropNonExtensible);
  277. return false;
  278. }
  279. if (setting_config_false) {
  280. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyDefinePropNonConfigurableNonExisting);
  281. return false;
  282. }
  283. } else {
  284. if (!is_compatible_property_descriptor(m_target.is_extensible(), PropertyDescriptor::from_dictionary(vm(), descriptor), target_desc)) {
  285. if (!vm().exception())
  286. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyDefinePropIncompatibleDescriptor);
  287. return false;
  288. }
  289. if (setting_config_false && target_desc.value().attributes.is_configurable()) {
  290. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyDefinePropExistingConfigurable);
  291. return false;
  292. }
  293. }
  294. return true;
  295. }
  296. bool ProxyObject::has_property(const PropertyName& name) const
  297. {
  298. if (m_is_revoked) {
  299. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyRevoked);
  300. return false;
  301. }
  302. auto trap = m_handler.get("has");
  303. if (vm().exception())
  304. return false;
  305. if (trap.is_empty() || trap.is_undefined() || trap.is_null())
  306. return m_target.has_property(name);
  307. if (!trap.is_function()) {
  308. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyInvalidTrap, "has");
  309. return false;
  310. }
  311. auto trap_result = vm().call(trap.as_function(), Value(&m_handler), Value(&m_target), js_string(vm(), name.to_string())).to_boolean();
  312. if (vm().exception())
  313. return false;
  314. if (!trap_result) {
  315. auto target_desc = m_target.get_own_property_descriptor(name);
  316. if (vm().exception())
  317. return false;
  318. if (target_desc.has_value()) {
  319. if (!target_desc.value().attributes.is_configurable()) {
  320. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyHasExistingNonConfigurable);
  321. return false;
  322. }
  323. if (!m_target.is_extensible()) {
  324. if (!vm().exception())
  325. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyHasExistingNonExtensible);
  326. return false;
  327. }
  328. }
  329. }
  330. return trap_result;
  331. }
  332. Value ProxyObject::get(const PropertyName& name, Value) const
  333. {
  334. if (m_is_revoked) {
  335. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyRevoked);
  336. return {};
  337. }
  338. auto trap = m_handler.get("get");
  339. if (vm().exception())
  340. return {};
  341. if (trap.is_empty() || trap.is_undefined() || trap.is_null())
  342. return m_target.get(name);
  343. if (!trap.is_function()) {
  344. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyInvalidTrap, "get");
  345. return {};
  346. }
  347. auto trap_result = vm().call(trap.as_function(), Value(&m_handler), Value(&m_target), js_string(vm(), name.to_string()), Value(const_cast<ProxyObject*>(this)));
  348. if (vm().exception())
  349. return {};
  350. auto target_desc = m_target.get_own_property_descriptor(name);
  351. if (target_desc.has_value()) {
  352. if (vm().exception())
  353. return {};
  354. if (target_desc.value().is_data_descriptor() && !target_desc.value().attributes.is_writable() && !same_value(trap_result, target_desc.value().value)) {
  355. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyGetImmutableDataProperty);
  356. return {};
  357. }
  358. if (target_desc.value().is_accessor_descriptor() && target_desc.value().getter == nullptr && !trap_result.is_undefined()) {
  359. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyGetNonConfigurableAccessor);
  360. return {};
  361. }
  362. }
  363. return trap_result;
  364. }
  365. bool ProxyObject::put(const PropertyName& name, Value value, Value)
  366. {
  367. if (m_is_revoked) {
  368. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyRevoked);
  369. return false;
  370. }
  371. auto trap = m_handler.get("set");
  372. if (vm().exception())
  373. return false;
  374. if (trap.is_empty() || trap.is_undefined() || trap.is_null())
  375. return m_target.put(name, value);
  376. if (!trap.is_function()) {
  377. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyInvalidTrap, "set");
  378. return false;
  379. }
  380. auto trap_result = vm().call(trap.as_function(), Value(&m_handler), Value(&m_target), js_string(vm(), name.to_string()), value, Value(const_cast<ProxyObject*>(this))).to_boolean();
  381. if (vm().exception() || !trap_result)
  382. return false;
  383. auto target_desc = m_target.get_own_property_descriptor(name);
  384. if (vm().exception())
  385. return false;
  386. if (target_desc.has_value() && !target_desc.value().attributes.is_configurable()) {
  387. if (target_desc.value().is_data_descriptor() && !target_desc.value().attributes.is_writable() && !same_value(value, target_desc.value().value)) {
  388. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxySetImmutableDataProperty);
  389. return false;
  390. }
  391. if (target_desc.value().is_accessor_descriptor() && !target_desc.value().setter) {
  392. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxySetNonConfigurableAccessor);
  393. }
  394. }
  395. return true;
  396. }
  397. Value ProxyObject::delete_property(const PropertyName& name)
  398. {
  399. if (m_is_revoked) {
  400. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyRevoked);
  401. return {};
  402. }
  403. auto trap = m_handler.get("deleteProperty");
  404. if (vm().exception())
  405. return {};
  406. if (trap.is_empty() || trap.is_undefined() || trap.is_null())
  407. return m_target.delete_property(name);
  408. if (!trap.is_function()) {
  409. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyInvalidTrap, "deleteProperty");
  410. return {};
  411. }
  412. auto trap_result = vm().call(trap.as_function(), Value(&m_handler), Value(&m_target), js_string(vm(), name.to_string())).to_boolean();
  413. if (vm().exception())
  414. return {};
  415. if (!trap_result)
  416. return Value(false);
  417. auto target_desc = m_target.get_own_property_descriptor(name);
  418. if (vm().exception())
  419. return {};
  420. if (!target_desc.has_value())
  421. return Value(true);
  422. if (!target_desc.value().attributes.is_configurable()) {
  423. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyDeleteNonConfigurable);
  424. return {};
  425. }
  426. return Value(true);
  427. }
  428. void ProxyObject::visit_children(Cell::Visitor& visitor)
  429. {
  430. Function::visit_children(visitor);
  431. visitor.visit(&m_target);
  432. visitor.visit(&m_handler);
  433. }
  434. Value ProxyObject::call()
  435. {
  436. if (!is_function()) {
  437. vm().throw_exception<TypeError>(global_object(), ErrorType::NotAFunction, Value(this).to_string_without_side_effects().characters());
  438. return {};
  439. }
  440. if (m_is_revoked) {
  441. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyRevoked);
  442. return {};
  443. }
  444. auto trap = m_handler.get("apply");
  445. if (vm().exception())
  446. return {};
  447. if (trap.is_empty() || trap.is_undefined() || trap.is_null())
  448. return static_cast<Function&>(m_target).call();
  449. if (!trap.is_function()) {
  450. vm().throw_exception<TypeError>(global_object(), ErrorType::ProxyInvalidTrap, "apply");
  451. return {};
  452. }
  453. MarkedValueList arguments(heap());
  454. arguments.append(Value(&m_target));
  455. arguments.append(Value(&m_handler));
  456. // FIXME: Pass global object
  457. auto arguments_array = Array::create(global_object());
  458. vm().for_each_argument([&](auto& argument) {
  459. arguments_array->indexed_properties().append(argument);
  460. });
  461. arguments.append(arguments_array);
  462. return vm().call(trap.as_function(), Value(&m_handler), move(arguments));
  463. }
  464. Value ProxyObject::construct(Function& new_target)
  465. {
  466. auto& vm = this->vm();
  467. if (!is_function()) {
  468. vm.throw_exception<TypeError>(global_object(), ErrorType::NotAConstructor, Value(this).to_string_without_side_effects().characters());
  469. return {};
  470. }
  471. if (m_is_revoked) {
  472. vm.throw_exception<TypeError>(global_object(), ErrorType::ProxyRevoked);
  473. return {};
  474. }
  475. auto trap = m_handler.get("construct");
  476. if (vm.exception())
  477. return {};
  478. if (trap.is_empty() || trap.is_undefined() || trap.is_null())
  479. return static_cast<Function&>(m_target).construct(new_target);
  480. if (!trap.is_function()) {
  481. vm.throw_exception<TypeError>(global_object(), ErrorType::ProxyInvalidTrap, "construct");
  482. return {};
  483. }
  484. MarkedValueList arguments(vm.heap());
  485. arguments.append(Value(&m_target));
  486. auto arguments_array = Array::create(global_object());
  487. vm.for_each_argument([&](auto& argument) {
  488. arguments_array->indexed_properties().append(argument);
  489. });
  490. arguments.append(arguments_array);
  491. arguments.append(Value(&new_target));
  492. auto result = vm.call(trap.as_function(), Value(&m_handler), move(arguments));
  493. if (!result.is_object()) {
  494. vm.throw_exception<TypeError>(global_object(), ErrorType::ProxyConstructBadReturnType);
  495. return {};
  496. }
  497. return result;
  498. }
  499. const FlyString& ProxyObject::name() const
  500. {
  501. ASSERT(is_function());
  502. return static_cast<Function&>(m_target).name();
  503. }
  504. LexicalEnvironment* ProxyObject::create_environment()
  505. {
  506. ASSERT(is_function());
  507. return static_cast<Function&>(m_target).create_environment();
  508. }
  509. }