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#pragma once
27
28#include "ParserModes.h"
29
30namespace JSC {
31
32enum class DerivedContextType : uint8_t { None, DerivedConstructorContext, DerivedMethodContext };
33enum class EvalContextType : uint8_t { None, FunctionEvalContext };
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, JSParserScriptMode scriptMode, SuperBinding superBinding, SourceParseMode parseMode, DerivedContextType derivedContextType, bool isArrowFunctionContext, bool isClassContext, EvalContextType evalContextType)
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_scriptMode(static_cast<unsigned>(scriptMode))
46 , m_parseMode(parseMode)
47 , m_derivedContextType(static_cast<unsigned>(derivedContextType))
48 , m_isArrowFunctionContext(isArrowFunctionContext)
49 , m_isClassContext(isClassContext)
50 , m_evalContextType(static_cast<unsigned>(evalContextType))
51 {
52 ASSERT(m_constructorKind == static_cast<unsigned>(constructorKind));
53 ASSERT(m_superBinding == static_cast<unsigned>(superBinding));
54 ASSERT(m_scriptMode == static_cast<unsigned>(scriptMode));
55 }
56
57 bool usesEval() const { return m_usesEval; }
58 bool isStrictMode() const { return m_isStrictMode; }
59 bool isConstructor() const { return m_isConstructor; }
60 bool isBuiltinFunction() const { return m_isBuiltinFunction; }
61 ConstructorKind constructorKind() const { return static_cast<ConstructorKind>(m_constructorKind); }
62 SuperBinding superBinding() const { return static_cast<SuperBinding>(m_superBinding); }
63 JSParserScriptMode scriptMode() const { return static_cast<JSParserScriptMode>(m_scriptMode); }
64 SourceParseMode parseMode() const { return m_parseMode; }
65 DerivedContextType derivedContextType() const { return static_cast<DerivedContextType>(m_derivedContextType); }
66 EvalContextType evalContextType() const { return static_cast<EvalContextType>(m_evalContextType); }
67 bool isArrowFunctionContext() const { return m_isArrowFunctionContext; }
68 bool isClassContext() const { return m_isClassContext; }
69
70private:
71 unsigned m_usesEval : 1;
72 unsigned m_isStrictMode : 1;
73 unsigned m_isConstructor : 1;
74 unsigned m_isBuiltinFunction : 1;
75 unsigned m_constructorKind : 2;
76 unsigned m_superBinding : 1;
77 unsigned m_scriptMode: 1;
78 SourceParseMode m_parseMode;
79 unsigned m_derivedContextType : 2;
80 unsigned m_isArrowFunctionContext : 1;
81 unsigned m_isClassContext : 1;
82 unsigned m_evalContextType : 2;
83};
84
85} // namespace JSC
86