source: webkit/trunk/Source/JavaScriptCore/parser/SyntaxChecker.h

Last change on this file was 288473, checked in by [email protected], 3 years ago

[JSC] Support import assertion syntax
https://bugs.webkit.org/show_bug.cgi?id=235312

Reviewed by Ross Kirsling.

JSTests:

  • modules/import-meta-syntax.js:

(shouldThrow):

  • stress/import-syntax.js:
  • stress/modules-syntax-error.js:
  • stress/modules-syntax-import-assertion-error.js: Added.

(shouldThrow):

  • stress/modules-syntax-import-assertion.js: Added.

LayoutTests/imported/w3c:

  • web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/css-module-worker-test-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-dynamic-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/import-assertions/dynamic-import-with-assertion-argument.any-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/import-assertions/dynamic-import-with-assertion-argument.any.worker-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/charset-bom.any-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/charset-bom.any.worker-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/invalid-content-type.any-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/invalid-content-type.any.worker-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/json-module-service-worker-test.https-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.any-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.any.worker-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any.worker-expected.txt:
  • web-platform-tests/service-workers/service-worker/dedicated-worker-service-worker-interception.https-expected.txt:
  • web-platform-tests/workers/dedicated-worker-parse-error-failure-expected.txt:
  • web-platform-tests/workers/modules/dedicated-worker-options-credentials-expected.txt:

Source/JavaScriptCore:

This patch adds syntax support for import assertion[1].
This does not add the actual feature propagating import assertion
to the module request yet.

[1]: https://github.com/tc39/proposal-import-assertions

  • bytecompiler/NodesCodegen.cpp:

(JSC::ImportNode::emitBytecode):

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createImportExpr):
(JSC::ASTBuilder::createImportAssertionList):
(JSC::ASTBuilder::appendImportAssertion):
(JSC::ASTBuilder::createImportDeclaration):
(JSC::ASTBuilder::createExportAllDeclaration):
(JSC::ASTBuilder::createExportNamedDeclaration):

  • parser/NodeConstructors.h:

(JSC::ImportNode::ImportNode):
(JSC::ImportDeclarationNode::ImportDeclarationNode):
(JSC::ExportAllDeclarationNode::ExportAllDeclarationNode):
(JSC::ExportNamedDeclarationNode::ExportNamedDeclarationNode):

  • parser/Nodes.h:
  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseImportAssertions):
(JSC::Parser<LexerType>::parseImportDeclaration):
(JSC::Parser<LexerType>::parseExportDeclaration):
(JSC::Parser<LexerType>::parseMemberExpression):

  • parser/Parser.h:
  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createImportExpr):
(JSC::SyntaxChecker::createImportAssertionList):
(JSC::SyntaxChecker::appendImportAssertion):
(JSC::SyntaxChecker::createImportDeclaration):
(JSC::SyntaxChecker::createExportAllDeclaration):
(JSC::SyntaxChecker::createExportNamedDeclaration):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):

  • runtime/OptionsList.h:
  • Property svn:eol-style set to native
