ProxyObject.cpp 21 KB

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