blob: 731ad2ff3f2a8468ade4204ca5a78243ce1fa56c [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),
whesse@chromium.org4acdc2c2011-08-15 13:01:23 +000053 is_initializer_block_(is_initializer_block),
54 block_scope_(NULL) {
vegorov@chromium.orgdff694e2010-05-17 09:10:26 +000055}
56
57
rossberg@chromium.org717967f2011-07-20 13:44:42 +000058BreakableStatement::BreakableStatement(Isolate* isolate,
59 ZoneStringList* labels,
60 Type type)
kasperl@chromium.orga5551262010-12-07 12:49:48 +000061 : labels_(labels),
62 type_(type),
rossberg@chromium.org717967f2011-07-20 13:44:42 +000063 entry_id_(GetNextId(isolate)),
64 exit_id_(GetNextId(isolate)) {
kasperl@chromium.orga5551262010-12-07 12:49:48 +000065 ASSERT(labels == NULL || labels->length() > 0);
66}
67
68
rossberg@chromium.org717967f2011-07-20 13:44:42 +000069IterationStatement::IterationStatement(Isolate* isolate, ZoneStringList* labels)
70 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS),
kasperl@chromium.orga5551262010-12-07 12:49:48 +000071 body_(NULL),
karlklose@chromium.org44bc7082011-04-11 12:33:05 +000072 continue_target_(),
rossberg@chromium.org717967f2011-07-20 13:44:42 +000073 osr_entry_id_(GetNextId(isolate)) {
kasperl@chromium.orga5551262010-12-07 12:49:48 +000074}
75
76
rossberg@chromium.org717967f2011-07-20 13:44:42 +000077DoWhileStatement::DoWhileStatement(Isolate* isolate, ZoneStringList* labels)
78 : IterationStatement(isolate, labels),
kasperl@chromium.orga5551262010-12-07 12:49:48 +000079 cond_(NULL),
80 condition_position_(-1),
rossberg@chromium.org717967f2011-07-20 13:44:42 +000081 continue_id_(GetNextId(isolate)),
82 back_edge_id_(GetNextId(isolate)) {
kasperl@chromium.orga5551262010-12-07 12:49:48 +000083}
84
85
rossberg@chromium.org717967f2011-07-20 13:44:42 +000086WhileStatement::WhileStatement(Isolate* isolate, ZoneStringList* labels)
87 : IterationStatement(isolate, labels),
kasperl@chromium.orga5551262010-12-07 12:49:48 +000088 cond_(NULL),
ager@chromium.org5f0c45f2010-12-17 08:51:21 +000089 may_have_function_literal_(true),
rossberg@chromium.org717967f2011-07-20 13:44:42 +000090 body_id_(GetNextId(isolate)) {
kasperl@chromium.orga5551262010-12-07 12:49:48 +000091}
92
93
rossberg@chromium.org717967f2011-07-20 13:44:42 +000094ForStatement::ForStatement(Isolate* isolate, ZoneStringList* labels)
95 : IterationStatement(isolate, labels),
vegorov@chromium.orgdff694e2010-05-17 09:10:26 +000096 init_(NULL),
97 cond_(NULL),
98 next_(NULL),
99 may_have_function_literal_(true),
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000100 loop_variable_(NULL),
rossberg@chromium.org717967f2011-07-20 13:44:42 +0000101 continue_id_(GetNextId(isolate)),
102 body_id_(GetNextId(isolate)) {
vegorov@chromium.orgdff694e2010-05-17 09:10:26 +0000103}
104
105
rossberg@chromium.org717967f2011-07-20 13:44:42 +0000106ForInStatement::ForInStatement(Isolate* isolate, ZoneStringList* labels)
107 : IterationStatement(isolate, labels),
108 each_(NULL),
109 enumerable_(NULL),
110 assignment_id_(GetNextId(isolate)) {
vegorov@chromium.orgdff694e2010-05-17 09:10:26 +0000111}
112
113
danno@chromium.org4d3fe4e2011-03-10 10:14:28 +0000114bool FunctionLiteral::strict_mode() const {
115 return scope()->is_strict_mode();
116}
117
118
vegorov@chromium.orgdff694e2010-05-17 09:10:26 +0000119} } // namespace v8::internal
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000120
121#endif // V8_AST_INL_H_