|
@@ -36,6 +36,7 @@ public class JavaStatementVisitor implements StatementVisitor<Boolean> {
|
36
|
36
|
|
37
|
37
|
@Override
|
38
|
38
|
public Boolean visitBlock(BlockStatement statement) {
|
|
39
|
+ javaWriter.position(statement.position.fromLine);
|
39
|
40
|
Boolean returns = false;
|
40
|
41
|
for (Statement statement1 : statement.statements) {
|
41
|
42
|
returns = statement1.accept(this);
|
|
@@ -45,18 +46,21 @@ public class JavaStatementVisitor implements StatementVisitor<Boolean> {
|
45
|
46
|
|
46
|
47
|
@Override
|
47
|
48
|
public Boolean visitBreak(BreakStatement statement) {
|
|
49
|
+ javaWriter.position(statement.position.fromLine);
|
48
|
50
|
javaWriter.goTo(javaWriter.getNamedLabel(statement.target.label + "_end"));
|
49
|
51
|
return false;
|
50
|
52
|
}
|
51
|
53
|
|
52
|
54
|
@Override
|
53
|
55
|
public Boolean visitContinue(ContinueStatement statement) {
|
|
56
|
+ javaWriter.position(statement.position.fromLine);
|
54
|
57
|
javaWriter.goTo(javaWriter.getNamedLabel(statement.target.label + "_start"));
|
55
|
58
|
return false;
|
56
|
59
|
}
|
57
|
60
|
|
58
|
61
|
@Override
|
59
|
62
|
public Boolean visitDoWhile(DoWhileStatement statement) {
|
|
63
|
+ javaWriter.position(statement.position.fromLine);
|
60
|
64
|
Label start = new Label();
|
61
|
65
|
Label end = new Label();
|
62
|
66
|
if (statement.label == null)
|
|
@@ -82,12 +86,14 @@ public class JavaStatementVisitor implements StatementVisitor<Boolean> {
|
82
|
86
|
|
83
|
87
|
@Override
|
84
|
88
|
public Boolean visitExpression(ExpressionStatement statement) {
|
|
89
|
+ javaWriter.position(statement.position.fromLine);
|
85
|
90
|
statement.expression.accept(nonPushingExpressionVisitor);
|
86
|
91
|
return false;
|
87
|
92
|
}
|
88
|
93
|
|
89
|
94
|
@Override
|
90
|
95
|
public Boolean visitForeach(ForeachStatement statement) {
|
|
96
|
+ javaWriter.position(statement.position.fromLine);
|
91
|
97
|
//Create Labels
|
92
|
98
|
Label start = new Label();
|
93
|
99
|
Label end = new Label();
|
|
@@ -147,6 +153,7 @@ public class JavaStatementVisitor implements StatementVisitor<Boolean> {
|
147
|
153
|
|
148
|
154
|
@Override
|
149
|
155
|
public Boolean visitIf(IfStatement statement) {
|
|
156
|
+ javaWriter.position(statement.position.fromLine);
|
150
|
157
|
statement.condition.accept(expressionVisitor);
|
151
|
158
|
Label onElse = null;
|
152
|
159
|
Label end = new Label();
|
|
@@ -171,9 +178,15 @@ public class JavaStatementVisitor implements StatementVisitor<Boolean> {
|
171
|
178
|
public Boolean visitLock(LockStatement statement) {
|
172
|
179
|
return false;
|
173
|
180
|
}
|
174
|
|
-
|
|
181
|
+
|
|
182
|
+ @Override
|
|
183
|
+ public Boolean visitInvalid(InvalidStatement statement) {
|
|
184
|
+ throw new UnsupportedOperationException("Invalid Statement: " + statement.message);
|
|
185
|
+ }
|
|
186
|
+
|
175
|
187
|
@Override
|
176
|
188
|
public Boolean visitReturn(ReturnStatement statement) {
|
|
189
|
+ javaWriter.position(statement.position.fromLine);
|
177
|
190
|
statement.value.accept(expressionVisitor);
|
178
|
191
|
javaWriter.returnType(context.getType(statement.value.type));
|
179
|
192
|
return true;
|
|
@@ -181,6 +194,7 @@ public class JavaStatementVisitor implements StatementVisitor<Boolean> {
|
181
|
194
|
|
182
|
195
|
@Override
|
183
|
196
|
public Boolean visitSwitch(SwitchStatement statement) {
|
|
197
|
+ javaWriter.position(statement.position.fromLine);
|
184
|
198
|
|
185
|
199
|
final Label start = new Label();
|
186
|
200
|
final Label end = new Label();
|
|
@@ -246,6 +260,7 @@ public class JavaStatementVisitor implements StatementVisitor<Boolean> {
|
246
|
260
|
|
247
|
261
|
@Override
|
248
|
262
|
public Boolean visitThrow(ThrowStatement statement) {
|
|
263
|
+ javaWriter.position(statement.position.fromLine);
|
249
|
264
|
statement.value.accept(expressionVisitor);
|
250
|
265
|
javaWriter.aThrow();
|
251
|
266
|
return false;
|
|
@@ -253,6 +268,7 @@ public class JavaStatementVisitor implements StatementVisitor<Boolean> {
|
253
|
268
|
|
254
|
269
|
@Override
|
255
|
270
|
public Boolean visitTryCatch(TryCatchStatement statement) {
|
|
271
|
+ javaWriter.position(statement.position.fromLine);
|
256
|
272
|
final Label tryCatchStart = new Label();
|
257
|
273
|
final Label tryFinish = new Label();
|
258
|
274
|
final Label tryCatchFinish = new Label();
|
|
@@ -304,6 +320,7 @@ public class JavaStatementVisitor implements StatementVisitor<Boolean> {
|
304
|
320
|
|
305
|
321
|
@Override
|
306
|
322
|
public Boolean visitVar(VarStatement statement) {
|
|
323
|
+ javaWriter.position(statement.position.fromLine);
|
307
|
324
|
if (statement.initializer != null) {
|
308
|
325
|
statement.initializer.accept(expressionVisitor);
|
309
|
326
|
}
|
|
@@ -322,6 +339,7 @@ public class JavaStatementVisitor implements StatementVisitor<Boolean> {
|
322
|
339
|
|
323
|
340
|
@Override
|
324
|
341
|
public Boolean visitWhile(WhileStatement statement) {
|
|
342
|
+ javaWriter.position(statement.position.fromLine);
|
325
|
343
|
Label start = new Label();
|
326
|
344
|
Label end = new Label();
|
327
|
345
|
|