Debian Codegraph @

js/src/vm/CallNonGenericMethod.cpp

raw
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #include "js/CallNonGenericMethod.h"
8
9 #include "proxy/Proxy.h"
10 #include "vm/JSFunction.h"
11 #include "vm/JSObject.h"
12 #include "vm/ProxyObject.h"
13 #include "vm/SelfHosting.h"
14
15 using namespace js;
16
17 bool JS::detail::CallMethodIfWrapped(JSContext* cx, IsAcceptableThis test,
18 NativeImpl impl, const CallArgs& args) {
19 HandleValue thisv = args.thisv();
20 MOZ_ASSERT(!test(thisv));
21
22 if (thisv.isObject()) {
23 JSObject& thisObj = args.thisv().toObject();
24 if (thisObj.is<ProxyObject>()) {
25 return Proxy::nativeCall(cx, test, impl, args);
26 }
27 }
28
29 if (IsCallSelfHostedNonGenericMethod(impl)) {
30 return ReportIncompatibleSelfHostedMethod(cx, thisv);
31 }
32
33 ReportIncompatible(cx, args);
34 return false;
35 }