1/*
2 * Copyright (C) 2012-2015 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 ExecutableInfo_h
27#define ExecutableInfo_h
28
29#include "ParserModes.h"
30
31namespace JSC {
32
33enum class DerivedContextType : uint8_t { None, DerivedConstructorContext, DerivedMethodContext };
34
35// FIXME: These flags, ParserModes and propagation to XXXCodeBlocks should be reorganized.
36// https://bugs.webkit.org/show_bug.cgi?id=151547
37struct ExecutableInfo {
38 ExecutableInfo(bool usesEval, bool isStrictMode, bool isConstructor, bool isBuiltinFunction, ConstructorKind constructorKind, SuperBinding superBinding, SourceParseMode parseMode, DerivedContextType derivedContextType, bool isArrowFunctionContext, bool isClassContext)
39 : m_usesEval(usesEval)
40 , m_isStrictMode(isStrictMode)
41 , m_isConstructor(isConstructor)
42 , m_isBuiltinFunction(isBuiltinFunction)
43 , m_constructorKind(static_cast<unsigned>(constructorKind))
44 , m_superBinding(static_cast<unsigned>(superBinding))
45 , m_parseMode(parseMode)
46 , m_derivedContextType(static_cast<unsigned>(derivedContextType))
47 , m_isArrowFunctionContext(isArrowFunctionContext)
48 , m_isClassContext(isClassContext)
49 {
50 ASSERT(m_constructorKind == static_cast<unsigned>(constructorKind));
51 ASSERT(m_superBinding == static_cast<unsigned>(superBinding));
52 }
53
54 bool usesEval() const { return m_usesEval; }
55 bool isStrictMode() const { return m_isStrictMode; }
56 bool isConstructor() const { return m_isConstructor; }
57 bool isBuiltinFunction() const { return m_isBuiltinFunction; }
58 ConstructorKind constructorKind() const { return static_cast<ConstructorKind>(m_constructorKind); }
59 SuperBinding superBinding() const { return static_cast<SuperBinding>(m_superBinding); }
60 SourceParseMode parseMode() const { return m_parseMode; }
61 DerivedContextType derivedContextType() const { return static_cast<DerivedContextType>(m_derivedContextType); }
62 bool isArrowFunctionContext() const { return m_isArrowFunctionContext; }
63 bool isClassContext() const { return m_isClassContext; }
64
65private:
66 unsigned m_usesEval : 1;
67 unsigned m_isStrictMode : 1;
68 unsigned m_isConstructor : 1;
69 unsigned m_isBuiltinFunction : 1;
70 unsigned m_constructorKind : 2;
71 unsigned m_superBinding : 1;
72 SourceParseMode m_parseMode;
73 unsigned m_derivedContextType : 2;
74 unsigned m_isArrowFunctionContext : 1;
75 unsigned m_isClassContext : 1;
76};
77
78} // namespace JSC
79
80#endif // ExecutableInfo_h
81