blob: c750e6b03c383cd87ea1de45a83bd9911f534057 [file] [log] [blame]
karlklose@chromium.org44bc7082011-04-11 12:33:05 +00001// Copyright 2011 the V8 project authors. All rights reserved.
vegorov@chromium.orgdff694e2010-05-17 09:10:26 +00002// 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
kasperl@chromium.orga5551262010-12-07 12:49:48 +000028#ifndef V8_AST_INL_H_
29#define V8_AST_INL_H_
30
vegorov@chromium.orgdff694e2010-05-17 09:10:26 +000031#include "v8.h"
32
33#include "ast.h"
fschneider@chromium.orgfb144a02011-05-04 12:43:48 +000034#include "scopes.h"
vegorov@chromium.orgdff694e2010-05-17 09:10:26 +000035
36namespace v8 {
37namespace internal {
38
vegorov@chromium.orgdff694e2010-05-17 09:10:26 +000039
rossberg@chromium.org717967f2011-07-20 13:44:42 +000040SwitchStatement::SwitchStatement(Isolate* isolate,
41 ZoneStringList* labels)
42 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS),
vegorov@chromium.orgdff694e2010-05-17 09:10:26 +000043 tag_(NULL), cases_(NULL) {
44}
45
46
rossberg@chromium.org717967f2011-07-20 13:44:42 +000047Block::Block(Isolate* isolate,
48 ZoneStringList* labels,
49 int capacity,
50 bool is_initializer_block)
51 : BreakableStatement(isolate, labels, TARGET_FOR_NAMED_ONLY),
vegorov@chromium.orgdff694e2010-05-17 09:10:26 +000052 statements_(capacity),
53 is_initializer_block_(is_initializer_block) {
54}
55
56
rossberg@chromium.org717967f2011-07-20 13:44:42 +000057BreakableStatement::BreakableStatement(Isolate* isolate,
58 ZoneStringList* labels,
59 Type type)
kasperl@chromium.orga5551262010-12-07 12:49:48 +000060 : labels_(labels),
61 type_(type),
rossberg@chromium.org717967f2011-07-20 13:44:42 +000062 entry_id_(GetNextId(isolate)),
63 exit_id_(GetNextId(isolate)) {
kasperl@chromium.orga5551262010-12-07 12:49:48 +000064 ASSERT(labels == NULL || labels->length() > 0);
65}
66
67
rossberg@chromium.org717967f2011-07-20 13:44:42 +000068IterationStatement::IterationStatement(Isolate* isolate, ZoneStringList* labels)
69 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS),
kasperl@chromium.orga5551262010-12-07 12:49:48 +000070 body_(NULL),
karlklose@chromium.org44bc7082011-04-11 12:33:05 +000071 continue_target_(),
rossberg@chromium.org717967f2011-07-20 13:44:42 +000072 osr_entry_id_(GetNextId(isolate)) {
kasperl@chromium.orga5551262010-12-07 12:49:48 +000073}
74
75
rossberg@chromium.org717967f2011-07-20 13:44:42 +000076DoWhileStatement::DoWhileStatement(Isolate* isolate, ZoneStringList* labels)
77 : IterationStatement(isolate, labels),
kasperl@chromium.orga5551262010-12-07 12:49:48 +000078 cond_(NULL),
79 condition_position_(-1),
rossberg@chromium.org717967f2011-07-20 13:44:42 +000080 continue_id_(GetNextId(isolate)),
81 back_edge_id_(GetNextId(isolate)) {
kasperl@chromium.orga5551262010-12-07 12:49:48 +000082}
83
84
rossberg@chromium.org717967f2011-07-20 13:44:42 +000085WhileStatement::WhileStatement(Isolate* isolate, ZoneStringList* labels)
86 : IterationStatement(isolate, labels),
kasperl@chromium.orga5551262010-12-07 12:49:48 +000087 cond_(NULL),
ager@chromium.org5f0c45f2010-12-17 08:51:21 +000088 may_have_function_literal_(true),
rossberg@chromium.org717967f2011-07-20 13:44:42 +000089 body_id_(GetNextId(isolate)) {
kasperl@chromium.orga5551262010-12-07 12:49:48 +000090}
91
92
rossberg@chromium.org717967f2011-07-20 13:44:42 +000093ForStatement::ForStatement(Isolate* isolate, ZoneStringList* labels)
94 : IterationStatement(isolate, labels),
vegorov@chromium.orgdff694e2010-05-17 09:10:26 +000095 init_(NULL),
96 cond_(NULL),
97 next_(NULL),
98 may_have_function_literal_(true),
kasperl@chromium.orga5551262010-12-07 12:49:48 +000099 loop_variable_(NULL),
rossberg@chromium.org717967f2011-07-20 13:44:42 +0000100 continue_id_(GetNextId(isolate)),
101 body_id_(GetNextId(isolate)) {
vegorov@chromium.orgdff694e2010-05-17 09:10:26 +0000102}
103
104
rossberg@chromium.org717967f2011-07-20 13:44:42 +0000105ForInStatement::ForInStatement(Isolate* isolate, ZoneStringList* labels)
106 : IterationStatement(isolate, labels),
107 each_(NULL),
108 enumerable_(NULL),
109 assignment_id_(GetNextId(isolate)) {
vegorov@chromium.orgdff694e2010-05-17 09:10:26 +0000110}
111
112
danno@chromium.org4d3fe4e2011-03-10 10:14:28 +0000113bool FunctionLiteral::strict_mode() const {
114 return scope()->is_strict_mode();
115}
116
117
vegorov@chromium.orgdff694e2010-05-17 09:10:26 +0000118} } // namespace v8::internal
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000119
120#endif // V8_AST_INL_H_