1 | /* |
2 | * Copyright (C) 2010, 2013, 2016 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 | |
32 | namespace JSC { |
33 | |
34 | class SyntaxChecker { |
35 | public: |
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, |
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 const bool CreatesAST = false; |
144 | static const bool NeedsFreeVariableInfo = false; |
145 | static const bool CanUseFunctionCache = true; |
146 | static const unsigned DontBuildKeywords = LexexFlagsDontBuildKeywords; |
147 | static const unsigned DontBuildStrings = LexerFlagsDontBuildStrings; |
148 | |
149 | int createSourceElements() { return SourceElementsResult; } |
150 | ExpressionType makeFunctionCallNode(const JSTokenLocation&, int, bool, int, int, int, int, size_t) { 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 createConditionalExpr(const JSTokenLocation&, ExpressionType, ExpressionType, ExpressionType) { return ConditionalExpr; } |
188 | ExpressionType createAssignResolve(const JSTokenLocation&, const Identifier&, ExpressionType, int, int, int, AssignmentContext) { return AssignmentExpr; } |
189 | ExpressionType createEmptyVarExpression(const JSTokenLocation&, const Identifier&) { return AssignmentExpr; } |
190 | ExpressionType createEmptyLetExpression(const JSTokenLocation&, const Identifier&) { return AssignmentExpr; } |
191 | ExpressionType createYield(const JSTokenLocation&) { return YieldExpr; } |
192 | ExpressionType createYield(const JSTokenLocation&, ExpressionType, bool, int, int, int) { return YieldExpr; } |
193 | ExpressionType createAwait(const JSTokenLocation&, ExpressionType, int, int, int) { return AwaitExpr; } |
194 | ClassExpression createClassExpr(const JSTokenLocation&, const ParserClassInfo<SyntaxChecker>&, VariableEnvironment&, ExpressionType, ExpressionType, PropertyList) { return ClassExpr; } |
195 | ExpressionType createFunctionExpr(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; } |
196 | ExpressionType createGeneratorFunctionBody(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&, const Identifier&) { return FunctionExpr; } |
197 | ExpressionType createAsyncFunctionBody(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; } |
198 | int createFunctionMetadata(const JSTokenLocation&, const JSTokenLocation&, int, int, bool, int, int, int, ConstructorKind, SuperBinding, unsigned, SourceParseMode, bool, InnerArrowFunctionCodeFeatures = NoInnerArrowFunctionFeatures) { return FunctionBodyResult; } |
199 | ExpressionType createArrowFunctionExpr(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; } |
200 | ExpressionType createMethodDefinition(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; } |
201 | void setFunctionNameStart(int, int) { } |
202 | int createArguments() { return ArgumentsResult; } |
203 | int createArguments(int) { return ArgumentsResult; } |
204 | ExpressionType createSpreadExpression(const JSTokenLocation&, ExpressionType, int, int, int) { return SpreadExpr; } |
205 | ExpressionType createObjectSpreadExpression(const JSTokenLocation&, ExpressionType, int, int, int) { return ObjectSpreadExpr; } |
206 | TemplateString createTemplateString(const JSTokenLocation&, const Identifier*, const Identifier*) { return TemplateStringResult; } |
207 | TemplateStringList createTemplateStringList(TemplateString) { return TemplateStringListResult; } |
208 | TemplateStringList createTemplateStringList(TemplateStringList, TemplateString) { return TemplateStringListResult; } |
209 | TemplateExpressionList createTemplateExpressionList(Expression) { return TemplateExpressionListResult; } |
210 | TemplateExpressionList createTemplateExpressionList(TemplateExpressionList, Expression) { return TemplateExpressionListResult; } |
211 | TemplateLiteral createTemplateLiteral(const JSTokenLocation&, TemplateStringList) { return TemplateExpr; } |
212 | TemplateLiteral createTemplateLiteral(const JSTokenLocation&, TemplateStringList, TemplateExpressionList) { return TemplateExpr; } |
213 | ExpressionType createTaggedTemplate(const JSTokenLocation&, ExpressionType, TemplateLiteral, int, int, int) { return TaggedTemplateExpr; } |
214 | |
215 | int createArgumentsList(const JSTokenLocation&, int) { return ArgumentsListResult; } |
216 | int createArgumentsList(const JSTokenLocation&, int, int) { return ArgumentsListResult; } |
217 | Property createProperty(const Identifier* name, int, PropertyNode::Type type, PropertyNode::PutType, bool complete, SuperBinding, InferName, ClassElementTag) |
218 | { |
219 | if (!complete) |
220 | return Property(type); |
221 | ASSERT(name); |
222 | return Property(name, type); |
223 | } |
224 | Property createProperty(int, PropertyNode::Type type, PropertyNode::PutType, bool, SuperBinding, ClassElementTag) |
225 | { |
226 | return Property(type); |
227 | } |
228 | Property createProperty(VM* vm, ParserArena& parserArena, double name, int, PropertyNode::Type type, PropertyNode::PutType, bool complete, SuperBinding, ClassElementTag) |
229 | { |
230 | if (!complete) |
231 | return Property(type); |
232 | return Property(&parserArena.identifierArena().makeNumericIdentifier(vm, name), type); |
233 | } |
234 | Property createProperty(int, int, PropertyNode::Type type, PropertyNode::PutType, bool, SuperBinding, ClassElementTag) |
235 | { |
236 | return Property(type); |
237 | } |
238 | int createPropertyList(const JSTokenLocation&, Property) { return PropertyListResult; } |
239 | int createPropertyList(const JSTokenLocation&, Property, int) { return PropertyListResult; } |
240 | int createElementList(int, int) { return ElementsListResult; } |
241 | int createElementList(int, int, int) { return ElementsListResult; } |
242 | int createElementList(int) { return ElementsListResult; } |
243 | int createFormalParameterList() { return FormalParameterListResult; } |
244 | void appendParameter(int, DestructuringPattern, int) { } |
245 | int createClause(int, int) { return ClauseResult; } |
246 | int createClauseList(int) { return ClauseListResult; } |
247 | int createClauseList(int, int) { return ClauseListResult; } |
248 | int createFuncDeclStatement(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return StatementResult; } |
249 | int createClassDeclStatement(const JSTokenLocation&, ClassExpression, |
250 | const JSTextPosition&, const JSTextPosition&, int, int) { return StatementResult; } |
251 | int createBlockStatement(const JSTokenLocation&, int, int, int, VariableEnvironment&, DeclarationStacks::FunctionStack&&) { return StatementResult; } |
252 | int createExprStatement(const JSTokenLocation&, int, int, int) { return StatementResult; } |
253 | int createIfStatement(const JSTokenLocation&, int, int, int, int) { return StatementResult; } |
254 | int createIfStatement(const JSTokenLocation&, int, int, int, int, int) { return StatementResult; } |
255 | int createForLoop(const JSTokenLocation&, int, int, int, int, int, int, VariableEnvironment&) { return StatementResult; } |
256 | int createForInLoop(const JSTokenLocation&, int, int, int, const JSTokenLocation&, int, int, int, int, int, VariableEnvironment&) { return StatementResult; } |
257 | int createForOfLoop(bool, const JSTokenLocation&, int, int, int, const JSTokenLocation&, int, int, int, int, int, VariableEnvironment&) { return StatementResult; } |
258 | int createEmptyStatement(const JSTokenLocation&) { return StatementResult; } |
259 | int createDeclarationStatement(const JSTokenLocation&, int, int, int) { return StatementResult; } |
260 | int createReturnStatement(const JSTokenLocation&, int, int, int) { return StatementResult; } |
261 | int createBreakStatement(const JSTokenLocation&, int, int) { return StatementResult; } |
262 | int createBreakStatement(const JSTokenLocation&, const Identifier*, int, int) { return StatementResult; } |
263 | int createContinueStatement(const JSTokenLocation&, int, int) { return StatementResult; } |
264 | int createContinueStatement(const JSTokenLocation&, const Identifier*, int, int) { return StatementResult; } |
265 | int createTryStatement(const JSTokenLocation&, int, int, int, int, int, int, VariableEnvironment&) { return StatementResult; } |
266 | int createSwitchStatement(const JSTokenLocation&, int, int, int, int, int, int, VariableEnvironment&, DeclarationStacks::FunctionStack&&) { return StatementResult; } |
267 | int createWhileStatement(const JSTokenLocation&, int, int, int, int) { return StatementResult; } |
268 | int createWithStatement(const JSTokenLocation&, int, int, int, int, int, int) { return StatementResult; } |
269 | int createDoWhileStatement(const JSTokenLocation&, int, int, int, int) { return StatementResult; } |
270 | int createLabelStatement(const JSTokenLocation&, const Identifier*, int, int, int) { return StatementResult; } |
271 | int createThrowStatement(const JSTokenLocation&, int, int, int) { return StatementResult; } |
272 | int createDebugger(const JSTokenLocation&, int, int) { return StatementResult; } |
273 | int createConstStatement(const JSTokenLocation&, int, int, int) { return StatementResult; } |
274 | int createModuleName(const JSTokenLocation&, const Identifier&) { return ModuleNameResult; } |
275 | ImportSpecifier createImportSpecifier(const JSTokenLocation&, const Identifier&, const Identifier&) { return ImportSpecifierResult; } |
276 | ImportSpecifierList createImportSpecifierList() { return ImportSpecifierListResult; } |
277 | void appendImportSpecifier(ImportSpecifierList, ImportSpecifier) { } |
278 | int createImportDeclaration(const JSTokenLocation&, ImportSpecifierList, ModuleName) { return StatementResult; } |
279 | int createExportAllDeclaration(const JSTokenLocation&, ModuleName) { return StatementResult; } |
280 | int createExportDefaultDeclaration(const JSTokenLocation&, int, const Identifier&) { return StatementResult; } |
281 | int createExportLocalDeclaration(const JSTokenLocation&, int) { return StatementResult; } |
282 | int createExportNamedDeclaration(const JSTokenLocation&, ExportSpecifierList, ModuleName) { return StatementResult; } |
283 | ExportSpecifier createExportSpecifier(const JSTokenLocation&, const Identifier&, const Identifier&) { return ExportSpecifierResult; } |
284 | ExportSpecifierList createExportSpecifierList() { return ExportSpecifierListResult; } |
285 | void appendExportSpecifier(ExportSpecifierList, ExportSpecifier) { } |
286 | |
287 | int appendConstDecl(const JSTokenLocation&, int, const Identifier*, int) { return StatementResult; } |
288 | Property createGetterOrSetterProperty(const JSTokenLocation&, PropertyNode::Type type, bool strict, const Identifier* name, const ParserFunctionInfo<SyntaxChecker>&, ClassElementTag) |
289 | { |
290 | ASSERT(name); |
291 | if (!strict) |
292 | return Property(type); |
293 | return Property(name, type); |
294 | } |
295 | Property createGetterOrSetterProperty(const JSTokenLocation&, PropertyNode::Type type, bool, int, const ParserFunctionInfo<SyntaxChecker>&, ClassElementTag) |
296 | { |
297 | return Property(type); |
298 | } |
299 | Property createGetterOrSetterProperty(VM* vm, ParserArena& parserArena, const JSTokenLocation&, PropertyNode::Type type, bool strict, double name, const ParserFunctionInfo<SyntaxChecker>&, ClassElementTag) |
300 | { |
301 | if (!strict) |
302 | return Property(type); |
303 | return Property(&parserArena.identifierArena().makeNumericIdentifier(vm, name), type); |
304 | } |
305 | |
306 | void appendStatement(int, int) { } |
307 | int combineCommaNodes(const JSTokenLocation&, int, int) { return CommaExpr; } |
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 | |
332 | void assignmentStackAppend(int, int, int, int, int, Operator) { } |
333 | int createAssignment(const JSTokenLocation&, int, int, int, int, int) { RELEASE_ASSERT_NOT_REACHED(); return AssignmentExpr; } |
334 | const Identifier* getName(const Property& property) const { return property.name; } |
335 | PropertyNode::Type getType(const Property& property) const { return property.type; } |
336 | bool isResolve(ExpressionType expr) const { return expr == ResolveExpr || expr == ResolveEvalExpr; } |
337 | ExpressionType createDestructuringAssignment(const JSTokenLocation&, int, ExpressionType) |
338 | { |
339 | return DestructuringAssignment; |
340 | } |
341 | |
342 | ArrayPattern createArrayPattern(const JSTokenLocation&) |
343 | { |
344 | return ArrayDestructuring; |
345 | } |
346 | void appendArrayPatternSkipEntry(ArrayPattern, const JSTokenLocation&) |
347 | { |
348 | } |
349 | void appendArrayPatternEntry(ArrayPattern, const JSTokenLocation&, DestructuringPattern, int) |
350 | { |
351 | } |
352 | void appendArrayPatternRestEntry(ArrayPattern, const JSTokenLocation&, DestructuringPattern) |
353 | { |
354 | } |
355 | void finishArrayPattern(ArrayPattern, const JSTextPosition&, const JSTextPosition&, const JSTextPosition&) |
356 | { |
357 | } |
358 | ObjectPattern createObjectPattern(const JSTokenLocation&) |
359 | { |
360 | return ObjectDestructuring; |
361 | } |
362 | void appendObjectPatternEntry(ObjectPattern, const JSTokenLocation&, bool, const Identifier&, DestructuringPattern, int) |
363 | { |
364 | } |
365 | void appendObjectPatternEntry(VM&, ObjectPattern, const JSTokenLocation&, Expression, DestructuringPattern, Expression) |
366 | { |
367 | } |
368 | void appendObjectPatternRestEntry(VM&, ObjectPattern, const JSTokenLocation&, DestructuringPattern) |
369 | { |
370 | } |
371 | void setContainsObjectRestElement(ObjectPattern, bool) |
372 | { |
373 | } |
374 | void setContainsComputedProperty(ObjectPattern, bool) |
375 | { |
376 | } |
377 | |
378 | DestructuringPattern createBindingLocation(const JSTokenLocation&, const Identifier&, const JSTextPosition&, const JSTextPosition&, AssignmentContext) |
379 | { |
380 | return BindingDestructuring; |
381 | } |
382 | RestPattern createRestParameter(DestructuringPattern, size_t) |
383 | { |
384 | return RestParameter; |
385 | } |
386 | DestructuringPattern createAssignmentElement(const Expression&, const JSTextPosition&, const JSTextPosition&) |
387 | { |
388 | return BindingDestructuring; |
389 | } |
390 | |
391 | bool isBindingNode(DestructuringPattern pattern) |
392 | { |
393 | return pattern == BindingDestructuring; |
394 | } |
395 | |
396 | bool isLocation(ExpressionType type) |
397 | { |
398 | return type == ResolveExpr || type == DotExpr || type == BracketExpr; |
399 | } |
400 | |
401 | bool isAssignmentLocation(ExpressionType type) |
402 | { |
403 | return isLocation(type) || type == DestructuringAssignment; |
404 | } |
405 | |
406 | bool isObjectLiteral(ExpressionType type) |
407 | { |
408 | return type == ObjectLiteralExpr; |
409 | } |
410 | |
411 | bool isArrayLiteral(ExpressionType type) |
412 | { |
413 | return type == ArrayLiteralExpr; |
414 | } |
415 | |
416 | bool isObjectOrArrayLiteral(ExpressionType type) |
417 | { |
418 | return isObjectLiteral(type) || isArrayLiteral(type); |
419 | } |
420 | |
421 | bool isFunctionCall(ExpressionType type) |
422 | { |
423 | return type == CallExpr; |
424 | } |
425 | |
426 | bool shouldSkipPauseLocation(int) const { return true; } |
427 | |
428 | void setEndOffset(int, int) { } |
429 | int endOffset(int) { return 0; } |
430 | void setStartOffset(int, int) { } |
431 | |
432 | JSTextPosition breakpointLocation(int) { return JSTextPosition(-1, 0, 0); } |
433 | |
434 | void propagateArgumentsUse() { } |
435 | |
436 | private: |
437 | int m_topBinaryExpr; |
438 | int m_topUnaryToken; |
439 | }; |
440 | |
441 | } // namespace JSC |
442 | |