]> git.saurik.com Git - apple/javascriptcore.git/blame - bytecode/MethodCallLinkStatus.h
JavaScriptCore-1097.13.tar.gz
[apple/javascriptcore.git] / bytecode / MethodCallLinkStatus.h
CommitLineData
6fe7ccc8
A
1/*
2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#ifndef MethodCallLinkStatus_h
27#define MethodCallLinkStatus_h
28
29namespace JSC {
30
31class CodeBlock;
32class JSObject;
33class Structure;
34
35class MethodCallLinkStatus {
36public:
37 MethodCallLinkStatus()
38 : m_structure(0)
39 , m_prototypeStructure(0)
40 , m_function(0)
41 , m_prototype(0)
42 {
43 }
44
45 MethodCallLinkStatus(
46 Structure* structure,
47 Structure* prototypeStructure,
48 JSObject* function,
49 JSObject* prototype)
50 : m_structure(structure)
51 , m_prototypeStructure(prototypeStructure)
52 , m_function(function)
53 , m_prototype(prototype)
54 {
55 if (!m_function) {
56 ASSERT(!m_structure);
57 ASSERT(!m_prototypeStructure);
58 ASSERT(!m_prototype);
59 } else
60 ASSERT(m_structure);
61
62 ASSERT(!m_prototype == !m_prototypeStructure);
63 }
64
65 static MethodCallLinkStatus computeFor(CodeBlock*, unsigned bytecodeIndex);
66
67 bool isSet() const { return !!m_function; }
68 bool operator!() const { return !m_function; }
69
70 bool needsPrototypeCheck() const { return !!m_prototype; }
71
72 Structure* structure() { return m_structure; }
73 Structure* prototypeStructure() { return m_prototypeStructure; }
74 JSObject* function() const { return m_function; }
75 JSObject* prototype() const { return m_prototype; }
76
77private:
78 Structure* m_structure;
79 Structure* m_prototypeStructure;
80 JSObject* m_function;
81 JSObject* m_prototype;
82};
83
84} // namespace JSC
85
86#endif // MethodCallLinkStatus_h
87