File size: 25.0 KB
Line 
1/*
2 * Copyright (C) 2010-2019 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. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#pragma once
27
28#include "Lexer.h"
29#include "ParserFunctionInfo.h"
30#include "YarrSyntaxChecker.h"
31
32namespace JSC {
33
34class SyntaxChecker {
35public:
36 struct BinaryExprContext {
37 BinaryExprContext(SyntaxChecker& context)
38 : m_context(&context)
39 {
40 m_token = m_context->m_topBinaryExpr;
41 m_context->m_topBinaryExpr = 0;
42 }
43 ~BinaryExprContext()
44 {
45 m_context->m_topBinaryExpr = m_token;
46 }
47 private:
48 int m_token;
49 SyntaxChecker* m_context;
50 };
51 struct UnaryExprContext {
52 UnaryExprContext(SyntaxChecker& context)
53 : m_context(&context)
54 {
55 m_token = m_context->m_topUnaryToken;
56 m_context->m_topUnaryToken = 0;
57 }
58 ~UnaryExprContext()
59 {
60 m_context->m_topUnaryToken = m_token;
61 }
62 private:
63 int m_token;
64 SyntaxChecker* m_context;
65 };
66
67 SyntaxChecker(VM& vm, void*)
68 : m_vm(vm)
69 {
70 }
71
72 static const constexpr int MetaPropertyBit = 0x80000000;
73 enum : int { NoneExpr = 0,
74 ResolveEvalExpr, ResolveExpr, IntegerExpr, DoubleExpr, StringExpr, BigIntExpr,
75 ThisExpr, NullExpr, BoolExpr, RegExpExpr, ObjectLiteralExpr,
76 FunctionExpr, ClassExpr, SuperExpr, ImportExpr, BracketExpr, DotExpr, CallExpr,
77 NewExpr, PreExpr, PostExpr, UnaryExpr, BinaryExpr, OptionalChain, PrivateDotExpr,
78 ConditionalExpr, AssignmentExpr, TypeofExpr,
79 DeleteExpr, ArrayLiteralExpr, BindingDestructuring, RestParameter,
80 ArrayDestructuring, ObjectDestructuring, SourceElementsResult,
81 FunctionBodyResult, SpreadExpr, ObjectSpreadExpr, ArgumentsResult,
82 PropertyListResult, ArgumentsListResult, ElementsListResult,
83 StatementResult, FormalParameterListResult, ClauseResult,
84 ClauseListResult, CommaExpr, DestructuringAssignment,
85 TemplateStringResult, TemplateStringListResult,
86 TemplateExpressionListResult, TemplateExpr,
87 TaggedTemplateExpr, YieldExpr, AwaitExpr,
88 ModuleNameResult, PrivateIdentifier,
89 ImportSpecifierResult, ImportSpecifierListResult, ImportAssertionListResult,
90 ExportSpecifierResult, ExportSpecifierListResult,
91
92 NewTargetExpr = MetaPropertyBit | 0,
93 ImportMetaExpr = MetaPropertyBit | 1,
94 };
95 typedef int ExpressionType;
96
97 typedef ExpressionType Expression;
98 typedef int SourceElements;
99 typedef int Arguments;
100 typedef ExpressionType Comma;
101 struct Property {
102 ALWAYS_INLINE Property(void* = nullptr)
103 {
104 }
105 ALWAYS_INLINE Property(PropertyNode::Type type)
106 : type(type)
107 {
108 }
109 ALWAYS_INLINE Property(PropertyNode::Type type, bool isUnderscoreProtoSetter)
110 : type(type)
111 , isUnderscoreProtoSetter(isUnderscoreProtoSetter)
112 {
113 }
114 ALWAYS_INLINE bool operator!() { return !type; }
115 PropertyNode::Type type { static_cast<PropertyNode::Type>(0) };
116 bool isUnderscoreProtoSetter { false };
117 };
118 typedef int PropertyList;
119 typedef int ElementList;
120 typedef int ArgumentsList;
121 typedef int TemplateExpressionList;
122 typedef int TemplateString;
123 typedef int TemplateStringList;
124 typedef int TemplateLiteral;
125 typedef int FormalParameterList;
126 typedef int FunctionBody;
127 typedef int ClassExpression;
128 typedef int ModuleName;
129 typedef int ImportSpecifier;
130 typedef int ImportSpecifierList;
131 typedef int ImportAssertionList;
132 typedef int ExportSpecifier;
133 typedef int ExportSpecifierList;
134 typedef int Statement;
135 typedef int ClauseList;
136 typedef int Clause;
137 typedef int BinaryOperand;
138 typedef int DestructuringPattern;
139 typedef DestructuringPattern ArrayPattern;
140 typedef DestructuringPattern ObjectPattern;
141 typedef DestructuringPattern RestPattern;
142
143 static constexpr bool CreatesAST = false;
144 static constexpr bool NeedsFreeVariableInfo = false;
145 static constexpr bool CanUseFunctionCache = true;
146 static constexpr OptionSet<LexerFlags> DontBuildKeywords = LexerFlags::DontBuildKeywords;
147 static constexpr OptionSet<LexerFlags> DontBuildStrings = LexerFlags::DontBuildStrings;
148
149 int createSourceElements() { return SourceElementsResult; }
150 ExpressionType makeFunctionCallNode(const JSTokenLocation&, ExpressionType, bool, int, int, int, int, size_t, bool) { return CallExpr; }
151 ExpressionType createCommaExpr(const JSTokenLocation&, ExpressionType) { return CommaExpr; }
152 ExpressionType appendToCommaExpr(const JSTokenLocation&, ExpressionType, ExpressionType, ExpressionType) { return CommaExpr; }
153 ExpressionType makeAssignNode(const JSTokenLocation&, ExpressionType, Operator, ExpressionType, bool, bool, int, int, int) { return AssignmentExpr; }
154 ExpressionType makePrefixNode(const JSTokenLocation&, ExpressionType, Operator, int, int, int) { return PreExpr; }
155 ExpressionType makePostfixNode(const JSTokenLocation&, ExpressionType, Operator, int, int, int) { return PostExpr; }
156 ExpressionType makeTypeOfNode(const JSTokenLocation&, ExpressionType) { return TypeofExpr; }
157 ExpressionType makeDeleteNode(const JSTokenLocation&, ExpressionType, int, int, int) { return DeleteExpr; }
158 ExpressionType makeNegateNode(const JSTokenLocation&, ExpressionType) { return UnaryExpr; }
159 ExpressionType makeBitwiseNotNode(const JSTokenLocation&, ExpressionType) { return UnaryExpr; }
160 ExpressionType createLogicalNot(const JSTokenLocation&, ExpressionType) { return UnaryExpr; }
161 ExpressionType createUnaryPlus(const JSTokenLocation&, ExpressionType) { return UnaryExpr; }
162 ExpressionType createVoid(const JSTokenLocation&, ExpressionType) { return UnaryExpr; }
163 ExpressionType createImportExpr(const JSTokenLocation&, ExpressionType, ExpressionType, int, int, int) { return ImportExpr; }
164 ExpressionType createThisExpr(const JSTokenLocation&) { return ThisExpr; }
165 ExpressionType createSuperExpr(const JSTokenLocation&) { return SuperExpr; }
166 ExpressionType createNewTargetExpr(const JSTokenLocation&) { return NewTargetExpr; }
167 ExpressionType createImportMetaExpr(const JSTokenLocation&, ExpressionType) { return ImportMetaExpr; }
168 ALWAYS_INLINE bool isMetaProperty(ExpressionType type) { return type & MetaPropertyBit; }
169 ALWAYS_INLINE bool isNewTarget(ExpressionType type) { return type == NewTargetExpr; }
170 ALWAYS_INLINE bool isImportMeta(ExpressionType type) { return type == ImportMetaExpr; }
171 ExpressionType createResolve(const JSTokenLocation&, const Identifier&, int, int) { return ResolveExpr; }
172 ExpressionType createPrivateIdentifierNode(const JSTokenLocation&, const Identifier&) { return PrivateIdentifier; }
173 ExpressionType createObjectLiteral(const JSTokenLocation&) { return ObjectLiteralExpr; }
174 ExpressionType createObjectLiteral(const JSTokenLocation&, int) { return ObjectLiteralExpr; }
175 ExpressionType createArray(const JSTokenLocation&, int) { return ArrayLiteralExpr; }
176 ExpressionType createArray(const JSTokenLocation&, int, int) { return ArrayLiteralExpr; }
177 ExpressionType createDoubleExpr(const JSTokenLocation&, double) { return DoubleExpr; }
178 ExpressionType createIntegerExpr(const JSTokenLocation&, double) { return IntegerExpr; }
179 ExpressionType createBigInt(const JSTokenLocation&, const Identifier*, int) { return BigIntExpr; }
180 ExpressionType createString(const JSTokenLocation&, const Identifier*) { return StringExpr; }
181 ExpressionType createBoolean(const JSTokenLocation&, bool) { return BoolExpr; }
182 ExpressionType createNull(const JSTokenLocation&) { return NullExpr; }
183 ExpressionType createBracketAccess(const JSTokenLocation&, ExpressionType, ExpressionType, bool, int, int, int) { return BracketExpr; }
184 ExpressionType createDotAccess(const JSTokenLocation&, ExpressionType, const Identifier*, DotType type, int, int, int) { return type == DotType::PrivateMember ? PrivateDotExpr : DotExpr; }
185 ExpressionType createRegExp(const JSTokenLocation&, const Identifier& pattern, const Identifier& flags, int) { return Yarr::hasError(Yarr::checkSyntax(pattern.string(), flags.string())) ? 0 : RegExpExpr; }
186 ExpressionType createNewExpr(const JSTokenLocation&, ExpressionType, int, int, int, int) { return NewExpr; }
187 ExpressionType createNewExpr(const JSTokenLocation&, ExpressionType, int, int) { return NewExpr; }
188 ExpressionType createOptionalChain(const JSTokenLocation&, ExpressionType, ExpressionType, bool) { return OptionalChain; }
189 ExpressionType createConditionalExpr(const JSTokenLocation&, ExpressionType, ExpressionType, ExpressionType) { return ConditionalExpr; }
190 ExpressionType createAssignResolve(const JSTokenLocation&, const Identifier&, ExpressionType, int, int, int, AssignmentContext) { return AssignmentExpr; }
191 ExpressionType createEmptyVarExpression(const JSTokenLocation&, const Identifier&) { return AssignmentExpr; }
192 ExpressionType createEmptyLetExpression(const JSTokenLocation&, const Identifier&) { return AssignmentExpr; }
193 ExpressionType createYield(const JSTokenLocation&) { return YieldExpr; }
194 ExpressionType createYield(const JSTokenLocation&, ExpressionType, bool, int, int, int) { return YieldExpr; }
195 ExpressionType createAwait(const JSTokenLocation&, ExpressionType, int, int, int) { return AwaitExpr; }
196 ClassExpression createClassExpr(const JSTokenLocation&, const ParserClassInfo<SyntaxChecker>&, VariableEnvironment&&, VariableEnvironment&&, ExpressionType, ExpressionType, PropertyList, int, int, int) { return ClassExpr; }
197 ExpressionType createFunctionExpr(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; }
198 ExpressionType createGeneratorFunctionBody(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&, const Identifier&) { return FunctionExpr; }
199 ExpressionType createAsyncFunctionBody(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; }
200 int createFunctionMetadata(const JSTokenLocation&, const JSTokenLocation&, unsigned, unsigned, int, int, int, LexicalScopeFeatures, ConstructorKind, SuperBinding, unsigned, SourceParseMode, bool) { return FunctionBodyResult; }
201 ExpressionType createArrowFunctionExpr(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; }
202 ExpressionType createMethodDefinition(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; }
203 void setFunctionNameStart(int, int) { }
204 int createArguments() { return ArgumentsResult; }
205 int createArguments(int, bool) { return ArgumentsResult; }
206 ExpressionType createSpreadExpression(const JSTokenLocation&, ExpressionType, int, int, int) { return SpreadExpr; }
207 ExpressionType createObjectSpreadExpression(const JSTokenLocation&, ExpressionType, int, int, int) { return ObjectSpreadExpr; }
208 TemplateString createTemplateString(const JSTokenLocation&, const Identifier*, const Identifier*) { return TemplateStringResult; }
209 TemplateStringList createTemplateStringList(TemplateString) { return TemplateStringListResult; }
210 TemplateStringList createTemplateStringList(TemplateStringList, TemplateString) { return TemplateStringListResult; }
211 TemplateExpressionList createTemplateExpressionList(Expression) { return TemplateExpressionListResult; }
212 TemplateExpressionList createTemplateExpressionList(TemplateExpressionList, Expression) { return TemplateExpressionListResult; }
213 TemplateLiteral createTemplateLiteral(const JSTokenLocation&, TemplateStringList) { return TemplateExpr; }
214 TemplateLiteral createTemplateLiteral(const JSTokenLocation&, TemplateStringList, TemplateExpressionList) { return TemplateExpr; }
215 ExpressionType createTaggedTemplate(const JSTokenLocation&, ExpressionType, TemplateLiteral, int, int, int) { return TaggedTemplateExpr; }
216
217 int createArgumentsList(const JSTokenLocation&, int) { return ArgumentsListResult; }
218 int createArgumentsList(const JSTokenLocation&, int, int) { return ArgumentsListResult; }
219 Property createProperty(const Identifier* name, int, PropertyNode::Type type, SuperBinding superBinding, InferName, ClassElementTag tag)
220 {
221 bool needsSuperBinding = superBinding == SuperBinding::Needed;
222 bool isClassProperty = tag != ClassElementTag::No;
223 return Property(type, PropertyNode::isUnderscoreProtoSetter(m_vm, name, type, needsSuperBinding, isClassProperty));
224 }
225 Property createProperty(int, PropertyNode::Type type, SuperBinding, ClassElementTag)
226 {
227 return Property(type);
228 }
229 Property createProperty(VM&, ParserArena&, double, int, PropertyNode::Type type, SuperBinding, ClassElementTag)
230 {
231 return Property(type);
232 }
233 Property createProperty(int, int, PropertyNode::Type type, SuperBinding, ClassElementTag)
234 {
235 return Property(type);
236 }
237 Property createProperty(const Identifier*, int, int, PropertyNode::Type type, SuperBinding, ClassElementTag)
238 {
239 return Property(type);
240 }
241 int createPropertyList(const JSTokenLocation&, Property) { return PropertyListResult; }
242 int createPropertyList(const JSTokenLocation&, Property, int) { return PropertyListResult; }
243 int createElementList(int, int) { return ElementsListResult; }
244 int createElementList(int, int, int) { return ElementsListResult; }
245 int createElementList(int) { return ElementsListResult; }
246 int createFormalParameterList() { return FormalParameterListResult; }
247 void appendParameter(int, DestructuringPattern, int) { }
248 int createClause(int, int) { return ClauseResult; }
249 int createClauseList(int) { return ClauseListResult; }
250 int createClauseList(int, int) { return ClauseListResult; }
251 int createFuncDeclStatement(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return StatementResult; }
252 int createDefineField(const JSTokenLocation&, const Identifier*, int, DefineFieldNode::Type) { return 0; }
253 int createClassDeclStatement(const JSTokenLocation&, ClassExpression,
254 const JSTextPosition&, const JSTextPosition&, int, int) { return StatementResult; }
255 int createBlockStatement(const JSTokenLocation&, int, int, int, VariableEnvironment&&, DeclarationStacks::FunctionStack&&) { return StatementResult; }
256 int createExprStatement(const JSTokenLocation&, int, int, int) { return StatementResult; }
257 int createIfStatement(const JSTokenLocation&, int, int, int, int) { return StatementResult; }
258 int createIfStatement(const JSTokenLocation&, int, int, int, int, int) { return StatementResult; }
259 int createForLoop(const JSTokenLocation&, int, int, int, int, int, int, VariableEnvironment&&) { return StatementResult; }
260 int createForInLoop(const JSTokenLocation&, int, int, int, const JSTokenLocation&, int, int, int, int, int, VariableEnvironment&&) { return StatementResult; }
261 int createForOfLoop(bool, const JSTokenLocation&, int, int, int, const JSTokenLocation&, int, int, int, int, int, VariableEnvironment&&) { return StatementResult; }
262 int createEmptyStatement(const JSTokenLocation&) { return StatementResult; }
263 int createDeclarationStatement(const JSTokenLocation&, int, int, int) { return StatementResult; }
264 int createReturnStatement(const JSTokenLocation&, int, int, int) { return StatementResult; }
265 int createBreakStatement(const JSTokenLocation&, int, int) { return StatementResult; }
266 int createBreakStatement(const JSTokenLocation&, const Identifier*, int, int) { return StatementResult; }
267 int createContinueStatement(const JSTokenLocation&, int, int) { return StatementResult; }
268 int createContinueStatement(const JSTokenLocation&, const Identifier*, int, int) { return StatementResult; }
269 int createTryStatement(const JSTokenLocation&, int, int, int, int, int, int, VariableEnvironment&&) { return StatementResult; }
270 int createSwitchStatement(const JSTokenLocation&, int, int, int, int, int, int, VariableEnvironment&&, DeclarationStacks::FunctionStack&&) { return StatementResult; }
271 int createWhileStatement(const JSTokenLocation&, int, int, int, int) { return StatementResult; }
272 int createWithStatement(const JSTokenLocation&, int, int, int, int, int, int) { return StatementResult; }
273 int createDoWhileStatement(const JSTokenLocation&, int, int, int, int) { return StatementResult; }
274 int createLabelStatement(const JSTokenLocation&, const Identifier*, int, int, int) { return StatementResult; }
275 int createThrowStatement(const JSTokenLocation&, int, int, int) { return StatementResult; }
276 int createDebugger(const JSTokenLocation&, int, int) { return StatementResult; }
277 int createConstStatement(const JSTokenLocation&, int, int, int) { return StatementResult; }
278 int createModuleName(const JSTokenLocation&, const Identifier&) { return ModuleNameResult; }
279 ImportSpecifier createImportSpecifier(const JSTokenLocation&, const Identifier&, const Identifier&) { return ImportSpecifierResult; }
280 ImportSpecifierList createImportSpecifierList() { return ImportSpecifierListResult; }
281 void appendImportSpecifier(ImportSpecifierList, ImportSpecifier) { }
282 ImportAssertionList createImportAssertionList() { return ImportAssertionListResult; }
283 void appendImportAssertion(ImportAssertionList, const Identifier&, const Identifier&) { }
284 int createImportDeclaration(const JSTokenLocation&, ImportSpecifierList, ModuleName, ImportAssertionList) { return StatementResult; }
285 int createExportAllDeclaration(const JSTokenLocation&, ModuleName, ImportAssertionList) { return StatementResult; }
286 int createExportDefaultDeclaration(const JSTokenLocation&, int, const Identifier&) { return StatementResult; }
287 int createExportLocalDeclaration(const JSTokenLocation&, int) { return StatementResult; }
288 int createExportNamedDeclaration(const JSTokenLocation&, ExportSpecifierList, ModuleName, ImportAssertionList) { return StatementResult; }
289 ExportSpecifier createExportSpecifier(const JSTokenLocation&, const Identifier&, const Identifier&) { return ExportSpecifierResult; }
290 ExportSpecifierList createExportSpecifierList() { return ExportSpecifierListResult; }
291 void appendExportSpecifier(ExportSpecifierList, ExportSpecifier) { }
292
293 int appendConstDecl(const JSTokenLocation&, int, const Identifier*, int) { return StatementResult; }
294 Property createGetterOrSetterProperty(const JSTokenLocation&, PropertyNode::Type type, const Identifier*, const ParserFunctionInfo<SyntaxChecker>&, ClassElementTag)
295 {
296 return Property(type);
297 }
298 Property createGetterOrSetterProperty(const JSTokenLocation&, PropertyNode::Type type, int, const ParserFunctionInfo<SyntaxChecker>&, ClassElementTag)
299 {
300 return Property(type);
301 }
302 Property createGetterOrSetterProperty(VM&, ParserArena&, const JSTokenLocation&, PropertyNode::Type type, double, const ParserFunctionInfo<SyntaxChecker>&, ClassElementTag)
303 {
304 return Property(type);
305 }
306
307 void appendStatement(int, int) { }
308 int evalCount() const { return 0; }
309 void appendBinaryExpressionInfo(int& operandStackDepth, int expr, int, int, int, bool)
310 {
311 if (!m_topBinaryExpr)
312 m_topBinaryExpr = expr;
313 else
314 m_topBinaryExpr = BinaryExpr;
315 operandStackDepth++;
316 }
317
318 // Logic to handle datastructures used during parsing of binary expressions
319 void operatorStackPop(int& operatorStackDepth) { operatorStackDepth--; }
320 bool operatorStackShouldReduce(int) { return true; }
321 BinaryOperand getFromOperandStack(int) { return m_topBinaryExpr; }
322 void shrinkOperandStackBy(int& operandStackDepth, int amount) { operandStackDepth -= amount; }
323 void appendBinaryOperation(const JSTokenLocation&, int& operandStackDepth, int&, BinaryOperand, BinaryOperand) { operandStackDepth++; }
324 void operatorStackAppend(int& operatorStackDepth, int, int) { operatorStackDepth++; }
325 int popOperandStack(int&) { int res = m_topBinaryExpr; m_topBinaryExpr = 0; return res; }
326
327 void appendUnaryToken(int& stackDepth, int tok, int) { stackDepth = 1; m_topUnaryToken = tok; }
328 int unaryTokenStackLastType(int&) { return m_topUnaryToken; }
329 JSTextPosition unaryTokenStackLastStart(int&) { return JSTextPosition(0, 0, 0); }
330 void unaryTokenStackRemoveLast(int& stackDepth) { stackDepth = 0; }
331 int unaryTokenStackDepth() const { return 0; }
332 void setUnaryTokenStackDepth(int) { }
333
334 void assignmentStackAppend(int& assignmentStackDepth, int, int, int, int, Operator) { assignmentStackDepth = 1; }
335 int createAssignment(const JSTokenLocation&, int& assignmentStackDepth, int, int, int, int) { assignmentStackDepth = 0; return AssignmentExpr; }
336 PropertyNode::Type getType(const Property& property) const { return property.type; }
337 bool isUnderscoreProtoSetter(const Property& property) const { return property.isUnderscoreProtoSetter; }
338 bool isResolve(ExpressionType expr) const { return expr == ResolveExpr || expr == ResolveEvalExpr; }
339 ExpressionType createDestructuringAssignment(const JSTokenLocation&, int, ExpressionType)
340 {
341 return DestructuringAssignment;
342 }
343
344 ArrayPattern createArrayPattern(const JSTokenLocation&)
345 {
346 return ArrayDestructuring;
347 }
348 void appendArrayPatternSkipEntry(ArrayPattern, const JSTokenLocation&)
349 {
350 }
351 void appendArrayPatternEntry(ArrayPattern, const JSTokenLocation&, DestructuringPattern, int)
352 {
353 }
354 void appendArrayPatternRestEntry(ArrayPattern, const JSTokenLocation&, DestructuringPattern)
355 {
356 }
357 void finishArrayPattern(ArrayPattern, const JSTextPosition&, const JSTextPosition&, const JSTextPosition&)
358 {
359 }
360 ObjectPattern createObjectPattern(const JSTokenLocation&)
361 {
362 return ObjectDestructuring;
363 }
364 void appendObjectPatternEntry(ObjectPattern, const JSTokenLocation&, bool, const Identifier&, DestructuringPattern, int)
365 {
366 }
367 void appendObjectPatternEntry(VM&, ObjectPattern, const JSTokenLocation&, Expression, DestructuringPattern, Expression)
368 {
369 }
370 void appendObjectPatternRestEntry(VM&, ObjectPattern, const JSTokenLocation&, DestructuringPattern)
371 {
372 }
373 void setContainsObjectRestElement(ObjectPattern, bool)
374 {
375 }
376 void setContainsComputedProperty(ObjectPattern, bool)
377 {
378 }
379
380 DestructuringPattern createBindingLocation(const JSTokenLocation&, const Identifier&, const JSTextPosition&, const JSTextPosition&, AssignmentContext)
381 {
382 return BindingDestructuring;
383 }
384 RestPattern createRestParameter(DestructuringPattern, size_t)
385 {
386 return RestParameter;
387 }
388 DestructuringPattern createAssignmentElement(const Expression&, const JSTextPosition&, const JSTextPosition&)
389 {
390 return BindingDestructuring;
391 }
392
393 bool isBindingNode(DestructuringPattern pattern)
394 {
395 return pattern == BindingDestructuring;
396 }
397
398 bool isLocation(ExpressionType type)
399 {
400 return type == ResolveExpr || type == DotExpr || type == PrivateDotExpr || type == BracketExpr;
401 }
402
403 bool isPrivateLocation(ExpressionType type)
404 {
405 return type == PrivateDotExpr;
406 }
407
408 bool isAssignmentLocation(ExpressionType type)
409 {
410 return isLocation(type) || type == DestructuringAssignment;
411 }
412
413 bool isObjectLiteral(ExpressionType type)
414 {
415 return type == ObjectLiteralExpr;
416 }
417
418 bool isArrayLiteral(ExpressionType type)
419 {
420 return type == ArrayLiteralExpr;
421 }
422
423 bool isObjectOrArrayLiteral(ExpressionType type)
424 {
425 return isObjectLiteral(type) || isArrayLiteral(type);
426 }
427
428 bool isFunctionCall(ExpressionType type)
429 {
430 return type == CallExpr;
431 }
432
433 bool shouldSkipPauseLocation(int) const { return true; }
434
435 void setEndOffset(int, int) { }
436 int endOffset(int) { return 0; }
437 void setStartOffset(int, int) { }
438
439 JSTextPosition breakpointLocation(int) { return { }; }
440
441 void propagateArgumentsUse() { }
442
443private:
444 VM& m_vm;
445 int m_topBinaryExpr;
446 int m_topUnaryToken;
447};
448
449} // namespace JSC
Note: See TracBrowser for help on using the repository browser.