X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/93a3786624b2768d89bfa27e46598dc64e2fb70a..ed1e77d3adeb83d26fd1dfb16dd84cabdcefd250:/parser/ParserModes.h diff --git a/parser/ParserModes.h b/parser/ParserModes.h index a7383a3..edf0296 100644 --- a/parser/ParserModes.h +++ b/parser/ParserModes.h @@ -27,15 +27,47 @@ #ifndef ParserModes_h #define ParserModes_h +#include "Identifier.h" + namespace JSC { -enum JSParserStrictness { JSParseNormal, JSParseStrict }; -enum JSParserMode { JSParseProgramCode, JSParseFunctionCode }; +enum class JSParserStrictMode { NotStrict, Strict }; +enum class JSParserBuiltinMode { NotBuiltin, Builtin }; +enum class JSParserCodeType { Program, Function }; + +enum class ConstructorKind { None, Base, Derived }; +enum class SuperBinding { Needed, NotNeeded }; +enum class ThisTDZMode { AlwaysCheck, CheckIfNeeded }; enum ProfilerMode { ProfilerOff, ProfilerOn }; enum DebuggerMode { DebuggerOff, DebuggerOn }; -enum FunctionNameIsInScopeToggle { FunctionNameIsNotInScope, FunctionNameIsInScope }; +enum FunctionMode { FunctionExpression, FunctionDeclaration }; + +inline bool functionNameIsInScope(const Identifier& name, FunctionMode functionMode) +{ + if (name.isNull()) + return false; + + if (functionMode != FunctionExpression) + return false; + + return true; +} + +inline bool functionNameScopeIsDynamic(bool usesEval, bool isStrictMode) +{ + // If non-strict eval is in play, a function gets a separate object in the scope chain for its name. + // This enables eval to declare and then delete a name that shadows the function's name. + + if (!usesEval) + return false; + + if (isStrictMode) + return false; + + return true; +} typedef unsigned CodeFeatures; @@ -47,8 +79,10 @@ const CodeFeatures CatchFeature = 1 << 3; const CodeFeatures ThisFeature = 1 << 4; const CodeFeatures StrictModeFeature = 1 << 5; const CodeFeatures ShadowsArgumentsFeature = 1 << 6; +const CodeFeatures ModifiedParameterFeature = 1 << 7; +const CodeFeatures ModifiedArgumentsFeature = 1 << 8; -const CodeFeatures AllFeatures = EvalFeature | ArgumentsFeature | WithFeature | CatchFeature | ThisFeature | StrictModeFeature | ShadowsArgumentsFeature; +const CodeFeatures AllFeatures = EvalFeature | ArgumentsFeature | WithFeature | CatchFeature | ThisFeature | StrictModeFeature | ShadowsArgumentsFeature | ModifiedParameterFeature; } // namespace JSC