Changeset 29836 in webkit for trunk/JavaScriptCore/kjs/nodes.h
- Timestamp:
- Jan 28, 2008, 12:50:45 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/nodes.h
r29825 r29836 2 2 * Copyright (C) 1999-2000 Harri Porten ([email protected]) 3 3 * Copyright (C) 2001 Peter Kelly ([email protected]) 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 5 5 * Copyright (C) 2007 Cameron Zwarich ([email protected]) 6 6 * Copyright (C) 2007 Maks Orlovich … … 43 43 namespace KJS { 44 44 45 class ConstDeclNode; 45 46 class FuncDeclNode; 46 47 class Node; 47 48 class PropertyListNode; 48 49 class SourceStream; 49 class ConstDeclNode;50 50 51 51 enum Operator { … … 87 87 PrecExpression 88 88 }; 89 90 struct DeclarationStacks { 91 typedef Vector<Node*, 16> NodeStack; 92 enum { IsConstant = 1, HasInitializer = 2 } VarAttrs; 93 typedef Vector<std::pair<Identifier, unsigned>, 16> VarStack; 94 typedef Vector<FuncDeclNode*, 16> FunctionStack; 95 96 DeclarationStacks(ExecState* e, NodeStack& n, VarStack& v, FunctionStack& f) 97 : exec(e) 98 , nodeStack(n) 99 , varStack(v) 100 , functionStack(f) 101 { 102 } 103 104 ExecState* exec; 105 NodeStack& nodeStack; 106 VarStack& varStack; 107 FunctionStack& functionStack; 108 }; 109 110 class ParserRefCounted : Noncopyable { 111 protected: 112 ParserRefCounted() KJS_FAST_CALL; 113 ParserRefCounted(PlacementNewAdoptType) KJS_FAST_CALL { } 114 115 public: 116 void ref() KJS_FAST_CALL; 117 void deref() KJS_FAST_CALL; 118 unsigned refcount() KJS_FAST_CALL; 119 120 static void deleteNewObjects() KJS_FAST_CALL; 121 122 virtual ~ParserRefCounted(); 123 }; 124 125 class Node : public ParserRefCounted { 126 public: 127 typedef DeclarationStacks::NodeStack NodeStack; 128 typedef DeclarationStacks::VarStack VarStack; 129 typedef DeclarationStacks::FunctionStack FunctionStack; 130 131 Node() KJS_FAST_CALL; 132 Node(PlacementNewAdoptType placementAdopt) KJS_FAST_CALL 133 : ParserRefCounted(placementAdopt) { } 134 135 UString toString() const KJS_FAST_CALL; 136 int lineNo() const KJS_FAST_CALL { return m_line; } 137 138 // Serialization. 139 virtual void streamTo(SourceStream&) const KJS_FAST_CALL = 0; 140 virtual Precedence precedence() const = 0; 141 virtual bool needsParensIfLeftmost() const { return false; } 142 143 // Used for iterative, depth-first traversal of the node tree. Does not cross function call boundaries. 144 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL { } 145 146 protected: 147 Node(JSType) KJS_FAST_CALL; // used by ExpressionNode 148 149 // for use in execute() 150 JSValue* setErrorCompletion(ExecState*, ErrorType, const char* msg) KJS_FAST_CALL; 151 JSValue* setErrorCompletion(ExecState*, ErrorType, const char* msg, const Identifier&) KJS_FAST_CALL; 152 153 // for use in evaluate() 154 JSValue* throwError(ExecState*, ErrorType, const char* msg) KJS_FAST_CALL; 155 JSValue* throwError(ExecState*, ErrorType, const char* msg, const char*) KJS_FAST_CALL; 156 JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, Node*) KJS_FAST_CALL; 157 JSValue* throwError(ExecState*, ErrorType, const char* msg, const Identifier&) KJS_FAST_CALL; 158 JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, const Identifier&) KJS_FAST_CALL; 159 JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, Node*, Node*) KJS_FAST_CALL; 160 JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, Node*, const Identifier&) KJS_FAST_CALL; 161 162 JSValue* throwUndefinedVariableError(ExecState*, const Identifier&) KJS_FAST_CALL; 163 164 void handleException(ExecState*) KJS_FAST_CALL; 165 void handleException(ExecState*, JSValue*) KJS_FAST_CALL; 166 167 // for use in execute() 168 JSValue* rethrowException(ExecState*) KJS_FAST_CALL; 169 170 int m_line : 28; 171 unsigned m_expectedReturnType : 3; // JSType 172 }; 173 89 90 struct DeclarationStacks { 91 typedef Vector<Node*, 16> NodeStack; 92 enum { IsConstant = 1, HasInitializer = 2 } VarAttrs; 93 typedef Vector<std::pair<Identifier, unsigned>, 16> VarStack; 94 typedef Vector<FuncDeclNode*, 16> FunctionStack; 95 96 DeclarationStacks(ExecState* e, NodeStack& n, VarStack& v, FunctionStack& f) 97 : exec(e) 98 , nodeStack(n) 99 , varStack(v) 100 , functionStack(f) 101 { 102 } 103 104 ExecState* exec; 105 NodeStack& nodeStack; 106 VarStack& varStack; 107 FunctionStack& functionStack; 108 }; 109 110 class ParserRefCounted : Noncopyable { 111 protected: 112 ParserRefCounted() KJS_FAST_CALL; 113 ParserRefCounted(PlacementNewAdoptType) KJS_FAST_CALL 114 { 115 } 116 117 public: 118 void ref() KJS_FAST_CALL; 119 void deref() KJS_FAST_CALL; 120 unsigned refcount() KJS_FAST_CALL; 121 122 static void deleteNewObjects() KJS_FAST_CALL; 123 124 virtual ~ParserRefCounted(); 125 }; 126 127 class Node : public ParserRefCounted { 128 public: 129 typedef DeclarationStacks::NodeStack NodeStack; 130 typedef DeclarationStacks::VarStack VarStack; 131 typedef DeclarationStacks::FunctionStack FunctionStack; 132 133 Node() KJS_FAST_CALL; 134 Node(PlacementNewAdoptType placementAdopt) KJS_FAST_CALL 135 : ParserRefCounted(placementAdopt) 136 { 137 } 138 139 UString toString() const KJS_FAST_CALL; 140 int lineNo() const KJS_FAST_CALL { return m_line; } 141 142 // Serialization. 143 virtual void streamTo(SourceStream&) const KJS_FAST_CALL = 0; 144 virtual Precedence precedence() const = 0; 145 virtual bool needsParensIfLeftmost() const { return false; } 146 147 // Used for iterative, depth-first traversal of the node tree. Does not cross function call boundaries. 148 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL { } 149 150 protected: 151 Node(JSType) KJS_FAST_CALL; // used by ExpressionNode 152 153 // for use in execute() 154 JSValue* setErrorCompletion(ExecState*, ErrorType, const char* msg) KJS_FAST_CALL; 155 JSValue* setErrorCompletion(ExecState*, ErrorType, const char* msg, const Identifier&) KJS_FAST_CALL; 156 157 // for use in evaluate() 158 JSValue* throwError(ExecState*, ErrorType, const char* msg) KJS_FAST_CALL; 159 JSValue* throwError(ExecState*, ErrorType, const char* msg, const char*) KJS_FAST_CALL; 160 JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, Node*) KJS_FAST_CALL; 161 JSValue* throwError(ExecState*, ErrorType, const char* msg, const Identifier&) KJS_FAST_CALL; 162 JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, const Identifier&) KJS_FAST_CALL; 163 JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, Node*, Node*) KJS_FAST_CALL; 164 JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, Node*, const Identifier&) KJS_FAST_CALL; 165 166 JSValue* throwUndefinedVariableError(ExecState*, const Identifier&) KJS_FAST_CALL; 167 168 void handleException(ExecState*) KJS_FAST_CALL; 169 void handleException(ExecState*, JSValue*) KJS_FAST_CALL; 170 171 // for use in execute() 172 JSValue* rethrowException(ExecState*) KJS_FAST_CALL; 173 174 int m_line : 28; 175 unsigned m_expectedReturnType : 3; // JSType 176 }; 177 174 178 class ExpressionNode : public Node { 175 179 public: 176 180 ExpressionNode() KJS_FAST_CALL : Node() {} 177 181 ExpressionNode(JSType expectedReturn) KJS_FAST_CALL 178 : Node(expectedReturn) {} 179 182 : Node(expectedReturn) 183 { 184 } 185 180 186 // Special constructor for cases where we overwrite an object in place. 181 187 ExpressionNode(PlacementNewAdoptType) KJS_FAST_CALL 182 : Node(PlacementNewAdopt) {} 183 188 : Node(PlacementNewAdopt) 189 { 190 } 191 184 192 virtual bool isNumber() const KJS_FAST_CALL { return false; } 185 193 virtual bool isLocation() const KJS_FAST_CALL { return false; } … … 187 195 virtual bool isBracketAccessorNode() const KJS_FAST_CALL { return false; } 188 196 virtual bool isDotAccessorNode() const KJS_FAST_CALL { return false; } 189 197 190 198 JSType expectedReturnType() const KJS_FAST_CALL { return static_cast<JSType>(m_expectedReturnType); } 191 199 192 200 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL = 0; 193 201 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; … … 198 206 // Used to optimize those nodes that do extra work when returning a result, even if the result has no semantic relevance 199 207 virtual void optimizeForUnnecessaryResult() { } 200 }; 201 202 class StatementNode : public Node { 203 public: 204 StatementNode() KJS_FAST_CALL; 205 void setLoc(int line0, int line1) KJS_FAST_CALL; 206 int firstLine() const KJS_FAST_CALL { return lineNo(); } 207 int lastLine() const KJS_FAST_CALL { return m_lastLine; } 208 virtual JSValue* execute(ExecState *exec) KJS_FAST_CALL = 0; 209 void pushLabel(const Identifier& ident) KJS_FAST_CALL { m_labelStack.push(ident); } 210 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 211 virtual bool isEmptyStatement() const KJS_FAST_CALL { return false; } 212 protected: 213 LabelStack m_labelStack; 214 private: 215 int m_lastLine; 216 }; 217 218 class NullNode : public ExpressionNode { 219 public: 220 NullNode() KJS_FAST_CALL : ExpressionNode(NullType) {} 221 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 222 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 223 virtual Precedence precedence() const { return PrecPrimary; } 224 }; 225 226 class FalseNode : public ExpressionNode { 227 public: 228 FalseNode() KJS_FAST_CALL : ExpressionNode(BooleanType) {} 229 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 230 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL { return false; } 231 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 232 virtual Precedence precedence() const { return PrecPrimary; } 233 }; 234 235 class TrueNode : public ExpressionNode { 236 public: 237 TrueNode() KJS_FAST_CALL : ExpressionNode(BooleanType) {} 238 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 239 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL { return true; } 240 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 241 virtual Precedence precedence() const { return PrecPrimary; } 242 }; 243 244 class PlaceholderTrueNode : public TrueNode { 245 public: 246 // Like TrueNode, but does not serialize as "true". 247 PlaceholderTrueNode() KJS_FAST_CALL : TrueNode() { } 248 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 249 }; 250 251 class NumberNode : public ExpressionNode { 252 public: 253 NumberNode(double v) KJS_FAST_CALL : ExpressionNode(NumberType), m_double(v) {} 254 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 255 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 256 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 257 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 258 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 259 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 260 virtual Precedence precedence() const { return signbit(m_double) ? PrecUnary : PrecPrimary; } 261 262 virtual bool isNumber() const KJS_FAST_CALL { return true; } 263 double value() const KJS_FAST_CALL { return m_double; } 264 virtual void setValue(double d) KJS_FAST_CALL { m_double = d; } 265 266 protected: 267 double m_double; 268 }; 269 270 class ImmediateNumberNode : public NumberNode { 271 public: 272 ImmediateNumberNode(JSValue* v, double d) KJS_FAST_CALL : NumberNode(d), m_value(v) { ASSERT(v == JSImmediate::from(d)); } 273 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 274 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 275 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 276 277 virtual void setValue(double d) KJS_FAST_CALL { m_double = d; m_value = JSImmediate::from(d); ASSERT(m_value); } 278 private: 279 JSValue* m_value; // This is never a JSCell, only JSImmediate, thus no ProtectedPtr 280 }; 281 282 class StringNode : public ExpressionNode { 283 public: 284 StringNode(const UString* v) KJS_FAST_CALL : ExpressionNode(StringType), m_value(*v) {} 285 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 286 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 287 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 288 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 289 virtual Precedence precedence() const { return PrecPrimary; } 290 291 private: 292 UString m_value; 293 }; 294 295 class RegExpNode : public ExpressionNode { 296 public: 297 RegExpNode(const UString& pattern, const UString& flags) KJS_FAST_CALL 298 : m_regExp(new RegExp(pattern, flags)) 299 { 300 } 301 JSValue* evaluate(ExecState*) KJS_FAST_CALL; 302 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 303 virtual Precedence precedence() const { return PrecPrimary; } 304 private: 305 RefPtr<RegExp> m_regExp; 306 }; 307 308 class ThisNode : public ExpressionNode { 309 public: 310 ThisNode() KJS_FAST_CALL {} 311 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 312 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 313 virtual Precedence precedence() const { return PrecPrimary; } 314 }; 315 316 class ResolveNode : public ExpressionNode { 317 public: 318 ResolveNode(const Identifier& ident) KJS_FAST_CALL 319 : m_ident(ident) 320 { 321 } 322 323 // Special constructor for cases where we overwrite an object in place. 324 ResolveNode(PlacementNewAdoptType) KJS_FAST_CALL 325 : ExpressionNode(PlacementNewAdopt) 326 , m_ident(PlacementNewAdopt) 327 { 328 } 329 330 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 331 332 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 333 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 334 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 335 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 336 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 337 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 338 virtual Precedence precedence() const { return PrecPrimary; } 339 340 virtual bool isLocation() const KJS_FAST_CALL { return true; } 341 virtual bool isResolveNode() const KJS_FAST_CALL { return true; } 342 const Identifier& identifier() const KJS_FAST_CALL { return m_ident; } 343 344 protected: 345 ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); 346 Identifier m_ident; 347 size_t m_index; // Used by LocalVarAccessNode. 348 }; 349 350 class LocalVarAccessNode : public ResolveNode { 351 public: 352 // Overwrites a ResolveNode in place. 353 LocalVarAccessNode(size_t i) KJS_FAST_CALL 354 : ResolveNode(PlacementNewAdopt) 355 { 356 ASSERT(i != missingSymbolMarker()); 357 m_index = i; 358 } 359 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 360 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 361 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 362 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 363 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 364 private: 365 ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); 366 }; 367 368 class ElementNode : public Node { 369 public: 370 ElementNode(int elision, ExpressionNode* node) KJS_FAST_CALL 371 : m_elision(elision), m_node(node) { } 372 ElementNode(ElementNode* l, int elision, ExpressionNode* node) KJS_FAST_CALL 373 : m_elision(elision), m_node(node) { l->m_next = this; } 374 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 375 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 376 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 377 378 PassRefPtr<ElementNode> releaseNext() KJS_FAST_CALL { return m_next.release(); } 379 380 JSValue* evaluate(ExecState*) KJS_FAST_CALL; 381 382 private: 383 friend class ArrayNode; 384 ListRefPtr<ElementNode> m_next; 385 int m_elision; 386 RefPtr<ExpressionNode> m_node; 387 }; 388 389 class ArrayNode : public ExpressionNode { 390 public: 391 ArrayNode(int e) KJS_FAST_CALL 392 : m_elision(e), m_opt(true) { } 393 ArrayNode(ElementNode* element) KJS_FAST_CALL 394 : m_element(element), m_elision(0), m_opt(false) { } 395 ArrayNode(int elision, ElementNode* element) KJS_FAST_CALL 396 : m_element(element), m_elision(elision), m_opt(true) { } 397 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 398 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 399 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 400 virtual Precedence precedence() const { return PrecPrimary; } 401 private: 402 RefPtr<ElementNode> m_element; 403 int m_elision; 404 bool m_opt; 405 }; 406 407 class PropertyNode : public Node { 408 public: 409 enum Type { Constant, Getter, Setter }; 410 PropertyNode(const Identifier& n, ExpressionNode* a, Type t) KJS_FAST_CALL 411 : m_name(n), m_assign(a), m_type(t) { } 412 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 413 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 414 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 415 416 JSValue* evaluate(ExecState*) KJS_FAST_CALL; 417 const Identifier& name() const { return m_name; } 418 419 private: 420 friend class PropertyListNode; 421 Identifier m_name; 422 RefPtr<ExpressionNode> m_assign; 423 Type m_type; 424 }; 425 426 class PropertyListNode : public Node { 427 public: 428 PropertyListNode(PropertyNode* node) KJS_FAST_CALL 429 : m_node(node) { } 430 PropertyListNode(PropertyNode* node, PropertyListNode* list) KJS_FAST_CALL 431 : m_node(node) { list->m_next = this; } 432 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 433 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 434 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 435 436 JSValue* evaluate(ExecState*) KJS_FAST_CALL; 437 PassRefPtr<PropertyListNode> releaseNext() KJS_FAST_CALL { return m_next.release(); } 438 439 private: 440 friend class ObjectLiteralNode; 441 RefPtr<PropertyNode> m_node; 442 ListRefPtr<PropertyListNode> m_next; 443 }; 444 445 class ObjectLiteralNode : public ExpressionNode { 446 public: 447 ObjectLiteralNode() KJS_FAST_CALL { } 448 ObjectLiteralNode(PropertyListNode* list) KJS_FAST_CALL : m_list(list) { } 449 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 450 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 451 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 452 virtual Precedence precedence() const { return PrecPrimary; } 453 virtual bool needsParensIfLeftmost() const { return true; } 454 private: 455 RefPtr<PropertyListNode> m_list; 456 }; 457 458 class BracketAccessorNode : public ExpressionNode { 459 public: 460 BracketAccessorNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL 461 : m_base(base), m_subscript(subscript) { } 462 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 463 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 464 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 465 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 466 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 467 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 468 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 469 virtual Precedence precedence() const { return PrecMember; } 470 471 virtual bool isLocation() const KJS_FAST_CALL { return true; } 472 virtual bool isBracketAccessorNode() const KJS_FAST_CALL { return true; } 473 ExpressionNode* base() KJS_FAST_CALL { return m_base.get(); } 474 ExpressionNode* subscript() KJS_FAST_CALL { return m_subscript.get(); } 475 476 private: 477 ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); 478 RefPtr<ExpressionNode> m_base; 479 RefPtr<ExpressionNode> m_subscript; 480 }; 481 482 class DotAccessorNode : public ExpressionNode { 483 public: 484 DotAccessorNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL : m_base(base), m_ident(ident) { } 485 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 486 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 487 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 488 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 489 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 490 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 491 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 492 virtual Precedence precedence() const { return PrecMember; } 493 494 virtual bool isLocation() const KJS_FAST_CALL { return true; } 495 virtual bool isDotAccessorNode() const KJS_FAST_CALL { return true; } 496 ExpressionNode* base() const KJS_FAST_CALL { return m_base.get(); } 497 const Identifier& identifier() const KJS_FAST_CALL { return m_ident; } 498 499 private: 500 ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); 501 RefPtr<ExpressionNode> m_base; 502 Identifier m_ident; 503 }; 504 505 class ArgumentListNode : public Node { 506 public: 507 ArgumentListNode(ExpressionNode* expr) KJS_FAST_CALL 508 : m_expr(expr) { } 509 ArgumentListNode(ArgumentListNode* listNode, ExpressionNode* expr) KJS_FAST_CALL 510 : m_expr(expr) { listNode->m_next = this; } 511 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 512 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 513 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 514 515 void evaluateList(ExecState*, List&) KJS_FAST_CALL; 516 PassRefPtr<ArgumentListNode> releaseNext() KJS_FAST_CALL { return m_next.release(); } 517 518 private: 519 friend class ArgumentsNode; 520 ListRefPtr<ArgumentListNode> m_next; 521 RefPtr<ExpressionNode> m_expr; 522 }; 523 524 class ArgumentsNode : public Node { 525 public: 526 ArgumentsNode() KJS_FAST_CALL { } 527 ArgumentsNode(ArgumentListNode* listNode) KJS_FAST_CALL 528 : m_listNode(listNode) { } 529 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 530 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 531 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 532 533 void evaluateList(ExecState* exec, List& list) KJS_FAST_CALL { if (m_listNode) m_listNode->evaluateList(exec, list); } 534 535 private: 536 RefPtr<ArgumentListNode> m_listNode; 537 }; 538 539 class NewExprNode : public ExpressionNode { 540 public: 541 NewExprNode(ExpressionNode* expr) KJS_FAST_CALL 542 : m_expr(expr) { } 543 NewExprNode(ExpressionNode* expr, ArgumentsNode* args) KJS_FAST_CALL 544 : m_expr(expr), m_args(args) { } 545 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 546 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 547 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 548 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 549 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 550 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 551 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 552 virtual Precedence precedence() const { return PrecLeftHandSide; } 553 private: 554 ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); 555 RefPtr<ExpressionNode> m_expr; 556 RefPtr<ArgumentsNode> m_args; 557 }; 558 559 class FunctionCallValueNode : public ExpressionNode { 560 public: 561 FunctionCallValueNode(ExpressionNode* expr, ArgumentsNode* args) KJS_FAST_CALL 562 : m_expr(expr), m_args(args) { } 563 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 564 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 565 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 566 virtual Precedence precedence() const { return PrecCall; } 567 private: 568 RefPtr<ExpressionNode> m_expr; 569 RefPtr<ArgumentsNode> m_args; 570 }; 571 572 class FunctionCallResolveNode : public ExpressionNode { 573 public: 574 FunctionCallResolveNode(const Identifier& ident, ArgumentsNode* args) KJS_FAST_CALL 575 : m_ident(ident) 576 , m_args(args) 577 { 578 } 579 580 FunctionCallResolveNode(PlacementNewAdoptType) KJS_FAST_CALL 581 : ExpressionNode(PlacementNewAdopt) 582 , m_ident(PlacementNewAdopt) 583 , m_args(PlacementNewAdopt) 584 { 585 } 586 587 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 588 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 589 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 590 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 591 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 592 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 593 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 594 virtual Precedence precedence() const { return PrecCall; } 595 596 protected: 597 ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); 598 Identifier m_ident; 599 RefPtr<ArgumentsNode> m_args; 600 size_t m_index; // Used by LocalVarFunctionCallNode. 601 }; 602 603 class LocalVarFunctionCallNode : public FunctionCallResolveNode { 604 public: 605 LocalVarFunctionCallNode(size_t i) KJS_FAST_CALL 606 : FunctionCallResolveNode(PlacementNewAdopt) 607 { 608 ASSERT(i != missingSymbolMarker()); 609 m_index = i; 610 } 611 612 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 613 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 614 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 615 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 616 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 617 private: 618 ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); 619 }; 620 621 class FunctionCallBracketNode : public ExpressionNode { 622 public: 623 FunctionCallBracketNode(ExpressionNode* base, ExpressionNode* subscript, ArgumentsNode* args) KJS_FAST_CALL 624 : m_base(base), m_subscript(subscript), m_args(args) { } 625 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 626 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 627 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 628 virtual Precedence precedence() const { return PrecCall; } 629 protected: 630 RefPtr<ExpressionNode> m_base; 631 RefPtr<ExpressionNode> m_subscript; 632 RefPtr<ArgumentsNode> m_args; 633 }; 634 635 class FunctionCallDotNode : public ExpressionNode { 636 public: 637 FunctionCallDotNode(ExpressionNode* base, const Identifier& ident, ArgumentsNode* args) KJS_FAST_CALL 638 : m_base(base), m_ident(ident), m_args(args) { } 639 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 640 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 641 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 642 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 643 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 644 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 645 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 646 virtual Precedence precedence() const { return PrecCall; } 647 private: 648 ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); 649 RefPtr<ExpressionNode> m_base; 650 Identifier m_ident; 651 RefPtr<ArgumentsNode> m_args; 652 }; 653 654 class PrePostResolveNode : public ExpressionNode { 655 public: 656 PrePostResolveNode(const Identifier& i) KJS_FAST_CALL : ExpressionNode(NumberType), m_ident(i) {} 657 658 PrePostResolveNode(PlacementNewAdoptType) KJS_FAST_CALL 659 : ExpressionNode(PlacementNewAdopt) 660 , m_ident(PlacementNewAdopt) 661 { 662 } 663 664 protected: 665 Identifier m_ident; 666 size_t m_index; // Used by LocalVarPostfixNode. 667 }; 668 669 class PostIncResolveNode : public PrePostResolveNode { 670 public: 671 PostIncResolveNode(const Identifier& i) KJS_FAST_CALL : PrePostResolveNode(i) {} 672 673 PostIncResolveNode(PlacementNewAdoptType) KJS_FAST_CALL 674 : PrePostResolveNode(PlacementNewAdopt) 675 { 676 } 677 678 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 679 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 680 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 681 virtual Precedence precedence() const { return PrecPostfix; } 682 virtual void optimizeForUnnecessaryResult(); 683 }; 684 685 class PostIncLocalVarNode : public PostIncResolveNode { 686 public: 687 PostIncLocalVarNode(size_t i) KJS_FAST_CALL 688 : PostIncResolveNode(PlacementNewAdopt) 689 { 690 ASSERT(i != missingSymbolMarker()); 691 m_index = i; 692 } 693 694 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 695 virtual void optimizeForUnnecessaryResult(); 696 }; 697 698 class PostIncConstNode : public PostIncResolveNode { 699 public: 700 PostIncConstNode(size_t i) KJS_FAST_CALL 701 : PostIncResolveNode(PlacementNewAdopt) 702 { 703 ASSERT(i != missingSymbolMarker()); 704 m_index = i; 705 } 706 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 707 }; 708 709 class PostDecResolveNode : public PrePostResolveNode { 710 public: 711 PostDecResolveNode(const Identifier& i) KJS_FAST_CALL : PrePostResolveNode(i) {} 712 713 PostDecResolveNode(PlacementNewAdoptType) KJS_FAST_CALL 714 : PrePostResolveNode(PlacementNewAdopt) 715 { 716 } 717 718 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 719 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 720 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 721 virtual Precedence precedence() const { return PrecPostfix; } 722 virtual void optimizeForUnnecessaryResult(); 723 }; 724 725 class PostDecLocalVarNode : public PostDecResolveNode { 726 public: 727 PostDecLocalVarNode(size_t i) KJS_FAST_CALL 728 : PostDecResolveNode(PlacementNewAdopt) 729 { 730 ASSERT(i != missingSymbolMarker()); 731 m_index = i; 732 } 733 734 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 735 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 736 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 737 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 738 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 739 virtual void optimizeForUnnecessaryResult(); 740 private: 741 ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); 742 }; 743 744 class PostDecConstNode : public PostDecResolveNode { 745 public: 746 PostDecConstNode(size_t i) KJS_FAST_CALL 747 : PostDecResolveNode(PlacementNewAdopt) 748 { 749 ASSERT(i != missingSymbolMarker()); 750 m_index = i; 751 } 752 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 753 }; 754 755 class PostfixBracketNode : public ExpressionNode { 756 public: 757 PostfixBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL 758 : m_base(base), m_subscript(subscript) { } 759 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 760 virtual Precedence precedence() const { return PrecPostfix; } 761 protected: 762 RefPtr<ExpressionNode> m_base; 763 RefPtr<ExpressionNode> m_subscript; 764 }; 765 766 class PostIncBracketNode : public PostfixBracketNode { 767 public: 768 PostIncBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL 769 : PostfixBracketNode(base, subscript) { } 770 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 771 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 772 }; 773 774 class PostDecBracketNode : public PostfixBracketNode { 775 public: 776 PostDecBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL 777 : PostfixBracketNode(base, subscript) { } 778 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 779 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 780 }; 781 782 class PostfixDotNode : public ExpressionNode { 783 public: 784 PostfixDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL 785 : m_base(base), m_ident(ident) { } 786 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 787 virtual Precedence precedence() const { return PrecPostfix; } 788 protected: 789 RefPtr<ExpressionNode> m_base; 790 Identifier m_ident; 791 }; 792 793 class PostIncDotNode : public PostfixDotNode { 794 public: 795 PostIncDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL 796 : PostfixDotNode(base, ident) { } 797 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 798 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 799 }; 800 801 class PostDecDotNode : public PostfixDotNode { 802 public: 803 PostDecDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL 804 : PostfixDotNode(base, ident) { } 805 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 806 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 807 }; 808 809 class PostfixErrorNode : public ExpressionNode { 810 public: 811 PostfixErrorNode(ExpressionNode* expr, Operator oper) KJS_FAST_CALL 812 : m_expr(expr), m_oper(oper) { } 813 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 814 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 815 virtual Precedence precedence() const { return PrecPostfix; } 816 private: 817 RefPtr<ExpressionNode> m_expr; 818 Operator m_oper; 819 }; 820 821 class DeleteResolveNode : public ExpressionNode { 822 public: 823 DeleteResolveNode(const Identifier& ident) KJS_FAST_CALL 824 : m_ident(ident) 825 { 826 } 827 DeleteResolveNode(PlacementNewAdoptType) KJS_FAST_CALL 828 : ExpressionNode(PlacementNewAdopt) 829 , m_ident(PlacementNewAdopt) 830 { 831 } 832 833 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 834 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 835 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 836 virtual Precedence precedence() const { return PrecUnary; } 837 private: 838 Identifier m_ident; 839 }; 840 841 class LocalVarDeleteNode : public DeleteResolveNode { 842 public: 843 LocalVarDeleteNode() KJS_FAST_CALL 844 : DeleteResolveNode(PlacementNewAdopt) 845 { 846 } 847 848 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 849 }; 850 851 class DeleteBracketNode : public ExpressionNode { 852 public: 853 DeleteBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL 854 : m_base(base), m_subscript(subscript) { } 855 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 856 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 857 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 858 virtual Precedence precedence() const { return PrecUnary; } 859 private: 860 RefPtr<ExpressionNode> m_base; 861 RefPtr<ExpressionNode> m_subscript; 862 }; 863 864 class DeleteDotNode : public ExpressionNode { 865 public: 866 DeleteDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL 867 : m_base(base), m_ident(ident) { } 868 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 869 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 870 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 871 virtual Precedence precedence() const { return PrecUnary; } 872 private: 873 RefPtr<ExpressionNode> m_base; 874 Identifier m_ident; 875 }; 876 877 class DeleteValueNode : public ExpressionNode { 878 public: 879 DeleteValueNode(ExpressionNode* expr) KJS_FAST_CALL 880 : m_expr(expr) { } 881 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 882 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 883 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 884 virtual Precedence precedence() const { return PrecUnary; } 885 private: 886 RefPtr<ExpressionNode> m_expr; 887 }; 888 889 class VoidNode : public ExpressionNode { 890 public: 891 VoidNode(ExpressionNode* expr) KJS_FAST_CALL 892 : m_expr(expr) { } 893 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 894 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 895 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 896 virtual Precedence precedence() const { return PrecUnary; } 897 private: 898 RefPtr<ExpressionNode> m_expr; 899 }; 900 901 class TypeOfResolveNode : public ExpressionNode { 902 public: 903 TypeOfResolveNode(const Identifier& ident) KJS_FAST_CALL 904 : ExpressionNode(StringType) 905 , m_ident(ident) 906 { 907 } 908 909 TypeOfResolveNode(PlacementNewAdoptType) KJS_FAST_CALL 910 : ExpressionNode(PlacementNewAdopt) 911 , m_ident(PlacementNewAdopt) 912 { 913 m_expectedReturnType = StringType; 914 } 915 916 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 917 918 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 919 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 920 virtual Precedence precedence() const { return PrecUnary; } 921 922 const Identifier& identifier() const KJS_FAST_CALL { return m_ident; } 923 924 protected: 925 Identifier m_ident; 926 size_t m_index; // Used by LocalTypeOfNode. 927 }; 928 929 class LocalVarTypeOfNode : public TypeOfResolveNode { 930 public: 931 LocalVarTypeOfNode(size_t i) KJS_FAST_CALL 932 : TypeOfResolveNode(PlacementNewAdopt) 933 { 934 m_expectedReturnType = StringType; 935 ASSERT(i != missingSymbolMarker()); 936 m_index = i; 937 } 938 939 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 940 }; 941 942 class TypeOfValueNode : public ExpressionNode { 943 public: 944 TypeOfValueNode(ExpressionNode* e) KJS_FAST_CALL : ExpressionNode(StringType), m_expr(e) {} 945 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 946 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 947 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 948 virtual Precedence precedence() const { return PrecUnary; } 949 private: 950 RefPtr<ExpressionNode> m_expr; 951 }; 952 953 class PreIncResolveNode : public PrePostResolveNode { 954 public: 955 PreIncResolveNode(const Identifier& ident) KJS_FAST_CALL 956 : PrePostResolveNode(ident) 957 { 958 } 959 960 PreIncResolveNode(PlacementNewAdoptType) KJS_FAST_CALL 961 : PrePostResolveNode(PlacementNewAdopt) 962 { 963 } 964 965 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 966 967 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 968 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 969 virtual Precedence precedence() const { return PrecUnary; } 970 }; 971 972 class PreIncLocalVarNode : public PreIncResolveNode { 973 public: 974 PreIncLocalVarNode(size_t i) KJS_FAST_CALL 975 : PreIncResolveNode(PlacementNewAdopt) 976 { 977 ASSERT(i != missingSymbolMarker()); 978 m_index = i; 979 } 980 981 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 982 }; 983 984 class PreIncConstNode : public PreIncResolveNode { 985 public: 986 PreIncConstNode(size_t i) KJS_FAST_CALL 987 : PreIncResolveNode(PlacementNewAdopt) 988 { 989 ASSERT(i != missingSymbolMarker()); 990 m_index = i; 991 } 992 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 993 }; 994 995 class PreDecResolveNode : public PrePostResolveNode { 996 public: 997 PreDecResolveNode(const Identifier& ident) KJS_FAST_CALL 998 : PrePostResolveNode(ident) 999 { 1000 } 1001 1002 PreDecResolveNode(PlacementNewAdoptType) KJS_FAST_CALL 1003 : PrePostResolveNode(PlacementNewAdopt) 1004 { 1005 } 1006 1007 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1008 1009 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1010 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1011 virtual Precedence precedence() const { return PrecUnary; } 1012 }; 1013 1014 class PreDecLocalVarNode : public PreDecResolveNode { 1015 public: 1016 PreDecLocalVarNode(size_t i) KJS_FAST_CALL 1017 : PreDecResolveNode(PlacementNewAdopt) 1018 { 1019 ASSERT(i != missingSymbolMarker()); 1020 m_index = i; 1021 } 1022 1023 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1024 }; 1025 1026 class PreDecConstNode : public PreDecResolveNode { 1027 public: 1028 PreDecConstNode(size_t i) KJS_FAST_CALL 1029 : PreDecResolveNode(PlacementNewAdopt) 1030 { 1031 ASSERT(i != missingSymbolMarker()); 1032 m_index = i; 1033 } 1034 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1035 }; 1036 1037 class PrefixBracketNode : public ExpressionNode { 1038 public: 1039 PrefixBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL 1040 : m_base(base), m_subscript(subscript) { } 1041 1042 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1043 virtual Precedence precedence() const { return PrecUnary; } 1044 protected: 1045 RefPtr<ExpressionNode> m_base; 1046 RefPtr<ExpressionNode> m_subscript; 1047 }; 1048 1049 class PreIncBracketNode : public PrefixBracketNode { 1050 public: 1051 PreIncBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL 1052 : PrefixBracketNode(base, subscript) { } 1053 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1054 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1055 }; 1056 1057 class PreDecBracketNode : public PrefixBracketNode { 1058 public: 1059 PreDecBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL 1060 : PrefixBracketNode(base, subscript) { } 1061 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1062 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1063 }; 1064 1065 class PrefixDotNode : public ExpressionNode { 1066 public: 1067 PrefixDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL 1068 : m_base(base), m_ident(ident) { } 1069 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1070 virtual Precedence precedence() const { return PrecPostfix; } 1071 protected: 1072 RefPtr<ExpressionNode> m_base; 1073 Identifier m_ident; 1074 }; 1075 1076 class PreIncDotNode : public PrefixDotNode { 1077 public: 1078 PreIncDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL 1079 : PrefixDotNode(base, ident) { } 1080 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1081 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1082 }; 1083 1084 class PreDecDotNode : public PrefixDotNode { 1085 public: 1086 PreDecDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL 1087 : PrefixDotNode(base, ident) { } 1088 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1089 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1090 }; 1091 1092 class PrefixErrorNode : public ExpressionNode { 1093 public: 1094 PrefixErrorNode(ExpressionNode* expr, Operator oper) KJS_FAST_CALL 1095 : m_expr(expr), m_oper(oper) { } 1096 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1097 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1098 virtual Precedence precedence() const { return PrecUnary; } 1099 private: 1100 RefPtr<ExpressionNode> m_expr; 1101 Operator m_oper; 1102 }; 1103 1104 class UnaryPlusNode : public ExpressionNode { 1105 public: 1106 UnaryPlusNode(ExpressionNode* expr) KJS_FAST_CALL 1107 : ExpressionNode(NumberType), m_expr(expr) { } 1108 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1109 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1110 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1111 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1112 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1113 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1114 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1115 virtual Precedence precedence() const { return PrecUnary; } 1116 private: 1117 RefPtr<ExpressionNode> m_expr; 1118 }; 1119 1120 class NegateNode : public ExpressionNode { 1121 public: 1122 NegateNode(ExpressionNode* expr) KJS_FAST_CALL 1123 : ExpressionNode(NumberType), m_expr(expr) { } 1124 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1125 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1126 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1127 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1128 virtual Precedence precedence() const { return PrecUnary; } 1129 private: 1130 RefPtr<ExpressionNode> m_expr; 1131 }; 1132 1133 class BitwiseNotNode : public ExpressionNode { 1134 public: 1135 BitwiseNotNode(ExpressionNode* expr) KJS_FAST_CALL 1136 : ExpressionNode(NumberType), m_expr(expr) { } 1137 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1138 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1139 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1140 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1141 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1142 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1143 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1144 virtual Precedence precedence() const { return PrecUnary; } 1145 private: 1146 ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); 1147 RefPtr<ExpressionNode> m_expr; 1148 }; 1149 1150 class LogicalNotNode : public ExpressionNode { 1151 public: 1152 LogicalNotNode(ExpressionNode* expr) KJS_FAST_CALL 1153 : ExpressionNode(BooleanType), m_expr(expr) { } 1154 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1155 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1156 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1157 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1158 virtual Precedence precedence() const { return PrecUnary; } 1159 private: 1160 RefPtr<ExpressionNode> m_expr; 1161 }; 1162 1163 class MultNode : public ExpressionNode { 1164 public: 1165 MultNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1166 : ExpressionNode(NumberType), m_term1(term1), m_term2(term2) { } 1167 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1168 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1169 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1170 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1171 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1172 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1173 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1174 virtual Precedence precedence() const { return PrecMultiplicitave; } 1175 private: 1176 ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); 1177 RefPtr<ExpressionNode> m_term1; 1178 RefPtr<ExpressionNode> m_term2; 1179 }; 1180 1181 class DivNode : public ExpressionNode { 1182 public: 1183 DivNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1184 : ExpressionNode(NumberType), m_term1(term1), m_term2(term2) { } 1185 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1186 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1187 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1188 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1189 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1190 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1191 virtual Precedence precedence() const { return PrecMultiplicitave; } 1192 private: 1193 ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); 1194 RefPtr<ExpressionNode> m_term1; 1195 RefPtr<ExpressionNode> m_term2; 1196 }; 1197 1198 class ModNode : public ExpressionNode { 1199 public: 1200 ModNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1201 : ExpressionNode(NumberType), m_term1(term1), m_term2(term2) { } 1202 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1203 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1204 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1205 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1206 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1207 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1208 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1209 virtual Precedence precedence() const { return PrecMultiplicitave; } 1210 private: 1211 ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); 1212 RefPtr<ExpressionNode> m_term1; 1213 RefPtr<ExpressionNode> m_term2; 1214 }; 1215 1216 class AddNode : public ExpressionNode { 1217 public: 1218 AddNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1219 : m_term1(term1), m_term2(term2) { } 1220 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1221 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1222 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1223 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1224 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1225 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1226 virtual Precedence precedence() const { return PrecAdditive; } 1227 protected: 1228 AddNode(ExpressionNode* term1, ExpressionNode* term2, JSType expectedReturn) KJS_FAST_CALL 1229 : ExpressionNode(expectedReturn), m_term1(term1), m_term2(term2) { } 1230 RefPtr<ExpressionNode> m_term1; 1231 RefPtr<ExpressionNode> m_term2; 1232 private: 1233 ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); 1234 }; 1235 1236 class AddNumbersNode : public AddNode { 1237 public: 1238 AddNumbersNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1239 : AddNode(term1, term2, NumberType) { } 1240 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 208 }; 209 210 class StatementNode : public Node { 211 public: 212 StatementNode() KJS_FAST_CALL; 213 void setLoc(int line0, int line1) KJS_FAST_CALL; 214 int firstLine() const KJS_FAST_CALL { return lineNo(); } 215 int lastLine() const KJS_FAST_CALL { return m_lastLine; } 216 virtual JSValue* execute(ExecState *exec) KJS_FAST_CALL = 0; 217 void pushLabel(const Identifier& ident) KJS_FAST_CALL { m_labelStack.push(ident); } 218 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 219 virtual bool isEmptyStatement() const KJS_FAST_CALL { return false; } 220 221 protected: 222 LabelStack m_labelStack; 223 224 private: 225 int m_lastLine; 226 }; 227 228 class NullNode : public ExpressionNode { 229 public: 230 NullNode() KJS_FAST_CALL : ExpressionNode(NullType) {} 231 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 232 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 233 virtual Precedence precedence() const { return PrecPrimary; } 234 }; 235 236 class FalseNode : public ExpressionNode { 237 public: 238 FalseNode() KJS_FAST_CALL 239 : ExpressionNode(BooleanType) 240 { 241 } 242 243 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 244 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL { return false; } 245 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 246 virtual Precedence precedence() const { return PrecPrimary; } 247 }; 248 249 class TrueNode : public ExpressionNode { 250 public: 251 TrueNode() KJS_FAST_CALL 252 : ExpressionNode(BooleanType) 253 { 254 } 255 256 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 257 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL { return true; } 258 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 259 virtual Precedence precedence() const { return PrecPrimary; } 260 }; 261 262 class PlaceholderTrueNode : public TrueNode { 263 public: 264 // Like TrueNode, but does not serialize as "true". 265 PlaceholderTrueNode() KJS_FAST_CALL 266 : TrueNode() 267 { 268 } 269 270 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 271 }; 272 273 class NumberNode : public ExpressionNode { 274 public: 275 NumberNode(double v) KJS_FAST_CALL 276 : ExpressionNode(NumberType) 277 , m_double(v) 278 { 279 } 280 281 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 282 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 283 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 284 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 285 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 286 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 287 virtual Precedence precedence() const { return signbit(m_double) ? PrecUnary : PrecPrimary; } 288 289 virtual bool isNumber() const KJS_FAST_CALL { return true; } 290 double value() const KJS_FAST_CALL { return m_double; } 291 virtual void setValue(double d) KJS_FAST_CALL { m_double = d; } 292 293 protected: 294 double m_double; 295 }; 296 297 class ImmediateNumberNode : public NumberNode { 298 public: 299 ImmediateNumberNode(JSValue* v, double d) KJS_FAST_CALL 300 : NumberNode(d) 301 , m_value(v) 302 { 303 ASSERT(v == JSImmediate::from(d)); 304 } 305 306 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 307 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 308 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 309 310 virtual void setValue(double d) KJS_FAST_CALL { m_double = d; m_value = JSImmediate::from(d); ASSERT(m_value); } 311 312 private: 313 JSValue* m_value; // This is never a JSCell, only JSImmediate, thus no ProtectedPtr 314 }; 315 316 class StringNode : public ExpressionNode { 317 public: 318 StringNode(const UString* v) KJS_FAST_CALL 319 : ExpressionNode(StringType) 320 , m_value(*v) 321 { 322 } 323 324 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 325 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 326 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 327 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 328 virtual Precedence precedence() const { return PrecPrimary; } 329 330 private: 331 UString m_value; 332 }; 333 334 class RegExpNode : public ExpressionNode { 335 public: 336 RegExpNode(const UString& pattern, const UString& flags) KJS_FAST_CALL 337 : m_regExp(new RegExp(pattern, flags)) 338 { 339 } 340 341 JSValue* evaluate(ExecState*) KJS_FAST_CALL; 342 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 343 virtual Precedence precedence() const { return PrecPrimary; } 344 345 private: 346 RefPtr<RegExp> m_regExp; 347 }; 348 349 class ThisNode : public ExpressionNode { 350 public: 351 ThisNode() KJS_FAST_CALL 352 { 353 } 354 355 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 356 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 357 virtual Precedence precedence() const { return PrecPrimary; } 358 }; 359 360 class ResolveNode : public ExpressionNode { 361 public: 362 ResolveNode(const Identifier& ident) KJS_FAST_CALL 363 : m_ident(ident) 364 { 365 } 366 367 // Special constructor for cases where we overwrite an object in place. 368 ResolveNode(PlacementNewAdoptType) KJS_FAST_CALL 369 : ExpressionNode(PlacementNewAdopt) 370 , m_ident(PlacementNewAdopt) 371 { 372 } 373 374 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 375 376 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 377 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1241 378 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1242 379 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1243 380 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 381 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 382 virtual Precedence precedence() const { return PrecPrimary; } 383 384 virtual bool isLocation() const KJS_FAST_CALL { return true; } 385 virtual bool isResolveNode() const KJS_FAST_CALL { return true; } 386 const Identifier& identifier() const KJS_FAST_CALL { return m_ident; } 387 388 protected: 389 ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); 390 Identifier m_ident; 391 size_t m_index; // Used by LocalVarAccessNode. 392 }; 393 394 class LocalVarAccessNode : public ResolveNode { 395 public: 396 // Overwrites a ResolveNode in place. 397 LocalVarAccessNode(size_t i) KJS_FAST_CALL 398 : ResolveNode(PlacementNewAdopt) 399 { 400 ASSERT(i != missingSymbolMarker()); 401 m_index = i; 402 } 403 404 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 405 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 406 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 407 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 408 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 409 410 private: 411 ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); 412 }; 413 414 class ElementNode : public Node { 415 public: 416 ElementNode(int elision, ExpressionNode* node) KJS_FAST_CALL 417 : m_elision(elision) 418 , m_node(node) 419 { 420 } 421 422 ElementNode(ElementNode* l, int elision, ExpressionNode* node) KJS_FAST_CALL 423 : m_elision(elision) 424 , m_node(node) 425 { 426 l->m_next = this; 427 } 428 429 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 430 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 431 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 432 433 PassRefPtr<ElementNode> releaseNext() KJS_FAST_CALL { return m_next.release(); } 434 435 JSValue* evaluate(ExecState*) KJS_FAST_CALL; 436 437 private: 438 friend class ArrayNode; 439 ListRefPtr<ElementNode> m_next; 440 int m_elision; 441 RefPtr<ExpressionNode> m_node; 442 }; 443 444 class ArrayNode : public ExpressionNode { 445 public: 446 ArrayNode(int elision) KJS_FAST_CALL 447 : m_elision(elision) 448 , m_optional(true) 449 { 450 } 451 452 ArrayNode(ElementNode* element) KJS_FAST_CALL 453 : m_element(element) 454 , m_elision(0) 455 , m_optional(false) 456 { 457 } 458 459 ArrayNode(int elision, ElementNode* element) KJS_FAST_CALL 460 : m_element(element) 461 , m_elision(elision) 462 , m_optional(true) 463 { 464 } 465 466 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 467 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 468 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 469 virtual Precedence precedence() const { return PrecPrimary; } 470 471 private: 472 RefPtr<ElementNode> m_element; 473 int m_elision; 474 bool m_optional; 475 }; 476 477 class PropertyNode : public Node { 478 public: 479 enum Type { Constant, Getter, Setter }; 480 481 PropertyNode(const Identifier& name, ExpressionNode* assign, Type type) KJS_FAST_CALL 482 : m_name(name) 483 , m_assign(assign) 484 , m_type(type) 485 { 486 } 487 488 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 489 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 490 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 491 492 JSValue* evaluate(ExecState*) KJS_FAST_CALL; 493 const Identifier& name() const { return m_name; } 494 495 private: 496 friend class PropertyListNode; 497 Identifier m_name; 498 RefPtr<ExpressionNode> m_assign; 499 Type m_type; 500 }; 501 502 class PropertyListNode : public Node { 503 public: 504 PropertyListNode(PropertyNode* node) KJS_FAST_CALL 505 : m_node(node) 506 { 507 } 508 509 PropertyListNode(PropertyNode* node, PropertyListNode* list) KJS_FAST_CALL 510 : m_node(node) 511 { 512 list->m_next = this; 513 } 514 515 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 516 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 517 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 518 519 JSValue* evaluate(ExecState*) KJS_FAST_CALL; 520 PassRefPtr<PropertyListNode> releaseNext() KJS_FAST_CALL { return m_next.release(); } 521 522 private: 523 friend class ObjectLiteralNode; 524 RefPtr<PropertyNode> m_node; 525 ListRefPtr<PropertyListNode> m_next; 526 }; 527 528 class ObjectLiteralNode : public ExpressionNode { 529 public: 530 ObjectLiteralNode() KJS_FAST_CALL 531 { 532 } 533 534 ObjectLiteralNode(PropertyListNode* list) KJS_FAST_CALL 535 : m_list(list) 536 { 537 } 538 539 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 540 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 541 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 542 virtual Precedence precedence() const { return PrecPrimary; } 543 virtual bool needsParensIfLeftmost() const { return true; } 544 545 private: 546 RefPtr<PropertyListNode> m_list; 547 }; 548 549 class BracketAccessorNode : public ExpressionNode { 550 public: 551 BracketAccessorNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL 552 : m_base(base) 553 , m_subscript(subscript) 554 { 555 } 556 557 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 558 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 559 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 560 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 561 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 562 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 563 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 564 virtual Precedence precedence() const { return PrecMember; } 565 566 virtual bool isLocation() const KJS_FAST_CALL { return true; } 567 virtual bool isBracketAccessorNode() const KJS_FAST_CALL { return true; } 568 ExpressionNode* base() KJS_FAST_CALL { return m_base.get(); } 569 ExpressionNode* subscript() KJS_FAST_CALL { return m_subscript.get(); } 570 571 private: 572 ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); 573 574 RefPtr<ExpressionNode> m_base; 575 RefPtr<ExpressionNode> m_subscript; 576 }; 577 578 class DotAccessorNode : public ExpressionNode { 579 public: 580 DotAccessorNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL 581 : m_base(base) 582 , m_ident(ident) 583 { 584 } 585 586 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 587 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 588 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 589 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 590 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 591 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 592 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 593 virtual Precedence precedence() const { return PrecMember; } 594 595 virtual bool isLocation() const KJS_FAST_CALL { return true; } 596 virtual bool isDotAccessorNode() const KJS_FAST_CALL { return true; } 597 ExpressionNode* base() const KJS_FAST_CALL { return m_base.get(); } 598 const Identifier& identifier() const KJS_FAST_CALL { return m_ident; } 599 600 private: 601 ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); 602 603 RefPtr<ExpressionNode> m_base; 604 Identifier m_ident; 605 }; 606 607 class ArgumentListNode : public Node { 608 public: 609 ArgumentListNode(ExpressionNode* expr) KJS_FAST_CALL 610 : m_expr(expr) 611 { 612 } 613 614 ArgumentListNode(ArgumentListNode* listNode, ExpressionNode* expr) KJS_FAST_CALL 615 : m_expr(expr) 616 { 617 listNode->m_next = this; 618 } 619 620 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 621 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 622 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 623 624 void evaluateList(ExecState*, List&) KJS_FAST_CALL; 625 PassRefPtr<ArgumentListNode> releaseNext() KJS_FAST_CALL { return m_next.release(); } 626 627 private: 628 friend class ArgumentsNode; 629 ListRefPtr<ArgumentListNode> m_next; 630 RefPtr<ExpressionNode> m_expr; 631 }; 632 633 class ArgumentsNode : public Node { 634 public: 635 ArgumentsNode() KJS_FAST_CALL 636 { 637 } 638 639 ArgumentsNode(ArgumentListNode* listNode) KJS_FAST_CALL 640 : m_listNode(listNode) 641 { 642 } 643 644 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 645 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 646 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 647 648 void evaluateList(ExecState* exec, List& list) KJS_FAST_CALL { if (m_listNode) m_listNode->evaluateList(exec, list); } 649 650 private: 651 RefPtr<ArgumentListNode> m_listNode; 652 }; 653 654 class NewExprNode : public ExpressionNode { 655 public: 656 NewExprNode(ExpressionNode* expr) KJS_FAST_CALL 657 : m_expr(expr) 658 { 659 } 660 661 NewExprNode(ExpressionNode* expr, ArgumentsNode* args) KJS_FAST_CALL 662 : m_expr(expr) 663 , m_args(args) 664 { 665 } 666 667 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 668 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 669 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 670 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 671 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 672 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 673 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 674 virtual Precedence precedence() const { return PrecLeftHandSide; } 675 676 private: 677 ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); 678 679 RefPtr<ExpressionNode> m_expr; 680 RefPtr<ArgumentsNode> m_args; 681 }; 682 683 class FunctionCallValueNode : public ExpressionNode { 684 public: 685 FunctionCallValueNode(ExpressionNode* expr, ArgumentsNode* args) KJS_FAST_CALL 686 : m_expr(expr) 687 , m_args(args) 688 { 689 } 690 691 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 692 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 693 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 694 virtual Precedence precedence() const { return PrecCall; } 695 696 private: 697 RefPtr<ExpressionNode> m_expr; 698 RefPtr<ArgumentsNode> m_args; 699 }; 700 701 class FunctionCallResolveNode : public ExpressionNode { 702 public: 703 FunctionCallResolveNode(const Identifier& ident, ArgumentsNode* args) KJS_FAST_CALL 704 : m_ident(ident) 705 , m_args(args) 706 { 707 } 708 709 FunctionCallResolveNode(PlacementNewAdoptType) KJS_FAST_CALL 710 : ExpressionNode(PlacementNewAdopt) 711 , m_ident(PlacementNewAdopt) 712 , m_args(PlacementNewAdopt) 713 { 714 } 715 716 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 717 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 718 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 719 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 720 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 721 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 722 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 723 virtual Precedence precedence() const { return PrecCall; } 724 725 protected: 726 ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); 727 728 Identifier m_ident; 729 RefPtr<ArgumentsNode> m_args; 730 size_t m_index; // Used by LocalVarFunctionCallNode. 731 }; 732 733 class LocalVarFunctionCallNode : public FunctionCallResolveNode { 734 public: 735 LocalVarFunctionCallNode(size_t i) KJS_FAST_CALL 736 : FunctionCallResolveNode(PlacementNewAdopt) 737 { 738 ASSERT(i != missingSymbolMarker()); 739 m_index = i; 740 } 741 742 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 743 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 744 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 745 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 746 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 747 748 private: 749 ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); 750 }; 751 752 class FunctionCallBracketNode : public ExpressionNode { 753 public: 754 FunctionCallBracketNode(ExpressionNode* base, ExpressionNode* subscript, ArgumentsNode* args) KJS_FAST_CALL 755 : m_base(base) 756 , m_subscript(subscript) 757 , m_args(args) 758 { 759 } 760 761 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 762 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 763 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 764 virtual Precedence precedence() const { return PrecCall; } 765 766 protected: 767 RefPtr<ExpressionNode> m_base; 768 RefPtr<ExpressionNode> m_subscript; 769 RefPtr<ArgumentsNode> m_args; 770 }; 771 772 class FunctionCallDotNode : public ExpressionNode { 773 public: 774 FunctionCallDotNode(ExpressionNode* base, const Identifier& ident, ArgumentsNode* args) KJS_FAST_CALL 775 : m_base(base) 776 , m_ident(ident) 777 , m_args(args) 778 { 779 } 780 781 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 782 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 783 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 784 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 785 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 786 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 787 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 788 virtual Precedence precedence() const { return PrecCall; } 789 790 private: 791 ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*); 792 793 RefPtr<ExpressionNode> m_base; 794 Identifier m_ident; 795 RefPtr<ArgumentsNode> m_args; 796 }; 797 798 class PrePostResolveNode : public ExpressionNode { 799 public: 800 PrePostResolveNode(const Identifier& ident) KJS_FAST_CALL 801 : ExpressionNode(NumberType) 802 , m_ident(ident) 803 { 804 } 805 806 PrePostResolveNode(PlacementNewAdoptType) KJS_FAST_CALL 807 : ExpressionNode(PlacementNewAdopt) 808 , m_ident(PlacementNewAdopt) 809 { 810 } 811 812 protected: 813 Identifier m_ident; 814 size_t m_index; // Used by LocalVarPostfixNode. 815 }; 816 817 class PostIncResolveNode : public PrePostResolveNode { 818 public: 819 PostIncResolveNode(const Identifier& ident) KJS_FAST_CALL 820 : PrePostResolveNode(ident) 821 { 822 } 823 824 PostIncResolveNode(PlacementNewAdoptType) KJS_FAST_CALL 825 : PrePostResolveNode(PlacementNewAdopt) 826 { 827 } 828 829 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 830 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 831 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 832 virtual Precedence precedence() const { return PrecPostfix; } 833 virtual void optimizeForUnnecessaryResult(); 834 }; 835 836 class PostIncLocalVarNode : public PostIncResolveNode { 837 public: 838 PostIncLocalVarNode(size_t i) KJS_FAST_CALL 839 : PostIncResolveNode(PlacementNewAdopt) 840 { 841 ASSERT(i != missingSymbolMarker()); 842 m_index = i; 843 } 844 845 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 846 virtual void optimizeForUnnecessaryResult(); 847 }; 848 849 class PostIncConstNode : public PostIncResolveNode { 850 public: 851 PostIncConstNode(size_t i) KJS_FAST_CALL 852 : PostIncResolveNode(PlacementNewAdopt) 853 { 854 ASSERT(i != missingSymbolMarker()); 855 m_index = i; 856 } 857 858 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 859 }; 860 861 class PostDecResolveNode : public PrePostResolveNode { 862 public: 863 PostDecResolveNode(const Identifier& ident) KJS_FAST_CALL 864 : PrePostResolveNode(ident) 865 { 866 } 867 868 PostDecResolveNode(PlacementNewAdoptType) KJS_FAST_CALL 869 : PrePostResolveNode(PlacementNewAdopt) 870 { 871 } 872 873 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 874 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 875 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 876 virtual Precedence precedence() const { return PrecPostfix; } 877 virtual void optimizeForUnnecessaryResult(); 878 }; 879 880 class PostDecLocalVarNode : public PostDecResolveNode { 881 public: 882 PostDecLocalVarNode(size_t i) KJS_FAST_CALL 883 : PostDecResolveNode(PlacementNewAdopt) 884 { 885 ASSERT(i != missingSymbolMarker()); 886 m_index = i; 887 } 888 889 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 890 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 891 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 892 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 893 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 894 virtual void optimizeForUnnecessaryResult(); 895 896 private: 897 ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); 898 }; 899 900 class PostDecConstNode : public PostDecResolveNode { 901 public: 902 PostDecConstNode(size_t i) KJS_FAST_CALL 903 : PostDecResolveNode(PlacementNewAdopt) 904 { 905 ASSERT(i != missingSymbolMarker()); 906 m_index = i; 907 } 908 909 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 910 }; 911 912 class PostfixBracketNode : public ExpressionNode { 913 public: 914 PostfixBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL 915 : m_base(base) 916 , m_subscript(subscript) 917 { 918 } 919 920 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 921 virtual Precedence precedence() const { return PrecPostfix; } 922 923 protected: 924 RefPtr<ExpressionNode> m_base; 925 RefPtr<ExpressionNode> m_subscript; 926 }; 927 928 class PostIncBracketNode : public PostfixBracketNode { 929 public: 930 PostIncBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL 931 : PostfixBracketNode(base, subscript) 932 { 933 } 934 935 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 936 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 937 }; 938 939 class PostDecBracketNode : public PostfixBracketNode { 940 public: 941 PostDecBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL 942 : PostfixBracketNode(base, subscript) 943 { 944 } 945 946 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 947 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 948 }; 949 950 class PostfixDotNode : public ExpressionNode { 951 public: 952 PostfixDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL 953 : m_base(base) 954 , m_ident(ident) 955 { 956 } 957 958 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 959 virtual Precedence precedence() const { return PrecPostfix; } 960 961 protected: 962 RefPtr<ExpressionNode> m_base; 963 Identifier m_ident; 964 }; 965 966 class PostIncDotNode : public PostfixDotNode { 967 public: 968 PostIncDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL 969 : PostfixDotNode(base, ident) 970 { 971 } 972 973 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 974 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 975 }; 976 977 class PostDecDotNode : public PostfixDotNode { 978 public: 979 PostDecDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL 980 : PostfixDotNode(base, ident) 981 { 982 } 983 984 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 985 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 986 }; 987 988 class PostfixErrorNode : public ExpressionNode { 989 public: 990 PostfixErrorNode(ExpressionNode* expr, Operator oper) KJS_FAST_CALL 991 : m_expr(expr) 992 , m_operator(oper) 993 { 994 } 995 996 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 997 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 998 virtual Precedence precedence() const { return PrecPostfix; } 999 1000 private: 1001 RefPtr<ExpressionNode> m_expr; 1002 Operator m_operator; 1003 }; 1004 1005 class DeleteResolveNode : public ExpressionNode { 1006 public: 1007 DeleteResolveNode(const Identifier& ident) KJS_FAST_CALL 1008 : m_ident(ident) 1009 { 1010 } 1011 1012 DeleteResolveNode(PlacementNewAdoptType) KJS_FAST_CALL 1013 : ExpressionNode(PlacementNewAdopt) 1014 , m_ident(PlacementNewAdopt) 1015 { 1016 } 1017 1018 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1019 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1020 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1021 virtual Precedence precedence() const { return PrecUnary; } 1022 1023 private: 1024 Identifier m_ident; 1025 }; 1026 1027 class LocalVarDeleteNode : public DeleteResolveNode { 1028 public: 1029 LocalVarDeleteNode() KJS_FAST_CALL 1030 : DeleteResolveNode(PlacementNewAdopt) 1031 { 1032 } 1033 1034 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1035 }; 1036 1037 class DeleteBracketNode : public ExpressionNode { 1038 public: 1039 DeleteBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL 1040 : m_base(base) 1041 , m_subscript(subscript) 1042 { 1043 } 1044 1045 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1046 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1047 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1048 virtual Precedence precedence() const { return PrecUnary; } 1049 1050 private: 1051 RefPtr<ExpressionNode> m_base; 1052 RefPtr<ExpressionNode> m_subscript; 1053 }; 1054 1055 class DeleteDotNode : public ExpressionNode { 1056 public: 1057 DeleteDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL 1058 : m_base(base) 1059 , m_ident(ident) 1060 { 1061 } 1062 1063 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1064 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1065 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1066 virtual Precedence precedence() const { return PrecUnary; } 1067 1068 private: 1069 RefPtr<ExpressionNode> m_base; 1070 Identifier m_ident; 1071 }; 1072 1073 class DeleteValueNode : public ExpressionNode { 1074 public: 1075 DeleteValueNode(ExpressionNode* expr) KJS_FAST_CALL 1076 : m_expr(expr) 1077 { 1078 } 1079 1080 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1081 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1082 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1083 virtual Precedence precedence() const { return PrecUnary; } 1084 1085 private: 1086 RefPtr<ExpressionNode> m_expr; 1087 }; 1088 1089 class VoidNode : public ExpressionNode { 1090 public: 1091 VoidNode(ExpressionNode* expr) KJS_FAST_CALL 1092 : m_expr(expr) 1093 { 1094 } 1095 1096 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1097 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1098 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1099 virtual Precedence precedence() const { return PrecUnary; } 1100 1101 private: 1102 RefPtr<ExpressionNode> m_expr; 1103 }; 1104 1105 class TypeOfResolveNode : public ExpressionNode { 1106 public: 1107 TypeOfResolveNode(const Identifier& ident) KJS_FAST_CALL 1108 : ExpressionNode(StringType) 1109 , m_ident(ident) 1110 { 1111 } 1112 1113 TypeOfResolveNode(PlacementNewAdoptType) KJS_FAST_CALL 1114 : ExpressionNode(PlacementNewAdopt) 1115 , m_ident(PlacementNewAdopt) 1116 { 1117 m_expectedReturnType = StringType; 1118 } 1119 1120 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1121 1122 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1123 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1124 virtual Precedence precedence() const { return PrecUnary; } 1125 1126 const Identifier& identifier() const KJS_FAST_CALL { return m_ident; } 1127 1128 protected: 1129 Identifier m_ident; 1130 size_t m_index; // Used by LocalTypeOfNode. 1131 }; 1132 1133 class LocalVarTypeOfNode : public TypeOfResolveNode { 1134 public: 1135 LocalVarTypeOfNode(size_t i) KJS_FAST_CALL 1136 : TypeOfResolveNode(PlacementNewAdopt) 1137 { 1138 m_expectedReturnType = StringType; 1139 ASSERT(i != missingSymbolMarker()); 1140 m_index = i; 1141 } 1142 1143 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1144 }; 1145 1146 class TypeOfValueNode : public ExpressionNode { 1147 public: 1148 TypeOfValueNode(ExpressionNode* expr) KJS_FAST_CALL 1149 : ExpressionNode(StringType) 1150 , m_expr(expr) 1151 { 1152 } 1153 1154 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1155 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1156 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1157 virtual Precedence precedence() const { return PrecUnary; } 1158 1159 private: 1160 RefPtr<ExpressionNode> m_expr; 1161 }; 1162 1163 class PreIncResolveNode : public PrePostResolveNode { 1164 public: 1165 PreIncResolveNode(const Identifier& ident) KJS_FAST_CALL 1166 : PrePostResolveNode(ident) 1167 { 1168 } 1169 1170 PreIncResolveNode(PlacementNewAdoptType) KJS_FAST_CALL 1171 : PrePostResolveNode(PlacementNewAdopt) 1172 { 1173 } 1174 1175 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1176 1177 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1178 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1179 virtual Precedence precedence() const { return PrecUnary; } 1180 }; 1181 1182 class PreIncLocalVarNode : public PreIncResolveNode { 1183 public: 1184 PreIncLocalVarNode(size_t i) KJS_FAST_CALL 1185 : PreIncResolveNode(PlacementNewAdopt) 1186 { 1187 ASSERT(i != missingSymbolMarker()); 1188 m_index = i; 1189 } 1190 1191 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1192 }; 1193 1194 class PreIncConstNode : public PreIncResolveNode { 1195 public: 1196 PreIncConstNode(size_t i) KJS_FAST_CALL 1197 : PreIncResolveNode(PlacementNewAdopt) 1198 { 1199 ASSERT(i != missingSymbolMarker()); 1200 m_index = i; 1201 } 1202 1203 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1204 }; 1205 1206 class PreDecResolveNode : public PrePostResolveNode { 1207 public: 1208 PreDecResolveNode(const Identifier& ident) KJS_FAST_CALL 1209 : PrePostResolveNode(ident) 1210 { 1211 } 1212 1213 PreDecResolveNode(PlacementNewAdoptType) KJS_FAST_CALL 1214 : PrePostResolveNode(PlacementNewAdopt) 1215 { 1216 } 1217 1218 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1219 1220 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1221 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1222 virtual Precedence precedence() const { return PrecUnary; } 1223 }; 1224 1225 class PreDecLocalVarNode : public PreDecResolveNode { 1226 public: 1227 PreDecLocalVarNode(size_t i) KJS_FAST_CALL 1228 : PreDecResolveNode(PlacementNewAdopt) 1229 { 1230 ASSERT(i != missingSymbolMarker()); 1231 m_index = i; 1232 } 1233 1234 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1235 }; 1236 1237 class PreDecConstNode : public PreDecResolveNode { 1238 public: 1239 PreDecConstNode(size_t i) KJS_FAST_CALL 1240 : PreDecResolveNode(PlacementNewAdopt) 1241 { 1242 ASSERT(i != missingSymbolMarker()); 1243 m_index = i; 1244 } 1245 1246 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1247 }; 1248 1249 class PrefixBracketNode : public ExpressionNode { 1250 public: 1251 PrefixBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL 1252 : m_base(base) 1253 , m_subscript(subscript) 1254 { 1255 } 1256 1257 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1258 virtual Precedence precedence() const { return PrecUnary; } 1259 1260 protected: 1261 RefPtr<ExpressionNode> m_base; 1262 RefPtr<ExpressionNode> m_subscript; 1263 }; 1264 1265 class PreIncBracketNode : public PrefixBracketNode { 1266 public: 1267 PreIncBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL 1268 : PrefixBracketNode(base, subscript) 1269 { 1270 } 1271 1272 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1273 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1274 }; 1275 1276 class PreDecBracketNode : public PrefixBracketNode { 1277 public: 1278 PreDecBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL 1279 : PrefixBracketNode(base, subscript) 1280 { 1281 } 1282 1283 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1284 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1285 }; 1286 1287 class PrefixDotNode : public ExpressionNode { 1288 public: 1289 PrefixDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL 1290 : m_base(base) 1291 , m_ident(ident) 1292 { 1293 } 1294 1295 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1296 virtual Precedence precedence() const { return PrecPostfix; } 1297 1298 protected: 1299 RefPtr<ExpressionNode> m_base; 1300 Identifier m_ident; 1301 }; 1302 1303 class PreIncDotNode : public PrefixDotNode { 1304 public: 1305 PreIncDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL 1306 : PrefixDotNode(base, ident) 1307 { 1308 } 1309 1310 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1311 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1312 }; 1313 1314 class PreDecDotNode : public PrefixDotNode { 1315 public: 1316 PreDecDotNode(ExpressionNode* base, const Identifier& ident) KJS_FAST_CALL 1317 : PrefixDotNode(base, ident) 1318 { 1319 } 1320 1321 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1322 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1323 }; 1324 1325 class PrefixErrorNode : public ExpressionNode { 1326 public: 1327 PrefixErrorNode(ExpressionNode* expr, Operator oper) KJS_FAST_CALL 1328 : m_expr(expr) 1329 , m_operator(oper) 1330 { 1331 } 1332 1333 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1334 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1335 virtual Precedence precedence() const { return PrecUnary; } 1336 1337 private: 1338 RefPtr<ExpressionNode> m_expr; 1339 Operator m_operator; 1340 }; 1341 1342 class UnaryPlusNode : public ExpressionNode { 1343 public: 1344 UnaryPlusNode(ExpressionNode* expr) KJS_FAST_CALL 1345 : ExpressionNode(NumberType) 1346 , m_expr(expr) 1347 { 1348 } 1349 1350 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1351 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1352 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1353 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1354 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1355 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1356 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1357 virtual Precedence precedence() const { return PrecUnary; } 1358 1359 private: 1360 RefPtr<ExpressionNode> m_expr; 1361 }; 1362 1363 class NegateNode : public ExpressionNode { 1364 public: 1365 NegateNode(ExpressionNode* expr) KJS_FAST_CALL 1366 : ExpressionNode(NumberType) 1367 , m_expr(expr) 1368 { 1369 } 1370 1371 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1372 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1373 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1374 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1375 virtual Precedence precedence() const { return PrecUnary; } 1376 1377 private: 1378 RefPtr<ExpressionNode> m_expr; 1379 }; 1380 1381 class BitwiseNotNode : public ExpressionNode { 1382 public: 1383 BitwiseNotNode(ExpressionNode* expr) KJS_FAST_CALL 1384 : ExpressionNode(NumberType) 1385 , m_expr(expr) 1386 { 1387 } 1388 1389 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1390 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1391 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1392 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1393 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1394 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1395 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1396 virtual Precedence precedence() const { return PrecUnary; } 1397 1398 private: 1399 ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); 1400 1401 RefPtr<ExpressionNode> m_expr; 1402 }; 1403 1404 class LogicalNotNode : public ExpressionNode { 1405 public: 1406 LogicalNotNode(ExpressionNode* expr) KJS_FAST_CALL 1407 : ExpressionNode(BooleanType) 1408 , m_expr(expr) 1409 { 1410 } 1411 1412 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1413 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1414 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1415 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1416 virtual Precedence precedence() const { return PrecUnary; } 1417 1418 private: 1419 RefPtr<ExpressionNode> m_expr; 1420 }; 1421 1422 class MultNode : public ExpressionNode { 1423 public: 1424 MultNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1425 : ExpressionNode(NumberType) 1426 , m_term1(term1) 1427 , m_term2(term2) 1428 { 1429 } 1430 1431 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1432 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1433 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1434 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1435 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1436 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1437 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1438 virtual Precedence precedence() const { return PrecMultiplicitave; } 1439 1440 private: 1441 ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); 1442 1443 RefPtr<ExpressionNode> m_term1; 1444 RefPtr<ExpressionNode> m_term2; 1445 }; 1446 1447 class DivNode : public ExpressionNode { 1448 public: 1449 DivNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1450 : ExpressionNode(NumberType) 1451 , m_term1(term1) 1452 , m_term2(term2) 1453 { 1454 } 1455 1456 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1457 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1458 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1459 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1460 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1461 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1462 virtual Precedence precedence() const { return PrecMultiplicitave; } 1463 1464 private: 1465 ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); 1466 1467 RefPtr<ExpressionNode> m_term1; 1468 RefPtr<ExpressionNode> m_term2; 1469 }; 1470 1471 class ModNode : public ExpressionNode { 1472 public: 1473 ModNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1474 : ExpressionNode(NumberType) 1475 , m_term1(term1) 1476 , m_term2(term2) 1477 { 1478 } 1479 1480 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1481 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1482 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1483 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1484 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1485 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1486 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1487 virtual Precedence precedence() const { return PrecMultiplicitave; } 1488 1489 private: 1490 ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); 1491 1492 RefPtr<ExpressionNode> m_term1; 1493 RefPtr<ExpressionNode> m_term2; 1494 }; 1495 1496 class AddNode : public ExpressionNode { 1497 public: 1498 AddNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1499 : m_term1(term1) 1500 , m_term2(term2) 1501 { 1502 } 1503 1504 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1505 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1506 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1507 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1508 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1509 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1510 virtual Precedence precedence() const { return PrecAdditive; } 1511 1512 protected: 1513 AddNode(ExpressionNode* term1, ExpressionNode* term2, JSType expectedReturn) KJS_FAST_CALL 1514 : ExpressionNode(expectedReturn) 1515 , m_term1(term1) 1516 , m_term2(term2) 1517 { 1518 } 1519 1520 RefPtr<ExpressionNode> m_term1; 1521 RefPtr<ExpressionNode> m_term2; 1522 1523 private: 1524 ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); 1525 }; 1526 1527 class AddNumbersNode : public AddNode { 1528 public: 1529 AddNumbersNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1530 : AddNode(term1, term2, NumberType) 1531 { 1532 } 1533 1534 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1535 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1536 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1537 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1538 1244 1539 private: 1245 1540 ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*) KJS_FAST_CALL; … … 1249 1544 public: 1250 1545 AddStringLeftNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1251 : AddNode(term1, term2, StringType) { } 1546 : AddNode(term1, term2, StringType) 1547 { 1548 } 1549 1252 1550 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1253 1551 }; … … 1256 1554 public: 1257 1555 AddStringRightNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1258 : AddNode(term1, term2, StringType) { } 1556 : AddNode(term1, term2, StringType) 1557 { 1558 } 1559 1259 1560 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1260 1561 }; … … 1263 1564 public: 1264 1565 AddStringsNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1265 : AddNode(term1, term2, StringType) { } 1266 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1267 }; 1268 1269 class SubNode : public ExpressionNode { 1270 public: 1271 SubNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1272 : ExpressionNode(NumberType), m_term1(term1), m_term2(term2) { } 1273 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1274 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1275 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1276 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1277 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1278 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1279 virtual Precedence precedence() const { return PrecAdditive; } 1280 private: 1281 ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); 1282 RefPtr<ExpressionNode> m_term1; 1283 RefPtr<ExpressionNode> m_term2; 1284 }; 1285 1286 class LeftShiftNode : public ExpressionNode { 1287 public: 1288 LeftShiftNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1289 : ExpressionNode(NumberType), m_term1(term1), m_term2(term2) { } 1290 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1291 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1292 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1293 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1294 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1295 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1296 virtual Precedence precedence() const { return PrecShift; } 1297 private: 1298 ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); 1299 RefPtr<ExpressionNode> m_term1; 1300 RefPtr<ExpressionNode> m_term2; 1301 }; 1302 1303 class RightShiftNode : public ExpressionNode { 1304 public: 1305 RightShiftNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1306 : ExpressionNode(NumberType), m_term1(term1), m_term2(term2) { } 1307 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1308 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1309 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1310 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1311 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1312 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1313 virtual Precedence precedence() const { return PrecShift; } 1314 private: 1315 ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); 1316 RefPtr<ExpressionNode> m_term1; 1317 RefPtr<ExpressionNode> m_term2; 1318 }; 1319 1320 class UnsignedRightShiftNode : public ExpressionNode { 1321 public: 1322 UnsignedRightShiftNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1323 : ExpressionNode(NumberType), m_term1(term1), m_term2(term2) { } 1324 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1325 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1326 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1327 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1328 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1329 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1330 virtual Precedence precedence() const { return PrecShift; } 1331 private: 1332 ALWAYS_INLINE uint32_t inlineEvaluateToUInt32(ExecState*); 1333 RefPtr<ExpressionNode> m_term1; 1334 RefPtr<ExpressionNode> m_term2; 1335 }; 1336 1337 class LessNode : public ExpressionNode { 1338 public: 1339 LessNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1340 : ExpressionNode(BooleanType), m_expr1(expr1), m_expr2(expr2) {} 1341 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1342 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1343 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1344 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1345 virtual Precedence precedence() const { return PrecRelational; } 1346 private: 1347 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 1348 protected: 1349 RefPtr<ExpressionNode> m_expr1; 1350 RefPtr<ExpressionNode> m_expr2; 1351 }; 1566 : AddNode(term1, term2, StringType) 1567 { 1568 } 1569 1570 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1571 }; 1572 1573 class SubNode : public ExpressionNode { 1574 public: 1575 SubNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1576 : ExpressionNode(NumberType) 1577 , m_term1(term1) 1578 , m_term2(term2) 1579 { 1580 } 1581 1582 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1583 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1584 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1585 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1586 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1587 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1588 virtual Precedence precedence() const { return PrecAdditive; } 1589 1590 private: 1591 ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*); 1592 1593 RefPtr<ExpressionNode> m_term1; 1594 RefPtr<ExpressionNode> m_term2; 1595 }; 1596 1597 class LeftShiftNode : public ExpressionNode { 1598 public: 1599 LeftShiftNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1600 : ExpressionNode(NumberType) 1601 , m_term1(term1) 1602 , m_term2(term2) 1603 { 1604 } 1605 1606 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1607 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1608 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1609 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1610 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1611 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1612 virtual Precedence precedence() const { return PrecShift; } 1613 1614 private: 1615 ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); 1616 1617 RefPtr<ExpressionNode> m_term1; 1618 RefPtr<ExpressionNode> m_term2; 1619 }; 1620 1621 class RightShiftNode : public ExpressionNode { 1622 public: 1623 RightShiftNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1624 : ExpressionNode(NumberType) 1625 , m_term1(term1) 1626 , m_term2(term2) 1627 { 1628 } 1629 1630 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1631 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1632 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1633 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1634 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1635 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1636 virtual Precedence precedence() const { return PrecShift; } 1637 1638 private: 1639 ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); 1640 1641 RefPtr<ExpressionNode> m_term1; 1642 RefPtr<ExpressionNode> m_term2; 1643 }; 1644 1645 class UnsignedRightShiftNode : public ExpressionNode { 1646 public: 1647 UnsignedRightShiftNode(ExpressionNode* term1, ExpressionNode* term2) KJS_FAST_CALL 1648 : ExpressionNode(NumberType) 1649 , m_term1(term1) 1650 , m_term2(term2) 1651 { 1652 } 1653 1654 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1655 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1656 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1657 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1658 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1659 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1660 virtual Precedence precedence() const { return PrecShift; } 1661 private: 1662 ALWAYS_INLINE uint32_t inlineEvaluateToUInt32(ExecState*); 1663 1664 RefPtr<ExpressionNode> m_term1; 1665 RefPtr<ExpressionNode> m_term2; 1666 }; 1667 1668 class LessNode : public ExpressionNode { 1669 public: 1670 LessNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1671 : ExpressionNode(BooleanType) 1672 , m_expr1(expr1) 1673 , m_expr2(expr2) 1674 { 1675 } 1676 1677 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1678 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1679 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1680 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1681 virtual Precedence precedence() const { return PrecRelational; } 1682 1683 private: 1684 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 1685 1686 protected: 1687 RefPtr<ExpressionNode> m_expr1; 1688 RefPtr<ExpressionNode> m_expr2; 1689 }; 1352 1690 1353 1691 class LessNumbersNode : public LessNode { 1354 1692 public: 1355 1693 LessNumbersNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1356 : LessNode(expr1, expr2) { } 1357 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1358 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1694 : LessNode(expr1, expr2) 1695 { 1696 } 1697 1698 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1699 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1700 1359 1701 private: 1360 1702 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); … … 1364 1706 public: 1365 1707 LessStringsNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1366 : LessNode(expr1, expr2) { } 1367 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1368 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1708 : LessNode(expr1, expr2) 1709 { 1710 } 1711 1712 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1713 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1714 1369 1715 private: 1370 1716 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 1371 1717 }; 1372 1718 1373 class GreaterNode : public ExpressionNode { 1374 public: 1375 GreaterNode(ExpressionNode* e1, ExpressionNode* e2) KJS_FAST_CALL : 1376 m_expr1(e1), m_expr2(e2) {} 1377 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1378 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1379 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1380 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1381 virtual Precedence precedence() const { return PrecRelational; } 1382 private: 1383 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 1384 RefPtr<ExpressionNode> m_expr1; 1385 RefPtr<ExpressionNode> m_expr2; 1386 }; 1387 1388 class LessEqNode : public ExpressionNode { 1389 public: 1390 LessEqNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1391 : m_expr1(expr1), m_expr2(expr2) { } 1392 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1393 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1394 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1395 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1396 virtual Precedence precedence() const { return PrecRelational; } 1397 private: 1398 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 1399 RefPtr<ExpressionNode> m_expr1; 1400 RefPtr<ExpressionNode> m_expr2; 1401 }; 1402 1403 class GreaterEqNode : public ExpressionNode { 1404 public: 1405 GreaterEqNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1406 : m_expr1(expr1), m_expr2(expr2) { } 1407 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1408 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1409 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1410 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1411 virtual Precedence precedence() const { return PrecRelational; } 1412 private: 1413 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 1414 RefPtr<ExpressionNode> m_expr1; 1415 RefPtr<ExpressionNode> m_expr2; 1416 }; 1719 class GreaterNode : public ExpressionNode { 1720 public: 1721 GreaterNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1722 : m_expr1(expr1) 1723 , m_expr2(expr2) 1724 { 1725 } 1726 1727 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1728 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1729 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1730 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1731 virtual Precedence precedence() const { return PrecRelational; } 1732 1733 private: 1734 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 1735 1736 RefPtr<ExpressionNode> m_expr1; 1737 RefPtr<ExpressionNode> m_expr2; 1738 }; 1739 1740 class LessEqNode : public ExpressionNode { 1741 public: 1742 LessEqNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1743 : m_expr1(expr1) 1744 , m_expr2(expr2) 1745 { 1746 } 1747 1748 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1749 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1750 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1751 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1752 virtual Precedence precedence() const { return PrecRelational; } 1753 1754 private: 1755 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 1756 1757 RefPtr<ExpressionNode> m_expr1; 1758 RefPtr<ExpressionNode> m_expr2; 1759 }; 1760 1761 class GreaterEqNode : public ExpressionNode { 1762 public: 1763 GreaterEqNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1764 : m_expr1(expr1) 1765 , m_expr2(expr2) 1766 { 1767 } 1768 1769 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1770 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1771 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1772 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1773 virtual Precedence precedence() const { return PrecRelational; } 1774 1775 private: 1776 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 1777 1778 RefPtr<ExpressionNode> m_expr1; 1779 RefPtr<ExpressionNode> m_expr2; 1780 }; 1417 1781 1418 1782 class InstanceOfNode : public ExpressionNode { 1419 public: 1420 InstanceOfNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1421 : ExpressionNode(BooleanType), m_expr1(expr1), m_expr2(expr2) { } 1422 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1423 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1424 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1425 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1426 virtual Precedence precedence() const { return PrecRelational; } 1427 private: 1428 RefPtr<ExpressionNode> m_expr1; 1429 RefPtr<ExpressionNode> m_expr2; 1430 }; 1783 public: 1784 InstanceOfNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1785 : ExpressionNode(BooleanType) 1786 , m_expr1(expr1) 1787 , m_expr2(expr2) 1788 { 1789 } 1790 1791 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1792 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1793 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1794 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1795 virtual Precedence precedence() const { return PrecRelational; } 1796 1797 private: 1798 RefPtr<ExpressionNode> m_expr1; 1799 RefPtr<ExpressionNode> m_expr2; 1800 }; 1431 1801 1432 1802 class InNode : public ExpressionNode { 1433 public: 1434 InNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1435 : m_expr1(expr1), m_expr2(expr2) { } 1436 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1437 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1438 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1439 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1440 virtual Precedence precedence() const { return PrecRelational; } 1441 private: 1442 RefPtr<ExpressionNode> m_expr1; 1443 RefPtr<ExpressionNode> m_expr2; 1444 }; 1803 public: 1804 InNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1805 : m_expr1(expr1) 1806 , m_expr2(expr2) 1807 { 1808 } 1809 1810 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1811 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1812 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1813 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1814 virtual Precedence precedence() const { return PrecRelational; } 1815 1816 private: 1817 RefPtr<ExpressionNode> m_expr1; 1818 RefPtr<ExpressionNode> m_expr2; 1819 }; 1445 1820 1446 1821 class EqualNode : public ExpressionNode { 1447 public: 1448 EqualNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1449 : ExpressionNode(BooleanType), m_expr1(expr1), m_expr2(expr2) { } 1450 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1451 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1452 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1453 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1454 virtual Precedence precedence() const { return PrecEquality; } 1455 private: 1456 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 1457 RefPtr<ExpressionNode> m_expr1; 1458 RefPtr<ExpressionNode> m_expr2; 1459 }; 1822 public: 1823 EqualNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1824 : ExpressionNode(BooleanType) 1825 , m_expr1(expr1) 1826 , m_expr2(expr2) 1827 { 1828 } 1829 1830 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1831 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1832 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1833 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1834 virtual Precedence precedence() const { return PrecEquality; } 1835 1836 private: 1837 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 1838 1839 RefPtr<ExpressionNode> m_expr1; 1840 RefPtr<ExpressionNode> m_expr2; 1841 }; 1460 1842 1461 1843 class NotEqualNode : public ExpressionNode { 1462 public: 1463 NotEqualNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1464 : ExpressionNode(BooleanType), m_expr1(expr1), m_expr2(expr2) { } 1465 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1466 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1467 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1468 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1469 virtual Precedence precedence() const { return PrecEquality; } 1470 private: 1471 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 1472 RefPtr<ExpressionNode> m_expr1; 1473 RefPtr<ExpressionNode> m_expr2; 1474 }; 1844 public: 1845 NotEqualNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1846 : ExpressionNode(BooleanType) 1847 , m_expr1(expr1) 1848 , m_expr2(expr2) 1849 { 1850 } 1851 1852 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1853 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1854 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1855 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1856 virtual Precedence precedence() const { return PrecEquality; } 1857 1858 private: 1859 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 1860 1861 RefPtr<ExpressionNode> m_expr1; 1862 RefPtr<ExpressionNode> m_expr2; 1863 }; 1475 1864 1476 1865 class StrictEqualNode : public ExpressionNode { 1477 public: 1478 StrictEqualNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1479 : ExpressionNode(BooleanType), m_expr1(expr1), m_expr2(expr2) { } 1480 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1481 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1482 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1483 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1484 virtual Precedence precedence() const { return PrecEquality; } 1485 private: 1486 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 1487 RefPtr<ExpressionNode> m_expr1; 1488 RefPtr<ExpressionNode> m_expr2; 1489 }; 1866 public: 1867 StrictEqualNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1868 : ExpressionNode(BooleanType) 1869 , m_expr1(expr1) 1870 , m_expr2(expr2) 1871 { 1872 } 1873 1874 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1875 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1876 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1877 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1878 virtual Precedence precedence() const { return PrecEquality; } 1879 1880 private: 1881 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 1882 1883 RefPtr<ExpressionNode> m_expr1; 1884 RefPtr<ExpressionNode> m_expr2; 1885 }; 1490 1886 1491 1887 class NotStrictEqualNode : public ExpressionNode { 1492 public: 1493 NotStrictEqualNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1494 : ExpressionNode(BooleanType), m_expr1(expr1), m_expr2(expr2) { } 1495 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1496 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1497 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1498 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1499 virtual Precedence precedence() const { return PrecEquality; } 1500 private: 1501 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 1502 RefPtr<ExpressionNode> m_expr1; 1503 RefPtr<ExpressionNode> m_expr2; 1504 }; 1888 public: 1889 NotStrictEqualNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1890 : ExpressionNode(BooleanType) 1891 , m_expr1(expr1) 1892 , m_expr2(expr2) 1893 { 1894 } 1895 1896 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1897 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1898 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1899 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1900 virtual Precedence precedence() const { return PrecEquality; } 1901 1902 private: 1903 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 1904 1905 RefPtr<ExpressionNode> m_expr1; 1906 RefPtr<ExpressionNode> m_expr2; 1907 }; 1505 1908 1506 1909 class BitAndNode : public ExpressionNode { 1507 public: 1508 BitAndNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1509 : ExpressionNode(NumberType), m_expr1(expr1), m_expr2(expr2) { } 1510 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1511 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1512 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1513 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1514 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1515 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1516 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1517 virtual Precedence precedence() const { return PrecBitwiseAnd; } 1518 private: 1519 ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); 1520 RefPtr<ExpressionNode> m_expr1; 1521 RefPtr<ExpressionNode> m_expr2; 1522 }; 1910 public: 1911 BitAndNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1912 : ExpressionNode(NumberType) 1913 , m_expr1(expr1) 1914 , m_expr2(expr2) 1915 { 1916 } 1917 1918 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1919 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1920 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1921 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1922 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1923 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1924 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1925 virtual Precedence precedence() const { return PrecBitwiseAnd; } 1926 1927 private: 1928 ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); 1929 1930 RefPtr<ExpressionNode> m_expr1; 1931 RefPtr<ExpressionNode> m_expr2; 1932 }; 1523 1933 1524 1934 class BitOrNode : public ExpressionNode { 1525 public: 1526 BitOrNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1527 : ExpressionNode(NumberType), m_expr1(expr1), m_expr2(expr2) { } 1528 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1529 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1530 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1531 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1532 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1533 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1534 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1535 virtual Precedence precedence() const { return PrecBitwiseOr; } 1536 private: 1537 ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); 1538 RefPtr<ExpressionNode> m_expr1; 1539 RefPtr<ExpressionNode> m_expr2; 1540 }; 1541 1542 class BitXOrNode : public ExpressionNode { 1543 public: 1544 BitXOrNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1545 : ExpressionNode(NumberType), m_expr1(expr1), m_expr2(expr2) { } 1546 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1547 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1548 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1549 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1550 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1551 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1552 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1553 virtual Precedence precedence() const { return PrecBitwiseXor; } 1554 private: 1555 ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); 1556 RefPtr<ExpressionNode> m_expr1; 1557 RefPtr<ExpressionNode> m_expr2; 1558 }; 1559 1560 /** 1561 * m_expr1 && m_expr2, m_expr1 || m_expr2 1562 */ 1935 public: 1936 BitOrNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1937 : ExpressionNode(NumberType) 1938 , m_expr1(expr1) 1939 , m_expr2(expr2) 1940 { 1941 } 1942 1943 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1944 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1945 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1946 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1947 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1948 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1949 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1950 virtual Precedence precedence() const { return PrecBitwiseOr; } 1951 1952 private: 1953 ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); 1954 1955 RefPtr<ExpressionNode> m_expr1; 1956 RefPtr<ExpressionNode> m_expr2; 1957 }; 1958 1959 class BitXOrNode : public ExpressionNode { 1960 public: 1961 BitXOrNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1962 : ExpressionNode(NumberType) 1963 , m_expr1(expr1) 1964 , m_expr2(expr2) 1965 { 1966 } 1967 1968 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1969 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1970 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1971 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1972 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1973 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1974 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1975 virtual Precedence precedence() const { return PrecBitwiseXor; } 1976 1977 private: 1978 ALWAYS_INLINE int32_t inlineEvaluateToInt32(ExecState*); 1979 1980 RefPtr<ExpressionNode> m_expr1; 1981 RefPtr<ExpressionNode> m_expr2; 1982 }; 1983 1984 /** 1985 * m_expr1 && m_expr2, m_expr1 || m_expr2 1986 */ 1563 1987 class LogicalAndNode : public ExpressionNode { 1564 public: 1565 LogicalAndNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1566 : ExpressionNode(BooleanType), m_expr1(expr1), m_expr2(expr2) { } 1567 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1568 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1569 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1570 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1571 virtual Precedence precedence() const { return PrecLogicalAnd; } 1572 private: 1573 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 1574 RefPtr<ExpressionNode> m_expr1; 1575 RefPtr<ExpressionNode> m_expr2; 1576 }; 1577 1988 public: 1989 LogicalAndNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1990 : ExpressionNode(BooleanType) 1991 , m_expr1(expr1) 1992 , m_expr2(expr2) 1993 { 1994 } 1995 1996 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1997 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1998 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1999 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2000 virtual Precedence precedence() const { return PrecLogicalAnd; } 2001 2002 private: 2003 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 2004 2005 RefPtr<ExpressionNode> m_expr1; 2006 RefPtr<ExpressionNode> m_expr2; 2007 }; 2008 1578 2009 class LogicalOrNode : public ExpressionNode { 1579 public: 1580 LogicalOrNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1581 : ExpressionNode(BooleanType), m_expr1(expr1), m_expr2(expr2) { } 1582 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1583 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1584 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1585 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1586 virtual Precedence precedence() const { return PrecLogicalOr; } 1587 private: 1588 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 1589 RefPtr<ExpressionNode> m_expr1; 1590 RefPtr<ExpressionNode> m_expr2; 1591 }; 1592 1593 /** 1594 * The ternary operator, "m_logical ? m_expr1 : m_expr2" 1595 */ 1596 class ConditionalNode : public ExpressionNode { 1597 public: 1598 ConditionalNode(ExpressionNode* logical, ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 1599 : m_logical(logical), m_expr1(expr1), m_expr2(expr2) { } 1600 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1601 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 1602 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 1603 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 1604 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 1605 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 1606 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1607 virtual Precedence precedence() const { return PrecConditional; } 1608 private: 1609 RefPtr<ExpressionNode> m_logical; 1610 RefPtr<ExpressionNode> m_expr1; 1611 RefPtr<ExpressionNode> m_expr2; 1612 }; 1613 1614 class ReadModifyResolveNode : public ExpressionNode { 1615 public: 1616 ReadModifyResolveNode(const Identifier& ident, Operator oper, ExpressionNode* right) KJS_FAST_CALL 1617 : m_ident(ident) 1618 , m_oper(oper) 1619 , m_right(right) 2010 public: 2011 LogicalOrNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 2012 : ExpressionNode(BooleanType) 2013 , m_expr1(expr1) 2014 , m_expr2(expr2) 2015 { 2016 } 2017 2018 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2019 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 2020 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 2021 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2022 virtual Precedence precedence() const { return PrecLogicalOr; } 2023 2024 private: 2025 ALWAYS_INLINE bool inlineEvaluateToBoolean(ExecState*); 2026 2027 RefPtr<ExpressionNode> m_expr1; 2028 RefPtr<ExpressionNode> m_expr2; 2029 }; 2030 2031 /** 2032 * The ternary operator, "m_logical ? m_expr1 : m_expr2" 2033 */ 2034 class ConditionalNode : public ExpressionNode { 2035 public: 2036 ConditionalNode(ExpressionNode* logical, ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 2037 : m_logical(logical) 2038 , m_expr1(expr1) 2039 , m_expr2(expr2) 2040 { 2041 } 2042 2043 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2044 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 2045 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL; 2046 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL; 2047 virtual int32_t evaluateToInt32(ExecState*) KJS_FAST_CALL; 2048 virtual uint32_t evaluateToUInt32(ExecState*) KJS_FAST_CALL; 2049 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2050 virtual Precedence precedence() const { return PrecConditional; } 2051 2052 private: 2053 RefPtr<ExpressionNode> m_logical; 2054 RefPtr<ExpressionNode> m_expr1; 2055 RefPtr<ExpressionNode> m_expr2; 2056 }; 2057 2058 class ReadModifyResolveNode : public ExpressionNode { 2059 public: 2060 ReadModifyResolveNode(const Identifier& ident, Operator oper, ExpressionNode* right) KJS_FAST_CALL 2061 : m_ident(ident) 2062 , m_operator(oper) 2063 , m_right(right) 2064 { 2065 } 2066 2067 ReadModifyResolveNode(PlacementNewAdoptType) KJS_FAST_CALL 2068 : ExpressionNode(PlacementNewAdopt) 2069 , m_ident(PlacementNewAdopt) 2070 , m_right(PlacementNewAdopt) 2071 { 2072 } 2073 2074 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2075 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 2076 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2077 virtual Precedence precedence() const { return PrecAssignment; } 2078 2079 protected: 2080 Identifier m_ident; 2081 Operator m_operator; 2082 RefPtr<ExpressionNode> m_right; 2083 size_t m_index; // Used by ReadModifyLocalVarNode. 2084 }; 2085 2086 class ReadModifyLocalVarNode : public ReadModifyResolveNode { 2087 public: 2088 ReadModifyLocalVarNode(size_t i) KJS_FAST_CALL 2089 : ReadModifyResolveNode(PlacementNewAdopt) 2090 { 2091 ASSERT(i != missingSymbolMarker()); 2092 m_index = i; 2093 } 2094 2095 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 2096 }; 2097 2098 class ReadModifyConstNode : public ReadModifyResolveNode { 2099 public: 2100 ReadModifyConstNode(size_t i) KJS_FAST_CALL 2101 : ReadModifyResolveNode(PlacementNewAdopt) 2102 { 2103 ASSERT(i != missingSymbolMarker()); 2104 m_index = i; 2105 } 2106 2107 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 2108 }; 2109 2110 class AssignResolveNode : public ExpressionNode { 2111 public: 2112 AssignResolveNode(const Identifier& ident, ExpressionNode* right) KJS_FAST_CALL 2113 : m_ident(ident) 2114 , m_right(right) 2115 { 2116 } 2117 2118 AssignResolveNode(PlacementNewAdoptType) KJS_FAST_CALL 2119 : ExpressionNode(PlacementNewAdopt) 2120 , m_ident(PlacementNewAdopt) 2121 , m_right(PlacementNewAdopt) 2122 { 2123 } 2124 2125 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2126 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 2127 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2128 virtual Precedence precedence() const { return PrecAssignment; } 2129 2130 protected: 2131 Identifier m_ident; 2132 RefPtr<ExpressionNode> m_right; 2133 size_t m_index; // Used by ReadModifyLocalVarNode. 2134 }; 2135 2136 class AssignLocalVarNode : public AssignResolveNode { 2137 public: 2138 AssignLocalVarNode(size_t i) KJS_FAST_CALL 2139 : AssignResolveNode(PlacementNewAdopt) 2140 { 2141 ASSERT(i != missingSymbolMarker()); 2142 m_index = i; 2143 } 2144 2145 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 2146 }; 2147 2148 class AssignConstNode : public AssignResolveNode { 2149 public: 2150 AssignConstNode() KJS_FAST_CALL 2151 : AssignResolveNode(PlacementNewAdopt) 2152 { 2153 } 2154 2155 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 2156 }; 2157 2158 class ReadModifyBracketNode : public ExpressionNode { 2159 public: 2160 ReadModifyBracketNode(ExpressionNode* base, ExpressionNode* subscript, Operator oper, ExpressionNode* right) KJS_FAST_CALL 2161 : m_base(base) 2162 , m_subscript(subscript) 2163 , m_operator(oper) 2164 , m_right(right) 2165 { 2166 } 2167 2168 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2169 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 2170 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2171 virtual Precedence precedence() const { return PrecAssignment; } 2172 2173 protected: 2174 RefPtr<ExpressionNode> m_base; 2175 RefPtr<ExpressionNode> m_subscript; 2176 Operator m_operator; 2177 RefPtr<ExpressionNode> m_right; 2178 }; 2179 2180 class AssignBracketNode : public ExpressionNode { 2181 public: 2182 AssignBracketNode(ExpressionNode* base, ExpressionNode* subscript, ExpressionNode* right) KJS_FAST_CALL 2183 : m_base(base) 2184 , m_subscript(subscript) 2185 , m_right(right) 2186 { 2187 } 2188 2189 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2190 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 2191 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2192 virtual Precedence precedence() const { return PrecAssignment; } 2193 2194 protected: 2195 RefPtr<ExpressionNode> m_base; 2196 RefPtr<ExpressionNode> m_subscript; 2197 RefPtr<ExpressionNode> m_right; 2198 }; 2199 2200 class AssignDotNode : public ExpressionNode { 2201 public: 2202 AssignDotNode(ExpressionNode* base, const Identifier& ident, ExpressionNode* right) KJS_FAST_CALL 2203 : m_base(base) 2204 , m_ident(ident) 2205 , m_right(right) 2206 { 2207 } 2208 2209 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2210 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 2211 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2212 virtual Precedence precedence() const { return PrecAssignment; } 2213 2214 protected: 2215 RefPtr<ExpressionNode> m_base; 2216 Identifier m_ident; 2217 RefPtr<ExpressionNode> m_right; 2218 }; 2219 2220 class ReadModifyDotNode : public ExpressionNode { 2221 public: 2222 ReadModifyDotNode(ExpressionNode* base, const Identifier& ident, Operator oper, ExpressionNode* right) KJS_FAST_CALL 2223 : m_base(base) 2224 , m_ident(ident) 2225 , m_operator(oper) 2226 , m_right(right) 2227 { 2228 } 2229 2230 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2231 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 2232 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2233 virtual Precedence precedence() const { return PrecAssignment; } 2234 2235 protected: 2236 RefPtr<ExpressionNode> m_base; 2237 Identifier m_ident; 2238 Operator m_operator; 2239 RefPtr<ExpressionNode> m_right; 2240 }; 2241 2242 class AssignErrorNode : public ExpressionNode { 2243 public: 2244 AssignErrorNode(ExpressionNode* left, Operator oper, ExpressionNode* right) KJS_FAST_CALL 2245 : m_left(left) 2246 , m_operator(oper) 2247 , m_right(right) 2248 { 2249 } 2250 2251 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 2252 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2253 virtual Precedence precedence() const { return PrecAssignment; } 2254 2255 protected: 2256 RefPtr<ExpressionNode> m_left; 2257 Operator m_operator; 2258 RefPtr<ExpressionNode> m_right; 2259 }; 2260 2261 class CommaNode : public ExpressionNode { 2262 public: 2263 CommaNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL 2264 : m_expr1(expr1) 2265 , m_expr2(expr2) 2266 { 2267 m_expr1->optimizeForUnnecessaryResult(); 2268 } 2269 2270 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2271 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 2272 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2273 virtual Precedence precedence() const { return PrecExpression; } 2274 2275 private: 2276 RefPtr<ExpressionNode> m_expr1; 2277 RefPtr<ExpressionNode> m_expr2; 2278 }; 2279 2280 class ConstDeclNode : public ExpressionNode { 2281 public: 2282 ConstDeclNode(const Identifier& ident, ExpressionNode* in) KJS_FAST_CALL; 2283 2284 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2285 virtual KJS::JSValue* evaluate(ExecState*) KJS_FAST_CALL; 2286 void evaluateSingle(ExecState*) KJS_FAST_CALL; 2287 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2288 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 2289 PassRefPtr<ConstDeclNode> releaseNext() KJS_FAST_CALL { return m_next.release(); } 2290 2291 Identifier m_ident; 2292 ListRefPtr<ConstDeclNode> m_next; 2293 RefPtr<ExpressionNode> m_init; 2294 2295 private: 2296 void handleSlowCase(ExecState*, const ScopeChain&, JSValue*) KJS_FAST_CALL NEVER_INLINE; 2297 }; 2298 2299 class ConstStatementNode : public StatementNode { 2300 public: 2301 ConstStatementNode(ConstDeclNode* next) KJS_FAST_CALL 2302 : m_next(next) 2303 { 2304 } 2305 2306 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2307 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2308 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2309 2310 private: 2311 RefPtr<ConstDeclNode> m_next; 2312 }; 2313 2314 typedef Vector<RefPtr<StatementNode> > StatementVector; 2315 2316 class SourceElements : public ParserRefCounted { 2317 public: 2318 void append(PassRefPtr<StatementNode>); 2319 void releaseContentsIntoVector(StatementVector& destination) 2320 { 2321 ASSERT(destination.isEmpty()); 2322 m_statements.swap(destination); 2323 } 2324 2325 private: 2326 StatementVector m_statements; 2327 }; 2328 2329 class BlockNode : public StatementNode { 2330 public: 2331 BlockNode(SourceElements* children) KJS_FAST_CALL; 2332 2333 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2334 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2335 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2336 2337 protected: 2338 StatementVector m_children; 2339 }; 2340 2341 class EmptyStatementNode : public StatementNode { 2342 public: 2343 EmptyStatementNode() KJS_FAST_CALL // debug 2344 { 2345 } 2346 2347 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2348 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2349 virtual bool isEmptyStatement() const KJS_FAST_CALL { return true; } 2350 }; 2351 2352 class ExprStatementNode : public StatementNode { 2353 public: 2354 ExprStatementNode(ExpressionNode* expr) KJS_FAST_CALL 2355 : m_expr(expr) 2356 { 2357 } 2358 2359 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2360 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2361 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2362 2363 private: 2364 RefPtr<ExpressionNode> m_expr; 2365 }; 2366 2367 class VarStatementNode : public StatementNode { 2368 public: 2369 VarStatementNode(ExpressionNode* expr) KJS_FAST_CALL 2370 : m_expr(expr) 2371 { 2372 } 2373 2374 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2375 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2376 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2377 2378 private: 2379 RefPtr<ExpressionNode> m_expr; 2380 }; 2381 2382 class IfNode : public StatementNode { 2383 public: 2384 IfNode(ExpressionNode* condition, StatementNode* ifBlock) KJS_FAST_CALL 2385 : m_condition(condition) 2386 , m_ifBlock(ifBlock) 2387 { 2388 } 2389 2390 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2391 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2392 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2393 2394 protected: 2395 RefPtr<ExpressionNode> m_condition; 2396 RefPtr<StatementNode> m_ifBlock; 2397 }; 2398 2399 class IfElseNode : public IfNode { 2400 public: 2401 IfElseNode(ExpressionNode* condtion, StatementNode* ifBlock, StatementNode* elseBlock) KJS_FAST_CALL 2402 : IfNode(condtion, ifBlock) 2403 , m_elseBlock(elseBlock) 2404 { 2405 } 2406 2407 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2408 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2409 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2410 2411 private: 2412 RefPtr<StatementNode> m_elseBlock; 2413 }; 2414 2415 class DoWhileNode : public StatementNode { 2416 public: 2417 DoWhileNode(StatementNode* statement, ExpressionNode* expr) KJS_FAST_CALL 2418 : m_statement(statement) 2419 , m_expr(expr) 2420 { 2421 } 2422 2423 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2424 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2425 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2426 2427 private: 2428 RefPtr<StatementNode> m_statement; 2429 RefPtr<ExpressionNode> m_expr; 2430 }; 2431 2432 class WhileNode : public StatementNode { 2433 public: 2434 WhileNode(ExpressionNode* expr, StatementNode* statement) KJS_FAST_CALL 2435 : m_expr(expr) 2436 , m_statement(statement) 2437 { 2438 } 2439 2440 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2441 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2442 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2443 2444 private: 2445 RefPtr<ExpressionNode> m_expr; 2446 RefPtr<StatementNode> m_statement; 2447 }; 2448 2449 class ForNode : public StatementNode { 2450 public: 2451 ForNode(ExpressionNode* expr1, ExpressionNode* expr2, ExpressionNode* expr3, StatementNode* statement, bool expr1WasVarDecl) KJS_FAST_CALL 2452 : m_expr1(expr1 ? expr1 : new PlaceholderTrueNode) 2453 , m_expr2(expr2 ? expr2 : new PlaceholderTrueNode) 2454 , m_expr3(expr3 ? expr3 : new PlaceholderTrueNode) 2455 , m_statement(statement) 2456 , m_expr1WasVarDecl(expr1 && expr1WasVarDecl) 2457 { 2458 ASSERT(m_expr1); 2459 ASSERT(m_expr2); 2460 ASSERT(m_expr3); 2461 ASSERT(statement); 2462 2463 m_expr1->optimizeForUnnecessaryResult(); 2464 m_expr3->optimizeForUnnecessaryResult(); 2465 } 2466 2467 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2468 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2469 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2470 2471 private: 2472 RefPtr<ExpressionNode> m_expr1; 2473 RefPtr<ExpressionNode> m_expr2; 2474 RefPtr<ExpressionNode> m_expr3; 2475 RefPtr<StatementNode> m_statement; 2476 bool m_expr1WasVarDecl; 2477 }; 2478 2479 class ForInNode : public StatementNode { 2480 public: 2481 ForInNode(ExpressionNode*, ExpressionNode*, StatementNode*) KJS_FAST_CALL; 2482 ForInNode(const Identifier&, ExpressionNode*, ExpressionNode*, StatementNode*) KJS_FAST_CALL; 2483 2484 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2485 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2486 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2487 2488 private: 2489 Identifier m_ident; 2490 RefPtr<ExpressionNode> m_init; 2491 RefPtr<ExpressionNode> m_lexpr; 2492 RefPtr<ExpressionNode> m_expr; 2493 RefPtr<StatementNode> m_statement; 2494 bool m_identIsVarDecl; 2495 }; 2496 2497 class ContinueNode : public StatementNode { 2498 public: 2499 ContinueNode() KJS_FAST_CALL 2500 { 2501 } 2502 2503 ContinueNode(const Identifier& ident) KJS_FAST_CALL 2504 : m_ident(ident) 2505 { 2506 } 2507 2508 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2509 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2510 2511 private: 2512 Identifier m_ident; 2513 }; 2514 2515 class BreakNode : public StatementNode { 2516 public: 2517 BreakNode() KJS_FAST_CALL 2518 { 2519 } 2520 2521 BreakNode(const Identifier& ident) KJS_FAST_CALL 2522 : m_ident(ident) 2523 { 2524 } 2525 2526 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2527 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2528 2529 private: 2530 Identifier m_ident; 2531 }; 2532 2533 class ReturnNode : public StatementNode { 2534 public: 2535 ReturnNode(ExpressionNode* value) KJS_FAST_CALL 2536 : m_value(value) 2537 { 2538 } 2539 2540 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2541 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2542 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2543 2544 private: 2545 RefPtr<ExpressionNode> m_value; 2546 }; 2547 2548 class WithNode : public StatementNode { 2549 public: 2550 WithNode(ExpressionNode* expr, StatementNode* statement) KJS_FAST_CALL 2551 : m_expr(expr) 2552 , m_statement(statement) 2553 { 2554 } 2555 2556 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2557 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2558 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2559 2560 private: 2561 RefPtr<ExpressionNode> m_expr; 2562 RefPtr<StatementNode> m_statement; 2563 }; 2564 2565 class LabelNode : public StatementNode { 2566 public: 2567 LabelNode(const Identifier& label, StatementNode* statement) KJS_FAST_CALL 2568 : m_label(label) 2569 , m_statement(statement) 1620 2570 { 1621 2571 } 1622 2572 1623 ReadModifyResolveNode(PlacementNewAdoptType) KJS_FAST_CALL1624 : ExpressionNode(PlacementNewAdopt)1625 , m_ident(PlacementNewAdopt)1626 , m_right(PlacementNewAdopt)1627 {1628 }1629 1630 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL;1631 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;1632 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;1633 virtual Precedence precedence() const { return PrecAssignment; }1634 protected:1635 Identifier m_ident;1636 Operator m_oper;1637 RefPtr<ExpressionNode> m_right;1638 size_t m_index; // Used by ReadModifyLocalVarNode.1639 };1640 1641 class ReadModifyLocalVarNode : public ReadModifyResolveNode {1642 public:1643 ReadModifyLocalVarNode(size_t i) KJS_FAST_CALL1644 : ReadModifyResolveNode(PlacementNewAdopt)1645 {1646 ASSERT(i != missingSymbolMarker());1647 m_index = i;1648 }1649 1650 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;1651 };1652 1653 class ReadModifyConstNode : public ReadModifyResolveNode {1654 public:1655 ReadModifyConstNode(size_t i) KJS_FAST_CALL1656 : ReadModifyResolveNode(PlacementNewAdopt)1657 {1658 ASSERT(i != missingSymbolMarker());1659 m_index = i;1660 }1661 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;1662 };1663 1664 class AssignResolveNode : public ExpressionNode {1665 public:1666 AssignResolveNode(const Identifier& ident, ExpressionNode* right) KJS_FAST_CALL1667 : m_ident(ident)1668 , m_right(right)1669 {1670 }1671 1672 AssignResolveNode(PlacementNewAdoptType) KJS_FAST_CALL1673 : ExpressionNode(PlacementNewAdopt)1674 , m_ident(PlacementNewAdopt)1675 , m_right(PlacementNewAdopt)1676 {1677 }1678 1679 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL;1680 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;1681 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;1682 virtual Precedence precedence() const { return PrecAssignment; }1683 protected:1684 Identifier m_ident;1685 RefPtr<ExpressionNode> m_right;1686 size_t m_index; // Used by ReadModifyLocalVarNode.1687 };1688 1689 class AssignLocalVarNode : public AssignResolveNode {1690 public:1691 AssignLocalVarNode(size_t i) KJS_FAST_CALL1692 : AssignResolveNode(PlacementNewAdopt)1693 {1694 ASSERT(i != missingSymbolMarker());1695 m_index = i;1696 }1697 1698 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;1699 };1700 1701 class AssignConstNode : public AssignResolveNode {1702 public:1703 AssignConstNode() KJS_FAST_CALL1704 : AssignResolveNode(PlacementNewAdopt)1705 {1706 }1707 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;1708 };1709 1710 class ReadModifyBracketNode : public ExpressionNode {1711 public:1712 ReadModifyBracketNode(ExpressionNode* base, ExpressionNode* subscript, Operator oper, ExpressionNode* right) KJS_FAST_CALL1713 : m_base(base), m_subscript(subscript), m_oper(oper), m_right(right) { }1714 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL;1715 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;1716 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;1717 virtual Precedence precedence() const { return PrecAssignment; }1718 protected:1719 RefPtr<ExpressionNode> m_base;1720 RefPtr<ExpressionNode> m_subscript;1721 Operator m_oper;1722 RefPtr<ExpressionNode> m_right;1723 };1724 1725 class AssignBracketNode : public ExpressionNode {1726 public:1727 AssignBracketNode(ExpressionNode* base, ExpressionNode* subscript, ExpressionNode* right) KJS_FAST_CALL1728 : m_base(base), m_subscript(subscript), m_right(right) { }1729 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL;1730 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;1731 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;1732 virtual Precedence precedence() const { return PrecAssignment; }1733 protected:1734 RefPtr<ExpressionNode> m_base;1735 RefPtr<ExpressionNode> m_subscript;1736 RefPtr<ExpressionNode> m_right;1737 };1738 1739 class AssignDotNode : public ExpressionNode {1740 public:1741 AssignDotNode(ExpressionNode* base, const Identifier& ident, ExpressionNode* right) KJS_FAST_CALL1742 : m_base(base), m_ident(ident), m_right(right) { }1743 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL;1744 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;1745 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;1746 virtual Precedence precedence() const { return PrecAssignment; }1747 protected:1748 RefPtr<ExpressionNode> m_base;1749 Identifier m_ident;1750 RefPtr<ExpressionNode> m_right;1751 };1752 1753 class ReadModifyDotNode : public ExpressionNode {1754 public:1755 ReadModifyDotNode(ExpressionNode* base, const Identifier& ident, Operator oper, ExpressionNode* right) KJS_FAST_CALL1756 : m_base(base), m_ident(ident), m_oper(oper), m_right(right) { }1757 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL;1758 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;1759 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;1760 virtual Precedence precedence() const { return PrecAssignment; }1761 protected:1762 RefPtr<ExpressionNode> m_base;1763 Identifier m_ident;1764 Operator m_oper;1765 RefPtr<ExpressionNode> m_right;1766 };1767 1768 class AssignErrorNode : public ExpressionNode {1769 public:1770 AssignErrorNode(ExpressionNode* left, Operator oper, ExpressionNode* right) KJS_FAST_CALL1771 : m_left(left), m_oper(oper), m_right(right) { }1772 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;1773 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;1774 virtual Precedence precedence() const { return PrecAssignment; }1775 protected:1776 RefPtr<ExpressionNode> m_left;1777 Operator m_oper;1778 RefPtr<ExpressionNode> m_right;1779 };1780 1781 class CommaNode : public ExpressionNode {1782 public:1783 CommaNode(ExpressionNode* expr1, ExpressionNode* expr2) KJS_FAST_CALL1784 : m_expr1(expr1)1785 , m_expr2(expr2)1786 {1787 m_expr1->optimizeForUnnecessaryResult();1788 }1789 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL;1790 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;1791 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;1792 virtual Precedence precedence() const { return PrecExpression; }1793 private:1794 RefPtr<ExpressionNode> m_expr1;1795 RefPtr<ExpressionNode> m_expr2;1796 };1797 1798 class ConstDeclNode : public ExpressionNode {1799 public:1800 ConstDeclNode(const Identifier& ident, ExpressionNode* in) KJS_FAST_CALL;1801 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL;1802 virtual KJS::JSValue* evaluate(ExecState*) KJS_FAST_CALL;1803 void evaluateSingle(ExecState*) KJS_FAST_CALL;1804 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;1805 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }1806 PassRefPtr<ConstDeclNode> releaseNext() KJS_FAST_CALL { return m_next.release(); }1807 1808 Identifier m_ident;1809 ListRefPtr<ConstDeclNode> m_next;1810 RefPtr<ExpressionNode> m_init;1811 private:1812 void handleSlowCase(ExecState*, const ScopeChain&, JSValue*) KJS_FAST_CALL NEVER_INLINE;1813 };1814 1815 class ConstStatementNode : public StatementNode {1816 public:1817 ConstStatementNode(ConstDeclNode* next) KJS_FAST_CALL1818 : m_next(next) { }1819 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL;1820 virtual JSValue* execute(ExecState*) KJS_FAST_CALL;1821 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;1822 private:1823 RefPtr<ConstDeclNode> m_next;1824 };1825 1826 typedef Vector<RefPtr<StatementNode> > StatementVector;1827 1828 class SourceElements : public ParserRefCounted {1829 public:1830 void append(PassRefPtr<StatementNode>);1831 void releaseContentsIntoVector(StatementVector& destination)1832 {1833 ASSERT(destination.isEmpty());1834 m_statements.swap(destination);1835 }1836 private:1837 StatementVector m_statements;1838 };1839 1840 class BlockNode : public StatementNode {1841 public:1842 BlockNode(SourceElements* children) KJS_FAST_CALL;1843 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL;1844 virtual JSValue* execute(ExecState*) KJS_FAST_CALL;1845 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;1846 protected:1847 StatementVector m_children;1848 };1849 1850 class EmptyStatementNode : public StatementNode {1851 public:1852 EmptyStatementNode() KJS_FAST_CALL { } // debug1853 virtual JSValue* execute(ExecState*) KJS_FAST_CALL;1854 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;1855 virtual bool isEmptyStatement() const KJS_FAST_CALL { return true; }1856 };1857 1858 class ExprStatementNode : public StatementNode {1859 public:1860 ExprStatementNode(ExpressionNode* expr) KJS_FAST_CALL1861 : m_expr(expr) { }1862 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL;1863 virtual JSValue* execute(ExecState*) KJS_FAST_CALL;1864 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;1865 private:1866 RefPtr<ExpressionNode> m_expr;1867 };1868 1869 class VarStatementNode : public StatementNode {1870 public:1871 VarStatementNode(ExpressionNode* e) KJS_FAST_CALL : m_expr(e) { }1872 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL;1873 virtual JSValue* execute(ExecState*) KJS_FAST_CALL;1874 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;1875 private:1876 RefPtr<ExpressionNode> m_expr;1877 };1878 1879 class IfNode : public StatementNode {1880 public:1881 IfNode(ExpressionNode* condition, StatementNode* ifBlock) KJS_FAST_CALL1882 : m_condition(condition), m_ifBlock(ifBlock) { }1883 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL;1884 virtual JSValue* execute(ExecState*) KJS_FAST_CALL;1885 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;1886 protected:1887 RefPtr<ExpressionNode> m_condition;1888 RefPtr<StatementNode> m_ifBlock;1889 };1890 1891 class IfElseNode : public IfNode {1892 public:1893 IfElseNode(ExpressionNode* condtion, StatementNode* ifBlock, StatementNode* elseBlock) KJS_FAST_CALL1894 : IfNode(condtion, ifBlock), m_elseBlock(elseBlock) { }1895 2573 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1896 2574 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 1897 2575 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1898 private: 1899 RefPtr<StatementNode> m_elseBlock; 1900 }; 1901 1902 class DoWhileNode : public StatementNode { 1903 public: 1904 DoWhileNode(StatementNode* statement, ExpressionNode* expr) KJS_FAST_CALL 1905 : m_statement(statement), m_expr(expr) { } 1906 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1907 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 1908 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1909 private: 1910 RefPtr<StatementNode> m_statement; 1911 RefPtr<ExpressionNode> m_expr; 1912 }; 1913 1914 class WhileNode : public StatementNode { 1915 public: 1916 WhileNode(ExpressionNode* expr, StatementNode* statement) KJS_FAST_CALL 1917 : m_expr(expr), m_statement(statement) { } 1918 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1919 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 1920 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1921 private: 1922 RefPtr<ExpressionNode> m_expr; 1923 RefPtr<StatementNode> m_statement; 1924 }; 1925 1926 class ForNode : public StatementNode { 1927 public: 1928 ForNode(ExpressionNode* expr1, ExpressionNode* expr2, ExpressionNode* expr3, StatementNode* statement, bool expr1WasVarDecl) KJS_FAST_CALL 1929 : m_expr1(expr1 ? expr1 : new PlaceholderTrueNode) 1930 , m_expr2(expr2 ? expr2 : new PlaceholderTrueNode) 1931 , m_expr3(expr3 ? expr3 : new PlaceholderTrueNode) 1932 , m_statement(statement) 1933 , m_expr1WasVarDecl(expr1 && expr1WasVarDecl) 1934 { 1935 ASSERT(m_expr1); 1936 ASSERT(m_expr2); 1937 ASSERT(m_expr3); 1938 ASSERT(statement); 1939 1940 m_expr1->optimizeForUnnecessaryResult(); 1941 m_expr3->optimizeForUnnecessaryResult(); 1942 } 1943 1944 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1945 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 1946 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1947 private: 1948 RefPtr<ExpressionNode> m_expr1; 1949 RefPtr<ExpressionNode> m_expr2; 1950 RefPtr<ExpressionNode> m_expr3; 1951 RefPtr<StatementNode> m_statement; 1952 bool m_expr1WasVarDecl; 1953 }; 1954 1955 class ForInNode : public StatementNode { 1956 public: 1957 ForInNode(ExpressionNode*, ExpressionNode*, StatementNode*) KJS_FAST_CALL; 1958 ForInNode(const Identifier&, ExpressionNode*, ExpressionNode*, StatementNode*) KJS_FAST_CALL; 1959 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1960 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 1961 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1962 private: 1963 Identifier m_ident; 1964 RefPtr<ExpressionNode> m_init; 1965 RefPtr<ExpressionNode> m_lexpr; 1966 RefPtr<ExpressionNode> m_expr; 1967 RefPtr<StatementNode> m_statement; 1968 bool m_identIsVarDecl; 1969 }; 1970 1971 class ContinueNode : public StatementNode { 1972 public: 1973 ContinueNode() KJS_FAST_CALL { } 1974 ContinueNode(const Identifier& ident) KJS_FAST_CALL 1975 : m_ident(ident) { } 1976 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 1977 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1978 private: 1979 Identifier m_ident; 1980 }; 1981 1982 class BreakNode : public StatementNode { 1983 public: 1984 BreakNode() KJS_FAST_CALL { } 1985 BreakNode(const Identifier& ident) KJS_FAST_CALL 1986 : m_ident(ident) { } 1987 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 1988 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 1989 private: 1990 Identifier m_ident; 1991 }; 1992 1993 class ReturnNode : public StatementNode { 1994 public: 1995 ReturnNode(ExpressionNode* value) KJS_FAST_CALL 1996 : m_value(value) { } 1997 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 1998 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 1999 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2000 private: 2001 RefPtr<ExpressionNode> m_value; 2002 }; 2003 2004 class WithNode : public StatementNode { 2005 public: 2006 WithNode(ExpressionNode* expr, StatementNode* statement) KJS_FAST_CALL 2007 : m_expr(expr), m_statement(statement) { } 2008 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2009 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2010 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2011 private: 2012 RefPtr<ExpressionNode> m_expr; 2013 RefPtr<StatementNode> m_statement; 2014 }; 2015 2016 class LabelNode : public StatementNode { 2017 public: 2018 LabelNode(const Identifier& label, StatementNode* statement) KJS_FAST_CALL 2019 : m_label(label), m_statement(statement) { } 2020 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2021 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2022 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2023 private: 2024 Identifier m_label; 2025 RefPtr<StatementNode> m_statement; 2026 }; 2027 2028 class ThrowNode : public StatementNode { 2029 public: 2030 ThrowNode(ExpressionNode* expr) KJS_FAST_CALL 2031 : m_expr(expr) { } 2032 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2033 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2034 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2035 private: 2036 RefPtr<ExpressionNode> m_expr; 2037 }; 2038 2039 class TryNode : public StatementNode { 2040 public: 2041 TryNode(StatementNode* tryBlock, const Identifier& exceptionIdent, StatementNode* catchBlock, StatementNode* finallyBlock) KJS_FAST_CALL 2042 : m_tryBlock(tryBlock), m_exceptionIdent(exceptionIdent), m_catchBlock(catchBlock), m_finallyBlock(finallyBlock) { } 2043 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2044 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2045 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2046 private: 2047 RefPtr<StatementNode> m_tryBlock; 2048 Identifier m_exceptionIdent; 2049 RefPtr<StatementNode> m_catchBlock; 2050 RefPtr<StatementNode> m_finallyBlock; 2051 }; 2052 2053 class ParameterNode : public Node { 2054 public: 2055 ParameterNode(const Identifier& ident) KJS_FAST_CALL 2056 : m_ident(ident) { } 2057 ParameterNode(ParameterNode* l, const Identifier& ident) KJS_FAST_CALL 2058 : m_ident(ident) { l->m_next = this; } 2059 Identifier ident() KJS_FAST_CALL { return m_ident; } 2060 ParameterNode *nextParam() KJS_FAST_CALL { return m_next.get(); } 2061 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2062 PassRefPtr<ParameterNode> releaseNext() KJS_FAST_CALL { return m_next.release(); } 2063 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 2064 private: 2065 friend class FuncDeclNode; 2066 friend class FuncExprNode; 2067 Identifier m_ident; 2068 ListRefPtr<ParameterNode> m_next; 2069 }; 2070 2071 class ScopeNode : public BlockNode { 2072 public: 2073 ScopeNode(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; 2074 2075 int sourceId() const KJS_FAST_CALL { return m_sourceId; } 2076 const UString& sourceURL() const KJS_FAST_CALL { return m_sourceURL; } 2077 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2078 2079 protected: 2080 void optimizeVariableAccess(ExecState*) KJS_FAST_CALL; 2081 2082 VarStack m_varStack; 2083 FunctionStack m_functionStack; 2084 2085 private: 2086 UString m_sourceURL; 2087 int m_sourceId; 2088 }; 2089 2090 class ProgramNode : public ScopeNode { 2091 public: 2092 static ProgramNode* create(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; 2093 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2094 2095 private: 2096 ProgramNode(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; 2097 void initializeSymbolTable(ExecState*) KJS_FAST_CALL; 2098 ALWAYS_INLINE void processDeclarations(ExecState*) KJS_FAST_CALL; 2099 2100 Vector<size_t> m_varIndexes; // Storage indexes belonging to the nodes in m_varStack. (Recorded to avoid double lookup.) 2101 Vector<size_t> m_functionIndexes; // Storage indexes belonging to the nodes in m_functionStack. (Recorded to avoid double lookup.) 2102 }; 2103 2104 class EvalNode : public ScopeNode { 2105 public: 2106 static EvalNode* create(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; 2107 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2108 2109 private: 2110 EvalNode(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; 2111 ALWAYS_INLINE void processDeclarations(ExecState*) KJS_FAST_CALL; 2112 }; 2113 2114 class FunctionBodyNode : public ScopeNode { 2115 public: 2116 static FunctionBodyNode* create(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; 2117 2118 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2119 2120 SymbolTable& symbolTable() KJS_FAST_CALL { return m_symbolTable; } 2121 2122 Vector<Identifier>& parameters() KJS_FAST_CALL { return m_parameters; } 2123 UString paramString() const KJS_FAST_CALL; 2124 2125 protected: 2126 FunctionBodyNode(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; 2127 2128 private: 2129 void initializeSymbolTable(ExecState*) KJS_FAST_CALL; 2130 ALWAYS_INLINE void processDeclarations(ExecState*) KJS_FAST_CALL; 2131 2132 bool m_initialized; 2133 Vector<Identifier> m_parameters; 2134 SymbolTable m_symbolTable; 2135 }; 2136 2137 class FuncExprNode : public ExpressionNode { 2138 public: 2139 FuncExprNode(const Identifier& ident, FunctionBodyNode* body, ParameterNode* parameter = 0) KJS_FAST_CALL 2140 : m_ident(ident), m_parameter(parameter), m_body(body) { addParams(); } 2141 virtual JSValue *evaluate(ExecState*) KJS_FAST_CALL; 2142 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2143 virtual Precedence precedence() const { return PrecMember; } 2144 virtual bool needsParensIfLeftmost() const { return true; } 2145 private: 2146 void addParams() KJS_FAST_CALL; 2147 // Used for streamTo 2148 friend class PropertyNode; 2149 Identifier m_ident; 2150 RefPtr<ParameterNode> m_parameter; 2151 RefPtr<FunctionBodyNode> m_body; 2152 }; 2153 2154 class FuncDeclNode : public StatementNode { 2155 public: 2156 FuncDeclNode(const Identifier& ident, FunctionBodyNode* body) KJS_FAST_CALL 2157 : m_ident(ident), m_body(body) { addParams(); } 2158 FuncDeclNode(const Identifier& ident, ParameterNode* parameter, FunctionBodyNode* body) KJS_FAST_CALL 2159 : m_ident(ident), m_parameter(parameter), m_body(body) { addParams(); } 2160 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2161 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2162 ALWAYS_INLINE FunctionImp* makeFunction(ExecState*) KJS_FAST_CALL; 2163 Identifier m_ident; 2164 private: 2165 void addParams() KJS_FAST_CALL; 2166 RefPtr<ParameterNode> m_parameter; 2167 RefPtr<FunctionBodyNode> m_body; 2168 }; 2169 2170 class CaseClauseNode : public Node { 2171 public: 2172 CaseClauseNode(ExpressionNode* e) KJS_FAST_CALL 2173 : m_expr(e) { } 2174 CaseClauseNode(ExpressionNode* e, SourceElements* children) KJS_FAST_CALL 2175 : m_expr(e) { if (children) children->releaseContentsIntoVector(m_children); } 2176 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2177 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2178 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 2179 2180 JSValue* evaluate(ExecState*) KJS_FAST_CALL; 2181 JSValue* executeStatements(ExecState*) KJS_FAST_CALL; 2182 2183 private: 2184 RefPtr<ExpressionNode> m_expr; 2185 StatementVector m_children; 2186 }; 2187 2188 class ClauseListNode : public Node { 2189 public: 2190 ClauseListNode(CaseClauseNode* clause) KJS_FAST_CALL 2191 : m_clause(clause) { } 2192 ClauseListNode(ClauseListNode* clauseList, CaseClauseNode* clause) KJS_FAST_CALL 2193 : m_clause(clause) { clauseList->m_next = this; } 2194 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2195 CaseClauseNode* getClause() const KJS_FAST_CALL { return m_clause.get(); } 2196 ClauseListNode* getNext() const KJS_FAST_CALL { return m_next.get(); } 2197 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2198 PassRefPtr<ClauseListNode> releaseNext() KJS_FAST_CALL { return m_next.release(); } 2199 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 2200 private: 2201 friend class CaseBlockNode; 2202 RefPtr<CaseClauseNode> m_clause; 2203 ListRefPtr<ClauseListNode> m_next; 2204 }; 2205 2206 class CaseBlockNode : public Node { 2207 public: 2208 CaseBlockNode(ClauseListNode* list1, CaseClauseNode* defaultClause, ClauseListNode* list2) KJS_FAST_CALL; 2209 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2210 JSValue* executeBlock(ExecState*, JSValue *input) KJS_FAST_CALL; 2211 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2212 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 2213 private: 2214 RefPtr<ClauseListNode> m_list1; 2215 RefPtr<CaseClauseNode> m_defaultClause; 2216 RefPtr<ClauseListNode> m_list2; 2217 }; 2218 2219 class SwitchNode : public StatementNode { 2220 public: 2221 SwitchNode(ExpressionNode* expr, CaseBlockNode* block) KJS_FAST_CALL 2222 : m_expr(expr), m_block(block) { } 2223 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2224 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2225 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2226 private: 2227 RefPtr<ExpressionNode> m_expr; 2228 RefPtr<CaseBlockNode> m_block; 2229 }; 2576 2577 private: 2578 Identifier m_label; 2579 RefPtr<StatementNode> m_statement; 2580 }; 2581 2582 class ThrowNode : public StatementNode { 2583 public: 2584 ThrowNode(ExpressionNode* expr) KJS_FAST_CALL 2585 : m_expr(expr) 2586 { 2587 } 2588 2589 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2590 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2591 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2592 2593 private: 2594 RefPtr<ExpressionNode> m_expr; 2595 }; 2596 2597 class TryNode : public StatementNode { 2598 public: 2599 TryNode(StatementNode* tryBlock, const Identifier& exceptionIdent, StatementNode* catchBlock, StatementNode* finallyBlock) KJS_FAST_CALL 2600 : m_tryBlock(tryBlock) 2601 , m_exceptionIdent(exceptionIdent) 2602 , m_catchBlock(catchBlock) 2603 , m_finallyBlock(finallyBlock) 2604 { 2605 } 2606 2607 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2608 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2609 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2610 2611 private: 2612 RefPtr<StatementNode> m_tryBlock; 2613 Identifier m_exceptionIdent; 2614 RefPtr<StatementNode> m_catchBlock; 2615 RefPtr<StatementNode> m_finallyBlock; 2616 }; 2617 2618 class ParameterNode : public Node { 2619 public: 2620 ParameterNode(const Identifier& ident) KJS_FAST_CALL 2621 : m_ident(ident) 2622 { 2623 } 2624 2625 ParameterNode(ParameterNode* l, const Identifier& ident) KJS_FAST_CALL 2626 : m_ident(ident) 2627 { 2628 l->m_next = this; 2629 } 2630 2631 Identifier ident() KJS_FAST_CALL { return m_ident; } 2632 ParameterNode *nextParam() KJS_FAST_CALL { return m_next.get(); } 2633 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2634 PassRefPtr<ParameterNode> releaseNext() KJS_FAST_CALL { return m_next.release(); } 2635 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 2636 2637 private: 2638 friend class FuncDeclNode; 2639 friend class FuncExprNode; 2640 Identifier m_ident; 2641 ListRefPtr<ParameterNode> m_next; 2642 }; 2643 2644 class ScopeNode : public BlockNode { 2645 public: 2646 ScopeNode(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; 2647 2648 int sourceId() const KJS_FAST_CALL { return m_sourceId; } 2649 const UString& sourceURL() const KJS_FAST_CALL { return m_sourceURL; } 2650 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2651 2652 protected: 2653 void optimizeVariableAccess(ExecState*) KJS_FAST_CALL; 2654 2655 VarStack m_varStack; 2656 FunctionStack m_functionStack; 2657 2658 private: 2659 UString m_sourceURL; 2660 int m_sourceId; 2661 }; 2662 2663 class ProgramNode : public ScopeNode { 2664 public: 2665 static ProgramNode* create(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; 2666 2667 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2668 2669 private: 2670 ProgramNode(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; 2671 2672 void initializeSymbolTable(ExecState*) KJS_FAST_CALL; 2673 ALWAYS_INLINE void processDeclarations(ExecState*) KJS_FAST_CALL; 2674 2675 Vector<size_t> m_varIndexes; // Storage indexes belonging to the nodes in m_varStack. (Recorded to avoid double lookup.) 2676 Vector<size_t> m_functionIndexes; // Storage indexes belonging to the nodes in m_functionStack. (Recorded to avoid double lookup.) 2677 }; 2678 2679 class EvalNode : public ScopeNode { 2680 public: 2681 static EvalNode* create(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; 2682 2683 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2684 2685 private: 2686 EvalNode(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; 2687 2688 ALWAYS_INLINE void processDeclarations(ExecState*) KJS_FAST_CALL; 2689 }; 2690 2691 class FunctionBodyNode : public ScopeNode { 2692 public: 2693 static FunctionBodyNode* create(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; 2694 2695 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2696 2697 SymbolTable& symbolTable() KJS_FAST_CALL { return m_symbolTable; } 2698 2699 Vector<Identifier>& parameters() KJS_FAST_CALL { return m_parameters; } 2700 UString paramString() const KJS_FAST_CALL; 2701 2702 protected: 2703 FunctionBodyNode(SourceElements*, VarStack*, FunctionStack*) KJS_FAST_CALL; 2704 2705 private: 2706 void initializeSymbolTable(ExecState*) KJS_FAST_CALL; 2707 ALWAYS_INLINE void processDeclarations(ExecState*) KJS_FAST_CALL; 2708 2709 bool m_initialized; 2710 Vector<Identifier> m_parameters; 2711 SymbolTable m_symbolTable; 2712 }; 2713 2714 class FuncExprNode : public ExpressionNode { 2715 public: 2716 FuncExprNode(const Identifier& ident, FunctionBodyNode* body, ParameterNode* parameter = 0) KJS_FAST_CALL 2717 : m_ident(ident) 2718 , m_parameter(parameter) 2719 , m_body(body) 2720 { 2721 addParams(); 2722 } 2723 2724 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL; 2725 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2726 virtual Precedence precedence() const { return PrecMember; } 2727 virtual bool needsParensIfLeftmost() const { return true; } 2728 2729 private: 2730 void addParams() KJS_FAST_CALL; 2731 2732 // Used for streamTo 2733 friend class PropertyNode; 2734 Identifier m_ident; 2735 RefPtr<ParameterNode> m_parameter; 2736 RefPtr<FunctionBodyNode> m_body; 2737 }; 2738 2739 class FuncDeclNode : public StatementNode { 2740 public: 2741 FuncDeclNode(const Identifier& ident, FunctionBodyNode* body) KJS_FAST_CALL 2742 : m_ident(ident) 2743 , m_body(body) 2744 { 2745 addParams(); 2746 } 2747 2748 FuncDeclNode(const Identifier& ident, ParameterNode* parameter, FunctionBodyNode* body) KJS_FAST_CALL 2749 : m_ident(ident) 2750 , m_parameter(parameter) 2751 , m_body(body) 2752 { 2753 addParams(); 2754 } 2755 2756 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2757 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2758 ALWAYS_INLINE FunctionImp* makeFunction(ExecState*) KJS_FAST_CALL; 2759 2760 Identifier m_ident; 2761 2762 private: 2763 void addParams() KJS_FAST_CALL; 2764 2765 RefPtr<ParameterNode> m_parameter; 2766 RefPtr<FunctionBodyNode> m_body; 2767 }; 2768 2769 class CaseClauseNode : public Node { 2770 public: 2771 CaseClauseNode(ExpressionNode* expr) KJS_FAST_CALL 2772 : m_expr(expr) 2773 { 2774 } 2775 2776 CaseClauseNode(ExpressionNode* expr, SourceElements* children) KJS_FAST_CALL 2777 : m_expr(expr) 2778 { 2779 if (children) 2780 children->releaseContentsIntoVector(m_children); 2781 } 2782 2783 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2784 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2785 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 2786 2787 JSValue* evaluate(ExecState*) KJS_FAST_CALL; 2788 JSValue* executeStatements(ExecState*) KJS_FAST_CALL; 2789 2790 private: 2791 RefPtr<ExpressionNode> m_expr; 2792 StatementVector m_children; 2793 }; 2794 2795 class ClauseListNode : public Node { 2796 public: 2797 ClauseListNode(CaseClauseNode* clause) KJS_FAST_CALL 2798 : m_clause(clause) 2799 { 2800 } 2801 2802 ClauseListNode(ClauseListNode* clauseList, CaseClauseNode* clause) KJS_FAST_CALL 2803 : m_clause(clause) 2804 { 2805 clauseList->m_next = this; 2806 } 2807 2808 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2809 CaseClauseNode* getClause() const KJS_FAST_CALL { return m_clause.get(); } 2810 ClauseListNode* getNext() const KJS_FAST_CALL { return m_next.get(); } 2811 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2812 PassRefPtr<ClauseListNode> releaseNext() KJS_FAST_CALL { return m_next.release(); } 2813 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 2814 2815 private: 2816 friend class CaseBlockNode; 2817 RefPtr<CaseClauseNode> m_clause; 2818 ListRefPtr<ClauseListNode> m_next; 2819 }; 2820 2821 class CaseBlockNode : public Node { 2822 public: 2823 CaseBlockNode(ClauseListNode* list1, CaseClauseNode* defaultClause, ClauseListNode* list2) KJS_FAST_CALL; 2824 2825 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2826 JSValue* executeBlock(ExecState*, JSValue *input) KJS_FAST_CALL; 2827 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2828 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; } 2829 2830 private: 2831 RefPtr<ClauseListNode> m_list1; 2832 RefPtr<CaseClauseNode> m_defaultClause; 2833 RefPtr<ClauseListNode> m_list2; 2834 }; 2835 2836 class SwitchNode : public StatementNode { 2837 public: 2838 SwitchNode(ExpressionNode* expr, CaseBlockNode* block) KJS_FAST_CALL 2839 : m_expr(expr) 2840 , m_block(block) 2841 { 2842 } 2843 2844 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2845 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2846 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2847 2848 private: 2849 RefPtr<ExpressionNode> m_expr; 2850 RefPtr<CaseBlockNode> m_block; 2851 }; 2230 2852 2231 2853 class BreakpointCheckStatement : public StatementNode { 2232 2854 public: 2233 2855 BreakpointCheckStatement(PassRefPtr<StatementNode>) KJS_FAST_CALL; 2856 2234 2857 virtual JSValue* execute(ExecState*) KJS_FAST_CALL; 2235 2858 virtual void streamTo(SourceStream&) const KJS_FAST_CALL; 2236 2859 virtual void optimizeVariableAccess(const SymbolTable&, const LocalStorage&, NodeStack&) KJS_FAST_CALL; 2860 2237 2861 private: 2238 2862 RefPtr<StatementNode> m_statement; 2239 2863 }; 2240 2864 2241 struct ElementList {2242 ElementNode* head;2243 ElementNode* tail;2244 };2245 2246 struct PropertyList {2247 PropertyListNode* head;2248 PropertyListNode* tail;2249 };2250 2251 struct ArgumentList {2252 ArgumentListNode* head;2253 ArgumentListNode* tail;2254 };2255 2256 struct ConstDeclList {2257 ConstDeclNode* head;2258 ConstDeclNode* tail;2259 };2260 2261 struct ParameterList {2262 ParameterNode* head;2263 ParameterNode* tail;2264 };2265 2266 struct ClauseList {2267 ClauseListNode* head;2268 ClauseListNode* tail;2269 };2865 struct ElementList { 2866 ElementNode* head; 2867 ElementNode* tail; 2868 }; 2869 2870 struct PropertyList { 2871 PropertyListNode* head; 2872 PropertyListNode* tail; 2873 }; 2874 2875 struct ArgumentList { 2876 ArgumentListNode* head; 2877 ArgumentListNode* tail; 2878 }; 2879 2880 struct ConstDeclList { 2881 ConstDeclNode* head; 2882 ConstDeclNode* tail; 2883 }; 2884 2885 struct ParameterList { 2886 ParameterNode* head; 2887 ParameterNode* tail; 2888 }; 2889 2890 struct ClauseList { 2891 ClauseListNode* head; 2892 ClauseListNode* tail; 2893 }; 2270 2894 2271 2895 } // namespace KJS
Note:
See TracChangeset
for help on using the changeset viewer.