Home | History | Annotate | Download | only in src
      1 // Copyright 2011 the V8 project authors. All rights reserved.
      2 // Redistribution and use in source and binary forms, with or without
      3 // modification, are permitted provided that the following conditions are
      4 // met:
      5 //
      6 //     * Redistributions of source code must retain the above copyright
      7 //       notice, this list of conditions and the following disclaimer.
      8 //     * Redistributions in binary form must reproduce the above
      9 //       copyright notice, this list of conditions and the following
     10 //       disclaimer in the documentation and/or other materials provided
     11 //       with the distribution.
     12 //     * Neither the name of Google Inc. nor the names of its
     13 //       contributors may be used to endorse or promote products derived
     14 //       from this software without specific prior written permission.
     15 //
     16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 
     28 #ifndef V8_AST_INL_H_
     29 #define V8_AST_INL_H_
     30 
     31 #include "v8.h"
     32 
     33 #include "ast.h"
     34 
     35 namespace v8 {
     36 namespace internal {
     37 
     38 
     39 SwitchStatement::SwitchStatement(ZoneStringList* labels)
     40     : BreakableStatement(labels, TARGET_FOR_ANONYMOUS),
     41       tag_(NULL), cases_(NULL) {
     42 }
     43 
     44 
     45 Block::Block(ZoneStringList* labels, int capacity, bool is_initializer_block)
     46     : BreakableStatement(labels, TARGET_FOR_NAMED_ONLY),
     47       statements_(capacity),
     48       is_initializer_block_(is_initializer_block) {
     49 }
     50 
     51 
     52 BreakableStatement::BreakableStatement(ZoneStringList* labels, Type type)
     53     : labels_(labels),
     54       type_(type),
     55       entry_id_(GetNextId()),
     56       exit_id_(GetNextId()) {
     57   ASSERT(labels == NULL || labels->length() > 0);
     58 }
     59 
     60 
     61 IterationStatement::IterationStatement(ZoneStringList* labels)
     62     : BreakableStatement(labels, TARGET_FOR_ANONYMOUS),
     63       body_(NULL),
     64       continue_target_(),
     65       osr_entry_id_(GetNextId()) {
     66 }
     67 
     68 
     69 DoWhileStatement::DoWhileStatement(ZoneStringList* labels)
     70     : IterationStatement(labels),
     71       cond_(NULL),
     72       condition_position_(-1),
     73       continue_id_(GetNextId()),
     74       back_edge_id_(GetNextId()) {
     75 }
     76 
     77 
     78 WhileStatement::WhileStatement(ZoneStringList* labels)
     79     : IterationStatement(labels),
     80       cond_(NULL),
     81       may_have_function_literal_(true),
     82       body_id_(GetNextId()) {
     83 }
     84 
     85 
     86 ForStatement::ForStatement(ZoneStringList* labels)
     87     : IterationStatement(labels),
     88       init_(NULL),
     89       cond_(NULL),
     90       next_(NULL),
     91       may_have_function_literal_(true),
     92       loop_variable_(NULL),
     93       continue_id_(GetNextId()),
     94       body_id_(GetNextId()) {
     95 }
     96 
     97 
     98 ForInStatement::ForInStatement(ZoneStringList* labels)
     99     : IterationStatement(labels), each_(NULL), enumerable_(NULL),
    100       assignment_id_(GetNextId()) {
    101 }
    102 
    103 
    104 bool FunctionLiteral::strict_mode() const {
    105   return scope()->is_strict_mode();
    106 }
    107 
    108 
    109 } }  // namespace v8::internal
    110 
    111 #endif  // V8_AST_INL_H_
    112