Skip to content

Commit 6ec8735

Browse files
committed
#162: conflicts resolving
2 parents 904a975 + caad833 commit 6ec8735

File tree

9 files changed

+33
-17
lines changed

9 files changed

+33
-17
lines changed

src/main/kotlin/org/polystat/j2eo/eotree/EOMetaObjects.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import arrow.core.Option
1212
*/
1313
fun EOSeqCall(vararg statements: EOCopy): EOBndExpr = EOSeqCall(statements.toList())
1414

15-
// TODO: maybe expand list type from List<EOCopy> to List<EOExpr>?
15+
// @todo #165:90m maybe we should expand list type from List<EOCopy> to List<EOExpr>?
1616
/**
1717
* Generator of seq > @ blocks.
1818
*/

src/main/kotlin/org/polystat/j2eo/translator/Expressions.kt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ fun mapParenthesized(expr: Parenthesized, name: String, context: Context): List<
181181
) + mapExpression(expr.expression, parExprName, context)
182182
}
183183

184-
// addition of support for type
184+
// @todo #165:90m Support for type should be added
185185
fun mapThis(expr: This, name: String, context: Context): EOBndExpr {
186186
return EOBndExpr(
187187
EOObject(
@@ -290,8 +290,13 @@ fun mapUnaryPostfix(expr: UnaryPostfix, name: String, context: Context): List<EO
290290
) + mapExpression(expr.operand, operandName, context)
291291
}
292292

293-
// Addition of automatic casting for primitive types is needed
294-
// population with all Java binary operators is needed
293+
// @todo #165:90m Add automatic casting for primitive types
294+
295+
// @todo #165:90m Populate with all Java binary operators
296+
297+
// @todo #165:90m in val function double check is needed for some TokenCodes:
298+
// NonEqual, DoubleVertical, DoubleAmpersand, Ampersand, Vertical, Caret
299+
295300
fun mapBinary(expr: Binary, name: String, context: Context): List<EOBndExpr> {
296301
val function = when (expr.operator) {
297302
TokenCode.Plus -> "add"
@@ -315,14 +320,14 @@ fun mapBinary(expr: Binary, name: String, context: Context): List<EOBndExpr> {
315320
TokenCode.LeftShiftAssign -> "shift_l_equal"
316321
TokenCode.ArithmRightShift -> "shift_u"
317322
TokenCode.ArithmRightShiftAssign -> "shift_u_equal"
318-
TokenCode.NonEqual -> "not_eq" /* double check is needed */
319-
TokenCode.DoubleVertical -> "or" /* double check is needed */
320-
TokenCode.DoubleAmpersand -> "and" /* double check is needed */
321-
TokenCode.Ampersand -> "bit_and" /* double check is needed */
322-
TokenCode.Vertical -> "bit_or" /* double check is needed */
323+
TokenCode.NonEqual -> "not_eq"
324+
TokenCode.DoubleVertical -> "or"
325+
TokenCode.DoubleAmpersand -> "and"
326+
TokenCode.Ampersand -> "bit_and"
327+
TokenCode.Vertical -> "bit_or"
323328
TokenCode.VerticalAssign -> "or_write" /* FIXME */
324329
TokenCode.AmpersandAssign -> "and_write" /* FIXME */
325-
TokenCode.Caret -> "bit_xor" /* double check is needed */
330+
TokenCode.Caret -> "bit_xor"
326331
else ->
327332
"binary_op_placeholder" // FIXME
328333
// throw IllegalArgumentException("Binary operation ${expr.operator} is not supported")

src/main/kotlin/org/polystat/j2eo/translator/MethodInvocations.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fun trueMethodInvocationName(name: String): List<String> {
7070
}
7171
}
7272

73-
// Creation of state object to store binding of expression is needed
73+
// @todo #165:90m Create state object to store binding of expression
7474
fun mapMethodInvocation(methodInvocation: MethodInvocation, name: String, context: Context): List<EOBndExpr> {
7575
// require(!methodInvocation.superSign) { "Super sign isn't supported yet" }
7676
/* FIXME (NOW PARTIALLY SUPPORTED) */

src/main/kotlin/org/polystat/j2eo/translator/Statements.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,9 @@ fun mapIfThenElseStatement(rn: IfThenElse, name: String, context: Context): List
185185
*
186186
* conditionExpr and statement are mapped into separate objects.
187187
*
188-
* We should check if we can use iterator inside of statement.
189188
*/
189+
190+
// @todo #165:90m We should check if we can use iterator inside of statement
190191
fun mapWhileStatement(wh: While, name: String, context: Context): List<EOBndExpr> {
191192
val emptyName = context.genUniqueEntityName("empty")
192193
val condName = context.genUniqueEntityName(wh.condition)

src/main/kotlin/org/polystat/j2eo/translator/Translator.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ class Translator(val relativePath: Path) {
2929
" is not supported"
3030
)
3131
}
32-
32+
// @todo #165:30m We should add license to EOLicense()
3333
fun mapPackage(pkg: Package, context: Context): EOProgram {
3434
return EOProgram(
35-
EOLicense(), // is license added?
35+
EOLicense(),
3636
EOMetas(
3737
Some(pkg.compoundName.names.joinToString(".")),
3838
ArrayList()

src/main/kotlin/org/polystat/j2eo/treeMapper/TreeMappings.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ fun TypeDeclarationContext.toTopLevelComponent(): TopLevelComponent? =
3838
null // throw java.lang.Exception("Cannot translate") // FIXME
3939
}
4040

41+
// @todo #165:90m We should implement this.typeList(1) for PERMITS (Java 17)
4142
fun ClassDeclarationContext.toClassDeclaration(): ClassDeclaration =
4243
NormalClassDeclaration(
4344
identifier().toToken(),
4445
typeParameters()?.toTypeParameters(),
4546
typeType()?.toType(),
46-
typeList(0)?.toTypeList(), // TODO: use this.typeList(1) for PERMITS (Java 17)
47+
typeList(0)?.toTypeList(),
4748
classBody().toDeclarations()
4849
)
4950

@@ -187,12 +188,17 @@ fun TypeTypeOrVoidContext.toType(): Type? = typeType()?.toType()
187188
fun BlockContext.toDeclaration(isStatic: TerminalNode?): List<Declaration> =
188189
listOf(ClassInitializer(this.toBlock(), isStatic != null))
189190

191+
// @todo #165:90m return Block(null, ...). Is it always null?
190192
fun BlockContext.toBlock(): Block {
191193
val blockStmntsLst = ArrayList(this.blockStatement().map { it.toBlockStatement() })
192194
val blockStmnts = BlockStatements(blockStmntsLst.removeFirstOrNull())
193195
blockStmntsLst.forEach { blockStmnts.add(it) }
194196
blockStmnts.blockStatements.removeIf { it == null }
197+
<<<<<<< HEAD
195198
return Block(null /*not always null? */, blockStmnts)
199+
=======
200+
return Block(null, blockStmnts)
201+
>>>>>>> master
196202
}
197203

198204
fun Declaration.toBlockStatement(): BlockStatement = BlockStatement(this)
@@ -465,6 +471,7 @@ fun ArgumentsContext.toArgList(): ArgumentList {
465471
}
466472
}
467473

474+
// @todo #165:60m Maybe type arguments are somewhere else?
468475
fun MethodCallContext.toExpression(expr: Expression?): Expression {
469476
val exprLst = if (expressionList() == null)
470477
listOf()
@@ -476,7 +483,7 @@ fun MethodCallContext.toExpression(expr: Expression?): Expression {
476483
return MethodInvocation(
477484
expr,
478485
SUPER() != null,
479-
null, // TODO: type arguments are somewhere else
486+
null,
480487
identifier()?.toToken()
481488
?: if (SUPER() != null) { Token(TokenCode.Super, "super") } else { null }
482489
?: if (THIS() != null) { Token(TokenCode.This, "this") } else { null },

src/main/kotlin/org/polystat/j2eo/util/Naming.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ fun String.eoClassName(): String = genClassName(this)
77
fun genClassName(javaName: String): String =
88
"class__$javaName"
99

10-
// We should introduce logic considering packages and classes
10+
// @todo #165:90m introduce logic considering packages and classes
1111
fun CompoundName.eoClassCompoundName(): CompoundName =
1212
CompoundName(names.dropLast(1) + names.last().eoClassName())

src/main/kotlin/org/polystat/j2eo/util/StaticGenerator.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ import tree.Declaration.NormalClassDeclaration
1313
/**
1414
* Maps all static class members to EO bindings, skipping non-static ones.
1515
*/
16+
// @todo #165:90m dec is ClassDeclaration is not always true
1617
fun generateStatic(clsDec: NormalClassDeclaration, context: Context): List<EOBndExpr> {
1718
return clsDec.body.declarations
1819
.filter { dec: Declaration ->
1920
dec.modifiers?.modifiers?.modifiers?.find { it == TokenCode.Static } != null ||
2021
dec is ConstructorDeclaration ||
2122
dec is ClassDeclaration /* FIXME (IT'S NOT ALWAYS TRUE) */
23+
dec is ClassDeclaration
2224
}
2325
.map { mapClassDeclaration(it, context) }
2426
.flatten()

src/test/resources/test_ready/ch_8_classes/sec_8_4_method_declarations/sec_8_4_3_method_modifiers/sec_8_4_3_4_native_methods/SampleTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @todo #165:90m method() is left for the future
12
public class SimpleNativeMethod {
23

34
static native void method();

0 commit comments

Comments
 (0)