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& , void*)
68 {
69 }
70
71 static const constexpr int MetaPropertyBit = 0x80000000;
72 enum : int { NoneExpr = 0,
73 ResolveEvalExpr, ResolveExpr, IntegerExpr, DoubleExpr, StringExpr, BigIntExpr,
74 ThisExpr, NullExpr, BoolExpr, RegExpExpr, ObjectLiteralExpr,
75 FunctionExpr, ClassExpr, SuperExpr, ImportExpr, BracketExpr, DotExpr, CallExpr,
76 NewExpr, PreExpr, PostExpr, UnaryExpr, BinaryExpr, OptionalChain,
77 ConditionalExpr, AssignmentExpr, TypeofExpr,
78 DeleteExpr, ArrayLiteralExpr, BindingDestructuring, RestParameter,
79 ArrayDestructuring, ObjectDestructuring, SourceElementsResult,
80 FunctionBodyResult, SpreadExpr, ObjectSpreadExpr, ArgumentsResult,
81 PropertyListResult, ArgumentsListResult, ElementsListResult,
82 StatementResult, FormalParameterListResult, ClauseResult,
83 ClauseListResult, CommaExpr, DestructuringAssignment,
84 TemplateStringResult, TemplateStringListResult,
85 TemplateExpressionListResult, TemplateExpr,
86 TaggedTemplateExpr, YieldExpr, AwaitExpr,
87 ModuleNameResult,
88 ImportSpecifierResult, ImportSpecifierListResult,
89 ExportSpecifierResult, ExportSpecifierListResult,
90
91 NewTargetExpr = MetaPropertyBit | 0,
92 ImportMetaExpr = MetaPropertyBit | 1,
93 };
94 typedef int ExpressionType;
95
96 typedef ExpressionType Expression;
97 typedef int SourceElements;
98 typedef int Arguments;
99 typedef ExpressionType Comma;
100 struct Property {
101 ALWAYS_INLINE Property(void* = 0)
102 : type((PropertyNode::Type)0)
103 {
104 }
105 ALWAYS_INLINE Property(const Identifier* ident, PropertyNode::Type ty)
106 : name(ident)
107 , type(ty)
108 {
109 }
110 ALWAYS_INLINE Property(PropertyNode::Type ty)
111 : name(0)
112 , type(ty)
113 {
114 }
115 ALWAYS_INLINE bool operator!() { return !type; }
116 const Identifier* name;
117 PropertyNode::Type type;
118 };
119 typedef int PropertyList;
120 typedef int ElementList;
121 typedef int ArgumentsList;
122 typedef int TemplateExpressionList;
123 typedef int TemplateString;
124 typedef int TemplateStringList;
125 typedef int TemplateLiteral;
126 typedef int FormalParameterList;
127 typedef int FunctionBody;
128 typedef int ClassExpression;
129 typedef int ModuleName;
130 typedef int ImportSpecifier;
131 typedef int ImportSpecifierList;
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 expr) { return expr; }
152 ExpressionType appendToCommaExpr(const JSTokenLocation&, ExpressionType& head, ExpressionType, ExpressionType next) { head = next; return next; }
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, 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 createObjectLiteral(const JSTokenLocation&) { return ObjectLiteralExpr; }
173 ExpressionType createObjectLiteral(const JSTokenLocation&, int) { return ObjectLiteralExpr; }
174 ExpressionType createArray(const JSTokenLocation&, int) { return ArrayLiteralExpr; }
175 ExpressionType createArray(const JSTokenLocation&, int, int) { return ArrayLiteralExpr; }
176 ExpressionType createDoubleExpr(const JSTokenLocation&, double) { return DoubleExpr; }
177 ExpressionType createIntegerExpr(const JSTokenLocation&, double) { return IntegerExpr; }
178 ExpressionType createBigInt(const JSTokenLocation&, const Identifier*, int) { return BigIntExpr; }
179 ExpressionType createString(const JSTokenLocation&, const Identifier*) { return StringExpr; }
180 ExpressionType createBoolean(const JSTokenLocation&, bool) { return BoolExpr; }
181 ExpressionType createNull(const JSTokenLocation&) { return NullExpr; }
182 ExpressionType createBracketAccess(const JSTokenLocation&, ExpressionType, ExpressionType, bool, int, int, int) { return BracketExpr; }
183 ExpressionType createDotAccess(const JSTokenLocation&, ExpressionType, const Identifier*, int, int, int) { return DotExpr; }
184 ExpressionType createRegExp(const JSTokenLocation&, const Identifier& pattern, const Identifier& flags, int) { return Yarr::hasError(Yarr::checkSyntax(pattern.string(), flags.string())) ? 0 : RegExpExpr; }
185 ExpressionType createNewExpr(const JSTokenLocation&, ExpressionType, int, int, int, int) { return NewExpr; }
186 ExpressionType createNewExpr(const JSTokenLocation&, ExpressionType, int, int) { return NewExpr; }
187 ExpressionType createOptionalChain(const JSTokenLocation&, ExpressionType, ExpressionType, bool) { return OptionalChain; }
188 ExpressionType createConditionalExpr(const JSTokenLocation&, ExpressionType, ExpressionType, ExpressionType) { return ConditionalExpr; }
189 ExpressionType createAssignResolve(const JSTokenLocation&, const Identifier&, ExpressionType, int, int, int, AssignmentContext) { return AssignmentExpr; }
190 ExpressionType createEmptyVarExpression(const JSTokenLocation&, const Identifier&) { return AssignmentExpr; }
191 ExpressionType createEmptyLetExpression(const JSTokenLocation&, const Identifier&) { return AssignmentExpr; }
192 ExpressionType createYield(const JSTokenLocation&) { return YieldExpr; }
193 ExpressionType createYield(const JSTokenLocation&, ExpressionType, bool, int, int, int) { return YieldExpr; }
194 ExpressionType createAwait(const JSTokenLocation&, ExpressionType, int, int, int) { return AwaitExpr; }
195 ClassExpression createClassExpr(const JSTokenLocation&, const ParserClassInfo<SyntaxChecker>&, VariableEnvironment&, ExpressionType, ExpressionType, PropertyList) { return ClassExpr; }
196 ExpressionType createFunctionExpr(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; }
197 ExpressionType createGeneratorFunctionBody(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&, const Identifier&) { return FunctionExpr; }
198 ExpressionType createAsyncFunctionBody(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; }
199 int createFunctionMetadata(const JSTokenLocation&, const JSTokenLocation&, int, int, bool, int, int, int, ConstructorKind, SuperBinding, unsigned, SourceParseMode, bool, InnerArrowFunctionCodeFeatures = NoInnerArrowFunctionFeatures) { return FunctionBodyResult; }
200 ExpressionType createArrowFunctionExpr(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; }
201 ExpressionType createMethodDefinition(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; }
202 void setFunctionNameStart(int, int) { }
203 int createArguments() { return ArgumentsResult; }
204 int createArguments(int) { return ArgumentsResult; }
205 ExpressionType createSpreadExpression(const JSTokenLocation&, ExpressionType, int, int, int) { return SpreadExpr; }
206 ExpressionType createObjectSpreadExpression(const JSTokenLocation&, ExpressionType, int, int, int) { return ObjectSpreadExpr; }
207 TemplateString createTemplateString(const JSTokenLocation&, const Identifier*, const Identifier*) { return TemplateStringResult; }
208 TemplateStringList createTemplateStringList(TemplateString) { return TemplateStringListResult; }
209 TemplateStringList createTemplateStringList(TemplateStringList, TemplateString) { return TemplateStringListResult; }
210 TemplateExpressionList createTemplateExpressionList(Expression) { return TemplateExpressionListResult; }
211 TemplateExpressionList createTemplateExpressionList(TemplateExpressionList, Expression) { return TemplateExpressionListResult; }
212 TemplateLiteral createTemplateLiteral(const JSTokenLocation&, TemplateStringList) { return TemplateExpr; }
213 TemplateLiteral createTemplateLiteral(const JSTokenLocation&, TemplateStringList, TemplateExpressionList) { return TemplateExpr; }
214 ExpressionType createTaggedTemplate(const JSTokenLocation&, ExpressionType, TemplateLiteral, int, int, int) { return TaggedTemplateExpr; }
215
216 int createArgumentsList(const JSTokenLocation&, int) { return ArgumentsListResult; }
217 int createArgumentsList(const JSTokenLocation&, int, int) { return ArgumentsListResult; }
218 Property createProperty(const Identifier* name, int, PropertyNode::Type type, PropertyNode::PutType, bool complete, SuperBinding, InferName, ClassElementTag)
219 {
220 if (!complete)
221 return Property(type);
222 ASSERT(name);
223 return Property(name, type);
224 }
225 Property createProperty(int, PropertyNode::Type type, PropertyNode::PutType, bool, SuperBinding, ClassElementTag)
226 {
227 return Property(type);
228 }
229 Property createProperty(VM& vm, ParserArena& parserArena, double name, int, PropertyNode::Type type, PropertyNode::PutType, bool complete, SuperBinding, ClassElementTag)
230 {
231 if (!complete)
232 return Property(type);
233 return Property(&parserArena.identifierArena().makeNumericIdentifier(vm, name), type);
234 }
235 Property createProperty(int, int, PropertyNode::Type type, PropertyNode::PutType, bool, SuperBinding, ClassElementTag)
236 {
237 return Property(type);
238 }
239 int createPropertyList(const JSTokenLocation&, Property) { return PropertyListResult; }
240 int createPropertyList(const JSTokenLocation&, Property, int) { return PropertyListResult; }
241 int createElementList(int, int) { return ElementsListResult; }
242 int createElementList(int, int, int) { return ElementsListResult; }
243 int createElementList(int) { return ElementsListResult; }
244 int createFormalParameterList() { return FormalParameterListResult; }
245 void appendParameter(int, DestructuringPattern, int) { }
246 int createClause(int, int) { return ClauseResult; }
247 int createClauseList(int) { return ClauseListResult; }
248 int createClauseList(int, int) { return ClauseListResult; }
249 int createFuncDeclStatement(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return StatementResult; }
250 int createClassDeclStatement(const JSTokenLocation&, ClassExpression,
251 const JSTextPosition&, const JSTextPosition&, int, int) { return StatementResult; }
252 int createBlockStatement(const JSTokenLocation&, int, int, int, VariableEnvironment&, DeclarationStacks::FunctionStack&&) { return StatementResult; }
253 int createExprStatement(const JSTokenLocation&, int, int, int) { return StatementResult; }
254 int createIfStatement(const JSTokenLocation&, int, int, int, int) { return StatementResult; }
255 int createIfStatement(const JSTokenLocation&, int, int, int, int, int) { return StatementResult; }
256 int createForLoop(const JSTokenLocation&, int, int, int, int, int, int, VariableEnvironment&) { return StatementResult; }
257 int createForInLoop(const JSTokenLocation&, int, int, int, const JSTokenLocation&, int, int, int, int, int, VariableEnvironment&) { return StatementResult; }
258 int createForOfLoop(bool, const JSTokenLocation&, int, int, int, const JSTokenLocation&, int, int, int, int, int, VariableEnvironment&) { return StatementResult; }
259 int createEmptyStatement(const JSTokenLocation&) { return StatementResult; }
260 int createDeclarationStatement(const JSTokenLocation&, int, int, int) { return StatementResult; }
261 int createReturnStatement(const JSTokenLocation&, int, int, int) { return StatementResult; }
262 int createBreakStatement(const JSTokenLocation&, int, int) { return StatementResult; }
263 int createBreakStatement(const JSTokenLocation&, const Identifier*, int, int) { return StatementResult; }
264 int createContinueStatement(const JSTokenLocation&, int, int) { return StatementResult; }
265 int createContinueStatement(const JSTokenLocation&, const Identifier*, int, int) { return StatementResult; }
266 int createTryStatement(const JSTokenLocation&, int, int, int, int, int, int, VariableEnvironment&) { return StatementResult; }
267 int createSwitchStatement(const JSTokenLocation&, int, int, int, int, int, int, VariableEnvironment&, DeclarationStacks::FunctionStack&&) { return StatementResult; }
268 int createWhileStatement(const JSTokenLocation&, int, int, int, int) { return StatementResult; }
269 int createWithStatement(const JSTokenLocation&, int, int, int, int, int, int) { return StatementResult; }
270 int createDoWhileStatement(const JSTokenLocation&, int, int, int, int) { return StatementResult; }
271 int createLabelStatement(const JSTokenLocation&, const Identifier*, int, int, int) { return StatementResult; }
272 int createThrowStatement(const JSTokenLocation&, int, int, int) { return StatementResult; }
273 int createDebugger(const JSTokenLocation&, int, int) { return StatementResult; }
274 int createConstStatement(const JSTokenLocation&, int, int, int) { return StatementResult; }
275 int createModuleName(const JSTokenLocation&, const Identifier&) { return ModuleNameResult; }
276 ImportSpecifier createImportSpecifier(const JSTokenLocation&, const Identifier&, const Identifier&) { return ImportSpecifierResult; }
277 ImportSpecifierList createImportSpecifierList() { return ImportSpecifierListResult; }
278 void appendImportSpecifier(ImportSpecifierList, ImportSpecifier) { }
279 int createImportDeclaration(const JSTokenLocation&, ImportSpecifierList, ModuleName) { return StatementResult; }
280 int createExportAllDeclaration(const JSTokenLocation&, ModuleName) { return StatementResult; }
281 int createExportDefaultDeclaration(const JSTokenLocation&, int, const Identifier&) { return StatementResult; }
282 int createExportLocalDeclaration(const JSTokenLocation&, int) { return StatementResult; }
283 int createExportNamedDeclaration(const JSTokenLocation&, ExportSpecifierList, ModuleName) { return StatementResult; }
284 ExportSpecifier createExportSpecifier(const JSTokenLocation&, const Identifier&, const Identifier&) { return ExportSpecifierResult; }
285 ExportSpecifierList createExportSpecifierList() { return ExportSpecifierListResult; }
286 void appendExportSpecifier(ExportSpecifierList, ExportSpecifier) { }
287
288 int appendConstDecl(const JSTokenLocation&, int, const Identifier*, int) { return StatementResult; }
289 Property createGetterOrSetterProperty(const JSTokenLocation&, PropertyNode::Type type, bool strict, const Identifier* name, const ParserFunctionInfo<SyntaxChecker>&, ClassElementTag)
290 {
291 ASSERT(name);
292 if (!strict)
293 return Property(type);
294 return Property(name, type);
295 }
296 Property createGetterOrSetterProperty(const JSTokenLocation&, PropertyNode::Type type, bool, int, const ParserFunctionInfo<SyntaxChecker>&, ClassElementTag)
297 {
298 return Property(type);
299 }
300 Property createGetterOrSetterProperty(VM& vm, ParserArena& parserArena, const JSTokenLocation&, PropertyNode::Type type, bool strict, double name, const ParserFunctionInfo<SyntaxChecker>&, ClassElementTag)
301 {
302 if (!strict)
303 return Property(type);
304 return Property(&parserArena.identifierArena().makeNumericIdentifier(vm, name), type);
305 }
306
307 void appendStatement(int, int) { }
308 int combineCommaNodes(const JSTokenLocation&, int, int) { return CommaExpr; }
309 int evalCount() const { return 0; }
310 void appendBinaryExpressionInfo(int& operandStackDepth, int expr, int, int, int, bool)
311 {
312 if (!m_topBinaryExpr)
313 m_topBinaryExpr = expr;
314 else
315 m_topBinaryExpr = BinaryExpr;
316 operandStackDepth++;
317 }
318
319 // Logic to handle datastructures used during parsing of binary expressions
320 void operatorStackPop(int& operatorStackDepth) { operatorStackDepth--; }
321 bool operatorStackShouldReduce(int) { return true; }
322 BinaryOperand getFromOperandStack(int) { return m_topBinaryExpr; }
323 void shrinkOperandStackBy(int& operandStackDepth, int amount) { operandStackDepth -= amount; }
324 void appendBinaryOperation(const JSTokenLocation&, int& operandStackDepth, int&, BinaryOperand, BinaryOperand) { operandStackDepth++; }
325 void operatorStackAppend(int& operatorStackDepth, int, int) { operatorStackDepth++; }
326 int popOperandStack(int&) { int res = m_topBinaryExpr; m_topBinaryExpr = 0; return res; }
327
328 void appendUnaryToken(int& stackDepth, int tok, int) { stackDepth = 1; m_topUnaryToken = tok; }
329 int unaryTokenStackLastType(int&) { return m_topUnaryToken; }
330 JSTextPosition unaryTokenStackLastStart(int&) { return JSTextPosition(0, 0, 0); }
331 void unaryTokenStackRemoveLast(int& stackDepth) { stackDepth = 0; }
332
333 void assignmentStackAppend(int, int, int, int, int, Operator) { }
334 int createAssignment(const JSTokenLocation&, int, int, int, int, int) { RELEASE_ASSERT_NOT_REACHED(); return AssignmentExpr; }
335 const Identifier* getName(const Property& property) const { return property.name; }
336 PropertyNode::Type getType(const Property& property) const { return property.type; }
337 bool isResolve(ExpressionType expr) const { return expr == ResolveExpr || expr == ResolveEvalExpr; }
338 ExpressionType createDestructuringAssignment(const JSTokenLocation&, int, ExpressionType)
339 {
340 return DestructuringAssignment;
341 }
342
343 ArrayPattern createArrayPattern(const JSTokenLocation&)
344 {
345 return ArrayDestructuring;
346 }
347 void appendArrayPatternSkipEntry(ArrayPattern, const JSTokenLocation&)
348 {
349 }
350 void appendArrayPatternEntry(ArrayPattern, const JSTokenLocation&, DestructuringPattern, int)
351 {
352 }
353 void appendArrayPatternRestEntry(ArrayPattern, const JSTokenLocation&, DestructuringPattern)
354 {
355 }
356 void finishArrayPattern(ArrayPattern, const JSTextPosition&, const JSTextPosition&, const JSTextPosition&)
357 {
358 }
359 ObjectPattern createObjectPattern(const JSTokenLocation&)
360 {
361 return ObjectDestructuring;
362 }
363 void appendObjectPatternEntry(ObjectPattern, const JSTokenLocation&, bool, const Identifier&, DestructuringPattern, int)
364 {
365 }
366 void appendObjectPatternEntry(VM&, ObjectPattern, const JSTokenLocation&, Expression, DestructuringPattern, Expression)
367 {
368 }
369 void appendObjectPatternRestEntry(VM&, ObjectPattern, const JSTokenLocation&, DestructuringPattern)
370 {
371 }
372 void setContainsObjectRestElement(ObjectPattern, bool)
373 {
374 }
375 void setContainsComputedProperty(ObjectPattern, bool)
376 {
377 }
378
379 DestructuringPattern createBindingLocation(const JSTokenLocation&, const Identifier&, const JSTextPosition&, const JSTextPosition&, AssignmentContext)
380 {
381 return BindingDestructuring;
382 }
383 RestPattern createRestParameter(DestructuringPattern, size_t)
384 {
385 return RestParameter;
386 }
387 DestructuringPattern createAssignmentElement(const Expression&, const JSTextPosition&, const JSTextPosition&)
388 {
389 return BindingDestructuring;
390 }
391
392 bool isBindingNode(DestructuringPattern pattern)
393 {
394 return pattern == BindingDestructuring;
395 }
396
397 bool isLocation(ExpressionType type)
398 {
399 return type == ResolveExpr || type == DotExpr || type == BracketExpr;
400 }
401
402 bool isAssignmentLocation(ExpressionType type)
403 {
404 return isLocation(type) || type == DestructuringAssignment;
405 }
406
407 bool isObjectLiteral(ExpressionType type)
408 {
409 return type == ObjectLiteralExpr;
410 }
411
412 bool isArrayLiteral(ExpressionType type)
413 {
414 return type == ArrayLiteralExpr;
415 }
416
417 bool isObjectOrArrayLiteral(ExpressionType type)
418 {
419 return isObjectLiteral(type) || isArrayLiteral(type);
420 }
421
422 bool isFunctionCall(ExpressionType type)
423 {
424 return type == CallExpr;
425 }
426
427 bool shouldSkipPauseLocation(int) const { return true; }
428
429 void setEndOffset(int, int) { }
430 int endOffset(int) { return 0; }
431 void setStartOffset(int, int) { }
432
433 JSTextPosition breakpointLocation(int) { return JSTextPosition(-1, 0, 0); }
434
435 void propagateArgumentsUse() { }
436
437private:
438 int m_topBinaryExpr;
439 int m_topUnaryToken;
440};
441
442} // namespace JSC
443