blob: 6021fd9047be59f82f07a355509caaa1c177f6f2 [file] [log] [blame]
Kristian Monsen25f61362010-05-21 11:50:48 +01001// Copyright 2010 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
Ben Murdochb0fe1622011-05-05 13:52:32 +010028#ifndef V8_AST_INL_H_
29#define V8_AST_INL_H_
30
Kristian Monsen25f61362010-05-21 11:50:48 +010031#include "v8.h"
32
33#include "ast.h"
Ben Murdochb0fe1622011-05-05 13:52:32 +010034#include "jump-target-inl.h"
Kristian Monsen25f61362010-05-21 11:50:48 +010035
36namespace v8 {
37namespace internal {
38
Kristian Monsen25f61362010-05-21 11:50:48 +010039
40SwitchStatement::SwitchStatement(ZoneStringList* labels)
41 : BreakableStatement(labels, TARGET_FOR_ANONYMOUS),
42 tag_(NULL), cases_(NULL) {
43}
44
45
Kristian Monsen25f61362010-05-21 11:50:48 +010046Block::Block(ZoneStringList* labels, int capacity, bool is_initializer_block)
47 : BreakableStatement(labels, TARGET_FOR_NAMED_ONLY),
48 statements_(capacity),
49 is_initializer_block_(is_initializer_block) {
50}
51
52
Ben Murdochb0fe1622011-05-05 13:52:32 +010053BreakableStatement::BreakableStatement(ZoneStringList* labels, Type type)
54 : labels_(labels),
55 type_(type),
56 entry_id_(GetNextId()),
57 exit_id_(GetNextId()) {
58 ASSERT(labels == NULL || labels->length() > 0);
59}
60
61
62IterationStatement::IterationStatement(ZoneStringList* labels)
63 : BreakableStatement(labels, TARGET_FOR_ANONYMOUS),
64 body_(NULL),
65 continue_target_(JumpTarget::BIDIRECTIONAL),
66 osr_entry_id_(GetNextId()) {
67}
68
69
70DoWhileStatement::DoWhileStatement(ZoneStringList* labels)
71 : IterationStatement(labels),
72 cond_(NULL),
73 condition_position_(-1),
74 continue_id_(GetNextId()),
75 back_edge_id_(GetNextId()) {
76}
77
78
79WhileStatement::WhileStatement(ZoneStringList* labels)
80 : IterationStatement(labels),
81 cond_(NULL),
82 may_have_function_literal_(true),
83 body_id_(GetNextId()) {
84}
85
86
Kristian Monsen25f61362010-05-21 11:50:48 +010087ForStatement::ForStatement(ZoneStringList* labels)
88 : IterationStatement(labels),
89 init_(NULL),
90 cond_(NULL),
91 next_(NULL),
92 may_have_function_literal_(true),
Ben Murdochb0fe1622011-05-05 13:52:32 +010093 loop_variable_(NULL),
94 continue_id_(GetNextId()),
95 body_id_(GetNextId()) {
Kristian Monsen25f61362010-05-21 11:50:48 +010096}
97
98
99ForInStatement::ForInStatement(ZoneStringList* labels)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100100 : IterationStatement(labels), each_(NULL), enumerable_(NULL),
101 assignment_id_(GetNextId()) {
Kristian Monsen25f61362010-05-21 11:50:48 +0100102}
103
104
Steve Block44f0eee2011-05-26 01:26:41 +0100105bool FunctionLiteral::strict_mode() const {
106 return scope()->is_strict_mode();
107}
108
109
Kristian Monsen25f61362010-05-21 11:50:48 +0100110} } // namespace v8::internal
Ben Murdochb0fe1622011-05-05 13:52:32 +0100111
112#endif // V8_AST_INL_H_