kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 1 | /* |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 2 | * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 3 | * Copyright (C) 2001 Peter Kelly (pmk@post.com) |
mark.lam@apple.com | 4b79ce7 | 2016-03-11 21:08:08 +0000 | [diff] [blame] | 4 | * Copyright (C) 2003-2009, 2013, 2015-2016 Apple Inc. All rights reserved. |
ggaren | 6c0384f | 2007-10-29 05:32:23 +0000 | [diff] [blame] | 5 | * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) |
| 6 | * Copyright (C) 2007 Maks Orlovich |
eric@webkit.org | f02d379 | 2007-11-08 07:58:15 +0000 | [diff] [blame] | 7 | * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 8 | * |
| 9 | * This library is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU Library General Public |
| 11 | * License as published by the Free Software Foundation; either |
| 12 | * version 2 of the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This library is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | * Library General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU Library General Public License |
| 20 | * along with this library; see the file COPYING.LIB. If not, write to |
mjs | cdff33b | 2006-01-23 21:41:36 +0000 | [diff] [blame] | 21 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
ggaren | 07d4ce6 | 2005-07-14 18:27:04 +0000 | [diff] [blame] | 22 | * Boston, MA 02110-1301, USA. |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 23 | * |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 24 | */ |
| 25 | |
ryanhaddad@apple.com | 22104f5 | 2016-09-28 17:08:17 +0000 | [diff] [blame] | 26 | #pragma once |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 27 | |
keith_miller@apple.com | 1ec869c | 2016-06-21 17:54:33 +0000 | [diff] [blame] | 28 | #include "BuiltinNames.h" |
weinig@apple.com | f157abf | 2008-07-05 05:35:09 +0000 | [diff] [blame] | 29 | #include "Error.h" |
joepeck@webkit.org | f26f3b1 | 2016-09-30 19:22:50 +0000 | [diff] [blame] | 30 | #include "Interpreter.h" |
oliver@apple.com | e79807b | 2009-05-05 11:34:23 +0000 | [diff] [blame] | 31 | #include "JITCode.h" |
darin@apple.com | 7bf9de1 | 2009-05-11 04:30:14 +0000 | [diff] [blame] | 32 | #include "ParserArena.h" |
fpizlo@apple.com | bb8aa75 | 2013-02-18 06:28:54 +0000 | [diff] [blame] | 33 | #include "ParserTokens.h" |
barraclough@apple.com | b8b15e2 | 2008-09-27 01:44:15 +0000 | [diff] [blame] | 34 | #include "ResultType.h" |
cwzwarich@webkit.org | 16e3891 | 2008-11-01 01:05:21 +0000 | [diff] [blame] | 35 | #include "SourceCode.h" |
weinig | c45980a | 2007-10-27 01:01:20 +0000 | [diff] [blame] | 36 | #include "SymbolTable.h" |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 37 | #include "VariableEnvironment.h" |
darin@apple.com | 5b82a72 | 2008-01-27 04:21:43 +0000 | [diff] [blame] | 38 | #include <wtf/MathExtras.h> |
sbarati@apple.com | 432a3c9 | 2016-04-03 19:45:05 +0000 | [diff] [blame] | 39 | #include <wtf/SmallPtrSet.h> |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 40 | |
cwzwarich@webkit.org | 3f782f6 | 2008-09-08 01:28:33 +0000 | [diff] [blame] | 41 | namespace JSC { |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 42 | |
fpizlo@apple.com | bc16ddb | 2016-09-06 01:02:22 +0000 | [diff] [blame] | 43 | enum OpcodeID : unsigned; |
| 44 | |
oliver@apple.com | 65e286e | 2009-04-08 23:08:28 +0000 | [diff] [blame] | 45 | class ArgumentListNode; |
ggaren@apple.com | 8e06f20 | 2008-11-15 21:05:23 +0000 | [diff] [blame] | 46 | class BytecodeGenerator; |
ggaren@apple.com | e7afe40 | 2015-08-10 20:24:35 +0000 | [diff] [blame] | 47 | class FunctionMetadataNode; |
saambarati1@gmail.com | c497d15 | 2015-07-17 18:48:30 +0000 | [diff] [blame] | 48 | class FunctionParameters; |
mjs@apple.com | a46c49c | 2009-12-06 09:42:03 +0000 | [diff] [blame] | 49 | class Label; |
joepeck@webkit.org | 7e07f39 | 2016-09-22 18:59:47 +0000 | [diff] [blame] | 50 | class ModuleAnalyzer; |
| 51 | class ModuleScopeData; |
darin | 761633b | 2007-10-28 22:50:59 +0000 | [diff] [blame] | 52 | class PropertyListNode; |
barraclough@apple.com | 4b2fc99 | 2009-05-07 08:27:58 +0000 | [diff] [blame] | 53 | class ReadModifyResolveNode; |
darin@apple.com | 97ea242 | 2008-11-10 01:28:10 +0000 | [diff] [blame] | 54 | class RegisterID; |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 55 | class ScopeNode; |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 56 | |
sbarati@apple.com | 432a3c9 | 2016-04-03 19:45:05 +0000 | [diff] [blame] | 57 | typedef SmallPtrSet<UniquedStringImpl*> UniquedStringImplPtrSet; |
| 58 | |
darin | 761633b | 2007-10-28 22:50:59 +0000 | [diff] [blame] | 59 | enum Operator { |
| 60 | OpEqual, |
| 61 | OpPlusEq, |
| 62 | OpMinusEq, |
| 63 | OpMultEq, |
| 64 | OpDivEq, |
| 65 | OpPlusPlus, |
| 66 | OpMinusMinus, |
| 67 | OpAndEq, |
| 68 | OpXOrEq, |
| 69 | OpOrEq, |
| 70 | OpModEq, |
utatane.tea@gmail.com | e990638 | 2016-07-21 07:33:28 +0000 | [diff] [blame] | 71 | OpPowEq, |
darin | 761633b | 2007-10-28 22:50:59 +0000 | [diff] [blame] | 72 | OpLShift, |
| 73 | OpRShift, |
barraclough@apple.com | fcb5dd7 | 2008-07-17 12:06:13 +0000 | [diff] [blame] | 74 | OpURShift |
| 75 | }; |
| 76 | |
| 77 | enum LogicalOperator { |
| 78 | OpLogicalAnd, |
| 79 | OpLogicalOr |
darin | 761633b | 2007-10-28 22:50:59 +0000 | [diff] [blame] | 80 | }; |
| 81 | |
ggaren@apple.com | d7cf35d | 2013-03-29 19:12:18 +0000 | [diff] [blame] | 82 | enum FallThroughMode { |
| 83 | FallThroughMeansTrue = 0, |
| 84 | FallThroughMeansFalse = 1 |
| 85 | }; |
| 86 | inline FallThroughMode invert(FallThroughMode fallThroughMode) { return static_cast<FallThroughMode>(!fallThroughMode); } |
| 87 | |
darin@apple.com | 8c2bac0 | 2008-10-09 00:40:43 +0000 | [diff] [blame] | 88 | namespace DeclarationStacks { |
ggaren@apple.com | e7afe40 | 2015-08-10 20:24:35 +0000 | [diff] [blame] | 89 | typedef Vector<FunctionMetadataNode*> FunctionStack; |
darin@apple.com | 8c2bac0 | 2008-10-09 00:40:43 +0000 | [diff] [blame] | 90 | } |
darin@apple.com | 1076ac2 | 2008-01-27 09:38:01 +0000 | [diff] [blame] | 91 | |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 92 | struct SwitchInfo { |
| 93 | enum SwitchType { SwitchNone, SwitchImmediate, SwitchCharacter, SwitchString }; |
ggaren@apple.com | 77dd3c6 | 2008-11-15 20:34:40 +0000 | [diff] [blame] | 94 | uint32_t bytecodeOffset; |
oliver@apple.com | 8007f46 | 2008-07-24 00:49:46 +0000 | [diff] [blame] | 95 | SwitchType switchType; |
| 96 | }; |
| 97 | |
saambarati1@gmail.com | e455672 | 2015-07-19 16:57:44 +0000 | [diff] [blame] | 98 | enum class AssignmentContext { |
| 99 | DeclarationStatement, |
| 100 | ConstDeclarationStatement, |
| 101 | AssignmentExpression |
| 102 | }; |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 103 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 104 | class ParserArenaFreeable { |
| 105 | public: |
| 106 | // ParserArenaFreeable objects are are freed when the arena is deleted. |
| 107 | // Destructors are not called. Clients must not call delete on such objects. |
ggaren@apple.com | c0ccae0 | 2014-12-03 23:23:56 +0000 | [diff] [blame] | 108 | void* operator new(size_t, ParserArena&); |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 109 | }; |
mrowe@apple.com | 224b7e8 | 2009-08-20 18:04:37 +0000 | [diff] [blame] | 110 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 111 | class ParserArenaDeletable { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 112 | public: |
darin@apple.com | 7bf9de1 | 2009-05-11 04:30:14 +0000 | [diff] [blame] | 113 | virtual ~ParserArenaDeletable() { } |
darin@apple.com | 97ea242 | 2008-11-10 01:28:10 +0000 | [diff] [blame] | 114 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 115 | // ParserArenaDeletable objects are deleted when the arena is deleted. |
| 116 | // Clients must not call delete directly on such objects. |
ggaren@apple.com | c0ccae0 | 2014-12-03 23:23:56 +0000 | [diff] [blame] | 117 | void* operator new(size_t, ParserArena&); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 118 | }; |
ggaren | 62a50b2 | 2007-10-16 21:35:50 +0000 | [diff] [blame] | 119 | |
ggaren@apple.com | 9e5d58e | 2014-12-05 00:59:33 +0000 | [diff] [blame] | 120 | class ParserArenaRoot { |
andersca@apple.com | 1ad612f | 2014-02-18 01:32:18 +0000 | [diff] [blame] | 121 | WTF_MAKE_FAST_ALLOCATED; |
darin@apple.com | 7bf9de1 | 2009-05-11 04:30:14 +0000 | [diff] [blame] | 122 | protected: |
ggaren@apple.com | 9e5d58e | 2014-12-05 00:59:33 +0000 | [diff] [blame] | 123 | ParserArenaRoot(ParserArena&); |
darin@apple.com | e615d31 | 2009-05-05 23:09:52 +0000 | [diff] [blame] | 124 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 125 | public: |
ggaren@apple.com | 9e5d58e | 2014-12-05 00:59:33 +0000 | [diff] [blame] | 126 | ParserArena& parserArena() { return m_arena; } |
| 127 | virtual ~ParserArenaRoot() { } |
| 128 | |
| 129 | protected: |
| 130 | ParserArena m_arena; |
darin@apple.com | 7bf9de1 | 2009-05-11 04:30:14 +0000 | [diff] [blame] | 131 | }; |
| 132 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 133 | class Node : public ParserArenaFreeable { |
darin@apple.com | 7bf9de1 | 2009-05-11 04:30:14 +0000 | [diff] [blame] | 134 | protected: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 135 | Node(const JSTokenLocation&); |
darin@apple.com | 74da9e0 | 2007-12-20 21:57:18 +0000 | [diff] [blame] | 136 | |
darin@apple.com | 7bf9de1 | 2009-05-11 04:30:14 +0000 | [diff] [blame] | 137 | public: |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 138 | virtual ~Node() { } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 139 | |
ggaren@apple.com | 8e8bac4 | 2015-03-26 23:35:47 +0000 | [diff] [blame] | 140 | int firstLine() const { return m_position.line; } |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 141 | int startOffset() const { return m_position.offset; } |
saambarati1@gmail.com | d696146 | 2014-10-30 23:50:54 +0000 | [diff] [blame] | 142 | int endOffset() const { return m_endOffset; } |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 143 | int lineStartOffset() const { return m_position.lineStartOffset; } |
| 144 | const JSTextPosition& position() const { return m_position; } |
saambarati1@gmail.com | d696146 | 2014-10-30 23:50:54 +0000 | [diff] [blame] | 145 | void setEndOffset(int offset) { m_endOffset = offset; } |
saambarati1@gmail.com | 1595250 | 2015-02-23 22:10:51 +0000 | [diff] [blame] | 146 | void setStartOffset(int offset) { m_position.offset = offset; } |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 147 | |
joepeck@webkit.org | b5fbd45 | 2016-10-12 18:47:48 +0000 | [diff] [blame] | 148 | bool needsDebugHook() const { return m_needsDebugHook; } |
| 149 | void setNeedsDebugHook() { m_needsDebugHook = true; } |
| 150 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 151 | protected: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 152 | JSTextPosition m_position; |
saambarati1@gmail.com | d696146 | 2014-10-30 23:50:54 +0000 | [diff] [blame] | 153 | int m_endOffset; |
joepeck@webkit.org | b5fbd45 | 2016-10-12 18:47:48 +0000 | [diff] [blame] | 154 | bool m_needsDebugHook { false }; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 155 | }; |
| 156 | |
eseidel | 93b803f | 2007-11-09 00:43:52 +0000 | [diff] [blame] | 157 | class ExpressionNode : public Node { |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 158 | protected: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 159 | ExpressionNode(const JSTokenLocation&, ResultType = ResultType::unknownType()); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 160 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 161 | public: |
ggaren@apple.com | d786e6b | 2013-04-04 23:16:20 +0000 | [diff] [blame] | 162 | virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* destination = 0) = 0; |
| 163 | |
oliver@apple.com | 62cee78 | 2009-05-20 01:18:05 +0000 | [diff] [blame] | 164 | virtual bool isNumber() const { return false; } |
| 165 | virtual bool isString() const { return false; } |
commit-queue@webkit.org | 88a7476 | 2015-11-19 22:54:46 +0000 | [diff] [blame] | 166 | virtual bool isObjectLiteral() const { return false; } |
| 167 | virtual bool isArrayLiteral() const { return false; } |
oliver@apple.com | 62cee78 | 2009-05-20 01:18:05 +0000 | [diff] [blame] | 168 | virtual bool isNull() const { return false; } |
| 169 | virtual bool isPure(BytecodeGenerator&) const { return false; } |
ggaren@apple.com | 81c68cc | 2013-04-27 06:43:33 +0000 | [diff] [blame] | 170 | virtual bool isConstant() const { return false; } |
oliver@apple.com | 62cee78 | 2009-05-20 01:18:05 +0000 | [diff] [blame] | 171 | virtual bool isLocation() const { return false; } |
oliver@apple.com | 313fcd6 | 2014-03-25 20:06:07 +0000 | [diff] [blame] | 172 | virtual bool isAssignmentLocation() const { return isLocation(); } |
oliver@apple.com | 62cee78 | 2009-05-20 01:18:05 +0000 | [diff] [blame] | 173 | virtual bool isResolveNode() const { return false; } |
gskachkov@gmail.com | ad01d6b | 2016-08-24 13:35:38 +0000 | [diff] [blame] | 174 | virtual bool isAssignResolveNode() const { return false; } |
oliver@apple.com | 62cee78 | 2009-05-20 01:18:05 +0000 | [diff] [blame] | 175 | virtual bool isBracketAccessorNode() const { return false; } |
| 176 | virtual bool isDotAccessorNode() const { return false; } |
saambarati1@gmail.com | cc3bcb6 | 2015-07-02 23:53:10 +0000 | [diff] [blame] | 177 | virtual bool isDestructuringNode() const { return false; } |
commit-queue@webkit.org | c4df9c0 | 2016-09-29 19:01:42 +0000 | [diff] [blame] | 178 | virtual bool isBaseFuncExprNode() const { return false; } |
oliver@apple.com | 5242820 | 2009-06-24 22:01:34 +0000 | [diff] [blame] | 179 | virtual bool isFuncExprNode() const { return false; } |
commit-queue@webkit.org | a4201b0 | 2015-08-17 22:24:20 +0000 | [diff] [blame] | 180 | virtual bool isArrowFuncExprNode() const { return false; } |
mark.lam@apple.com | 4b79ce7 | 2016-03-11 21:08:08 +0000 | [diff] [blame] | 181 | virtual bool isClassExprNode() const { return false; } |
oliver@apple.com | 5242820 | 2009-06-24 22:01:34 +0000 | [diff] [blame] | 182 | virtual bool isCommaNode() const { return false; } |
oliver@apple.com | 62cee78 | 2009-05-20 01:18:05 +0000 | [diff] [blame] | 183 | virtual bool isSimpleArray() const { return false; } |
| 184 | virtual bool isAdd() const { return false; } |
barraclough@apple.com | b467c4c | 2010-07-13 20:34:11 +0000 | [diff] [blame] | 185 | virtual bool isSubtract() const { return false; } |
ggaren@apple.com | 81c68cc | 2013-04-27 06:43:33 +0000 | [diff] [blame] | 186 | virtual bool isBoolean() const { return false; } |
oliver@apple.com | 72f8a82 | 2013-10-17 01:02:34 +0000 | [diff] [blame] | 187 | virtual bool isSpreadExpression() const { return false; } |
rniwa@webkit.org | 059ef9b | 2015-03-09 23:47:06 +0000 | [diff] [blame] | 188 | virtual bool isSuperNode() const { return false; } |
utatane.tea@gmail.com | 5e63912 | 2017-01-09 22:02:47 +0000 | [diff] [blame] | 189 | virtual bool isImportNode() const { return false; } |
sbarati@apple.com | fa0c147 | 2016-03-14 18:38:28 +0000 | [diff] [blame] | 190 | virtual bool isNewTarget() const { return false; } |
utatane.tea@gmail.com | bf8978b | 2016-02-02 19:33:05 +0000 | [diff] [blame] | 191 | virtual bool isBytecodeIntrinsicNode() const { return false; } |
mjs@apple.com | a46c49c | 2009-12-06 09:42:03 +0000 | [diff] [blame] | 192 | |
utatane.tea@gmail.com | 6f1b3f3 | 2017-02-16 07:56:48 +0000 | [diff] [blame] | 193 | virtual void emitBytecodeInConditionContext(BytecodeGenerator&, Label&, Label&, FallThroughMode); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 194 | |
mjs@apple.com | 9b5c619 | 2008-10-08 10:53:13 +0000 | [diff] [blame] | 195 | virtual ExpressionNode* stripUnaryPlus() { return this; } |
| 196 | |
oliver@apple.com | 62cee78 | 2009-05-20 01:18:05 +0000 | [diff] [blame] | 197 | ResultType resultDescriptor() const { return m_resultType; } |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 198 | |
barraclough@apple.com | b8b15e2 | 2008-09-27 01:44:15 +0000 | [diff] [blame] | 199 | private: |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 200 | ResultType m_resultType; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 201 | }; |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 202 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 203 | class StatementNode : public Node { |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 204 | protected: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 205 | StatementNode(const JSTokenLocation&); |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 206 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 207 | public: |
ggaren@apple.com | d786e6b | 2013-04-04 23:16:20 +0000 | [diff] [blame] | 208 | virtual void emitBytecode(BytecodeGenerator&, RegisterID* destination = 0) = 0; |
| 209 | |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 210 | void setLoc(unsigned firstLine, unsigned lastLine, int startOffset, int lineStartOffset); |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 211 | unsigned lastLine() const { return m_lastLine; } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 212 | |
ggaren@apple.com | 86cb7be | 2014-12-09 01:53:53 +0000 | [diff] [blame] | 213 | StatementNode* next() { return m_next; } |
| 214 | void setNext(StatementNode* next) { m_next = next; } |
| 215 | |
oliver@apple.com | 62cee78 | 2009-05-20 01:18:05 +0000 | [diff] [blame] | 216 | virtual bool isEmptyStatement() const { return false; } |
joepeck@webkit.org | b5fbd45 | 2016-10-12 18:47:48 +0000 | [diff] [blame] | 217 | virtual bool isDebuggerStatement() const { return false; } |
joepeck@webkit.org | bb70ac6 | 2016-09-30 19:22:37 +0000 | [diff] [blame] | 218 | virtual bool isFunctionNode() const { return false; } |
oliver@apple.com | 62cee78 | 2009-05-20 01:18:05 +0000 | [diff] [blame] | 219 | virtual bool isReturnNode() const { return false; } |
| 220 | virtual bool isExprStatement() const { return false; } |
ggaren@apple.com | 81c68cc | 2013-04-27 06:43:33 +0000 | [diff] [blame] | 221 | virtual bool isBreak() const { return false; } |
| 222 | virtual bool isContinue() const { return false; } |
joepeck@webkit.org | f26f3b1 | 2016-09-30 19:22:50 +0000 | [diff] [blame] | 223 | virtual bool isLabel() const { return false; } |
oliver@apple.com | 62cee78 | 2009-05-20 01:18:05 +0000 | [diff] [blame] | 224 | virtual bool isBlock() const { return false; } |
ggaren@apple.com | ddc6f10 | 2015-03-20 20:12:10 +0000 | [diff] [blame] | 225 | virtual bool isFuncDeclNode() const { return false; } |
utatane.tea@gmail.com | 505049b | 2015-08-13 23:55:35 +0000 | [diff] [blame] | 226 | virtual bool isModuleDeclarationNode() const { return false; } |
joepeck@webkit.org | bb70ac6 | 2016-09-30 19:22:37 +0000 | [diff] [blame] | 227 | virtual bool isForOfNode() const { return false; } |
timothy@apple.com | dbdf2443 | 2009-03-01 20:14:44 +0000 | [diff] [blame] | 228 | |
mark.lam@apple.com | fa35e78 | 2013-11-19 21:55:16 +0000 | [diff] [blame] | 229 | protected: |
ggaren@apple.com | 86cb7be | 2014-12-09 01:53:53 +0000 | [diff] [blame] | 230 | StatementNode* m_next; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 231 | int m_lastLine; |
| 232 | }; |
| 233 | |
sbarati@apple.com | 62be0b0 | 2015-09-19 15:36:46 +0000 | [diff] [blame] | 234 | class VariableEnvironmentNode : public ParserArenaDeletable { |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 235 | public: |
sbarati@apple.com | 8e614bd | 2016-03-10 02:04:20 +0000 | [diff] [blame] | 236 | typedef DeclarationStacks::FunctionStack FunctionStack; |
| 237 | |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 238 | VariableEnvironmentNode() |
| 239 | { |
| 240 | } |
| 241 | |
| 242 | VariableEnvironmentNode(VariableEnvironment& lexicalDeclaredVariables); |
sbarati@apple.com | 8e614bd | 2016-03-10 02:04:20 +0000 | [diff] [blame] | 243 | VariableEnvironmentNode(VariableEnvironment& lexicalDeclaredVariables, FunctionStack&&); |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 244 | |
| 245 | VariableEnvironment& lexicalVariables() { return m_lexicalVariables; } |
sbarati@apple.com | 8e614bd | 2016-03-10 02:04:20 +0000 | [diff] [blame] | 246 | FunctionStack& functionStack() { return m_functionStack; } |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 247 | |
| 248 | protected: |
| 249 | VariableEnvironment m_lexicalVariables; |
sbarati@apple.com | 8e614bd | 2016-03-10 02:04:20 +0000 | [diff] [blame] | 250 | FunctionStack m_functionStack; |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 251 | }; |
| 252 | |
ggaren@apple.com | 81c68cc | 2013-04-27 06:43:33 +0000 | [diff] [blame] | 253 | class ConstantNode : public ExpressionNode { |
| 254 | public: |
| 255 | ConstantNode(const JSTokenLocation&, ResultType); |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 256 | bool isPure(BytecodeGenerator&) const override { return true; } |
| 257 | bool isConstant() const override { return true; } |
ggaren@apple.com | 81c68cc | 2013-04-27 06:43:33 +0000 | [diff] [blame] | 258 | virtual JSValue jsValue(BytecodeGenerator&) const = 0; |
| 259 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 260 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
utatane.tea@gmail.com | 6f1b3f3 | 2017-02-16 07:56:48 +0000 | [diff] [blame] | 261 | void emitBytecodeInConditionContext(BytecodeGenerator&, Label& trueTarget, Label& falseTarget, FallThroughMode) override; |
ggaren@apple.com | 81c68cc | 2013-04-27 06:43:33 +0000 | [diff] [blame] | 262 | }; |
| 263 | |
| 264 | class NullNode : public ConstantNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 265 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 266 | NullNode(const JSTokenLocation&); |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 267 | |
| 268 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 269 | bool isNull() const override { return true; } |
| 270 | JSValue jsValue(BytecodeGenerator&) const override { return jsNull(); } |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 271 | }; |
| 272 | |
ggaren@apple.com | 81c68cc | 2013-04-27 06:43:33 +0000 | [diff] [blame] | 273 | class BooleanNode : public ConstantNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 274 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 275 | BooleanNode(const JSTokenLocation&, bool value); |
ggaren@apple.com | 81c68cc | 2013-04-27 06:43:33 +0000 | [diff] [blame] | 276 | bool value() { return m_value; } |
oliver@apple.com | 3812e42 | 2014-04-13 18:01:54 +0000 | [diff] [blame] | 277 | |
commit-queue@webkit.org | 5fb8032 | 2014-04-15 17:46:42 +0000 | [diff] [blame] | 278 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 279 | bool isBoolean() const override { return true; } |
| 280 | JSValue jsValue(BytecodeGenerator&) const override { return jsBoolean(m_value); } |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 281 | |
cwzwarich@webkit.org | 9cb74e3 | 2008-06-14 05:06:21 +0000 | [diff] [blame] | 282 | bool m_value; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 283 | }; |
| 284 | |
ggaren@apple.com | 81c68cc | 2013-04-27 06:43:33 +0000 | [diff] [blame] | 285 | class NumberNode : public ConstantNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 286 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 287 | NumberNode(const JSTokenLocation&, double value); |
benjamin@webkit.org | 54d94f5 | 2015-02-28 03:21:37 +0000 | [diff] [blame] | 288 | double value() const { return m_value; } |
| 289 | virtual bool isIntegerNode() const = 0; |
darin@apple.com | 49cc03e | 2016-03-04 17:20:46 +0000 | [diff] [blame] | 290 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) final; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 291 | |
| 292 | private: |
darin@apple.com | 49cc03e | 2016-03-04 17:20:46 +0000 | [diff] [blame] | 293 | bool isNumber() const final { return true; } |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 294 | JSValue jsValue(BytecodeGenerator&) const override { return jsNumber(m_value); } |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 295 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 296 | double m_value; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 297 | }; |
| 298 | |
benjamin@webkit.org | 54d94f5 | 2015-02-28 03:21:37 +0000 | [diff] [blame] | 299 | class DoubleNode : public NumberNode { |
| 300 | public: |
| 301 | DoubleNode(const JSTokenLocation&, double value); |
| 302 | |
| 303 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 304 | bool isIntegerNode() const override { return false; } |
benjamin@webkit.org | 54d94f5 | 2015-02-28 03:21:37 +0000 | [diff] [blame] | 305 | }; |
| 306 | |
| 307 | // An integer node represent a number represented as an integer (e.g. 42 instead of 42., 42.0, 42e0) |
| 308 | class IntegerNode : public DoubleNode { |
| 309 | public: |
| 310 | IntegerNode(const JSTokenLocation&, double value); |
darin@apple.com | 49cc03e | 2016-03-04 17:20:46 +0000 | [diff] [blame] | 311 | bool isIntegerNode() const final { return true; } |
benjamin@webkit.org | 54d94f5 | 2015-02-28 03:21:37 +0000 | [diff] [blame] | 312 | }; |
| 313 | |
ggaren@apple.com | 81c68cc | 2013-04-27 06:43:33 +0000 | [diff] [blame] | 314 | class StringNode : public ConstantNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 315 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 316 | StringNode(const JSTokenLocation&, const Identifier&); |
darin@apple.com | 2543b4d | 2008-09-19 06:32:12 +0000 | [diff] [blame] | 317 | const Identifier& value() { return m_value; } |
darin@apple.com | de5d6e2 | 2009-08-20 14:24:49 +0000 | [diff] [blame] | 318 | |
mrowe@apple.com | 224b7e8 | 2009-08-20 18:04:37 +0000 | [diff] [blame] | 319 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 320 | bool isString() const override { return true; } |
| 321 | JSValue jsValue(BytecodeGenerator&) const override; |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 322 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 323 | const Identifier& m_value; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 324 | }; |
utatane.tea@gmail.com | 4014aea | 2015-04-27 00:27:28 +0000 | [diff] [blame] | 325 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 326 | class ThrowableExpressionData { |
| 327 | public: |
| 328 | ThrowableExpressionData() |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 329 | : m_divot(-1, -1, -1) |
| 330 | , m_divotStart(-1, -1, -1) |
| 331 | , m_divotEnd(-1, -1, -1) |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 332 | { |
| 333 | } |
| 334 | |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 335 | ThrowableExpressionData(const JSTextPosition& divot, const JSTextPosition& start, const JSTextPosition& end) |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 336 | : m_divot(divot) |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 337 | , m_divotStart(start) |
| 338 | , m_divotEnd(end) |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 339 | { |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 340 | ASSERT(m_divot.offset >= m_divot.lineStartOffset); |
| 341 | ASSERT(m_divotStart.offset >= m_divotStart.lineStartOffset); |
| 342 | ASSERT(m_divotEnd.offset >= m_divotEnd.lineStartOffset); |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 343 | } |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 344 | |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 345 | void setExceptionSourceCode(const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd) |
| 346 | { |
| 347 | ASSERT(divot.offset >= divot.lineStartOffset); |
| 348 | ASSERT(divotStart.offset >= divotStart.lineStartOffset); |
| 349 | ASSERT(divotEnd.offset >= divotEnd.lineStartOffset); |
| 350 | m_divot = divot; |
| 351 | m_divotStart = divotStart; |
| 352 | m_divotEnd = divotEnd; |
| 353 | } |
| 354 | |
| 355 | const JSTextPosition& divot() const { return m_divot; } |
| 356 | const JSTextPosition& divotStart() const { return m_divotStart; } |
| 357 | const JSTextPosition& divotEnd() const { return m_divotEnd; } |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 358 | |
| 359 | protected: |
benjamin@webkit.org | cff06e4 | 2012-08-30 21:23:51 +0000 | [diff] [blame] | 360 | RegisterID* emitThrowReferenceError(BytecodeGenerator&, const String& message); |
darin@apple.com | 97ea242 | 2008-11-10 01:28:10 +0000 | [diff] [blame] | 361 | |
| 362 | private: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 363 | JSTextPosition m_divot; |
| 364 | JSTextPosition m_divotStart; |
| 365 | JSTextPosition m_divotEnd; |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 366 | }; |
| 367 | |
| 368 | class ThrowableSubExpressionData : public ThrowableExpressionData { |
| 369 | public: |
| 370 | ThrowableSubExpressionData() |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 371 | : m_subexpressionDivotOffset(0) |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 372 | , m_subexpressionEndOffset(0) |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 373 | , m_subexpressionLineOffset(0) |
| 374 | , m_subexpressionLineStartOffset(0) |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 375 | { |
| 376 | } |
| 377 | |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 378 | ThrowableSubExpressionData(const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd) |
| 379 | : ThrowableExpressionData(divot, divotStart, divotEnd) |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 380 | , m_subexpressionDivotOffset(0) |
| 381 | , m_subexpressionEndOffset(0) |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 382 | , m_subexpressionLineOffset(0) |
| 383 | , m_subexpressionLineStartOffset(0) |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 384 | { |
| 385 | } |
| 386 | |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 387 | void setSubexpressionInfo(const JSTextPosition& subexpressionDivot, int subexpressionOffset) |
darin@apple.com | 97ea242 | 2008-11-10 01:28:10 +0000 | [diff] [blame] | 388 | { |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 389 | ASSERT(subexpressionDivot.offset <= divot().offset); |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 390 | // Overflow means we can't do this safely, so just point at the primary divot, |
| 391 | // divotLine, or divotLineStart. |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 392 | if ((divot() - subexpressionDivot.offset) & ~0xFFFF) |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 393 | return; |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 394 | if ((divot().line - subexpressionDivot.line) & ~0xFFFF) |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 395 | return; |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 396 | if ((divot().lineStartOffset - subexpressionDivot.lineStartOffset) & ~0xFFFF) |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 397 | return; |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 398 | if ((divotEnd() - subexpressionOffset) & ~0xFFFF) |
| 399 | return; |
| 400 | m_subexpressionDivotOffset = divot() - subexpressionDivot.offset; |
| 401 | m_subexpressionEndOffset = divotEnd() - subexpressionOffset; |
| 402 | m_subexpressionLineOffset = divot().line - subexpressionDivot.line; |
| 403 | m_subexpressionLineStartOffset = divot().lineStartOffset - subexpressionDivot.lineStartOffset; |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 404 | } |
| 405 | |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 406 | JSTextPosition subexpressionDivot() |
| 407 | { |
| 408 | int newLine = divot().line - m_subexpressionLineOffset; |
| 409 | int newOffset = divot().offset - m_subexpressionDivotOffset; |
| 410 | int newLineStartOffset = divot().lineStartOffset - m_subexpressionLineStartOffset; |
| 411 | return JSTextPosition(newLine, newOffset, newLineStartOffset); |
| 412 | } |
| 413 | JSTextPosition subexpressionStart() { return divotStart(); } |
| 414 | JSTextPosition subexpressionEnd() { return divotEnd() - static_cast<int>(m_subexpressionEndOffset); } |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 415 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 416 | protected: |
| 417 | uint16_t m_subexpressionDivotOffset; |
| 418 | uint16_t m_subexpressionEndOffset; |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 419 | uint16_t m_subexpressionLineOffset; |
| 420 | uint16_t m_subexpressionLineStartOffset; |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 421 | }; |
| 422 | |
| 423 | class ThrowablePrefixedSubExpressionData : public ThrowableExpressionData { |
| 424 | public: |
| 425 | ThrowablePrefixedSubExpressionData() |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 426 | : m_subexpressionDivotOffset(0) |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 427 | , m_subexpressionStartOffset(0) |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 428 | , m_subexpressionLineOffset(0) |
| 429 | , m_subexpressionLineStartOffset(0) |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 430 | { |
| 431 | } |
| 432 | |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 433 | ThrowablePrefixedSubExpressionData(const JSTextPosition& divot, const JSTextPosition& start, const JSTextPosition& end) |
| 434 | : ThrowableExpressionData(divot, start, end) |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 435 | , m_subexpressionDivotOffset(0) |
| 436 | , m_subexpressionStartOffset(0) |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 437 | , m_subexpressionLineOffset(0) |
| 438 | , m_subexpressionLineStartOffset(0) |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 439 | { |
| 440 | } |
| 441 | |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 442 | void setSubexpressionInfo(const JSTextPosition& subexpressionDivot, int subexpressionOffset) |
darin@apple.com | 97ea242 | 2008-11-10 01:28:10 +0000 | [diff] [blame] | 443 | { |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 444 | ASSERT(subexpressionDivot.offset >= divot().offset); |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 445 | // Overflow means we can't do this safely, so just point at the primary divot, |
| 446 | // divotLine, or divotLineStart. |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 447 | if ((subexpressionDivot.offset - divot()) & ~0xFFFF) |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 448 | return; |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 449 | if ((subexpressionDivot.line - divot().line) & ~0xFFFF) |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 450 | return; |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 451 | if ((subexpressionDivot.lineStartOffset - divot().lineStartOffset) & ~0xFFFF) |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 452 | return; |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 453 | if ((subexpressionOffset - divotStart()) & ~0xFFFF) |
| 454 | return; |
| 455 | m_subexpressionDivotOffset = subexpressionDivot.offset - divot(); |
| 456 | m_subexpressionStartOffset = subexpressionOffset - divotStart(); |
| 457 | m_subexpressionLineOffset = subexpressionDivot.line - divot().line; |
| 458 | m_subexpressionLineStartOffset = subexpressionDivot.lineStartOffset - divot().lineStartOffset; |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 459 | } |
| 460 | |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 461 | JSTextPosition subexpressionDivot() |
| 462 | { |
| 463 | int newLine = divot().line + m_subexpressionLineOffset; |
| 464 | int newOffset = divot().offset + m_subexpressionDivotOffset; |
| 465 | int newLineStartOffset = divot().lineStartOffset + m_subexpressionLineStartOffset; |
| 466 | return JSTextPosition(newLine, newOffset, newLineStartOffset); |
| 467 | } |
| 468 | JSTextPosition subexpressionStart() { return divotStart() + static_cast<int>(m_subexpressionStartOffset); } |
| 469 | JSTextPosition subexpressionEnd() { return divotEnd(); } |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 470 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 471 | protected: |
| 472 | uint16_t m_subexpressionDivotOffset; |
| 473 | uint16_t m_subexpressionStartOffset; |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 474 | uint16_t m_subexpressionLineOffset; |
| 475 | uint16_t m_subexpressionLineStartOffset; |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 476 | }; |
| 477 | |
utatane.tea@gmail.com | 4014aea | 2015-04-27 00:27:28 +0000 | [diff] [blame] | 478 | class TemplateExpressionListNode : public ParserArenaFreeable { |
| 479 | public: |
| 480 | TemplateExpressionListNode(ExpressionNode*); |
| 481 | TemplateExpressionListNode(TemplateExpressionListNode*, ExpressionNode*); |
| 482 | |
| 483 | ExpressionNode* value() { return m_node; } |
| 484 | TemplateExpressionListNode* next() { return m_next; } |
| 485 | |
| 486 | private: |
| 487 | TemplateExpressionListNode* m_next { nullptr }; |
| 488 | ExpressionNode* m_node { nullptr }; |
| 489 | }; |
| 490 | |
| 491 | class TemplateStringNode : public ExpressionNode { |
| 492 | public: |
utatane.tea@gmail.com | a10944d | 2017-01-28 03:09:12 +0000 | [diff] [blame] | 493 | TemplateStringNode(const JSTokenLocation&, const Identifier* cooked, const Identifier* raw); |
utatane.tea@gmail.com | 4014aea | 2015-04-27 00:27:28 +0000 | [diff] [blame] | 494 | |
utatane.tea@gmail.com | a10944d | 2017-01-28 03:09:12 +0000 | [diff] [blame] | 495 | const Identifier* cooked() { return m_cooked; } |
| 496 | const Identifier* raw() { return m_raw; } |
utatane.tea@gmail.com | 4014aea | 2015-04-27 00:27:28 +0000 | [diff] [blame] | 497 | |
| 498 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 499 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
utatane.tea@gmail.com | 4014aea | 2015-04-27 00:27:28 +0000 | [diff] [blame] | 500 | |
utatane.tea@gmail.com | a10944d | 2017-01-28 03:09:12 +0000 | [diff] [blame] | 501 | const Identifier* m_cooked; |
| 502 | const Identifier* m_raw; |
utatane.tea@gmail.com | 4014aea | 2015-04-27 00:27:28 +0000 | [diff] [blame] | 503 | }; |
| 504 | |
| 505 | class TemplateStringListNode : public ParserArenaFreeable { |
| 506 | public: |
| 507 | TemplateStringListNode(TemplateStringNode*); |
| 508 | TemplateStringListNode(TemplateStringListNode*, TemplateStringNode*); |
| 509 | |
| 510 | TemplateStringNode* value() { return m_node; } |
| 511 | TemplateStringListNode* next() { return m_next; } |
| 512 | |
| 513 | private: |
| 514 | TemplateStringListNode* m_next { nullptr }; |
| 515 | TemplateStringNode* m_node { nullptr }; |
| 516 | }; |
| 517 | |
| 518 | class TemplateLiteralNode : public ExpressionNode { |
| 519 | public: |
| 520 | TemplateLiteralNode(const JSTokenLocation&, TemplateStringListNode*); |
| 521 | TemplateLiteralNode(const JSTokenLocation&, TemplateStringListNode*, TemplateExpressionListNode*); |
| 522 | |
utatane.tea@gmail.com | d68d248 | 2015-05-14 16:07:54 +0000 | [diff] [blame] | 523 | TemplateStringListNode* templateStrings() const { return m_templateStrings; } |
| 524 | TemplateExpressionListNode* templateExpressions() const { return m_templateExpressions; } |
| 525 | |
utatane.tea@gmail.com | 4014aea | 2015-04-27 00:27:28 +0000 | [diff] [blame] | 526 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 527 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
utatane.tea@gmail.com | 4014aea | 2015-04-27 00:27:28 +0000 | [diff] [blame] | 528 | |
| 529 | TemplateStringListNode* m_templateStrings; |
| 530 | TemplateExpressionListNode* m_templateExpressions; |
| 531 | }; |
utatane.tea@gmail.com | d68d248 | 2015-05-14 16:07:54 +0000 | [diff] [blame] | 532 | |
| 533 | class TaggedTemplateNode : public ExpressionNode, public ThrowableExpressionData { |
| 534 | public: |
| 535 | TaggedTemplateNode(const JSTokenLocation&, ExpressionNode*, TemplateLiteralNode*); |
| 536 | |
| 537 | TemplateLiteralNode* templateLiteral() const { return m_templateLiteral; } |
| 538 | |
| 539 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 540 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
utatane.tea@gmail.com | d68d248 | 2015-05-14 16:07:54 +0000 | [diff] [blame] | 541 | |
| 542 | ExpressionNode* m_tag; |
| 543 | TemplateLiteralNode* m_templateLiteral; |
| 544 | }; |
utatane.tea@gmail.com | 4014aea | 2015-04-27 00:27:28 +0000 | [diff] [blame] | 545 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 546 | class RegExpNode : public ExpressionNode, public ThrowableExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 547 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 548 | RegExpNode(const JSTokenLocation&, const Identifier& pattern, const Identifier& flags); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 549 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 550 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 551 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 552 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 553 | const Identifier& m_pattern; |
| 554 | const Identifier& m_flags; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 555 | }; |
| 556 | |
| 557 | class ThisNode : public ExpressionNode { |
| 558 | public: |
utatane.tea@gmail.com | c202907 | 2016-05-24 12:04:35 +0000 | [diff] [blame] | 559 | ThisNode(const JSTokenLocation&); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 560 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 561 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 562 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 563 | }; |
| 564 | |
rniwa@webkit.org | 059ef9b | 2015-03-09 23:47:06 +0000 | [diff] [blame] | 565 | class SuperNode final : public ExpressionNode { |
| 566 | public: |
| 567 | SuperNode(const JSTokenLocation&); |
| 568 | |
| 569 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 570 | bool isSuperNode() const override { return true; } |
| 571 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
rniwa@webkit.org | 059ef9b | 2015-03-09 23:47:06 +0000 | [diff] [blame] | 572 | }; |
| 573 | |
utatane.tea@gmail.com | 5e63912 | 2017-01-09 22:02:47 +0000 | [diff] [blame] | 574 | class ImportNode : public ExpressionNode, public ThrowableExpressionData { |
| 575 | public: |
| 576 | ImportNode(const JSTokenLocation&, ExpressionNode*); |
| 577 | |
| 578 | private: |
| 579 | bool isImportNode() const override { return true; } |
| 580 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
| 581 | |
| 582 | ExpressionNode* m_expr; |
| 583 | }; |
| 584 | |
commit-queue@webkit.org | 17f99e4 | 2015-07-21 18:18:42 +0000 | [diff] [blame] | 585 | class NewTargetNode final : public ExpressionNode { |
| 586 | public: |
| 587 | NewTargetNode(const JSTokenLocation&); |
| 588 | |
| 589 | private: |
sbarati@apple.com | fa0c147 | 2016-03-14 18:38:28 +0000 | [diff] [blame] | 590 | bool isNewTarget() const final { return true; } |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 591 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
commit-queue@webkit.org | 17f99e4 | 2015-07-21 18:18:42 +0000 | [diff] [blame] | 592 | }; |
| 593 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 594 | class ResolveNode : public ExpressionNode { |
| 595 | public: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 596 | ResolveNode(const JSTokenLocation&, const Identifier&, const JSTextPosition& start); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 597 | |
oliver@apple.com | 62cee78 | 2009-05-20 01:18:05 +0000 | [diff] [blame] | 598 | const Identifier& identifier() const { return m_ident; } |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 599 | |
| 600 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 601 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 602 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 603 | bool isPure(BytecodeGenerator&) const override; |
| 604 | bool isLocation() const override { return true; } |
| 605 | bool isResolveNode() const override { return true; } |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 606 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 607 | const Identifier& m_ident; |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 608 | JSTextPosition m_start; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 609 | }; |
| 610 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 611 | class ElementNode : public ParserArenaFreeable { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 612 | public: |
msaboff@apple.com | 2e5003e | 2011-10-31 22:13:01 +0000 | [diff] [blame] | 613 | ElementNode(int elision, ExpressionNode*); |
| 614 | ElementNode(ElementNode*, int elision, ExpressionNode*); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 615 | |
darin@apple.com | 9ce7902 | 2008-06-28 15:50:49 +0000 | [diff] [blame] | 616 | int elision() const { return m_elision; } |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 617 | ExpressionNode* value() { return m_node; } |
| 618 | ElementNode* next() { return m_next; } |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 619 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 620 | private: |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 621 | ElementNode* m_next; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 622 | int m_elision; |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 623 | ExpressionNode* m_node; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 624 | }; |
| 625 | |
| 626 | class ArrayNode : public ExpressionNode { |
| 627 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 628 | ArrayNode(const JSTokenLocation&, int elision); |
| 629 | ArrayNode(const JSTokenLocation&, ElementNode*); |
| 630 | ArrayNode(const JSTokenLocation&, int elision, ElementNode*); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 631 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 632 | bool isArrayLiteral() const override { return true; } |
commit-queue@webkit.org | 88a7476 | 2015-11-19 22:54:46 +0000 | [diff] [blame] | 633 | |
ggaren@apple.com | c0ccae0 | 2014-12-03 23:23:56 +0000 | [diff] [blame] | 634 | ArgumentListNode* toArgumentList(ParserArena&, int, int) const; |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 635 | |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 636 | ElementNode* elements() const { ASSERT(isSimpleArray()); return m_element; } |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 637 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 638 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 639 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 640 | bool isSimpleArray() const override; |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 641 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 642 | ElementNode* m_element; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 643 | int m_elision; |
| 644 | bool m_optional; |
| 645 | }; |
| 646 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 647 | class PropertyNode : public ParserArenaFreeable { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 648 | public: |
commit-queue@webkit.org | 17b4870 | 2015-05-20 16:54:09 +0000 | [diff] [blame] | 649 | enum Type { Constant = 1, Getter = 2, Setter = 4, Computed = 8, Shorthand = 16 }; |
joepeck@webkit.org | a26e6e5 | 2015-03-06 21:31:27 +0000 | [diff] [blame] | 650 | enum PutType { Unknown, KnownDirect }; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 651 | |
ggaren@apple.com | cadd8c5 | 2016-04-22 23:04:55 +0000 | [diff] [blame] | 652 | PropertyNode(const Identifier&, ExpressionNode*, Type, PutType, SuperBinding, bool isClassProperty); |
| 653 | PropertyNode(ExpressionNode* propertyName, ExpressionNode*, Type, PutType, SuperBinding, bool isClassProperty); |
rniwa@webkit.org | 059ef9b | 2015-03-09 23:47:06 +0000 | [diff] [blame] | 654 | |
oliver@apple.com | 72d3832 | 2013-10-21 19:23:24 +0000 | [diff] [blame] | 655 | ExpressionNode* expressionName() const { return m_expression; } |
| 656 | const Identifier* name() const { return m_name; } |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 657 | |
rniwa@webkit.org | 059ef9b | 2015-03-09 23:47:06 +0000 | [diff] [blame] | 658 | Type type() const { return static_cast<Type>(m_type); } |
| 659 | bool needsSuperBinding() const { return m_needsSuperBinding; } |
ggaren@apple.com | cadd8c5 | 2016-04-22 23:04:55 +0000 | [diff] [blame] | 660 | bool isClassProperty() const { return m_isClassProperty; } |
rniwa@webkit.org | 059ef9b | 2015-03-09 23:47:06 +0000 | [diff] [blame] | 661 | PutType putType() const { return static_cast<PutType>(m_putType); } |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 662 | |
| 663 | private: |
| 664 | friend class PropertyListNode; |
oliver@apple.com | 72d3832 | 2013-10-21 19:23:24 +0000 | [diff] [blame] | 665 | const Identifier* m_name; |
| 666 | ExpressionNode* m_expression; |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 667 | ExpressionNode* m_assign; |
commit-queue@webkit.org | 17b4870 | 2015-05-20 16:54:09 +0000 | [diff] [blame] | 668 | unsigned m_type : 5; |
rniwa@webkit.org | 059ef9b | 2015-03-09 23:47:06 +0000 | [diff] [blame] | 669 | unsigned m_needsSuperBinding : 1; |
| 670 | unsigned m_putType : 1; |
ggaren@apple.com | cadd8c5 | 2016-04-22 23:04:55 +0000 | [diff] [blame] | 671 | unsigned m_isClassProperty: 1; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 672 | }; |
| 673 | |
ggaren@apple.com | d786e6b | 2013-04-04 23:16:20 +0000 | [diff] [blame] | 674 | class PropertyListNode : public ExpressionNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 675 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 676 | PropertyListNode(const JSTokenLocation&, PropertyNode*); |
| 677 | PropertyListNode(const JSTokenLocation&, PropertyNode*, PropertyListNode*); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 678 | |
mark.lam@apple.com | 47c2f14 | 2016-03-16 18:16:32 +0000 | [diff] [blame] | 679 | bool hasStaticallyNamedProperty(const Identifier& propName); |
| 680 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 681 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 682 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
rniwa@webkit.org | 95698ee | 2015-01-22 18:07:16 +0000 | [diff] [blame] | 683 | void emitPutConstantProperty(BytecodeGenerator&, RegisterID*, PropertyNode&); |
| 684 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 685 | PropertyNode* m_node; |
| 686 | PropertyListNode* m_next; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 687 | }; |
| 688 | |
| 689 | class ObjectLiteralNode : public ExpressionNode { |
| 690 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 691 | ObjectLiteralNode(const JSTokenLocation&); |
| 692 | ObjectLiteralNode(const JSTokenLocation&, PropertyListNode*); |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 693 | bool isObjectLiteral() const override { return true; } |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 694 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 695 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 696 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 697 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 698 | PropertyListNode* m_list; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 699 | }; |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 700 | |
| 701 | class BracketAccessorNode : public ExpressionNode, public ThrowableExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 702 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 703 | BracketAccessorNode(const JSTokenLocation&, ExpressionNode* base, ExpressionNode* subscript, bool subscriptHasAssignments); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 704 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 705 | ExpressionNode* base() const { return m_base; } |
| 706 | ExpressionNode* subscript() const { return m_subscript; } |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 707 | |
barraclough@apple.com | e3aa3f5 | 2012-09-06 00:55:46 +0000 | [diff] [blame] | 708 | bool subscriptHasAssignments() const { return m_subscriptHasAssignments; } |
| 709 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 710 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 711 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 712 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 713 | bool isLocation() const override { return true; } |
| 714 | bool isBracketAccessorNode() const override { return true; } |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 715 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 716 | ExpressionNode* m_base; |
| 717 | ExpressionNode* m_subscript; |
cwzwarich@webkit.org | 1cb10a1 | 2008-06-05 09:19:48 +0000 | [diff] [blame] | 718 | bool m_subscriptHasAssignments; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 719 | }; |
| 720 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 721 | class DotAccessorNode : public ExpressionNode, public ThrowableExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 722 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 723 | DotAccessorNode(const JSTokenLocation&, ExpressionNode* base, const Identifier&); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 724 | |
oliver@apple.com | 62cee78 | 2009-05-20 01:18:05 +0000 | [diff] [blame] | 725 | ExpressionNode* base() const { return m_base; } |
| 726 | const Identifier& identifier() const { return m_ident; } |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 727 | |
| 728 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 729 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 730 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 731 | bool isLocation() const override { return true; } |
| 732 | bool isDotAccessorNode() const override { return true; } |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 733 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 734 | ExpressionNode* m_base; |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 735 | const Identifier& m_ident; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 736 | }; |
| 737 | |
oliver@apple.com | 72f8a82 | 2013-10-17 01:02:34 +0000 | [diff] [blame] | 738 | class SpreadExpressionNode : public ExpressionNode, public ThrowableExpressionData { |
| 739 | public: |
| 740 | SpreadExpressionNode(const JSTokenLocation&, ExpressionNode*); |
| 741 | |
| 742 | ExpressionNode* expression() const { return m_expression; } |
| 743 | |
| 744 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 745 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
oliver@apple.com | 72f8a82 | 2013-10-17 01:02:34 +0000 | [diff] [blame] | 746 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 747 | bool isSpreadExpression() const override { return true; } |
oliver@apple.com | 72f8a82 | 2013-10-17 01:02:34 +0000 | [diff] [blame] | 748 | ExpressionNode* m_expression; |
| 749 | }; |
| 750 | |
ggaren@apple.com | d786e6b | 2013-04-04 23:16:20 +0000 | [diff] [blame] | 751 | class ArgumentListNode : public ExpressionNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 752 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 753 | ArgumentListNode(const JSTokenLocation&, ExpressionNode*); |
| 754 | ArgumentListNode(const JSTokenLocation&, ArgumentListNode*, ExpressionNode*); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 755 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 756 | ArgumentListNode* m_next; |
| 757 | ExpressionNode* m_expr; |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 758 | |
| 759 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 760 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 761 | }; |
| 762 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 763 | class ArgumentsNode : public ParserArenaFreeable { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 764 | public: |
msaboff@apple.com | 2e5003e | 2011-10-31 22:13:01 +0000 | [diff] [blame] | 765 | ArgumentsNode(); |
| 766 | ArgumentsNode(ArgumentListNode*); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 767 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 768 | ArgumentListNode* m_listNode; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 769 | }; |
| 770 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 771 | class NewExprNode : public ExpressionNode, public ThrowableExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 772 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 773 | NewExprNode(const JSTokenLocation&, ExpressionNode*); |
| 774 | NewExprNode(const JSTokenLocation&, ExpressionNode*, ArgumentsNode*); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 775 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 776 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 777 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 778 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 779 | ExpressionNode* m_expr; |
| 780 | ArgumentsNode* m_args; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 781 | }; |
| 782 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 783 | class EvalFunctionCallNode : public ExpressionNode, public ThrowableExpressionData { |
ggaren@apple.com | 6171673 | 2008-03-07 19:46:33 +0000 | [diff] [blame] | 784 | public: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 785 | EvalFunctionCallNode(const JSTokenLocation&, ArgumentsNode*, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 786 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 787 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 788 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
ggaren@apple.com | 6171673 | 2008-03-07 19:46:33 +0000 | [diff] [blame] | 789 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 790 | ArgumentsNode* m_args; |
ggaren@apple.com | 6171673 | 2008-03-07 19:46:33 +0000 | [diff] [blame] | 791 | }; |
| 792 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 793 | class FunctionCallValueNode : public ExpressionNode, public ThrowableExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 794 | public: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 795 | FunctionCallValueNode(const JSTokenLocation&, ExpressionNode*, ArgumentsNode*, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 796 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 797 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 798 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 799 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 800 | ExpressionNode* m_expr; |
| 801 | ArgumentsNode* m_args; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 802 | }; |
| 803 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 804 | class FunctionCallResolveNode : public ExpressionNode, public ThrowableExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 805 | public: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 806 | FunctionCallResolveNode(const JSTokenLocation&, const Identifier&, ArgumentsNode*, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 807 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 808 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 809 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 810 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 811 | const Identifier& m_ident; |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 812 | ArgumentsNode* m_args; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 813 | }; |
oliver@apple.com | c11549e | 2008-03-18 05:36:26 +0000 | [diff] [blame] | 814 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 815 | class FunctionCallBracketNode : public ExpressionNode, public ThrowableSubExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 816 | public: |
utatane.tea@gmail.com | c85b06f | 2015-05-07 22:35:56 +0000 | [diff] [blame] | 817 | FunctionCallBracketNode(const JSTokenLocation&, ExpressionNode* base, ExpressionNode* subscript, bool subscriptHasAssignments, ArgumentsNode*, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 818 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 819 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 820 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 821 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 822 | ExpressionNode* m_base; |
| 823 | ExpressionNode* m_subscript; |
| 824 | ArgumentsNode* m_args; |
utatane.tea@gmail.com | c85b06f | 2015-05-07 22:35:56 +0000 | [diff] [blame] | 825 | bool m_subscriptHasAssignments; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 826 | }; |
| 827 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 828 | class FunctionCallDotNode : public ExpressionNode, public ThrowableSubExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 829 | public: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 830 | FunctionCallDotNode(const JSTokenLocation&, ExpressionNode* base, const Identifier&, ArgumentsNode*, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 831 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 832 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 833 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 834 | |
oliver@apple.com | 6c10600 | 2009-03-28 03:50:39 +0000 | [diff] [blame] | 835 | protected: |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 836 | ExpressionNode* m_base; |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 837 | const Identifier& m_ident; |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 838 | ArgumentsNode* m_args; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 839 | }; |
| 840 | |
utatane.tea@gmail.com | defc166 | 2015-04-20 01:45:50 +0000 | [diff] [blame] | 841 | class BytecodeIntrinsicNode : public ExpressionNode, public ThrowableExpressionData { |
| 842 | public: |
utatane.tea@gmail.com | bf8978b | 2016-02-02 19:33:05 +0000 | [diff] [blame] | 843 | enum class Type { |
| 844 | Constant, |
| 845 | Function |
| 846 | }; |
| 847 | |
utatane.tea@gmail.com | defc166 | 2015-04-20 01:45:50 +0000 | [diff] [blame] | 848 | typedef RegisterID* (BytecodeIntrinsicNode::* EmitterType)(BytecodeGenerator&, RegisterID*); |
| 849 | |
utatane.tea@gmail.com | bf8978b | 2016-02-02 19:33:05 +0000 | [diff] [blame] | 850 | BytecodeIntrinsicNode(Type, const JSTokenLocation&, EmitterType, const Identifier&, ArgumentsNode*, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd); |
utatane.tea@gmail.com | defc166 | 2015-04-20 01:45:50 +0000 | [diff] [blame] | 851 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 852 | bool isBytecodeIntrinsicNode() const override { return true; } |
utatane.tea@gmail.com | bf8978b | 2016-02-02 19:33:05 +0000 | [diff] [blame] | 853 | |
| 854 | Type type() const { return m_type; } |
| 855 | EmitterType emitter() const { return m_emitter; } |
utatane.tea@gmail.com | defc166 | 2015-04-20 01:45:50 +0000 | [diff] [blame] | 856 | const Identifier& identifier() const { return m_ident; } |
| 857 | |
| 858 | #define JSC_DECLARE_BYTECODE_INTRINSIC_FUNCTIONS(name) RegisterID* emit_intrinsic_##name(BytecodeGenerator&, RegisterID*); |
utatane.tea@gmail.com | bf8978b | 2016-02-02 19:33:05 +0000 | [diff] [blame] | 859 | JSC_COMMON_BYTECODE_INTRINSIC_FUNCTIONS_EACH_NAME(JSC_DECLARE_BYTECODE_INTRINSIC_FUNCTIONS) |
| 860 | JSC_COMMON_BYTECODE_INTRINSIC_CONSTANTS_EACH_NAME(JSC_DECLARE_BYTECODE_INTRINSIC_FUNCTIONS) |
utatane.tea@gmail.com | defc166 | 2015-04-20 01:45:50 +0000 | [diff] [blame] | 861 | #undef JSC_DECLARE_BYTECODE_INTRINSIC_FUNCTIONS |
| 862 | |
| 863 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 864 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
utatane.tea@gmail.com | defc166 | 2015-04-20 01:45:50 +0000 | [diff] [blame] | 865 | |
utatane.tea@gmail.com | bf8978b | 2016-02-02 19:33:05 +0000 | [diff] [blame] | 866 | Type m_type; |
utatane.tea@gmail.com | defc166 | 2015-04-20 01:45:50 +0000 | [diff] [blame] | 867 | EmitterType m_emitter; |
| 868 | const Identifier& m_ident; |
| 869 | ArgumentsNode* m_args; |
| 870 | }; |
| 871 | |
oliver@apple.com | 6c10600 | 2009-03-28 03:50:39 +0000 | [diff] [blame] | 872 | class CallFunctionCallDotNode : public FunctionCallDotNode { |
| 873 | public: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 874 | CallFunctionCallDotNode(const JSTokenLocation&, ExpressionNode* base, const Identifier&, ArgumentsNode*, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd); |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 875 | |
| 876 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 877 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
oliver@apple.com | 6c10600 | 2009-03-28 03:50:39 +0000 | [diff] [blame] | 878 | }; |
oliver@apple.com | 65e286e | 2009-04-08 23:08:28 +0000 | [diff] [blame] | 879 | |
| 880 | class ApplyFunctionCallDotNode : public FunctionCallDotNode { |
| 881 | public: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 882 | ApplyFunctionCallDotNode(const JSTokenLocation&, ExpressionNode* base, const Identifier&, ArgumentsNode*, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd); |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 883 | |
| 884 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 885 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
oliver@apple.com | 65e286e | 2009-04-08 23:08:28 +0000 | [diff] [blame] | 886 | }; |
oliver@apple.com | 6c10600 | 2009-03-28 03:50:39 +0000 | [diff] [blame] | 887 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 888 | class DeleteResolveNode : public ExpressionNode, public ThrowableExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 889 | public: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 890 | DeleteResolveNode(const JSTokenLocation&, const Identifier&, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 891 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 892 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 893 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 894 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 895 | const Identifier& m_ident; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 896 | }; |
| 897 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 898 | class DeleteBracketNode : public ExpressionNode, public ThrowableExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 899 | public: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 900 | DeleteBracketNode(const JSTokenLocation&, ExpressionNode* base, ExpressionNode* subscript, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 901 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 902 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 903 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 904 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 905 | ExpressionNode* m_base; |
| 906 | ExpressionNode* m_subscript; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 907 | }; |
| 908 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 909 | class DeleteDotNode : public ExpressionNode, public ThrowableExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 910 | public: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 911 | DeleteDotNode(const JSTokenLocation&, ExpressionNode* base, const Identifier&, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 912 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 913 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 914 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 915 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 916 | ExpressionNode* m_base; |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 917 | const Identifier& m_ident; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 918 | }; |
| 919 | |
| 920 | class DeleteValueNode : public ExpressionNode { |
| 921 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 922 | DeleteValueNode(const JSTokenLocation&, ExpressionNode*); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 923 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 924 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 925 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 926 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 927 | ExpressionNode* m_expr; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 928 | }; |
| 929 | |
| 930 | class VoidNode : public ExpressionNode { |
| 931 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 932 | VoidNode(const JSTokenLocation&, ExpressionNode*); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 933 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 934 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 935 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 936 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 937 | ExpressionNode* m_expr; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 938 | }; |
| 939 | |
| 940 | class TypeOfResolveNode : public ExpressionNode { |
| 941 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 942 | TypeOfResolveNode(const JSTokenLocation&, const Identifier&); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 943 | |
oliver@apple.com | 62cee78 | 2009-05-20 01:18:05 +0000 | [diff] [blame] | 944 | const Identifier& identifier() const { return m_ident; } |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 945 | |
darin@apple.com | 97ea242 | 2008-11-10 01:28:10 +0000 | [diff] [blame] | 946 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 947 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 948 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 949 | const Identifier& m_ident; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 950 | }; |
| 951 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 952 | class TypeOfValueNode : public ExpressionNode { |
| 953 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 954 | TypeOfValueNode(const JSTokenLocation&, ExpressionNode*); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 955 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 956 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 957 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 958 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 959 | ExpressionNode* m_expr; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 960 | }; |
| 961 | |
barraclough@apple.com | ff7867a | 2012-09-05 23:00:29 +0000 | [diff] [blame] | 962 | class PrefixNode : public ExpressionNode, public ThrowablePrefixedSubExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 963 | public: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 964 | PrefixNode(const JSTokenLocation&, ExpressionNode*, Operator, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 965 | |
ggaren@apple.com | 20c0b6c | 2013-04-04 18:31:37 +0000 | [diff] [blame] | 966 | protected: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 967 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
barraclough@apple.com | ff7867a | 2012-09-05 23:00:29 +0000 | [diff] [blame] | 968 | virtual RegisterID* emitResolve(BytecodeGenerator&, RegisterID* = 0); |
| 969 | virtual RegisterID* emitBracket(BytecodeGenerator&, RegisterID* = 0); |
| 970 | virtual RegisterID* emitDot(BytecodeGenerator&, RegisterID* = 0); |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 971 | |
barraclough@apple.com | ff7867a | 2012-09-05 23:00:29 +0000 | [diff] [blame] | 972 | ExpressionNode* m_expr; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 973 | Operator m_operator; |
| 974 | }; |
| 975 | |
ggaren@apple.com | 20c0b6c | 2013-04-04 18:31:37 +0000 | [diff] [blame] | 976 | class PostfixNode : public PrefixNode { |
| 977 | public: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 978 | PostfixNode(const JSTokenLocation&, ExpressionNode*, Operator, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd); |
ggaren@apple.com | 20c0b6c | 2013-04-04 18:31:37 +0000 | [diff] [blame] | 979 | |
| 980 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 981 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
| 982 | RegisterID* emitResolve(BytecodeGenerator&, RegisterID* = 0) override; |
| 983 | RegisterID* emitBracket(BytecodeGenerator&, RegisterID* = 0) override; |
| 984 | RegisterID* emitDot(BytecodeGenerator&, RegisterID* = 0) override; |
ggaren@apple.com | 20c0b6c | 2013-04-04 18:31:37 +0000 | [diff] [blame] | 985 | }; |
| 986 | |
cwzwarich@webkit.org | 65f5e2b | 2008-06-16 08:19:17 +0000 | [diff] [blame] | 987 | class UnaryOpNode : public ExpressionNode { |
| 988 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 989 | UnaryOpNode(const JSTokenLocation&, ResultType, ExpressionNode*, OpcodeID); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 990 | |
cwzwarich@webkit.org | 65f5e2b | 2008-06-16 08:19:17 +0000 | [diff] [blame] | 991 | protected: |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 992 | ExpressionNode* expr() { return m_expr; } |
mjs@apple.com | a46c49c | 2009-12-06 09:42:03 +0000 | [diff] [blame] | 993 | const ExpressionNode* expr() const { return m_expr; } |
utatane.tea@gmail.com | db32c54 | 2016-06-30 15:26:47 +0000 | [diff] [blame] | 994 | OpcodeID opcodeID() const { return m_opcodeID; } |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 995 | |
| 996 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 997 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 998 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 999 | ExpressionNode* m_expr; |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1000 | OpcodeID m_opcodeID; |
cwzwarich@webkit.org | 65f5e2b | 2008-06-16 08:19:17 +0000 | [diff] [blame] | 1001 | }; |
| 1002 | |
| 1003 | class UnaryPlusNode : public UnaryOpNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1004 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1005 | UnaryPlusNode(const JSTokenLocation&, ExpressionNode*); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1006 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1007 | private: |
utatane.tea@gmail.com | db32c54 | 2016-06-30 15:26:47 +0000 | [diff] [blame] | 1008 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
| 1009 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1010 | ExpressionNode* stripUnaryPlus() override { return expr(); } |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1011 | }; |
| 1012 | |
cwzwarich@webkit.org | 65f5e2b | 2008-06-16 08:19:17 +0000 | [diff] [blame] | 1013 | class NegateNode : public UnaryOpNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1014 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1015 | NegateNode(const JSTokenLocation&, ExpressionNode*); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1016 | }; |
| 1017 | |
barraclough@apple.com | a6bdfc8 | 2012-02-27 18:26:23 +0000 | [diff] [blame] | 1018 | class BitwiseNotNode : public ExpressionNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1019 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1020 | BitwiseNotNode(const JSTokenLocation&, ExpressionNode*); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1021 | |
barraclough@apple.com | a6bdfc8 | 2012-02-27 18:26:23 +0000 | [diff] [blame] | 1022 | protected: |
| 1023 | ExpressionNode* expr() { return m_expr; } |
| 1024 | const ExpressionNode* expr() const { return m_expr; } |
| 1025 | |
| 1026 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1027 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
barraclough@apple.com | a6bdfc8 | 2012-02-27 18:26:23 +0000 | [diff] [blame] | 1028 | |
| 1029 | ExpressionNode* m_expr; |
| 1030 | }; |
| 1031 | |
cwzwarich@webkit.org | 65f5e2b | 2008-06-16 08:19:17 +0000 | [diff] [blame] | 1032 | class LogicalNotNode : public UnaryOpNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1033 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1034 | LogicalNotNode(const JSTokenLocation&, ExpressionNode*); |
mjs@apple.com | a46c49c | 2009-12-06 09:42:03 +0000 | [diff] [blame] | 1035 | private: |
utatane.tea@gmail.com | 6f1b3f3 | 2017-02-16 07:56:48 +0000 | [diff] [blame] | 1036 | void emitBytecodeInConditionContext(BytecodeGenerator&, Label& trueTarget, Label& falseTarget, FallThroughMode) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1037 | }; |
| 1038 | |
cwzwarich@webkit.org | 875318a | 2008-06-15 09:30:56 +0000 | [diff] [blame] | 1039 | class BinaryOpNode : public ExpressionNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1040 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1041 | BinaryOpNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID, bool rightHasAssignments); |
| 1042 | BinaryOpNode(const JSTokenLocation&, ResultType, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID, bool rightHasAssignments); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1043 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 1044 | RegisterID* emitStrcat(BytecodeGenerator& generator, RegisterID* destination, RegisterID* lhs = 0, ReadModifyResolveNode* emitExpressionInfoForMe = 0); |
utatane.tea@gmail.com | 6f1b3f3 | 2017-02-16 07:56:48 +0000 | [diff] [blame] | 1045 | void emitBytecodeInConditionContext(BytecodeGenerator&, Label& trueTarget, Label& falseTarget, FallThroughMode) override; |
barraclough@apple.com | 4b2fc99 | 2009-05-07 08:27:58 +0000 | [diff] [blame] | 1046 | |
barraclough@apple.com | b467c4c | 2010-07-13 20:34:11 +0000 | [diff] [blame] | 1047 | ExpressionNode* lhs() { return m_expr1; }; |
| 1048 | ExpressionNode* rhs() { return m_expr2; }; |
| 1049 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1050 | private: |
ggaren@apple.com | 81c68cc | 2013-04-27 06:43:33 +0000 | [diff] [blame] | 1051 | void tryFoldToBranch(BytecodeGenerator&, TriState& branchCondition, ExpressionNode*& branchExpression); |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1052 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1053 | |
| 1054 | protected: |
| 1055 | OpcodeID opcodeID() const { return m_opcodeID; } |
cwzwarich@webkit.org | 875318a | 2008-06-15 09:30:56 +0000 | [diff] [blame] | 1056 | |
| 1057 | protected: |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1058 | ExpressionNode* m_expr1; |
| 1059 | ExpressionNode* m_expr2; |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1060 | private: |
| 1061 | OpcodeID m_opcodeID; |
| 1062 | protected: |
cwzwarich@webkit.org | ce46a1c | 2008-06-14 07:52:27 +0000 | [diff] [blame] | 1063 | bool m_rightHasAssignments; |
eseidel | dc7c497 | 2007-11-12 00:34:37 +0000 | [diff] [blame] | 1064 | }; |
| 1065 | |
utatane.tea@gmail.com | e990638 | 2016-07-21 07:33:28 +0000 | [diff] [blame] | 1066 | class PowNode : public BinaryOpNode { |
| 1067 | public: |
| 1068 | PowNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
| 1069 | }; |
| 1070 | |
cwzwarich@webkit.org | 875318a | 2008-06-15 09:30:56 +0000 | [diff] [blame] | 1071 | class MultNode : public BinaryOpNode { |
| 1072 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1073 | MultNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
cwzwarich@webkit.org | 875318a | 2008-06-15 09:30:56 +0000 | [diff] [blame] | 1074 | }; |
| 1075 | |
| 1076 | class DivNode : public BinaryOpNode { |
| 1077 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1078 | DivNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
cwzwarich@webkit.org | 875318a | 2008-06-15 09:30:56 +0000 | [diff] [blame] | 1079 | }; |
| 1080 | |
| 1081 | class ModNode : public BinaryOpNode { |
| 1082 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1083 | ModNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
cwzwarich@webkit.org | 875318a | 2008-06-15 09:30:56 +0000 | [diff] [blame] | 1084 | }; |
| 1085 | |
| 1086 | class AddNode : public BinaryOpNode { |
| 1087 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1088 | AddNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
barraclough@apple.com | 14dc4e1 | 2009-05-07 00:06:07 +0000 | [diff] [blame] | 1089 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1090 | bool isAdd() const override { return true; } |
cwzwarich@webkit.org | 875318a | 2008-06-15 09:30:56 +0000 | [diff] [blame] | 1091 | }; |
| 1092 | |
| 1093 | class SubNode : public BinaryOpNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1094 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1095 | SubNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
barraclough@apple.com | b467c4c | 2010-07-13 20:34:11 +0000 | [diff] [blame] | 1096 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1097 | bool isSubtract() const override { return true; } |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1098 | }; |
oliver | c322dca | 2007-10-23 21:25:44 +0000 | [diff] [blame] | 1099 | |
cwzwarich@webkit.org | 875318a | 2008-06-15 09:30:56 +0000 | [diff] [blame] | 1100 | class LeftShiftNode : public BinaryOpNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1101 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1102 | LeftShiftNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1103 | }; |
| 1104 | |
cwzwarich@webkit.org | 875318a | 2008-06-15 09:30:56 +0000 | [diff] [blame] | 1105 | class RightShiftNode : public BinaryOpNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1106 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1107 | RightShiftNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1108 | }; |
| 1109 | |
cwzwarich@webkit.org | 875318a | 2008-06-15 09:30:56 +0000 | [diff] [blame] | 1110 | class UnsignedRightShiftNode : public BinaryOpNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1111 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1112 | UnsignedRightShiftNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1113 | }; |
| 1114 | |
cwzwarich@webkit.org | 875318a | 2008-06-15 09:30:56 +0000 | [diff] [blame] | 1115 | class LessNode : public BinaryOpNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1116 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1117 | LessNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1118 | }; |
oliver | c322dca | 2007-10-23 21:25:44 +0000 | [diff] [blame] | 1119 | |
barraclough@apple.com | 57b4bdb8 | 2011-07-04 19:26:05 +0000 | [diff] [blame] | 1120 | class GreaterNode : public BinaryOpNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1121 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1122 | GreaterNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1123 | }; |
| 1124 | |
cwzwarich@webkit.org | 875318a | 2008-06-15 09:30:56 +0000 | [diff] [blame] | 1125 | class LessEqNode : public BinaryOpNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1126 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1127 | LessEqNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1128 | }; |
| 1129 | |
barraclough@apple.com | 57b4bdb8 | 2011-07-04 19:26:05 +0000 | [diff] [blame] | 1130 | class GreaterEqNode : public BinaryOpNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1131 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1132 | GreaterEqNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1133 | }; |
oliver | c322dca | 2007-10-23 21:25:44 +0000 | [diff] [blame] | 1134 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1135 | class ThrowableBinaryOpNode : public BinaryOpNode, public ThrowableExpressionData { |
| 1136 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1137 | ThrowableBinaryOpNode(const JSTokenLocation&, ResultType, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID, bool rightHasAssignments); |
| 1138 | ThrowableBinaryOpNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID, bool rightHasAssignments); |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1139 | |
| 1140 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1141 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1142 | }; |
| 1143 | |
| 1144 | class InstanceOfNode : public ThrowableBinaryOpNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1145 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1146 | InstanceOfNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1147 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1148 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1149 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1150 | }; |
oliver | c322dca | 2007-10-23 21:25:44 +0000 | [diff] [blame] | 1151 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1152 | class InNode : public ThrowableBinaryOpNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1153 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1154 | InNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
keith_miller@apple.com | 6fc2fb7 | 2017-02-09 00:02:20 +0000 | [diff] [blame] | 1155 | |
| 1156 | private: |
| 1157 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1158 | }; |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 1159 | |
cwzwarich@webkit.org | 875318a | 2008-06-15 09:30:56 +0000 | [diff] [blame] | 1160 | class EqualNode : public BinaryOpNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1161 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1162 | EqualNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1163 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1164 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1165 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1166 | }; |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 1167 | |
cwzwarich@webkit.org | 875318a | 2008-06-15 09:30:56 +0000 | [diff] [blame] | 1168 | class NotEqualNode : public BinaryOpNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1169 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1170 | NotEqualNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1171 | }; |
oliver | c322dca | 2007-10-23 21:25:44 +0000 | [diff] [blame] | 1172 | |
cwzwarich@webkit.org | 875318a | 2008-06-15 09:30:56 +0000 | [diff] [blame] | 1173 | class StrictEqualNode : public BinaryOpNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1174 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1175 | StrictEqualNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1176 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1177 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1178 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1179 | }; |
oliver | c322dca | 2007-10-23 21:25:44 +0000 | [diff] [blame] | 1180 | |
cwzwarich@webkit.org | 875318a | 2008-06-15 09:30:56 +0000 | [diff] [blame] | 1181 | class NotStrictEqualNode : public BinaryOpNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1182 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1183 | NotStrictEqualNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1184 | }; |
oliver | c322dca | 2007-10-23 21:25:44 +0000 | [diff] [blame] | 1185 | |
cwzwarich@webkit.org | 875318a | 2008-06-15 09:30:56 +0000 | [diff] [blame] | 1186 | class BitAndNode : public BinaryOpNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1187 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1188 | BitAndNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1189 | }; |
oliver | c322dca | 2007-10-23 21:25:44 +0000 | [diff] [blame] | 1190 | |
cwzwarich@webkit.org | 875318a | 2008-06-15 09:30:56 +0000 | [diff] [blame] | 1191 | class BitOrNode : public BinaryOpNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1192 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1193 | BitOrNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1194 | }; |
| 1195 | |
cwzwarich@webkit.org | 875318a | 2008-06-15 09:30:56 +0000 | [diff] [blame] | 1196 | class BitXOrNode : public BinaryOpNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1197 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1198 | BitXOrNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1199 | }; |
| 1200 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1201 | // m_expr1 && m_expr2, m_expr1 || m_expr2 |
barraclough@apple.com | fcb5dd7 | 2008-07-17 12:06:13 +0000 | [diff] [blame] | 1202 | class LogicalOpNode : public ExpressionNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1203 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1204 | LogicalOpNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, LogicalOperator); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1205 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1206 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1207 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
utatane.tea@gmail.com | 6f1b3f3 | 2017-02-16 07:56:48 +0000 | [diff] [blame] | 1208 | void emitBytecodeInConditionContext(BytecodeGenerator&, Label& trueTarget, Label& falseTarget, FallThroughMode) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1209 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1210 | ExpressionNode* m_expr1; |
| 1211 | ExpressionNode* m_expr2; |
barraclough@apple.com | fcb5dd7 | 2008-07-17 12:06:13 +0000 | [diff] [blame] | 1212 | LogicalOperator m_operator; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1213 | }; |
oliver | f885d88 | 2007-10-30 03:14:00 +0000 | [diff] [blame] | 1214 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1215 | // The ternary operator, "m_logical ? m_expr1 : m_expr2" |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1216 | class ConditionalNode : public ExpressionNode { |
| 1217 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1218 | ConditionalNode(const JSTokenLocation&, ExpressionNode* logical, ExpressionNode* expr1, ExpressionNode* expr2); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1219 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1220 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1221 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
oliver | f885d88 | 2007-10-30 03:14:00 +0000 | [diff] [blame] | 1222 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1223 | ExpressionNode* m_logical; |
| 1224 | ExpressionNode* m_expr1; |
| 1225 | ExpressionNode* m_expr2; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1226 | }; |
darin@apple.com | 1076ac2 | 2008-01-27 09:38:01 +0000 | [diff] [blame] | 1227 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1228 | class ReadModifyResolveNode : public ExpressionNode, public ThrowableExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1229 | public: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 1230 | ReadModifyResolveNode(const JSTokenLocation&, const Identifier&, Operator, ExpressionNode* right, bool rightHasAssignments, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1231 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1232 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1233 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1234 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 1235 | const Identifier& m_ident; |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1236 | ExpressionNode* m_right; |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1237 | Operator m_operator; |
| 1238 | bool m_rightHasAssignments; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1239 | }; |
mjs | f4a2a7f | 2005-08-11 10:26:54 +0000 | [diff] [blame] | 1240 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1241 | class AssignResolveNode : public ExpressionNode, public ThrowableExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1242 | public: |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1243 | AssignResolveNode(const JSTokenLocation&, const Identifier&, ExpressionNode* right, AssignmentContext); |
gskachkov@gmail.com | ad01d6b | 2016-08-24 13:35:38 +0000 | [diff] [blame] | 1244 | bool isAssignResolveNode() const override { return true; } |
| 1245 | const Identifier& identifier() const { return m_ident; } |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1246 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1247 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1248 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
darin | ed8ee1a | 2007-04-23 08:38:46 +0000 | [diff] [blame] | 1249 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 1250 | const Identifier& m_ident; |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1251 | ExpressionNode* m_right; |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1252 | AssignmentContext m_assignmentContext; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1253 | }; |
mjs | bb64c24 | 2007-11-03 10:09:45 +0000 | [diff] [blame] | 1254 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1255 | class ReadModifyBracketNode : public ExpressionNode, public ThrowableSubExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1256 | public: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 1257 | ReadModifyBracketNode(const JSTokenLocation&, ExpressionNode* base, ExpressionNode* subscript, Operator, ExpressionNode* right, bool subscriptHasAssignments, bool rightHasAssignments, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1258 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1259 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1260 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1261 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1262 | ExpressionNode* m_base; |
| 1263 | ExpressionNode* m_subscript; |
| 1264 | ExpressionNode* m_right; |
bfulgham@apple.com | 9c9b8a1 | 2014-06-24 19:49:25 +0000 | [diff] [blame] | 1265 | unsigned m_operator : 30; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1266 | bool m_subscriptHasAssignments : 1; |
| 1267 | bool m_rightHasAssignments : 1; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1268 | }; |
| 1269 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1270 | class AssignBracketNode : public ExpressionNode, public ThrowableExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1271 | public: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 1272 | AssignBracketNode(const JSTokenLocation&, ExpressionNode* base, ExpressionNode* subscript, ExpressionNode* right, bool subscriptHasAssignments, bool rightHasAssignments, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1273 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1274 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1275 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1276 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1277 | ExpressionNode* m_base; |
| 1278 | ExpressionNode* m_subscript; |
| 1279 | ExpressionNode* m_right; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1280 | bool m_subscriptHasAssignments : 1; |
| 1281 | bool m_rightHasAssignments : 1; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1282 | }; |
| 1283 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1284 | class AssignDotNode : public ExpressionNode, public ThrowableExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1285 | public: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 1286 | AssignDotNode(const JSTokenLocation&, ExpressionNode* base, const Identifier&, ExpressionNode* right, bool rightHasAssignments, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1287 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1288 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1289 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1290 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1291 | ExpressionNode* m_base; |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 1292 | const Identifier& m_ident; |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1293 | ExpressionNode* m_right; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1294 | bool m_rightHasAssignments; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1295 | }; |
| 1296 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1297 | class ReadModifyDotNode : public ExpressionNode, public ThrowableSubExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1298 | public: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 1299 | ReadModifyDotNode(const JSTokenLocation&, ExpressionNode* base, const Identifier&, Operator, ExpressionNode* right, bool rightHasAssignments, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1300 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1301 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1302 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1303 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1304 | ExpressionNode* m_base; |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 1305 | const Identifier& m_ident; |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1306 | ExpressionNode* m_right; |
bfulgham@apple.com | 9c9b8a1 | 2014-06-24 19:49:25 +0000 | [diff] [blame] | 1307 | unsigned m_operator : 31; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1308 | bool m_rightHasAssignments : 1; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1309 | }; |
| 1310 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1311 | class AssignErrorNode : public ExpressionNode, public ThrowableExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1312 | public: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 1313 | AssignErrorNode(const JSTokenLocation&, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1314 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1315 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1316 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1317 | }; |
oliver@apple.com | 5242820 | 2009-06-24 22:01:34 +0000 | [diff] [blame] | 1318 | |
gyuyoung.kim@samsung.com | 9ea4728 | 2014-12-09 05:53:00 +0000 | [diff] [blame] | 1319 | class CommaNode final : public ExpressionNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1320 | public: |
ggaren@apple.com | 86cb7be | 2014-12-09 01:53:53 +0000 | [diff] [blame] | 1321 | CommaNode(const JSTokenLocation&, ExpressionNode*); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1322 | |
ggaren@apple.com | 86cb7be | 2014-12-09 01:53:53 +0000 | [diff] [blame] | 1323 | void setNext(CommaNode* next) { m_next = next; } |
| 1324 | CommaNode* next() { return m_next; } |
oliver@apple.com | 5242820 | 2009-06-24 22:01:34 +0000 | [diff] [blame] | 1325 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1326 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1327 | bool isCommaNode() const override { return true; } |
| 1328 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1329 | |
ggaren@apple.com | 86cb7be | 2014-12-09 01:53:53 +0000 | [diff] [blame] | 1330 | ExpressionNode* m_expr; |
| 1331 | CommaNode* m_next; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1332 | }; |
oliver@apple.com | 7e36d6a | 2008-02-09 05:17:06 +0000 | [diff] [blame] | 1333 | |
ggaren@apple.com | 86cb7be | 2014-12-09 01:53:53 +0000 | [diff] [blame] | 1334 | class SourceElements final : public ParserArenaFreeable { |
darin@apple.com | 5e49bae | 2007-12-21 21:54:51 +0000 | [diff] [blame] | 1335 | public: |
msaboff@apple.com | 2e5003e | 2011-10-31 22:13:01 +0000 | [diff] [blame] | 1336 | SourceElements(); |
ap@webkit.org | 9e7ecd3 | 2008-06-25 07:07:38 +0000 | [diff] [blame] | 1337 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1338 | void append(StatementNode*); |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 1339 | |
| 1340 | StatementNode* singleStatement() const; |
| 1341 | StatementNode* lastStatement() const; |
| 1342 | |
| 1343 | void emitBytecode(BytecodeGenerator&, RegisterID* destination); |
utatane.tea@gmail.com | 1c1bac0 | 2015-08-12 20:38:45 +0000 | [diff] [blame] | 1344 | void analyzeModule(ModuleAnalyzer&); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1345 | |
darin@apple.com | 5e49bae | 2007-12-21 21:54:51 +0000 | [diff] [blame] | 1346 | private: |
ggaren@apple.com | 86cb7be | 2014-12-09 01:53:53 +0000 | [diff] [blame] | 1347 | StatementNode* m_head; |
| 1348 | StatementNode* m_tail; |
darin@apple.com | 5e49bae | 2007-12-21 21:54:51 +0000 | [diff] [blame] | 1349 | }; |
| 1350 | |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1351 | class BlockNode : public StatementNode, public VariableEnvironmentNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1352 | public: |
sbarati@apple.com | 62be0b0 | 2015-09-19 15:36:46 +0000 | [diff] [blame] | 1353 | using ParserArenaDeletable::operator new; |
| 1354 | |
sbarati@apple.com | 8e614bd | 2016-03-10 02:04:20 +0000 | [diff] [blame] | 1355 | BlockNode(const JSTokenLocation&, SourceElements*, VariableEnvironment&, FunctionStack&&); |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 1356 | |
barraclough@apple.com | b467c4c | 2010-07-13 20:34:11 +0000 | [diff] [blame] | 1357 | StatementNode* singleStatement() const; |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 1358 | StatementNode* lastStatement() const; |
ggaren@apple.com | 873cb42 | 2008-06-02 20:45:13 +0000 | [diff] [blame] | 1359 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1360 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1361 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1362 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1363 | bool isBlock() const override { return true; } |
timothy@apple.com | dbdf2443 | 2009-03-01 20:14:44 +0000 | [diff] [blame] | 1364 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 1365 | SourceElements* m_statements; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1366 | }; |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 1367 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1368 | class EmptyStatementNode : public StatementNode { |
| 1369 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1370 | EmptyStatementNode(const JSTokenLocation&); |
mjs@apple.com | d0af829 | 2007-12-24 10:13:00 +0000 | [diff] [blame] | 1371 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1372 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1373 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1374 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1375 | bool isEmptyStatement() const override { return true; } |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1376 | }; |
oliver@apple.com | 139b529 | 2008-06-03 22:48:52 +0000 | [diff] [blame] | 1377 | |
| 1378 | class DebuggerStatementNode : public StatementNode { |
| 1379 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1380 | DebuggerStatementNode(const JSTokenLocation&); |
joepeck@webkit.org | b5fbd45 | 2016-10-12 18:47:48 +0000 | [diff] [blame] | 1381 | |
| 1382 | bool isDebuggerStatement() const override { return true; } |
oliver@apple.com | 139b529 | 2008-06-03 22:48:52 +0000 | [diff] [blame] | 1383 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1384 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1385 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
oliver@apple.com | 139b529 | 2008-06-03 22:48:52 +0000 | [diff] [blame] | 1386 | }; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1387 | |
| 1388 | class ExprStatementNode : public StatementNode { |
| 1389 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1390 | ExprStatementNode(const JSTokenLocation&, ExpressionNode*); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1391 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1392 | ExpressionNode* expr() const { return m_expr; } |
weinig@apple.com | 9b5bf06 | 2008-11-20 23:23:59 +0000 | [diff] [blame] | 1393 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1394 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1395 | bool isExprStatement() const override { return true; } |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1396 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1397 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1398 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1399 | ExpressionNode* m_expr; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1400 | }; |
| 1401 | |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1402 | class DeclarationStatement : public StatementNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1403 | public: |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1404 | DeclarationStatement(const JSTokenLocation&, ExpressionNode*); |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1405 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1406 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1407 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1408 | ExpressionNode* m_expr; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1409 | }; |
| 1410 | |
commit-queue@webkit.org | 200ce5b | 2014-08-18 19:11:41 +0000 | [diff] [blame] | 1411 | class EmptyVarExpression : public ExpressionNode { |
| 1412 | public: |
| 1413 | EmptyVarExpression(const JSTokenLocation&, const Identifier&); |
| 1414 | |
| 1415 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1416 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
commit-queue@webkit.org | 200ce5b | 2014-08-18 19:11:41 +0000 | [diff] [blame] | 1417 | |
| 1418 | const Identifier& m_ident; |
| 1419 | }; |
| 1420 | |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1421 | class EmptyLetExpression : public ExpressionNode { |
| 1422 | public: |
| 1423 | EmptyLetExpression(const JSTokenLocation&, const Identifier&); |
| 1424 | |
| 1425 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1426 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1427 | |
| 1428 | const Identifier& m_ident; |
| 1429 | }; |
commit-queue@webkit.org | 200ce5b | 2014-08-18 19:11:41 +0000 | [diff] [blame] | 1430 | |
ggaren@apple.com | 81c68cc | 2013-04-27 06:43:33 +0000 | [diff] [blame] | 1431 | class IfElseNode : public StatementNode { |
eric@webkit.org | 52f2ea3 | 2007-12-21 07:21:20 +0000 | [diff] [blame] | 1432 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1433 | IfElseNode(const JSTokenLocation&, ExpressionNode* condition, StatementNode* ifBlock, StatementNode* elseBlock); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1434 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1435 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1436 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
ggaren@apple.com | 81c68cc | 2013-04-27 06:43:33 +0000 | [diff] [blame] | 1437 | bool tryFoldBreakAndContinue(BytecodeGenerator&, StatementNode* ifBlock, |
| 1438 | Label*& trueTarget, FallThroughMode&); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1439 | |
ggaren@apple.com | 81c68cc | 2013-04-27 06:43:33 +0000 | [diff] [blame] | 1440 | ExpressionNode* m_condition; |
| 1441 | StatementNode* m_ifBlock; |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1442 | StatementNode* m_elseBlock; |
eric@webkit.org | 52f2ea3 | 2007-12-21 07:21:20 +0000 | [diff] [blame] | 1443 | }; |
| 1444 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1445 | class DoWhileNode : public StatementNode { |
| 1446 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1447 | DoWhileNode(const JSTokenLocation&, StatementNode*, ExpressionNode*); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1448 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1449 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1450 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 1451 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1452 | StatementNode* m_statement; |
| 1453 | ExpressionNode* m_expr; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1454 | }; |
| 1455 | |
| 1456 | class WhileNode : public StatementNode { |
| 1457 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1458 | WhileNode(const JSTokenLocation&, ExpressionNode*, StatementNode*); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1459 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1460 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1461 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1462 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1463 | ExpressionNode* m_expr; |
| 1464 | StatementNode* m_statement; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1465 | }; |
| 1466 | |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1467 | class ForNode : public StatementNode, public VariableEnvironmentNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1468 | public: |
sbarati@apple.com | 62be0b0 | 2015-09-19 15:36:46 +0000 | [diff] [blame] | 1469 | using ParserArenaDeletable::operator new; |
| 1470 | |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1471 | ForNode(const JSTokenLocation&, ExpressionNode* expr1, ExpressionNode* expr2, ExpressionNode* expr3, StatementNode*, VariableEnvironment&); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1472 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1473 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1474 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1475 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1476 | ExpressionNode* m_expr1; |
| 1477 | ExpressionNode* m_expr2; |
| 1478 | ExpressionNode* m_expr3; |
| 1479 | StatementNode* m_statement; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1480 | }; |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 1481 | |
saambarati1@gmail.com | cc3bcb6 | 2015-07-02 23:53:10 +0000 | [diff] [blame] | 1482 | class DestructuringPatternNode; |
oliver@apple.com | 20a9bf0 | 2013-10-04 20:35:24 +0000 | [diff] [blame] | 1483 | |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1484 | class EnumerationNode : public StatementNode, public ThrowableExpressionData, public VariableEnvironmentNode { |
oliver@apple.com | 20a9bf0 | 2013-10-04 20:35:24 +0000 | [diff] [blame] | 1485 | public: |
sbarati@apple.com | 62be0b0 | 2015-09-19 15:36:46 +0000 | [diff] [blame] | 1486 | using ParserArenaDeletable::operator new; |
| 1487 | |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1488 | EnumerationNode(const JSTokenLocation&, ExpressionNode*, ExpressionNode*, StatementNode*, VariableEnvironment&); |
joepeck@webkit.org | bb70ac6 | 2016-09-30 19:22:37 +0000 | [diff] [blame] | 1489 | |
joepeck@webkit.org | b5fbd45 | 2016-10-12 18:47:48 +0000 | [diff] [blame] | 1490 | ExpressionNode* lexpr() const { return m_lexpr; } |
joepeck@webkit.org | bb70ac6 | 2016-09-30 19:22:37 +0000 | [diff] [blame] | 1491 | ExpressionNode* expr() const { return m_expr; } |
| 1492 | |
oliver@apple.com | 20a9bf0 | 2013-10-04 20:35:24 +0000 | [diff] [blame] | 1493 | protected: |
| 1494 | ExpressionNode* m_lexpr; |
| 1495 | ExpressionNode* m_expr; |
| 1496 | StatementNode* m_statement; |
| 1497 | }; |
| 1498 | |
| 1499 | class ForInNode : public EnumerationNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1500 | public: |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1501 | ForInNode(const JSTokenLocation&, ExpressionNode*, ExpressionNode*, StatementNode*, VariableEnvironment&); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1502 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1503 | private: |
fpizlo@apple.com | a398a56 | 2014-08-06 21:32:55 +0000 | [diff] [blame] | 1504 | RegisterID* tryGetBoundLocal(BytecodeGenerator&); |
| 1505 | void emitLoopHeader(BytecodeGenerator&, RegisterID* propertyName); |
fpizlo@apple.com | a398a56 | 2014-08-06 21:32:55 +0000 | [diff] [blame] | 1506 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1507 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
oliver@apple.com | 20a9bf0 | 2013-10-04 20:35:24 +0000 | [diff] [blame] | 1508 | }; |
| 1509 | |
| 1510 | class ForOfNode : public EnumerationNode { |
| 1511 | public: |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1512 | ForOfNode(const JSTokenLocation&, ExpressionNode*, ExpressionNode*, StatementNode*, VariableEnvironment&); |
joepeck@webkit.org | bb70ac6 | 2016-09-30 19:22:37 +0000 | [diff] [blame] | 1513 | bool isForOfNode() const override { return true; } |
| 1514 | |
oliver@apple.com | 20a9bf0 | 2013-10-04 20:35:24 +0000 | [diff] [blame] | 1515 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1516 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1517 | }; |
| 1518 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1519 | class ContinueNode : public StatementNode, public ThrowableExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1520 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1521 | ContinueNode(const JSTokenLocation&, const Identifier&); |
ggaren@apple.com | 81c68cc | 2013-04-27 06:43:33 +0000 | [diff] [blame] | 1522 | Label* trivialTarget(BytecodeGenerator&); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1523 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1524 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1525 | bool isContinue() const override { return true; } |
| 1526 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1527 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 1528 | const Identifier& m_ident; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1529 | }; |
| 1530 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1531 | class BreakNode : public StatementNode, public ThrowableExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1532 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1533 | BreakNode(const JSTokenLocation&, const Identifier&); |
ggaren@apple.com | 81c68cc | 2013-04-27 06:43:33 +0000 | [diff] [blame] | 1534 | Label* trivialTarget(BytecodeGenerator&); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1535 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1536 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1537 | bool isBreak() const override { return true; } |
| 1538 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1539 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 1540 | const Identifier& m_ident; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1541 | }; |
| 1542 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1543 | class ReturnNode : public StatementNode, public ThrowableExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1544 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1545 | ReturnNode(const JSTokenLocation&, ExpressionNode* value); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1546 | |
barraclough@apple.com | b467c4c | 2010-07-13 20:34:11 +0000 | [diff] [blame] | 1547 | ExpressionNode* value() { return m_value; } |
| 1548 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1549 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1550 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1551 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1552 | bool isReturnNode() const override { return true; } |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1553 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1554 | ExpressionNode* m_value; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1555 | }; |
| 1556 | |
| 1557 | class WithNode : public StatementNode { |
| 1558 | public: |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 1559 | WithNode(const JSTokenLocation&, ExpressionNode*, StatementNode*, const JSTextPosition& divot, uint32_t expressionLength); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1560 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1561 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1562 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1563 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1564 | ExpressionNode* m_expr; |
| 1565 | StatementNode* m_statement; |
mark.lam@apple.com | 3b256ca | 2013-07-30 17:01:40 +0000 | [diff] [blame] | 1566 | JSTextPosition m_divot; |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1567 | uint32_t m_expressionLength; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1568 | }; |
| 1569 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1570 | class LabelNode : public StatementNode, public ThrowableExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1571 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1572 | LabelNode(const JSTokenLocation&, const Identifier& name, StatementNode*); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1573 | |
joepeck@webkit.org | f26f3b1 | 2016-09-30 19:22:50 +0000 | [diff] [blame] | 1574 | bool isLabel() const override { return true; } |
| 1575 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1576 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1577 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 1578 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 1579 | const Identifier& m_name; |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1580 | StatementNode* m_statement; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1581 | }; |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 1582 | |
oliver@apple.com | 90b88ae | 2008-07-19 01:44:24 +0000 | [diff] [blame] | 1583 | class ThrowNode : public StatementNode, public ThrowableExpressionData { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1584 | public: |
commit-queue@webkit.org | 1b331cb | 2012-08-06 03:16:46 +0000 | [diff] [blame] | 1585 | ThrowNode(const JSTokenLocation&, ExpressionNode*); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1586 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1587 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1588 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 1589 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1590 | ExpressionNode* m_expr; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1591 | }; |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 1592 | |
sbarati@apple.com | 62be0b0 | 2015-09-19 15:36:46 +0000 | [diff] [blame] | 1593 | class TryNode : public StatementNode, public VariableEnvironmentNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1594 | public: |
sbarati@apple.com | 62be0b0 | 2015-09-19 15:36:46 +0000 | [diff] [blame] | 1595 | using ParserArenaDeletable::operator new; |
| 1596 | |
utatane.tea@gmail.com | 08fe311 | 2016-01-22 04:21:36 +0000 | [diff] [blame] | 1597 | TryNode(const JSTokenLocation&, StatementNode* tryBlock, DestructuringPatternNode* catchPattern, StatementNode* catchBlock, VariableEnvironment& catchEnvironment, StatementNode* finallyBlock); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 1598 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1599 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1600 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1601 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1602 | StatementNode* m_tryBlock; |
utatane.tea@gmail.com | 08fe311 | 2016-01-22 04:21:36 +0000 | [diff] [blame] | 1603 | DestructuringPatternNode* m_catchPattern; |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 1604 | StatementNode* m_catchBlock; |
| 1605 | StatementNode* m_finallyBlock; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1606 | }; |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 1607 | |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1608 | class ScopeNode : public StatementNode, public ParserArenaRoot, public VariableEnvironmentNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1609 | public: |
darin@apple.com | 97ea242 | 2008-11-10 01:28:10 +0000 | [diff] [blame] | 1610 | |
ggaren@apple.com | c0ccae0 | 2014-12-03 23:23:56 +0000 | [diff] [blame] | 1611 | ScopeNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, bool inStrictContext); |
sbarati@apple.com | 432a3c9 | 2016-04-03 19:45:05 +0000 | [diff] [blame] | 1612 | ScopeNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, const SourceCode&, SourceElements*, VariableEnvironment&, FunctionStack&&, VariableEnvironment&, UniquedStringImplPtrSet&&, CodeFeatures, InnerArrowFunctionCodeFeatures, int numConstants); |
weinig@apple.com | 9b5bf06 | 2008-11-20 23:23:59 +0000 | [diff] [blame] | 1613 | |
ggaren@apple.com | 9e5d58e | 2014-12-05 00:59:33 +0000 | [diff] [blame] | 1614 | using ParserArenaRoot::operator new; |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 1615 | |
wingo@igalia.com | 0700f68 | 2012-03-09 12:06:48 +0000 | [diff] [blame] | 1616 | const SourceCode& source() const { return m_source; } |
benjamin@webkit.org | cff06e4 | 2012-08-30 21:23:51 +0000 | [diff] [blame] | 1617 | const String& sourceURL() const { return m_source.provider()->url(); } |
fpizlo@apple.com | d55e815 | 2012-05-30 21:04:23 +0000 | [diff] [blame] | 1618 | intptr_t sourceID() const { return m_source.providerID(); } |
wingo@igalia.com | 0700f68 | 2012-03-09 12:06:48 +0000 | [diff] [blame] | 1619 | |
mark.lam@apple.com | faa5393 | 2013-03-20 09:09:38 +0000 | [diff] [blame] | 1620 | int startLine() const { return m_startLineNumber; } |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 1621 | int startStartOffset() const { return m_startStartOffset; } |
| 1622 | int startLineStartOffset() const { return m_startLineStartOffset; } |
mark.lam@apple.com | faa5393 | 2013-03-20 09:09:38 +0000 | [diff] [blame] | 1623 | |
oliver@apple.com | 6bc1137 | 2012-05-07 23:35:52 +0000 | [diff] [blame] | 1624 | void setFeatures(CodeFeatures features) { m_features = features; } |
| 1625 | CodeFeatures features() { return m_features; } |
gskachkov@gmail.com | a198dd1 | 2016-02-28 19:14:26 +0000 | [diff] [blame] | 1626 | InnerArrowFunctionCodeFeatures innerArrowFunctionCodeFeatures() { return m_innerArrowFunctionCodeFeatures; } |
gskachkov@gmail.com | 7866786 | 2016-03-01 21:28:45 +0000 | [diff] [blame] | 1627 | bool doAnyInnerArrowFunctionsUseAnyFeature() { return m_innerArrowFunctionCodeFeatures != NoInnerArrowFunctionFeatures; } |
gskachkov@gmail.com | a198dd1 | 2016-02-28 19:14:26 +0000 | [diff] [blame] | 1628 | bool doAnyInnerArrowFunctionsUseArguments() { return m_innerArrowFunctionCodeFeatures & ArgumentsInnerArrowFunctionFeature; } |
| 1629 | bool doAnyInnerArrowFunctionsUseSuperCall() { return m_innerArrowFunctionCodeFeatures & SuperCallInnerArrowFunctionFeature; } |
| 1630 | bool doAnyInnerArrowFunctionsUseSuperProperty() { return m_innerArrowFunctionCodeFeatures & SuperPropertyInnerArrowFunctionFeature; } |
| 1631 | bool doAnyInnerArrowFunctionsUseEval() { return m_innerArrowFunctionCodeFeatures & EvalInnerArrowFunctionFeature; } |
| 1632 | bool doAnyInnerArrowFunctionsUseThis() { return m_innerArrowFunctionCodeFeatures & ThisInnerArrowFunctionFeature; } |
| 1633 | bool doAnyInnerArrowFunctionsUseNewTarget() { return m_innerArrowFunctionCodeFeatures & NewTargetInnerArrowFunctionFeature; } |
oliver@apple.com | 6bc1137 | 2012-05-07 23:35:52 +0000 | [diff] [blame] | 1634 | |
| 1635 | bool usesEval() const { return m_features & EvalFeature; } |
| 1636 | bool usesArguments() const { return (m_features & ArgumentsFeature) && !(m_features & ShadowsArgumentsFeature); } |
commit-queue@webkit.org | b2610c0 | 2015-12-08 20:24:04 +0000 | [diff] [blame] | 1637 | bool usesArrowFunction() const { return m_features & ArrowFunctionFeature; } |
oliver@apple.com | 6bc1137 | 2012-05-07 23:35:52 +0000 | [diff] [blame] | 1638 | bool isStrictMode() const { return m_features & StrictModeFeature; } |
| 1639 | void setUsesArguments() { m_features |= ArgumentsFeature; } |
| 1640 | bool usesThis() const { return m_features & ThisFeature; } |
gskachkov@gmail.com | a198dd1 | 2016-02-28 19:14:26 +0000 | [diff] [blame] | 1641 | bool usesSuperCall() const { return m_features & SuperCallFeature; } |
| 1642 | bool usesSuperProperty() const { return m_features & SuperPropertyFeature; } |
gskachkov@gmail.com | f7ba3e4 | 2016-03-10 08:19:42 +0000 | [diff] [blame] | 1643 | bool usesNewTarget() const { return m_features & NewTargetFeature; } |
commit-queue@webkit.org | e4b5df8 | 2015-09-15 19:26:45 +0000 | [diff] [blame] | 1644 | bool needsActivation() const { return (hasCapturedVariables()) || (m_features & (EvalFeature | WithFeature)); } |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1645 | bool hasCapturedVariables() const { return m_varDeclarations.hasCapturedVariables(); } |
| 1646 | bool captures(UniquedStringImpl* uid) { return m_varDeclarations.captures(uid); } |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 1647 | bool captures(const Identifier& ident) { return captures(ident.impl()); } |
sbarati@apple.com | 432a3c9 | 2016-04-03 19:45:05 +0000 | [diff] [blame] | 1648 | bool hasSloppyModeHoistedFunction(UniquedStringImpl* uid) const { return m_sloppyModeHoistedFunctions.contains(uid); } |
oliver@apple.com | 6bc1137 | 2012-05-07 23:35:52 +0000 | [diff] [blame] | 1649 | |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1650 | VariableEnvironment& varDeclarations() { return m_varDeclarations; } |
weinig@apple.com | 9b5bf06 | 2008-11-20 23:23:59 +0000 | [diff] [blame] | 1651 | |
cwzwarich@webkit.org | 300bb75 | 2008-08-06 10:37:34 +0000 | [diff] [blame] | 1652 | int neededConstants() |
| 1653 | { |
ggaren@apple.com | 68313b0 | 2008-11-13 00:48:23 +0000 | [diff] [blame] | 1654 | // We may need 2 more constants than the count given by the parser, |
| 1655 | // because of the various uses of jsUndefined() and jsNull(). |
wingo@igalia.com | 08f0e4c | 2012-03-07 10:18:43 +0000 | [diff] [blame] | 1656 | return m_numConstants + 2; |
cwzwarich@webkit.org | 300bb75 | 2008-08-06 10:37:34 +0000 | [diff] [blame] | 1657 | } |
| 1658 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 1659 | StatementNode* singleStatement() const; |
| 1660 | |
| 1661 | void emitStatementsBytecode(BytecodeGenerator&, RegisterID* destination); |
oliver@apple.com | ba848d1 | 2014-02-12 17:14:23 +0000 | [diff] [blame] | 1662 | |
utatane.tea@gmail.com | 1c1bac0 | 2015-08-12 20:38:45 +0000 | [diff] [blame] | 1663 | void analyzeModule(ModuleAnalyzer&); |
| 1664 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1665 | protected: |
mark.lam@apple.com | faa5393 | 2013-03-20 09:09:38 +0000 | [diff] [blame] | 1666 | int m_startLineNumber; |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 1667 | unsigned m_startStartOffset; |
| 1668 | unsigned m_startLineStartOffset; |
mark.lam@apple.com | faa5393 | 2013-03-20 09:09:38 +0000 | [diff] [blame] | 1669 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1670 | private: |
oliver@apple.com | 6bc1137 | 2012-05-07 23:35:52 +0000 | [diff] [blame] | 1671 | CodeFeatures m_features; |
gskachkov@gmail.com | a198dd1 | 2016-02-28 19:14:26 +0000 | [diff] [blame] | 1672 | InnerArrowFunctionCodeFeatures m_innerArrowFunctionCodeFeatures; |
weinig@apple.com | 9b5bf06 | 2008-11-20 23:23:59 +0000 | [diff] [blame] | 1673 | SourceCode m_source; |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 1674 | VariableEnvironment m_varDeclarations; |
sbarati@apple.com | 432a3c9 | 2016-04-03 19:45:05 +0000 | [diff] [blame] | 1675 | UniquedStringImplPtrSet m_sloppyModeHoistedFunctions; |
wingo@igalia.com | 08f0e4c | 2012-03-07 10:18:43 +0000 | [diff] [blame] | 1676 | int m_numConstants; |
| 1677 | SourceElements* m_statements; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1678 | }; |
ggaren | 76f1d81 | 2007-10-25 07:09:44 +0000 | [diff] [blame] | 1679 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1680 | class ProgramNode : public ScopeNode { |
| 1681 | public: |
utatane.tea@gmail.com | a03b21b | 2016-07-31 07:04:57 +0000 | [diff] [blame] | 1682 | ProgramNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VariableEnvironment&, FunctionStack&&, VariableEnvironment&, UniquedStringImplPtrSet&&, FunctionParameters*, const SourceCode&, CodeFeatures, InnerArrowFunctionCodeFeatures, int numConstants, RefPtr<ModuleScopeData>&&); |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 1683 | |
mark.lam@apple.com | fa35e78 | 2013-11-19 21:55:16 +0000 | [diff] [blame] | 1684 | unsigned startColumn() const { return m_startColumn; } |
| 1685 | unsigned endColumn() const { return m_endColumn; } |
cwzwarich@webkit.org | f064af6 | 2008-06-21 06:32:25 +0000 | [diff] [blame] | 1686 | |
barraclough@apple.com | 1050f79 | 2009-08-25 02:53:51 +0000 | [diff] [blame] | 1687 | static const bool scopeIsFunction = false; |
| 1688 | |
ggaren@apple.com | 9e5d58e | 2014-12-05 00:59:33 +0000 | [diff] [blame] | 1689 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1690 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 1691 | unsigned m_startColumn; |
mark.lam@apple.com | fa35e78 | 2013-11-19 21:55:16 +0000 | [diff] [blame] | 1692 | unsigned m_endColumn; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1693 | }; |
ggaren@apple.com | e65a290 | 2007-12-11 05:47:41 +0000 | [diff] [blame] | 1694 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1695 | class EvalNode : public ScopeNode { |
| 1696 | public: |
utatane.tea@gmail.com | a03b21b | 2016-07-31 07:04:57 +0000 | [diff] [blame] | 1697 | EvalNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VariableEnvironment&, FunctionStack&&, VariableEnvironment&, UniquedStringImplPtrSet&&, FunctionParameters*, const SourceCode&, CodeFeatures, InnerArrowFunctionCodeFeatures, int numConstants, RefPtr<ModuleScopeData>&&); |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 1698 | |
mark.lam@apple.com | fa35e78 | 2013-11-19 21:55:16 +0000 | [diff] [blame] | 1699 | ALWAYS_INLINE unsigned startColumn() const { return 0; } |
| 1700 | unsigned endColumn() const { return m_endColumn; } |
cwzwarich@webkit.org | f064af6 | 2008-06-21 06:32:25 +0000 | [diff] [blame] | 1701 | |
barraclough@apple.com | 1050f79 | 2009-08-25 02:53:51 +0000 | [diff] [blame] | 1702 | static const bool scopeIsFunction = false; |
| 1703 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1704 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1705 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
mark.lam@apple.com | fa35e78 | 2013-11-19 21:55:16 +0000 | [diff] [blame] | 1706 | |
| 1707 | unsigned m_endColumn; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1708 | }; |
mjs | f06d2de | 2005-09-21 05:53:05 +0000 | [diff] [blame] | 1709 | |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1710 | class ModuleProgramNode : public ScopeNode { |
| 1711 | public: |
utatane.tea@gmail.com | a03b21b | 2016-07-31 07:04:57 +0000 | [diff] [blame] | 1712 | ModuleProgramNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VariableEnvironment&, FunctionStack&&, VariableEnvironment&, UniquedStringImplPtrSet&&, FunctionParameters*, const SourceCode&, CodeFeatures, InnerArrowFunctionCodeFeatures, int numConstants, RefPtr<ModuleScopeData>&&); |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1713 | |
| 1714 | unsigned startColumn() const { return m_startColumn; } |
| 1715 | unsigned endColumn() const { return m_endColumn; } |
| 1716 | |
| 1717 | static const bool scopeIsFunction = false; |
| 1718 | |
utatane.tea@gmail.com | a03b21b | 2016-07-31 07:04:57 +0000 | [diff] [blame] | 1719 | ModuleScopeData& moduleScopeData() |
| 1720 | { |
| 1721 | return m_moduleScopeData; |
| 1722 | } |
| 1723 | |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1724 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1725 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1726 | unsigned m_startColumn; |
| 1727 | unsigned m_endColumn; |
utatane.tea@gmail.com | a03b21b | 2016-07-31 07:04:57 +0000 | [diff] [blame] | 1728 | Ref<ModuleScopeData> m_moduleScopeData; |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1729 | }; |
| 1730 | |
utatane.tea@gmail.com | 505049b | 2015-08-13 23:55:35 +0000 | [diff] [blame] | 1731 | class ModuleNameNode : public Node { |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1732 | public: |
utatane.tea@gmail.com | 505049b | 2015-08-13 23:55:35 +0000 | [diff] [blame] | 1733 | ModuleNameNode(const JSTokenLocation&, const Identifier& moduleName); |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1734 | |
| 1735 | const Identifier& moduleName() { return m_moduleName; } |
| 1736 | |
| 1737 | private: |
| 1738 | const Identifier& m_moduleName; |
| 1739 | }; |
| 1740 | |
| 1741 | class ImportSpecifierNode : public Node { |
| 1742 | public: |
| 1743 | ImportSpecifierNode(const JSTokenLocation&, const Identifier& importedName, const Identifier& localName); |
| 1744 | |
| 1745 | const Identifier& importedName() { return m_importedName; } |
| 1746 | const Identifier& localName() { return m_localName; } |
| 1747 | |
| 1748 | private: |
| 1749 | const Identifier& m_importedName; |
| 1750 | const Identifier& m_localName; |
| 1751 | }; |
| 1752 | |
| 1753 | class ImportSpecifierListNode : public ParserArenaDeletable { |
| 1754 | public: |
| 1755 | typedef Vector<ImportSpecifierNode*, 3> Specifiers; |
| 1756 | |
| 1757 | const Specifiers& specifiers() const { return m_specifiers; } |
| 1758 | void append(ImportSpecifierNode* specifier) |
| 1759 | { |
| 1760 | m_specifiers.append(specifier); |
| 1761 | } |
| 1762 | |
| 1763 | private: |
| 1764 | Specifiers m_specifiers; |
| 1765 | }; |
| 1766 | |
utatane.tea@gmail.com | 1c1bac0 | 2015-08-12 20:38:45 +0000 | [diff] [blame] | 1767 | class ModuleDeclarationNode : public StatementNode { |
| 1768 | public: |
| 1769 | virtual void analyzeModule(ModuleAnalyzer&) = 0; |
annulen@yandex.ru | d6de8df | 2016-12-15 21:26:08 +0000 | [diff] [blame] | 1770 | bool isModuleDeclarationNode() const override { return true; } |
utatane.tea@gmail.com | 1c1bac0 | 2015-08-12 20:38:45 +0000 | [diff] [blame] | 1771 | |
| 1772 | protected: |
| 1773 | ModuleDeclarationNode(const JSTokenLocation&); |
| 1774 | }; |
| 1775 | |
| 1776 | class ImportDeclarationNode : public ModuleDeclarationNode { |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1777 | public: |
utatane.tea@gmail.com | 505049b | 2015-08-13 23:55:35 +0000 | [diff] [blame] | 1778 | ImportDeclarationNode(const JSTokenLocation&, ImportSpecifierListNode*, ModuleNameNode*); |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1779 | |
| 1780 | ImportSpecifierListNode* specifierList() const { return m_specifierList; } |
utatane.tea@gmail.com | 505049b | 2015-08-13 23:55:35 +0000 | [diff] [blame] | 1781 | ModuleNameNode* moduleName() const { return m_moduleName; } |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1782 | |
| 1783 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1784 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
| 1785 | void analyzeModule(ModuleAnalyzer&) override; |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1786 | |
| 1787 | ImportSpecifierListNode* m_specifierList; |
utatane.tea@gmail.com | 505049b | 2015-08-13 23:55:35 +0000 | [diff] [blame] | 1788 | ModuleNameNode* m_moduleName; |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1789 | }; |
| 1790 | |
utatane.tea@gmail.com | 1c1bac0 | 2015-08-12 20:38:45 +0000 | [diff] [blame] | 1791 | class ExportAllDeclarationNode : public ModuleDeclarationNode { |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1792 | public: |
utatane.tea@gmail.com | 505049b | 2015-08-13 23:55:35 +0000 | [diff] [blame] | 1793 | ExportAllDeclarationNode(const JSTokenLocation&, ModuleNameNode*); |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1794 | |
utatane.tea@gmail.com | 505049b | 2015-08-13 23:55:35 +0000 | [diff] [blame] | 1795 | ModuleNameNode* moduleName() const { return m_moduleName; } |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1796 | |
| 1797 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1798 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
| 1799 | void analyzeModule(ModuleAnalyzer&) override; |
utatane.tea@gmail.com | 1c1bac0 | 2015-08-12 20:38:45 +0000 | [diff] [blame] | 1800 | |
utatane.tea@gmail.com | 505049b | 2015-08-13 23:55:35 +0000 | [diff] [blame] | 1801 | ModuleNameNode* m_moduleName; |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1802 | }; |
| 1803 | |
utatane.tea@gmail.com | 1c1bac0 | 2015-08-12 20:38:45 +0000 | [diff] [blame] | 1804 | class ExportDefaultDeclarationNode : public ModuleDeclarationNode { |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1805 | public: |
utatane.tea@gmail.com | 1c1bac0 | 2015-08-12 20:38:45 +0000 | [diff] [blame] | 1806 | ExportDefaultDeclarationNode(const JSTokenLocation&, StatementNode*, const Identifier& localName); |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1807 | |
| 1808 | const StatementNode& declaration() const { return *m_declaration; } |
utatane.tea@gmail.com | 1c1bac0 | 2015-08-12 20:38:45 +0000 | [diff] [blame] | 1809 | const Identifier& localName() const { return m_localName; } |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1810 | |
| 1811 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1812 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
| 1813 | void analyzeModule(ModuleAnalyzer&) override; |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1814 | StatementNode* m_declaration; |
utatane.tea@gmail.com | 1c1bac0 | 2015-08-12 20:38:45 +0000 | [diff] [blame] | 1815 | const Identifier& m_localName; |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1816 | }; |
| 1817 | |
utatane.tea@gmail.com | 1c1bac0 | 2015-08-12 20:38:45 +0000 | [diff] [blame] | 1818 | class ExportLocalDeclarationNode : public ModuleDeclarationNode { |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1819 | public: |
| 1820 | ExportLocalDeclarationNode(const JSTokenLocation&, StatementNode*); |
| 1821 | |
| 1822 | const StatementNode& declaration() const { return *m_declaration; } |
| 1823 | |
| 1824 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1825 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
| 1826 | void analyzeModule(ModuleAnalyzer&) override; |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1827 | StatementNode* m_declaration; |
| 1828 | }; |
| 1829 | |
| 1830 | class ExportSpecifierNode : public Node { |
| 1831 | public: |
| 1832 | ExportSpecifierNode(const JSTokenLocation&, const Identifier& localName, const Identifier& exportedName); |
| 1833 | |
| 1834 | const Identifier& exportedName() { return m_exportedName; } |
| 1835 | const Identifier& localName() { return m_localName; } |
| 1836 | |
| 1837 | private: |
| 1838 | const Identifier& m_localName; |
| 1839 | const Identifier& m_exportedName; |
| 1840 | }; |
| 1841 | |
| 1842 | class ExportSpecifierListNode : public ParserArenaDeletable { |
| 1843 | public: |
| 1844 | typedef Vector<ExportSpecifierNode*, 3> Specifiers; |
| 1845 | |
| 1846 | const Specifiers& specifiers() const { return m_specifiers; } |
| 1847 | void append(ExportSpecifierNode* specifier) |
| 1848 | { |
| 1849 | m_specifiers.append(specifier); |
| 1850 | } |
| 1851 | |
| 1852 | private: |
| 1853 | Specifiers m_specifiers; |
| 1854 | }; |
| 1855 | |
utatane.tea@gmail.com | 1c1bac0 | 2015-08-12 20:38:45 +0000 | [diff] [blame] | 1856 | class ExportNamedDeclarationNode : public ModuleDeclarationNode { |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1857 | public: |
utatane.tea@gmail.com | 505049b | 2015-08-13 23:55:35 +0000 | [diff] [blame] | 1858 | ExportNamedDeclarationNode(const JSTokenLocation&, ExportSpecifierListNode*, ModuleNameNode*); |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1859 | |
| 1860 | ExportSpecifierListNode* specifierList() const { return m_specifierList; } |
utatane.tea@gmail.com | 505049b | 2015-08-13 23:55:35 +0000 | [diff] [blame] | 1861 | ModuleNameNode* moduleName() const { return m_moduleName; } |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1862 | |
| 1863 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1864 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
| 1865 | void analyzeModule(ModuleAnalyzer&) override; |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1866 | ExportSpecifierListNode* m_specifierList; |
utatane.tea@gmail.com | 505049b | 2015-08-13 23:55:35 +0000 | [diff] [blame] | 1867 | ModuleNameNode* m_moduleName { nullptr }; |
utatane.tea@gmail.com | 9f9c975 | 2015-08-04 21:26:49 +0000 | [diff] [blame] | 1868 | }; |
| 1869 | |
ggaren@apple.com | e7afe40 | 2015-08-10 20:24:35 +0000 | [diff] [blame] | 1870 | class FunctionMetadataNode final : public Node, public ParserArenaDeletable { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1871 | public: |
ggaren@apple.com | 6f851d7 | 2014-12-04 23:47:49 +0000 | [diff] [blame] | 1872 | using ParserArenaDeletable::operator new; |
| 1873 | |
ggaren@apple.com | e7afe40 | 2015-08-10 20:24:35 +0000 | [diff] [blame] | 1874 | FunctionMetadataNode( |
ggaren@apple.com | d3e1f86 | 2015-03-20 23:37:51 +0000 | [diff] [blame] | 1875 | ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, |
| 1876 | unsigned startColumn, unsigned endColumn, int functionKeywordStart, |
| 1877 | int functionNameStart, int parametersStart, bool isInStrictContext, |
utatane.tea@gmail.com | 3e031ac | 2017-03-16 05:12:53 +0000 | [diff] [blame] | 1878 | ConstructorKind, SuperBinding, unsigned parameterCount, |
commit-queue@webkit.org | a1e1d57 | 2016-09-22 19:11:23 +0000 | [diff] [blame] | 1879 | SourceParseMode, bool isArrowFunctionBodyExpression); |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1880 | |
saambarati1@gmail.com | c497d15 | 2015-07-17 18:48:30 +0000 | [diff] [blame] | 1881 | void finishParsing(const SourceCode&, const Identifier&, FunctionMode); |
ggaren@apple.com | 69e9ccf | 2008-10-02 06:44:37 +0000 | [diff] [blame] | 1882 | |
oliver@apple.com | 4cbc701 | 2014-02-14 23:29:31 +0000 | [diff] [blame] | 1883 | void overrideName(const Identifier& ident) { m_ident = ident; } |
barraclough@apple.com | 3dc1233 | 2009-08-12 05:22:33 +0000 | [diff] [blame] | 1884 | const Identifier& ident() { return m_ident; } |
mark.lam@apple.com | 4b79ce7 | 2016-03-11 21:08:08 +0000 | [diff] [blame] | 1885 | void setEcmaName(const Identifier& ecmaName) { m_ecmaName = ecmaName; } |
mark.lam@apple.com | c7f7bdf | 2016-03-09 19:36:21 +0000 | [diff] [blame] | 1886 | const Identifier& ecmaName() { return m_ident.isEmpty() ? m_ecmaName : m_ident; } |
oliver@apple.com | ddf4b48 | 2012-02-17 21:17:59 +0000 | [diff] [blame] | 1887 | void setInferredName(const Identifier& inferredName) { ASSERT(!inferredName.isNull()); m_inferredName = inferredName; } |
oliver@apple.com | f7190bf | 2012-02-01 23:23:30 +0000 | [diff] [blame] | 1888 | const Identifier& inferredName() { return m_inferredName.isEmpty() ? m_ident : m_inferredName; } |
barraclough@apple.com | 3dc1233 | 2009-08-12 05:22:33 +0000 | [diff] [blame] | 1889 | |
ggaren@apple.com | 7d92d07 | 2014-02-03 20:39:38 +0000 | [diff] [blame] | 1890 | FunctionMode functionMode() { return m_functionMode; } |
ggaren@apple.com | f820008 | 2012-09-07 01:42:53 +0000 | [diff] [blame] | 1891 | |
mark.lam@apple.com | fa35e78 | 2013-11-19 21:55:16 +0000 | [diff] [blame] | 1892 | int functionNameStart() const { return m_functionNameStart; } |
saambarati1@gmail.com | b4f28a5 | 2014-12-05 05:58:07 +0000 | [diff] [blame] | 1893 | int functionKeywordStart() const { return m_functionKeywordStart; } |
commit-queue@webkit.org | 157a432 | 2015-03-24 20:07:26 +0000 | [diff] [blame] | 1894 | int parametersStart() const { return m_parametersStart; } |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 1895 | unsigned startColumn() const { return m_startColumn; } |
mark.lam@apple.com | fa35e78 | 2013-11-19 21:55:16 +0000 | [diff] [blame] | 1896 | unsigned endColumn() const { return m_endColumn; } |
saambarati1@gmail.com | c497d15 | 2015-07-17 18:48:30 +0000 | [diff] [blame] | 1897 | unsigned parameterCount() const { return m_parameterCount; } |
utatane.tea@gmail.com | 505049b | 2015-08-13 23:55:35 +0000 | [diff] [blame] | 1898 | SourceParseMode parseMode() const { return m_parseMode; } |
mark.lam@apple.com | fa35e78 | 2013-11-19 21:55:16 +0000 | [diff] [blame] | 1899 | |
| 1900 | void setEndPosition(JSTextPosition); |
oliver@apple.com | 924afcb | 2012-12-06 19:34:27 +0000 | [diff] [blame] | 1901 | |
ggaren@apple.com | 6f851d7 | 2014-12-04 23:47:49 +0000 | [diff] [blame] | 1902 | const SourceCode& source() const { return m_source; } |
mark.lam@apple.com | 4b79ce7 | 2016-03-11 21:08:08 +0000 | [diff] [blame] | 1903 | const SourceCode& classSource() const { return m_classSource; } |
| 1904 | void setClassSource(const SourceCode& source) { m_classSource = source; } |
barraclough@apple.com | 3dc1233 | 2009-08-12 05:22:33 +0000 | [diff] [blame] | 1905 | |
ggaren@apple.com | 6f851d7 | 2014-12-04 23:47:49 +0000 | [diff] [blame] | 1906 | int startStartOffset() const { return m_startStartOffset; } |
| 1907 | bool isInStrictContext() const { return m_isInStrictContext; } |
utatane.tea@gmail.com | fdd9bf4 | 2015-12-02 03:16:28 +0000 | [diff] [blame] | 1908 | SuperBinding superBinding() { return static_cast<SuperBinding>(m_superBinding); } |
rniwa@webkit.org | e6f8349 | 2015-03-13 23:01:51 +0000 | [diff] [blame] | 1909 | ConstructorKind constructorKind() { return static_cast<ConstructorKind>(m_constructorKind); } |
commit-queue@webkit.org | 04b2447 | 2015-08-25 19:10:29 +0000 | [diff] [blame] | 1910 | bool isArrowFunctionBodyExpression() const { return m_isArrowFunctionBodyExpression; } |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 1911 | |
ggaren@apple.com | e7afe40 | 2015-08-10 20:24:35 +0000 | [diff] [blame] | 1912 | void setLoc(unsigned firstLine, unsigned lastLine, int startOffset, int lineStartOffset) |
| 1913 | { |
| 1914 | m_lastLine = lastLine; |
| 1915 | m_position = JSTextPosition(firstLine, startOffset, lineStartOffset); |
| 1916 | ASSERT(m_position.offset >= m_position.lineStartOffset); |
| 1917 | } |
| 1918 | unsigned lastLine() const { return m_lastLine; } |
| 1919 | |
ggaren@apple.com | 6f851d7 | 2014-12-04 23:47:49 +0000 | [diff] [blame] | 1920 | protected: |
barraclough@apple.com | 3dc1233 | 2009-08-12 05:22:33 +0000 | [diff] [blame] | 1921 | Identifier m_ident; |
mark.lam@apple.com | c7f7bdf | 2016-03-09 19:36:21 +0000 | [diff] [blame] | 1922 | Identifier m_ecmaName; |
oliver@apple.com | f7190bf | 2012-02-01 23:23:30 +0000 | [diff] [blame] | 1923 | Identifier m_inferredName; |
ggaren@apple.com | 7d92d07 | 2014-02-03 20:39:38 +0000 | [diff] [blame] | 1924 | FunctionMode m_functionMode; |
mark.lam@apple.com | 5b45f90 | 2013-07-09 16:15:12 +0000 | [diff] [blame] | 1925 | unsigned m_startColumn; |
mark.lam@apple.com | fa35e78 | 2013-11-19 21:55:16 +0000 | [diff] [blame] | 1926 | unsigned m_endColumn; |
ggaren@apple.com | d3e1f86 | 2015-03-20 23:37:51 +0000 | [diff] [blame] | 1927 | int m_functionKeywordStart; |
| 1928 | int m_functionNameStart; |
| 1929 | int m_parametersStart; |
ggaren@apple.com | 6f851d7 | 2014-12-04 23:47:49 +0000 | [diff] [blame] | 1930 | SourceCode m_source; |
mark.lam@apple.com | 4b79ce7 | 2016-03-11 21:08:08 +0000 | [diff] [blame] | 1931 | SourceCode m_classSource; |
ggaren@apple.com | 6f851d7 | 2014-12-04 23:47:49 +0000 | [diff] [blame] | 1932 | int m_startStartOffset; |
saambarati1@gmail.com | c497d15 | 2015-07-17 18:48:30 +0000 | [diff] [blame] | 1933 | unsigned m_parameterCount; |
ggaren@apple.com | e7afe40 | 2015-08-10 20:24:35 +0000 | [diff] [blame] | 1934 | int m_lastLine; |
utatane.tea@gmail.com | 505049b | 2015-08-13 23:55:35 +0000 | [diff] [blame] | 1935 | SourceParseMode m_parseMode; |
rniwa@webkit.org | e6f8349 | 2015-03-13 23:01:51 +0000 | [diff] [blame] | 1936 | unsigned m_isInStrictContext : 1; |
utatane.tea@gmail.com | fdd9bf4 | 2015-12-02 03:16:28 +0000 | [diff] [blame] | 1937 | unsigned m_superBinding : 1; |
rniwa@webkit.org | e6f8349 | 2015-03-13 23:01:51 +0000 | [diff] [blame] | 1938 | unsigned m_constructorKind : 2; |
commit-queue@webkit.org | 04b2447 | 2015-08-25 19:10:29 +0000 | [diff] [blame] | 1939 | unsigned m_isArrowFunctionBodyExpression : 1; |
ggaren@apple.com | 6f851d7 | 2014-12-04 23:47:49 +0000 | [diff] [blame] | 1940 | }; |
| 1941 | |
ggaren@apple.com | 2ec9992 | 2014-12-04 23:55:34 +0000 | [diff] [blame] | 1942 | class FunctionNode final : public ScopeNode { |
ggaren@apple.com | 6f851d7 | 2014-12-04 23:47:49 +0000 | [diff] [blame] | 1943 | public: |
utatane.tea@gmail.com | a03b21b | 2016-07-31 07:04:57 +0000 | [diff] [blame] | 1944 | FunctionNode(ParserArena&, const JSTokenLocation& start, const JSTokenLocation& end, unsigned startColumn, unsigned endColumn, SourceElements*, VariableEnvironment&, FunctionStack&&, VariableEnvironment&, UniquedStringImplPtrSet&&, FunctionParameters*, const SourceCode&, CodeFeatures, InnerArrowFunctionCodeFeatures, int numConstants, RefPtr<ModuleScopeData>&&); |
ggaren@apple.com | 6f851d7 | 2014-12-04 23:47:49 +0000 | [diff] [blame] | 1945 | |
saambarati1@gmail.com | c497d15 | 2015-07-17 18:48:30 +0000 | [diff] [blame] | 1946 | FunctionParameters* parameters() const { return m_parameters; } |
ggaren@apple.com | 6f851d7 | 2014-12-04 23:47:49 +0000 | [diff] [blame] | 1947 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1948 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
ggaren@apple.com | 6f851d7 | 2014-12-04 23:47:49 +0000 | [diff] [blame] | 1949 | |
joepeck@webkit.org | bb70ac6 | 2016-09-30 19:22:37 +0000 | [diff] [blame] | 1950 | bool isFunctionNode() const override { return true; } |
| 1951 | |
saambarati1@gmail.com | c497d15 | 2015-07-17 18:48:30 +0000 | [diff] [blame] | 1952 | void finishParsing(const Identifier&, FunctionMode); |
ggaren@apple.com | 6f851d7 | 2014-12-04 23:47:49 +0000 | [diff] [blame] | 1953 | |
| 1954 | const Identifier& ident() { return m_ident; } |
| 1955 | |
mark.lam@apple.com | 4313787 | 2016-03-17 14:58:57 +0000 | [diff] [blame] | 1956 | FunctionMode functionMode() const { return m_functionMode; } |
ggaren@apple.com | 6f851d7 | 2014-12-04 23:47:49 +0000 | [diff] [blame] | 1957 | |
| 1958 | unsigned startColumn() const { return m_startColumn; } |
| 1959 | unsigned endColumn() const { return m_endColumn; } |
| 1960 | |
| 1961 | static const bool scopeIsFunction = true; |
| 1962 | |
| 1963 | private: |
ggaren@apple.com | 6f851d7 | 2014-12-04 23:47:49 +0000 | [diff] [blame] | 1964 | Identifier m_ident; |
| 1965 | FunctionMode m_functionMode; |
saambarati1@gmail.com | c497d15 | 2015-07-17 18:48:30 +0000 | [diff] [blame] | 1966 | FunctionParameters* m_parameters; |
ggaren@apple.com | 6f851d7 | 2014-12-04 23:47:49 +0000 | [diff] [blame] | 1967 | unsigned m_startColumn; |
| 1968 | unsigned m_endColumn; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1969 | }; |
| 1970 | |
commit-queue@webkit.org | a4201b0 | 2015-08-17 22:24:20 +0000 | [diff] [blame] | 1971 | class BaseFuncExprNode : public ExpressionNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1972 | public: |
ggaren@apple.com | e7afe40 | 2015-08-10 20:24:35 +0000 | [diff] [blame] | 1973 | FunctionMetadataNode* metadata() { return m_metadata; } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1974 | |
commit-queue@webkit.org | c4df9c0 | 2016-09-29 19:01:42 +0000 | [diff] [blame] | 1975 | bool isBaseFuncExprNode() const override { return true; } |
| 1976 | |
commit-queue@webkit.org | a4201b0 | 2015-08-17 22:24:20 +0000 | [diff] [blame] | 1977 | protected: |
mark.lam@apple.com | 4313787 | 2016-03-17 14:58:57 +0000 | [diff] [blame] | 1978 | BaseFuncExprNode(const JSTokenLocation&, const Identifier&, FunctionMetadataNode*, const SourceCode&, FunctionMode); |
| 1979 | |
commit-queue@webkit.org | a4201b0 | 2015-08-17 22:24:20 +0000 | [diff] [blame] | 1980 | FunctionMetadataNode* m_metadata; |
| 1981 | }; |
| 1982 | |
| 1983 | |
| 1984 | class FuncExprNode : public BaseFuncExprNode { |
| 1985 | public: |
| 1986 | FuncExprNode(const JSTokenLocation&, const Identifier&, FunctionMetadataNode*, const SourceCode&); |
| 1987 | |
mark.lam@apple.com | 4313787 | 2016-03-17 14:58:57 +0000 | [diff] [blame] | 1988 | protected: |
| 1989 | FuncExprNode(const JSTokenLocation&, const Identifier&, FunctionMetadataNode*, const SourceCode&, FunctionMode); |
| 1990 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 1991 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1992 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1993 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 1994 | bool isFuncExprNode() const override { return true; } |
commit-queue@webkit.org | a4201b0 | 2015-08-17 22:24:20 +0000 | [diff] [blame] | 1995 | }; |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 1996 | |
commit-queue@webkit.org | a4201b0 | 2015-08-17 22:24:20 +0000 | [diff] [blame] | 1997 | class ArrowFuncExprNode : public BaseFuncExprNode { |
| 1998 | public: |
| 1999 | ArrowFuncExprNode(const JSTokenLocation&, const Identifier&, FunctionMetadataNode*, const SourceCode&); |
| 2000 | |
| 2001 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 2002 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
commit-queue@webkit.org | a4201b0 | 2015-08-17 22:24:20 +0000 | [diff] [blame] | 2003 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 2004 | bool isArrowFuncExprNode() const override { return true; } |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 2005 | }; |
| 2006 | |
mark.lam@apple.com | 4313787 | 2016-03-17 14:58:57 +0000 | [diff] [blame] | 2007 | class MethodDefinitionNode : public FuncExprNode { |
| 2008 | public: |
| 2009 | MethodDefinitionNode(const JSTokenLocation&, const Identifier&, FunctionMetadataNode*, const SourceCode&); |
| 2010 | |
| 2011 | private: |
| 2012 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
| 2013 | }; |
| 2014 | |
utatane.tea@gmail.com | fdd9bf4 | 2015-12-02 03:16:28 +0000 | [diff] [blame] | 2015 | class YieldExprNode final : public ExpressionNode, public ThrowableExpressionData { |
utatane.tea@gmail.com | f2fde6a | 2015-11-02 05:46:17 +0000 | [diff] [blame] | 2016 | public: |
| 2017 | YieldExprNode(const JSTokenLocation&, ExpressionNode* argument, bool delegate); |
| 2018 | |
| 2019 | ExpressionNode* argument() const { return m_argument; } |
| 2020 | bool delegate() const { return m_delegate; } |
| 2021 | |
| 2022 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 2023 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
utatane.tea@gmail.com | f2fde6a | 2015-11-02 05:46:17 +0000 | [diff] [blame] | 2024 | |
| 2025 | ExpressionNode* m_argument; |
| 2026 | bool m_delegate; |
| 2027 | }; |
| 2028 | |
caitp@igalia.com | 0096c96 | 2016-09-23 22:24:27 +0000 | [diff] [blame] | 2029 | class AwaitExprNode final : public ExpressionNode, public ThrowableExpressionData { |
| 2030 | public: |
| 2031 | AwaitExprNode(const JSTokenLocation&, ExpressionNode* argument); |
| 2032 | |
| 2033 | ExpressionNode* argument() const { return m_argument; } |
| 2034 | |
| 2035 | private: |
| 2036 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
| 2037 | |
| 2038 | ExpressionNode* m_argument; |
| 2039 | }; |
| 2040 | |
utatane.tea@gmail.com | 0a4a7f8 | 2015-10-15 14:35:12 +0000 | [diff] [blame] | 2041 | class ClassExprNode final : public ExpressionNode, public VariableEnvironmentNode { |
rniwa@webkit.org | 65c9b0d | 2015-01-29 22:59:19 +0000 | [diff] [blame] | 2042 | public: |
utatane.tea@gmail.com | 0a4a7f8 | 2015-10-15 14:35:12 +0000 | [diff] [blame] | 2043 | using ParserArenaDeletable::operator new; |
| 2044 | |
mark.lam@apple.com | 4b79ce7 | 2016-03-11 21:08:08 +0000 | [diff] [blame] | 2045 | ClassExprNode(const JSTokenLocation&, const Identifier&, const SourceCode& classSource, |
| 2046 | VariableEnvironment& classEnvironment, ExpressionNode* constructorExpresssion, |
rniwa@webkit.org | 65c9b0d | 2015-01-29 22:59:19 +0000 | [diff] [blame] | 2047 | ExpressionNode* parentClass, PropertyListNode* instanceMethods, PropertyListNode* staticMethods); |
| 2048 | |
| 2049 | const Identifier& name() { return m_name; } |
mark.lam@apple.com | 4b79ce7 | 2016-03-11 21:08:08 +0000 | [diff] [blame] | 2050 | const Identifier& ecmaName() { return m_ecmaName ? *m_ecmaName : m_name; } |
| 2051 | void setEcmaName(const Identifier& name) { m_ecmaName = m_name.isNull() ? &name : &m_name; } |
rniwa@webkit.org | 65c9b0d | 2015-01-29 22:59:19 +0000 | [diff] [blame] | 2052 | |
mark.lam@apple.com | 47c2f14 | 2016-03-16 18:16:32 +0000 | [diff] [blame] | 2053 | bool hasStaticProperty(const Identifier& propName) { return m_staticMethods ? m_staticMethods->hasStaticallyNamedProperty(propName) : false; } |
| 2054 | |
rniwa@webkit.org | 65c9b0d | 2015-01-29 22:59:19 +0000 | [diff] [blame] | 2055 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 2056 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
rniwa@webkit.org | 65c9b0d | 2015-01-29 22:59:19 +0000 | [diff] [blame] | 2057 | |
mark.lam@apple.com | 4b79ce7 | 2016-03-11 21:08:08 +0000 | [diff] [blame] | 2058 | bool isClassExprNode() const override { return true; } |
| 2059 | |
| 2060 | SourceCode m_classSource; |
rniwa@webkit.org | 65c9b0d | 2015-01-29 22:59:19 +0000 | [diff] [blame] | 2061 | const Identifier& m_name; |
mark.lam@apple.com | 4b79ce7 | 2016-03-11 21:08:08 +0000 | [diff] [blame] | 2062 | const Identifier* m_ecmaName; |
rniwa@webkit.org | 65c9b0d | 2015-01-29 22:59:19 +0000 | [diff] [blame] | 2063 | ExpressionNode* m_constructorExpression; |
rniwa@webkit.org | 059ef9b | 2015-03-09 23:47:06 +0000 | [diff] [blame] | 2064 | ExpressionNode* m_classHeritage; |
rniwa@webkit.org | 65c9b0d | 2015-01-29 22:59:19 +0000 | [diff] [blame] | 2065 | PropertyListNode* m_instanceMethods; |
| 2066 | PropertyListNode* m_staticMethods; |
| 2067 | }; |
rniwa@webkit.org | 65c9b0d | 2015-01-29 22:59:19 +0000 | [diff] [blame] | 2068 | |
saambarati1@gmail.com | 91063c9 | 2015-07-21 19:18:47 +0000 | [diff] [blame] | 2069 | class DestructuringPatternNode : public ParserArenaFreeable { |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2070 | public: |
saambarati1@gmail.com | c497d15 | 2015-07-17 18:48:30 +0000 | [diff] [blame] | 2071 | virtual ~DestructuringPatternNode() { } |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2072 | virtual void collectBoundIdentifiers(Vector<Identifier>&) const = 0; |
oliver@apple.com | 47784d6 | 2013-10-25 21:31:36 +0000 | [diff] [blame] | 2073 | virtual void bindValue(BytecodeGenerator&, RegisterID* source) const = 0; |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2074 | virtual void toString(StringBuilder&) const = 0; |
| 2075 | |
| 2076 | virtual bool isBindingNode() const { return false; } |
sbarati@apple.com | c0722da | 2015-11-20 02:37:47 +0000 | [diff] [blame] | 2077 | virtual bool isRestParameter() const { return false; } |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2078 | virtual RegisterID* emitDirectBinding(BytecodeGenerator&, RegisterID*, ExpressionNode*) { return 0; } |
| 2079 | |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2080 | protected: |
saambarati1@gmail.com | cc3bcb6 | 2015-07-02 23:53:10 +0000 | [diff] [blame] | 2081 | DestructuringPatternNode(); |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2082 | }; |
| 2083 | |
saambarati1@gmail.com | 91063c9 | 2015-07-21 19:18:47 +0000 | [diff] [blame] | 2084 | class ArrayPatternNode : public DestructuringPatternNode, public ThrowableExpressionData, public ParserArenaDeletable { |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2085 | public: |
saambarati1@gmail.com | 91063c9 | 2015-07-21 19:18:47 +0000 | [diff] [blame] | 2086 | using ParserArenaDeletable::operator new; |
| 2087 | |
saambarati1@gmail.com | c497d15 | 2015-07-17 18:48:30 +0000 | [diff] [blame] | 2088 | ArrayPatternNode(); |
utatane.tea@gmail.com | 412d761 | 2015-06-26 03:13:25 +0000 | [diff] [blame] | 2089 | enum class BindingType { |
| 2090 | Elision, |
| 2091 | Element, |
| 2092 | RestElement |
| 2093 | }; |
| 2094 | |
saambarati1@gmail.com | cc3bcb6 | 2015-07-02 23:53:10 +0000 | [diff] [blame] | 2095 | void appendIndex(BindingType bindingType, const JSTokenLocation&, DestructuringPatternNode* node, ExpressionNode* defaultValue) |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2096 | { |
utatane.tea@gmail.com | 412d761 | 2015-06-26 03:13:25 +0000 | [diff] [blame] | 2097 | m_targetPatterns.append({ bindingType, node, defaultValue }); |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2098 | } |
| 2099 | |
| 2100 | private: |
saambarati1@gmail.com | 174581a | 2015-06-18 12:35:32 +0000 | [diff] [blame] | 2101 | struct Entry { |
utatane.tea@gmail.com | 412d761 | 2015-06-26 03:13:25 +0000 | [diff] [blame] | 2102 | BindingType bindingType; |
saambarati1@gmail.com | c497d15 | 2015-07-17 18:48:30 +0000 | [diff] [blame] | 2103 | DestructuringPatternNode* pattern; |
saambarati1@gmail.com | 174581a | 2015-06-18 12:35:32 +0000 | [diff] [blame] | 2104 | ExpressionNode* defaultValue; |
| 2105 | }; |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 2106 | void collectBoundIdentifiers(Vector<Identifier>&) const override; |
| 2107 | void bindValue(BytecodeGenerator&, RegisterID*) const override; |
| 2108 | RegisterID* emitDirectBinding(BytecodeGenerator&, RegisterID* dst, ExpressionNode*) override; |
| 2109 | void toString(StringBuilder&) const override; |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2110 | |
saambarati1@gmail.com | 174581a | 2015-06-18 12:35:32 +0000 | [diff] [blame] | 2111 | Vector<Entry> m_targetPatterns; |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2112 | }; |
| 2113 | |
commit-queue@webkit.org | 2162b03 | 2017-03-10 02:00:33 +0000 | [diff] [blame] | 2114 | class ObjectPatternNode : public DestructuringPatternNode, public ThrowableExpressionData, public ParserArenaDeletable { |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2115 | public: |
saambarati1@gmail.com | 91063c9 | 2015-07-21 19:18:47 +0000 | [diff] [blame] | 2116 | using ParserArenaDeletable::operator new; |
| 2117 | |
saambarati1@gmail.com | c497d15 | 2015-07-17 18:48:30 +0000 | [diff] [blame] | 2118 | ObjectPatternNode(); |
commit-queue@webkit.org | 2162b03 | 2017-03-10 02:00:33 +0000 | [diff] [blame] | 2119 | enum class BindingType { |
| 2120 | Element, |
| 2121 | RestElement |
| 2122 | }; |
| 2123 | void appendEntry(const JSTokenLocation&, const Identifier& identifier, bool wasString, DestructuringPatternNode* pattern, ExpressionNode* defaultValue, BindingType bindingType) |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2124 | { |
commit-queue@webkit.org | 2162b03 | 2017-03-10 02:00:33 +0000 | [diff] [blame] | 2125 | m_targetPatterns.append(Entry{ identifier, nullptr, wasString, pattern, defaultValue, bindingType }); |
commit-queue@webkit.org | 3898028 | 2015-11-25 01:43:14 +0000 | [diff] [blame] | 2126 | } |
| 2127 | |
commit-queue@webkit.org | 2162b03 | 2017-03-10 02:00:33 +0000 | [diff] [blame] | 2128 | void appendEntry(const JSTokenLocation&, ExpressionNode* propertyExpression, DestructuringPatternNode* pattern, ExpressionNode* defaultValue, BindingType bindingType) |
commit-queue@webkit.org | 3898028 | 2015-11-25 01:43:14 +0000 | [diff] [blame] | 2129 | { |
commit-queue@webkit.org | 2162b03 | 2017-03-10 02:00:33 +0000 | [diff] [blame] | 2130 | m_targetPatterns.append(Entry{ Identifier(), propertyExpression, false, pattern, defaultValue, bindingType }); |
| 2131 | } |
| 2132 | |
| 2133 | void setContainsRestElement(bool containsRestElement) |
| 2134 | { |
| 2135 | m_containsRestElement = containsRestElement; |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2136 | } |
saambarati1@gmail.com | 91063c9 | 2015-07-21 19:18:47 +0000 | [diff] [blame] | 2137 | |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2138 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 2139 | void collectBoundIdentifiers(Vector<Identifier>&) const override; |
| 2140 | void bindValue(BytecodeGenerator&, RegisterID*) const override; |
| 2141 | void toString(StringBuilder&) const override; |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2142 | struct Entry { |
saambarati1@gmail.com | 35f2d69 | 2015-07-21 20:22:37 +0000 | [diff] [blame] | 2143 | const Identifier& propertyName; |
commit-queue@webkit.org | 3898028 | 2015-11-25 01:43:14 +0000 | [diff] [blame] | 2144 | ExpressionNode* propertyExpression; |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2145 | bool wasString; |
saambarati1@gmail.com | c497d15 | 2015-07-17 18:48:30 +0000 | [diff] [blame] | 2146 | DestructuringPatternNode* pattern; |
saambarati1@gmail.com | 174581a | 2015-06-18 12:35:32 +0000 | [diff] [blame] | 2147 | ExpressionNode* defaultValue; |
commit-queue@webkit.org | 2162b03 | 2017-03-10 02:00:33 +0000 | [diff] [blame] | 2148 | BindingType bindingType; |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2149 | }; |
commit-queue@webkit.org | 2162b03 | 2017-03-10 02:00:33 +0000 | [diff] [blame] | 2150 | bool m_containsRestElement { false }; |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2151 | Vector<Entry> m_targetPatterns; |
| 2152 | }; |
| 2153 | |
saambarati1@gmail.com | cc3bcb6 | 2015-07-02 23:53:10 +0000 | [diff] [blame] | 2154 | class BindingNode : public DestructuringPatternNode { |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2155 | public: |
saambarati1@gmail.com | c497d15 | 2015-07-17 18:48:30 +0000 | [diff] [blame] | 2156 | BindingNode(const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end, AssignmentContext); |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2157 | const Identifier& boundProperty() const { return m_boundProperty; } |
akling@apple.com | bdf5d1d | 2014-01-21 01:10:29 +0000 | [diff] [blame] | 2158 | |
| 2159 | const JSTextPosition& divotStart() const { return m_divotStart; } |
| 2160 | const JSTextPosition& divotEnd() const { return m_divotEnd; } |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2161 | |
| 2162 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 2163 | void collectBoundIdentifiers(Vector<Identifier>&) const override; |
| 2164 | void bindValue(BytecodeGenerator&, RegisterID*) const override; |
| 2165 | void toString(StringBuilder&) const override; |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2166 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 2167 | bool isBindingNode() const override { return true; } |
akling@apple.com | bdf5d1d | 2014-01-21 01:10:29 +0000 | [diff] [blame] | 2168 | |
| 2169 | JSTextPosition m_divotStart; |
| 2170 | JSTextPosition m_divotEnd; |
saambarati1@gmail.com | 91063c9 | 2015-07-21 19:18:47 +0000 | [diff] [blame] | 2171 | const Identifier& m_boundProperty; |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 2172 | AssignmentContext m_bindingContext; |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2173 | }; |
| 2174 | |
sbarati@apple.com | c0722da | 2015-11-20 02:37:47 +0000 | [diff] [blame] | 2175 | class RestParameterNode : public DestructuringPatternNode { |
| 2176 | public: |
sbarati@apple.com | 6a68612 | 2016-08-03 07:50:40 +0000 | [diff] [blame] | 2177 | RestParameterNode(DestructuringPatternNode*, unsigned numParametersToSkip); |
sbarati@apple.com | c0722da | 2015-11-20 02:37:47 +0000 | [diff] [blame] | 2178 | |
| 2179 | bool isRestParameter() const override { return true; } |
| 2180 | |
| 2181 | void emit(BytecodeGenerator&); |
| 2182 | |
sbarati@apple.com | c0722da | 2015-11-20 02:37:47 +0000 | [diff] [blame] | 2183 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 2184 | void collectBoundIdentifiers(Vector<Identifier>&) const override; |
| 2185 | void bindValue(BytecodeGenerator&, RegisterID*) const override; |
| 2186 | void toString(StringBuilder&) const override; |
sbarati@apple.com | c0722da | 2015-11-20 02:37:47 +0000 | [diff] [blame] | 2187 | |
sbarati@apple.com | 6a68612 | 2016-08-03 07:50:40 +0000 | [diff] [blame] | 2188 | DestructuringPatternNode* m_pattern; |
sbarati@apple.com | c0722da | 2015-11-20 02:37:47 +0000 | [diff] [blame] | 2189 | unsigned m_numParametersToSkip; |
sbarati@apple.com | c0722da | 2015-11-20 02:37:47 +0000 | [diff] [blame] | 2190 | }; |
| 2191 | |
commit-queue@webkit.org | 88a7476 | 2015-11-19 22:54:46 +0000 | [diff] [blame] | 2192 | class AssignmentElementNode : public DestructuringPatternNode { |
| 2193 | public: |
| 2194 | AssignmentElementNode(ExpressionNode* assignmentTarget, const JSTextPosition& start, const JSTextPosition& end); |
| 2195 | const ExpressionNode* assignmentTarget() { return m_assignmentTarget; } |
| 2196 | |
| 2197 | const JSTextPosition& divotStart() const { return m_divotStart; } |
| 2198 | const JSTextPosition& divotEnd() const { return m_divotEnd; } |
| 2199 | |
| 2200 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 2201 | void collectBoundIdentifiers(Vector<Identifier>&) const override; |
| 2202 | void bindValue(BytecodeGenerator&, RegisterID*) const override; |
| 2203 | void toString(StringBuilder&) const override; |
commit-queue@webkit.org | 88a7476 | 2015-11-19 22:54:46 +0000 | [diff] [blame] | 2204 | |
| 2205 | JSTextPosition m_divotStart; |
| 2206 | JSTextPosition m_divotEnd; |
| 2207 | ExpressionNode* m_assignmentTarget; |
| 2208 | }; |
| 2209 | |
saambarati1@gmail.com | 91063c9 | 2015-07-21 19:18:47 +0000 | [diff] [blame] | 2210 | class DestructuringAssignmentNode : public ExpressionNode { |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2211 | public: |
saambarati1@gmail.com | c497d15 | 2015-07-17 18:48:30 +0000 | [diff] [blame] | 2212 | DestructuringAssignmentNode(const JSTokenLocation&, DestructuringPatternNode*, ExpressionNode*); |
| 2213 | DestructuringPatternNode* bindings() { return m_bindings; } |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2214 | |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2215 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 2216 | bool isAssignmentLocation() const override { return true; } |
| 2217 | bool isDestructuringNode() const override { return true; } |
| 2218 | RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2219 | |
saambarati1@gmail.com | c497d15 | 2015-07-17 18:48:30 +0000 | [diff] [blame] | 2220 | DestructuringPatternNode* m_bindings; |
oliver@apple.com | d055db6 | 2013-10-02 19:11:04 +0000 | [diff] [blame] | 2221 | ExpressionNode* m_initializer; |
| 2222 | }; |
| 2223 | |
utatane.tea@gmail.com | 3e031ac | 2017-03-16 05:12:53 +0000 | [diff] [blame] | 2224 | class FunctionParameters : public ParserArenaDeletable { |
| 2225 | public: |
| 2226 | FunctionParameters(); |
| 2227 | ALWAYS_INLINE unsigned size() const { return m_patterns.size(); } |
| 2228 | ALWAYS_INLINE std::pair<DestructuringPatternNode*, ExpressionNode*> at(unsigned index) { return m_patterns[index]; } |
| 2229 | ALWAYS_INLINE void append(DestructuringPatternNode* pattern, ExpressionNode* defaultValue) |
| 2230 | { |
| 2231 | ASSERT(pattern); |
| 2232 | |
| 2233 | // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-functiondeclarationinstantiation |
| 2234 | // This implements IsSimpleParameterList in the Ecma 2015 spec. |
| 2235 | // If IsSimpleParameterList is false, we will create a strict-mode like arguments object. |
| 2236 | // IsSimpleParameterList is false if the argument list contains any default parameter values, |
| 2237 | // a rest parameter, or any destructuring patterns. |
| 2238 | // If we do have default parameters, destructuring parameters, or a rest parameter, our parameters will be allocated in a different scope. |
| 2239 | |
| 2240 | bool hasDefaultParameterValue = defaultValue; |
| 2241 | bool isSimpleParameter = !hasDefaultParameterValue && pattern->isBindingNode(); |
| 2242 | m_isSimpleParameterList &= isSimpleParameter; |
| 2243 | |
| 2244 | m_patterns.append(std::make_pair(pattern, defaultValue)); |
| 2245 | } |
| 2246 | ALWAYS_INLINE bool isSimpleParameterList() const { return m_isSimpleParameterList; } |
| 2247 | |
| 2248 | private: |
| 2249 | |
| 2250 | Vector<std::pair<DestructuringPatternNode*, ExpressionNode*>, 3> m_patterns; |
| 2251 | bool m_isSimpleParameterList { true }; |
| 2252 | }; |
| 2253 | |
barraclough@apple.com | 3dc1233 | 2009-08-12 05:22:33 +0000 | [diff] [blame] | 2254 | class FuncDeclNode : public StatementNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 2255 | public: |
ggaren@apple.com | e7afe40 | 2015-08-10 20:24:35 +0000 | [diff] [blame] | 2256 | FuncDeclNode(const JSTokenLocation&, const Identifier&, FunctionMetadataNode*, const SourceCode&); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 2257 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 2258 | bool isFuncDeclNode() const override { return true; } |
ggaren@apple.com | e7afe40 | 2015-08-10 20:24:35 +0000 | [diff] [blame] | 2259 | FunctionMetadataNode* metadata() { return m_metadata; } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 2260 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 2261 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 2262 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 2263 | |
ggaren@apple.com | e7afe40 | 2015-08-10 20:24:35 +0000 | [diff] [blame] | 2264 | FunctionMetadataNode* m_metadata; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 2265 | }; |
| 2266 | |
rniwa@webkit.org | 65c9b0d | 2015-01-29 22:59:19 +0000 | [diff] [blame] | 2267 | class ClassDeclNode final : public StatementNode { |
| 2268 | public: |
| 2269 | ClassDeclNode(const JSTokenLocation&, ExpressionNode* classExpression); |
| 2270 | |
| 2271 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 2272 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
rniwa@webkit.org | 65c9b0d | 2015-01-29 22:59:19 +0000 | [diff] [blame] | 2273 | |
| 2274 | ExpressionNode* m_classDeclaration; |
| 2275 | }; |
rniwa@webkit.org | 65c9b0d | 2015-01-29 22:59:19 +0000 | [diff] [blame] | 2276 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 2277 | class CaseClauseNode : public ParserArenaFreeable { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 2278 | public: |
msaboff@apple.com | 2e5003e | 2011-10-31 22:13:01 +0000 | [diff] [blame] | 2279 | CaseClauseNode(ExpressionNode*, SourceElements* = 0); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 2280 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 2281 | ExpressionNode* expr() const { return m_expr; } |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 2282 | |
| 2283 | void emitBytecode(BytecodeGenerator&, RegisterID* destination); |
saambarati1@gmail.com | b4f28a5 | 2014-12-05 05:58:07 +0000 | [diff] [blame] | 2284 | void setStartOffset(int offset) { m_startOffset = offset; } |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 2285 | |
| 2286 | private: |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 2287 | ExpressionNode* m_expr; |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 2288 | SourceElements* m_statements; |
saambarati1@gmail.com | b4f28a5 | 2014-12-05 05:58:07 +0000 | [diff] [blame] | 2289 | int m_startOffset; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 2290 | }; |
| 2291 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 2292 | class ClauseListNode : public ParserArenaFreeable { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 2293 | public: |
msaboff@apple.com | 2e5003e | 2011-10-31 22:13:01 +0000 | [diff] [blame] | 2294 | ClauseListNode(CaseClauseNode*); |
| 2295 | ClauseListNode(ClauseListNode*, CaseClauseNode*); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 2296 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 2297 | CaseClauseNode* getClause() const { return m_clause; } |
| 2298 | ClauseListNode* getNext() const { return m_next; } |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 2299 | |
| 2300 | private: |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 2301 | CaseClauseNode* m_clause; |
| 2302 | ClauseListNode* m_next; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 2303 | }; |
| 2304 | |
darin@apple.com | 85a65c3 | 2009-08-22 06:40:53 +0000 | [diff] [blame] | 2305 | class CaseBlockNode : public ParserArenaFreeable { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 2306 | public: |
msaboff@apple.com | 2e5003e | 2011-10-31 22:13:01 +0000 | [diff] [blame] | 2307 | CaseBlockNode(ClauseListNode* list1, CaseClauseNode* defaultClause, ClauseListNode* list2); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 2308 | |
ggaren@apple.com | d786e6b | 2013-04-04 23:16:20 +0000 | [diff] [blame] | 2309 | void emitBytecodeForBlock(BytecodeGenerator&, RegisterID* input, RegisterID* destination); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 2310 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 2311 | private: |
ggaren@apple.com | 18bbb01 | 2013-01-30 05:43:47 +0000 | [diff] [blame] | 2312 | SwitchInfo::SwitchType tryTableSwitch(Vector<ExpressionNode*, 8>& literalVector, int32_t& min_num, int32_t& max_num); |
oliver@apple.com | 9b7647b | 2013-07-25 04:03:00 +0000 | [diff] [blame] | 2313 | static const size_t s_tableSwitchMinimum = 3; |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 2314 | ClauseListNode* m_list1; |
| 2315 | CaseClauseNode* m_defaultClause; |
| 2316 | ClauseListNode* m_list2; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 2317 | }; |
| 2318 | |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 2319 | class SwitchNode : public StatementNode, public VariableEnvironmentNode { |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 2320 | public: |
sbarati@apple.com | 62be0b0 | 2015-09-19 15:36:46 +0000 | [diff] [blame] | 2321 | using ParserArenaDeletable::operator new; |
| 2322 | |
sbarati@apple.com | 8e614bd | 2016-03-10 02:04:20 +0000 | [diff] [blame] | 2323 | SwitchNode(const JSTokenLocation&, ExpressionNode*, CaseBlockNode*, VariableEnvironment&, FunctionStack&&); |
darin@apple.com | fa06950 | 2008-11-10 01:04:30 +0000 | [diff] [blame] | 2324 | |
darin@apple.com | d7f6822 | 2009-05-06 17:10:22 +0000 | [diff] [blame] | 2325 | private: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 2326 | void emitBytecode(BytecodeGenerator&, RegisterID* = 0) override; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 2327 | |
darin@apple.com | 59c3715 | 2009-05-10 22:32:34 +0000 | [diff] [blame] | 2328 | ExpressionNode* m_expr; |
| 2329 | CaseBlockNode* m_block; |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 2330 | }; |
darin@apple.com | 5e49bae | 2007-12-21 21:54:51 +0000 | [diff] [blame] | 2331 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 2332 | struct ElementList { |
| 2333 | ElementNode* head; |
| 2334 | ElementNode* tail; |
| 2335 | }; |
mrowe@apple.com | 5e1c278 | 2007-10-29 08:31:46 +0000 | [diff] [blame] | 2336 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 2337 | struct PropertyList { |
| 2338 | PropertyListNode* head; |
| 2339 | PropertyListNode* tail; |
| 2340 | }; |
mrowe@apple.com | 5e1c278 | 2007-10-29 08:31:46 +0000 | [diff] [blame] | 2341 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 2342 | struct ArgumentList { |
| 2343 | ArgumentListNode* head; |
| 2344 | ArgumentListNode* tail; |
| 2345 | }; |
mrowe@apple.com | 5e1c278 | 2007-10-29 08:31:46 +0000 | [diff] [blame] | 2346 | |
weinig@apple.com | a443641 | 2008-01-28 20:50:45 +0000 | [diff] [blame] | 2347 | struct ClauseList { |
| 2348 | ClauseListNode* head; |
| 2349 | ClauseListNode* tail; |
| 2350 | }; |
mrowe@apple.com | 5e1c278 | 2007-10-29 08:31:46 +0000 | [diff] [blame] | 2351 | |
cwzwarich@webkit.org | 3f782f6 | 2008-09-08 01:28:33 +0000 | [diff] [blame] | 2352 | } // namespace JSC |