]>
Commit | Line | Data |
---|---|---|
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 | ||
93a37866 A |
26 | #ifndef ResolveGlobalStatus_h |
27 | #define ResolveGlobalStatus_h | |
28 | ||
29 | #include "JSCJSValue.h" | |
30 | #include "PropertyOffset.h" | |
31 | #include <wtf/NotFound.h> | |
6fe7ccc8 A |
32 | |
33 | namespace JSC { | |
34 | ||
35 | class CodeBlock; | |
93a37866 A |
36 | class Identifier; |
37 | struct ResolveOperation; | |
6fe7ccc8 A |
38 | class Structure; |
39 | ||
93a37866 | 40 | class ResolveGlobalStatus { |
6fe7ccc8 | 41 | public: |
93a37866 A |
42 | enum State { |
43 | NoInformation, | |
44 | Simple, | |
45 | TakesSlowPath | |
46 | }; | |
47 | ||
48 | ResolveGlobalStatus() | |
49 | : m_state(NoInformation) | |
50 | , m_structure(0) | |
51 | , m_offset(invalidOffset) | |
6fe7ccc8 A |
52 | { |
53 | } | |
54 | ||
93a37866 A |
55 | ResolveGlobalStatus( |
56 | State state, Structure* structure = 0, PropertyOffset offset = invalidOffset, | |
57 | JSValue specificValue = JSValue()) | |
58 | : m_state(state) | |
59 | , m_structure(structure) | |
60 | , m_offset(offset) | |
61 | , m_specificValue(specificValue) | |
6fe7ccc8 | 62 | { |
6fe7ccc8 A |
63 | } |
64 | ||
93a37866 | 65 | static ResolveGlobalStatus computeFor(CodeBlock*, int bytecodeIndex, ResolveOperation*, Identifier&); |
6fe7ccc8 | 66 | |
93a37866 | 67 | State state() const { return m_state; } |
6fe7ccc8 | 68 | |
93a37866 A |
69 | bool isSet() const { return m_state != NoInformation; } |
70 | bool operator!() const { return !isSet(); } | |
71 | bool isSimple() const { return m_state == Simple; } | |
72 | bool takesSlowPath() const { return m_state == TakesSlowPath; } | |
6fe7ccc8 | 73 | |
93a37866 A |
74 | Structure* structure() const { return m_structure; } |
75 | PropertyOffset offset() const { return m_offset; } | |
76 | JSValue specificValue() const { return m_specificValue; } | |
77 | ||
6fe7ccc8 | 78 | private: |
93a37866 | 79 | State m_state; |
6fe7ccc8 | 80 | Structure* m_structure; |
93a37866 A |
81 | PropertyOffset m_offset; |
82 | JSValue m_specificValue; | |
83 | }; // class ResolveGlobalStatus | |
6fe7ccc8 A |
84 | |
85 | } // namespace JSC | |
86 | ||
93a37866 | 87 | #endif // ResolveGlobalStatus_h |
6fe7ccc8 | 88 |