| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 #include "ast.h" | 30 #include "ast.h" |
| 31 #include "parser.h" | 31 #include "parser.h" |
| 32 #include "scopes.h" | 32 #include "scopes.h" |
| 33 #include "string-stream.h" | 33 #include "string-stream.h" |
| 34 #include "type-info.h" | 34 #include "type-info.h" |
| 35 | 35 |
| 36 namespace v8 { | 36 namespace v8 { |
| 37 namespace internal { | 37 namespace internal { |
| 38 | 38 |
| 39 AstSentinels::AstSentinels() | |
| 40 : this_proxy_(Isolate::Current(), true), | |
| 41 identifier_proxy_(Isolate::Current(), false), | |
| 42 valid_left_hand_side_sentinel_(Isolate::Current()), | |
| 43 this_property_(Isolate::Current(), &this_proxy_, NULL, 0), | |
| 44 call_sentinel_(Isolate::Current(), NULL, NULL, 0) { | |
| 45 } | |
| 46 | |
| 47 | |
| 48 // ---------------------------------------------------------------------------- | 39 // ---------------------------------------------------------------------------- |
| 49 // All the Accept member functions for each syntax tree node type. | 40 // All the Accept member functions for each syntax tree node type. |
| 50 | 41 |
| 51 void Slot::Accept(AstVisitor* v) { v->VisitSlot(this); } | |
| 52 | |
| 53 #define DECL_ACCEPT(type) \ | 42 #define DECL_ACCEPT(type) \ |
| 54 void type::Accept(AstVisitor* v) { v->Visit##type(this); } | 43 void type::Accept(AstVisitor* v) { v->Visit##type(this); } |
| 55 AST_NODE_LIST(DECL_ACCEPT) | 44 AST_NODE_LIST(DECL_ACCEPT) |
| 56 #undef DECL_ACCEPT | 45 #undef DECL_ACCEPT |
| 57 | 46 |
| 58 | 47 |
| 59 // ---------------------------------------------------------------------------- | 48 // ---------------------------------------------------------------------------- |
| 60 // Implementation of other node functionality. | 49 // Implementation of other node functionality. |
| 61 | 50 |
| 62 Assignment* ExpressionStatement::StatementAsSimpleAssignment() { | 51 Assignment* ExpressionStatement::StatementAsSimpleAssignment() { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 var_(NULL), | 83 var_(NULL), |
| 95 is_this_(is_this), | 84 is_this_(is_this), |
| 96 inside_with_(inside_with), | 85 inside_with_(inside_with), |
| 97 is_trivial_(false), | 86 is_trivial_(false), |
| 98 position_(position) { | 87 position_(position) { |
| 99 // Names must be canonicalized for fast equality checks. | 88 // Names must be canonicalized for fast equality checks. |
| 100 ASSERT(name->IsSymbol()); | 89 ASSERT(name->IsSymbol()); |
| 101 } | 90 } |
| 102 | 91 |
| 103 | 92 |
| 104 VariableProxy::VariableProxy(Isolate* isolate, bool is_this) | |
| 105 : Expression(isolate), | |
| 106 var_(NULL), | |
| 107 is_this_(is_this), | |
| 108 inside_with_(false), | |
| 109 is_trivial_(false) { | |
| 110 } | |
| 111 | |
| 112 | |
| 113 void VariableProxy::BindTo(Variable* var) { | 93 void VariableProxy::BindTo(Variable* var) { |
| 114 ASSERT(var_ == NULL); // must be bound only once | 94 ASSERT(var_ == NULL); // must be bound only once |
| 115 ASSERT(var != NULL); // must bind | 95 ASSERT(var != NULL); // must bind |
| 116 ASSERT((is_this() && var->is_this()) || name_.is_identical_to(var->name())); | 96 ASSERT((is_this() && var->is_this()) || name_.is_identical_to(var->name())); |
| 117 // Ideally CONST-ness should match. However, this is very hard to achieve | 97 // Ideally CONST-ness should match. However, this is very hard to achieve |
| 118 // because we don't know the exact semantics of conflicting (const and | 98 // because we don't know the exact semantics of conflicting (const and |
| 119 // non-const) multiple variable declarations, const vars introduced via | 99 // non-const) multiple variable declarations, const vars introduced via |
| 120 // eval() etc. Const-ness and variable declarations are a complete mess | 100 // eval() etc. Const-ness and variable declarations are a complete mess |
| 121 // in JS. Sigh... | 101 // in JS. Sigh... |
| 122 var_ = var; | 102 var_ = var; |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 return proxy()->var()->IsStackAllocated() && fun() == NULL; | 387 return proxy()->var()->IsStackAllocated() && fun() == NULL; |
| 408 } | 388 } |
| 409 | 389 |
| 410 | 390 |
| 411 bool TargetCollector::IsInlineable() const { | 391 bool TargetCollector::IsInlineable() const { |
| 412 UNREACHABLE(); | 392 UNREACHABLE(); |
| 413 return false; | 393 return false; |
| 414 } | 394 } |
| 415 | 395 |
| 416 | 396 |
| 417 bool Slot::IsInlineable() const { | |
| 418 UNREACHABLE(); | |
| 419 return false; | |
| 420 } | |
| 421 | |
| 422 | |
| 423 bool ForInStatement::IsInlineable() const { | 397 bool ForInStatement::IsInlineable() const { |
| 424 return false; | 398 return false; |
| 425 } | 399 } |
| 426 | 400 |
| 427 | 401 |
| 428 bool WithStatement::IsInlineable() const { | 402 bool WithStatement::IsInlineable() const { |
| 429 return false; | 403 return false; |
| 430 } | 404 } |
| 431 | 405 |
| 432 | 406 |
| 433 bool ExitContextStatement::IsInlineable() const { | |
| 434 return false; | |
| 435 } | |
| 436 | |
| 437 | |
| 438 bool SwitchStatement::IsInlineable() const { | 407 bool SwitchStatement::IsInlineable() const { |
| 439 return false; | 408 return false; |
| 440 } | 409 } |
| 441 | 410 |
| 442 | 411 |
| 443 bool TryStatement::IsInlineable() const { | 412 bool TryStatement::IsInlineable() const { |
| 444 return false; | 413 return false; |
| 445 } | 414 } |
| 446 | 415 |
| 447 | 416 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 bool ThisFunction::IsInlineable() const { | 449 bool ThisFunction::IsInlineable() const { |
| 481 return false; | 450 return false; |
| 482 } | 451 } |
| 483 | 452 |
| 484 | 453 |
| 485 bool SharedFunctionInfoLiteral::IsInlineable() const { | 454 bool SharedFunctionInfoLiteral::IsInlineable() const { |
| 486 return false; | 455 return false; |
| 487 } | 456 } |
| 488 | 457 |
| 489 | 458 |
| 490 bool ValidLeftHandSideSentinel::IsInlineable() const { | |
| 491 UNREACHABLE(); | |
| 492 return false; | |
| 493 } | |
| 494 | |
| 495 | |
| 496 bool ForStatement::IsInlineable() const { | 459 bool ForStatement::IsInlineable() const { |
| 497 return (init() == NULL || init()->IsInlineable()) | 460 return (init() == NULL || init()->IsInlineable()) |
| 498 && (cond() == NULL || cond()->IsInlineable()) | 461 && (cond() == NULL || cond()->IsInlineable()) |
| 499 && (next() == NULL || next()->IsInlineable()) | 462 && (next() == NULL || next()->IsInlineable()) |
| 500 && body()->IsInlineable(); | 463 && body()->IsInlineable(); |
| 501 } | 464 } |
| 502 | 465 |
| 503 | 466 |
| 504 bool WhileStatement::IsInlineable() const { | 467 bool WhileStatement::IsInlineable() const { |
| 505 return cond()->IsInlineable() | 468 return cond()->IsInlineable() |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 } | 522 } |
| 560 | 523 |
| 561 | 524 |
| 562 bool Conditional::IsInlineable() const { | 525 bool Conditional::IsInlineable() const { |
| 563 return condition()->IsInlineable() && then_expression()->IsInlineable() && | 526 return condition()->IsInlineable() && then_expression()->IsInlineable() && |
| 564 else_expression()->IsInlineable(); | 527 else_expression()->IsInlineable(); |
| 565 } | 528 } |
| 566 | 529 |
| 567 | 530 |
| 568 bool VariableProxy::IsInlineable() const { | 531 bool VariableProxy::IsInlineable() const { |
| 569 return var()->is_global() || var()->IsStackAllocated(); | 532 return var()->IsUnallocated() || var()->IsStackAllocated(); |
| 570 } | 533 } |
| 571 | 534 |
| 572 | 535 |
| 573 bool Assignment::IsInlineable() const { | 536 bool Assignment::IsInlineable() const { |
| 574 return target()->IsInlineable() && value()->IsInlineable(); | 537 return target()->IsInlineable() && value()->IsInlineable(); |
| 575 } | 538 } |
| 576 | 539 |
| 577 | 540 |
| 578 bool Property::IsInlineable() const { | 541 bool Property::IsInlineable() const { |
| 579 return obj()->IsInlineable() && key()->IsInlineable(); | 542 return obj()->IsInlineable() && key()->IsInlineable(); |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 int pos) | 1169 int pos) |
| 1207 : label_(label), | 1170 : label_(label), |
| 1208 statements_(statements), | 1171 statements_(statements), |
| 1209 position_(pos), | 1172 position_(pos), |
| 1210 compare_type_(NONE), | 1173 compare_type_(NONE), |
| 1211 compare_id_(AstNode::GetNextId(isolate)), | 1174 compare_id_(AstNode::GetNextId(isolate)), |
| 1212 entry_id_(AstNode::GetNextId(isolate)) { | 1175 entry_id_(AstNode::GetNextId(isolate)) { |
| 1213 } | 1176 } |
| 1214 | 1177 |
| 1215 } } // namespace v8::internal | 1178 } } // namespace v8::internal |
| OLD | NEW |