1 package net.sourceforge.jenesis4java;
2
3 /*
4 * #%L
5 * Jenesis 4 Java Code Generator
6 * %%
7 * Copyright (C) 2000 - 2015 jenesis4java
8 * %%
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as
11 * published by the Free Software Foundation, either version 3 of the
12 * License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Lesser Public License for more details.
18 *
19 * You should have received a copy of the GNU General Lesser Public
20 * License along with this program. If not, see
21 * <http://www.gnu.org/licenses/lgpl-3.0.html>.
22 * #L%
23 */
24
25 import java.util.Comparator;
26 import java.util.List;
27
28 /**
29 * Copyright (C) 2008, 2010 Richard van Nieuwenhoven - ritchie [at] gmx [dot] at
30 * Copyright (C) 2000, 2001 Paul Cody Johnston - pcj@inxar.org <br>
31 * This file is part of Jenesis4java. Jenesis4java is free software: you can
32 * redistribute it and/or modify it under the terms of the GNU Lesser General
33 * Public License as published by the Free Software Foundation, either version 3
34 * of the License, or (at your option) any later version.<br>
35 * Jenesis4java is distributed in the hope that it will be useful, but WITHOUT
36 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
37 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
38 * details.<br>
39 * You should have received a copy of the GNU Lesser General Public License
40 * along with Jenesis4java. If not, see <http://www.gnu.org/licenses/>.
41 */
42 /**
43 * The {@code Block} superinterface. A {@code Block} is a structure that holds
44 * Statements and typically delimited by braces. {@code Block} acts as a factory
45 * for all {@code Statement} objects.
46 */
47 public interface Block extends Codeable {
48
49 /**
50 * Gets the list of statements as an list of {@code Statement}.
51 */
52 List<Statement> getStatements();
53
54 /**
55 * Insert the expression at the specified index.
56 *
57 * @return the newly created {@link Statement}
58 */
59 Statement insertStatement(int index, Expression expression);
60
61 /**
62 * Insert the statement at the specified index.
63 */
64 void insertStatement(int index, Statement statement);
65
66 /**
67 * Adds a new {@code Break} statement to this block and returns it.
68 */
69 Break newBreak();
70
71 /**
72 * Adds a new {@code Continue} statement to this block and returns it.
73 */
74 Continue newContinue();
75
76 /**
77 * Adds a new {@code Let} statement to declaration section of this block for
78 * the given type and returns it.
79 */
80 Let newDeclarationLet(Type type);
81
82 /**
83 * Adds a new {@code DoWhile} statement to this block and returns it.
84 */
85 DoWhile newDoWhile(Expression predicate);
86
87 /**
88 * Adds a new {@code Empty} statement to this block and returns it.
89 */
90 Empty newEmpty();
91
92 /**
93 * Adds a new {@code For} statement to this block and returns it.
94 */
95 For newFor();
96
97 /**
98 * Adds a new {@code If} statement to this block and returns it.
99 */
100 If newIf(Expression predicate);
101
102 /**
103 * Adds a new {@code Let} statement to this block for the given type and
104 * returns it.
105 */
106 Let newLet(Type type);
107
108 /**
109 * Adds a new {@code LocalBlock} statement to this block and returns it.
110 */
111 LocalBlock newLocalBlock();
112
113 /**
114 * Adds a new {@code LocalClass} statement to this block and returns it.
115 */
116 LocalClass newLocalClass(String name);
117
118 /**
119 * Adds a new {@code LocalClass} statement to this block and returns it.
120 */
121 LocalClass newLocalClass(String name, Comparator comparator);
122
123 /**
124 * Adds a new {@code Return} statement to this block and returns it.
125 */
126 Return newReturn();
127
128 /**
129 * Adds a new {@code ExpressionStatement} statement to this block on the
130 * given statement {@code Expression} and returns it.
131 */
132 ExpressionStatement newStmt(Expression expr);
133
134 /**
135 * Adds a new {@code Switch} statement to this block and returns it.
136 */
137 Switch newSwitch(Expression integer);
138
139 /**
140 * Adds a new {@code Synchronized} statement to this block and returns it.
141 */
142 Synchronized newSynchronized(Expression mutex);
143
144 /**
145 * Adds a new {@code Throw} statement to this block and returns it.
146 */
147 Throw newThrow(Expression throwable);
148
149 /**
150 * Adds a new {@code Try} statement to this block and returns it.
151 */
152 Try newTry();
153
154 /**
155 * Adds a new {@code While} statement to this block and returns it.
156 */
157 While newWhile(Expression predicate);
158
159 /**
160 * removes a statement from the statement list.
161 */
162 void removeStmt(Statement statement);
163 }