diff --git a/src/org/jetbrains/jet/j2k/ast/ForeachStatement.java b/src/org/jetbrains/jet/j2k/ast/ForeachStatement.java deleted file mode 100644 index 431dcf4168e..00000000000 --- a/src/org/jetbrains/jet/j2k/ast/ForeachStatement.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2010-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.jet.j2k.ast; - -import org.jetbrains.annotations.NotNull; - -/** - * @author ignatov - */ -public class ForeachStatement extends Statement { - private final Parameter myVariable; - private final Expression myExpression; - private final Statement myStatement; - - public ForeachStatement(Parameter variable, Expression expression, Statement statement) { - myVariable = variable; - myExpression = expression; - myStatement = statement; - } - - @NotNull - @Override - public String toKotlin() { - return "for" + SPACE + "(" + myVariable.toKotlin() + SPACE + IN + SPACE + myExpression.toKotlin() + ")" + N + - myStatement.toKotlin(); - } -} diff --git a/src/org/jetbrains/jet/j2k/ast/ForeachWithRangeStatement.java b/src/org/jetbrains/jet/j2k/ast/ForeachWithRangeStatement.java deleted file mode 100644 index 57d085bce34..00000000000 --- a/src/org/jetbrains/jet/j2k/ast/ForeachWithRangeStatement.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2010-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.jet.j2k.ast; - -import org.jetbrains.annotations.NotNull; - -/** - * @author ignatov - */ -public class ForeachWithRangeStatement extends Statement { - private final Expression myStart; - private final Identifier myIdentifier; - private final Expression myEnd; - private final Statement myBody; - - public ForeachWithRangeStatement(Identifier identifier, Expression start, Expression end, Statement body) { - myStart = start; - myIdentifier = identifier; - myEnd = end; - myBody = body; - } - - @NotNull - @Override - public String toKotlin() { - return "for" + SPACE + "(" + - myIdentifier.toKotlin() + SPACE + "in" + SPACE + myStart.toKotlin() + ".." + myEnd.toKotlin() + - ")" + SPACE + - myBody.toKotlin(); - } -} diff --git a/src/org/jetbrains/jet/j2k/ast/IfStatement.kt b/src/org/jetbrains/jet/j2k/ast/IfStatement.kt deleted file mode 100644 index 65915e24c49..00000000000 --- a/src/org/jetbrains/jet/j2k/ast/IfStatement.kt +++ /dev/null @@ -1,13 +0,0 @@ -package org.jetbrains.jet.j2k.ast - - -public open class IfStatement(val condition: Expression, val thenStatement: Statement, val elseStatement: Statement): Expression() { - public override fun toKotlin(): String { - val result: String = "if (" + condition.toKotlin() + ")\n" + thenStatement.toKotlin() + "\n" - if (elseStatement != Statement.EMPTY_STATEMENT) { - return result + "else\n" + elseStatement.toKotlin() - } - - return result - } -} diff --git a/src/org/jetbrains/jet/j2k/ast/Statements.kt b/src/org/jetbrains/jet/j2k/ast/Statements.kt index dd68b37cc25..8ada7925a2a 100644 --- a/src/org/jetbrains/jet/j2k/ast/Statements.kt +++ b/src/org/jetbrains/jet/j2k/ast/Statements.kt @@ -28,6 +28,17 @@ public open class ReturnStatement(val expression: Expression): Statement() { public override fun toKotlin() = "return " + expression.toKotlin() } +public open class IfStatement(val condition: Expression, val thenStatement: Statement, val elseStatement: Statement): Expression() { + public override fun toKotlin(): String { + val result: String = "if (" + condition.toKotlin() + ")\n" + thenStatement.toKotlin() + "\n" + if (elseStatement != Statement.EMPTY_STATEMENT) { + return result + "else\n" + elseStatement.toKotlin() + } + + return result + } +} + // Loops -------------------------------------------------------------------------------------------------- public open class WhileStatement(val condition: Expression, val statement: Statement): Statement() { @@ -38,6 +49,21 @@ public open class DoWhileStatement(condition: Expression, statement: Statement): public override fun toKotlin() = "do\n" + statement.toKotlin() + "\nwhile (" + condition.toKotlin() + ")" } +public open class ForeachStatement(val variable: Parameter, + val expression: Expression, + val statement: Statement): Statement() { + public override fun toKotlin() = "for (" + variable.toKotlin() + " in " + + expression.toKotlin() + ")\n" + statement.toKotlin() +} + +public open class ForeachWithRangeStatement(val identifier: Identifier, + val start: Expression, + val end: Expression, + val body: Statement): Statement() { + public override fun toKotlin() = "for (" + identifier.toKotlin() + " in " + + start.toKotlin() + ".." + end.toKotlin() + ") " + body.toKotlin() +} + public open class BreakStatement(val label: Identifier = Identifier.EMPTY_IDENTIFIER) : Statement() { public override fun toKotlin() = "break" + label.withPrefix("@") }