Skip to content

Commit

Permalink
polystat#165: changed todo formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
includealex committed Sep 22, 2022
1 parent f1f09eb commit e40b73a
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 13,997 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/org/polystat/j2eo/eotree/EOMetaObjects.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import arrow.core.Option
*/
fun EOSeqCall(vararg statements: EOCopy): EOBndExpr = EOSeqCall(statements.toList())

// TODO: maybe expand list type from List<EOCopy> to List<EOExpr>?
// @todo #165:90m maybe we should expand list type from List<EOCopy> to List<EOExpr>?
/**
* Generator of seq > @ blocks.
*/
Expand Down
22 changes: 13 additions & 9 deletions src/main/kotlin/org/polystat/j2eo/translator/Expressions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ fun mapParenthesized(expr: Parenthesized, name: String, context: Context): List<
) + mapExpression(expr.expression, parExprName, context)
}

// TODO: add support for type
// @todo #165:90m Support for type should be added
fun mapThis(expr: This, name: String, context: Context): EOBndExpr {
return EOBndExpr(
EOObject(
Expand Down Expand Up @@ -290,8 +290,12 @@ fun mapUnaryPostfix(expr: UnaryPostfix, name: String, context: Context): List<EO
) + mapExpression(expr.operand, operandName, context)
}

// TODO: add automatic casting for primitive types
// TODO: populate with all Java binary operators
// @todo #165:90m Add automatic casting for primitive types

// @todo #165:90m Populate with all Java binary operators

// @todo #165:90m in val function double check is needed for some TokenCodes:
// NonEqual, DoubleVertical, DoubleAmpersand, Ampersand, Vertical, Caret
fun mapBinary(expr: Binary, name: String, context: Context): List<EOBndExpr> {
val function = when (expr.operator) {
TokenCode.Plus -> "add"
Expand All @@ -315,14 +319,14 @@ fun mapBinary(expr: Binary, name: String, context: Context): List<EOBndExpr> {
TokenCode.LeftShiftAssign -> "shift_l_equal"
TokenCode.ArithmRightShift -> "shift_u"
TokenCode.ArithmRightShiftAssign -> "shift_u_equal"
TokenCode.NonEqual -> "not_eq" /* TODO: double check */
TokenCode.DoubleVertical -> "or" /* TODO: double check */
TokenCode.DoubleAmpersand -> "and" /* TODO: double check */
TokenCode.Ampersand -> "bit_and" /* TODO: double check */
TokenCode.Vertical -> "bit_or" /* TODO: double check */
TokenCode.NonEqual -> "not_eq"
TokenCode.DoubleVertical -> "or"
TokenCode.DoubleAmpersand -> "and"
TokenCode.Ampersand -> "bit_and"
TokenCode.Vertical -> "bit_or"
TokenCode.VerticalAssign -> "or_write" /* FIXME */
TokenCode.AmpersandAssign -> "and_write" /* FIXME */
TokenCode.Caret -> "bit_xor" /* TODO: double check */
TokenCode.Caret -> "bit_xor"
else ->
"binary_op_placeholder" // FIXME
// throw IllegalArgumentException("Binary operation ${expr.operator} is not supported")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fun trueMethodInvocationName(name: String): List<String> {
}
}

// TODO: create state object to store binding of expression
// @todo #165:90m Create state object to store binding of expression
fun mapMethodInvocation(methodInvocation: MethodInvocation, name: String, context: Context): List<EOBndExpr> {
// require(!methodInvocation.superSign) { "Super sign isn't supported yet" }
/* FIXME (NOW PARTIALLY SUPPORTED) */
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/org/polystat/j2eo/translator/Statements.kt
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ fun mapIfThenElseStatement(rn: IfThenElse, name: String, context: Context): List
*
* conditionExpr and statement are mapped into separate objects.
*
* TODO: check if we can use iterator inside of statement.
*/

// @todo #165:90m We should check if we can use iterator inside of statement
fun mapWhileStatement(wh: While, name: String, context: Context): List<EOBndExpr> {
val emptyName = context.genUniqueEntityName("empty")
val condName = context.genUniqueEntityName(wh.condition)
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/polystat/j2eo/translator/Translator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class Translator(val relativePath: Path) {
" is not supported"
)
}

// @todo #165:30m We should add license to EOLicense()
fun mapPackage(pkg: Package, context: Context): EOProgram {
return EOProgram(
EOLicense(), // TODO: add license?
EOLicense(),
EOMetas(
Some(pkg.compoundName.names.joinToString(".")),
ArrayList()
Expand Down
9 changes: 6 additions & 3 deletions src/main/kotlin/org/polystat/j2eo/treeMapper/TreeMappings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ fun TypeDeclarationContext.toTopLevelComponent(): TopLevelComponent? =
null // throw java.lang.Exception("Cannot translate") // FIXME
}

// @todo #165:90m We should implement this.typeList(1) for PERMITS (Java 17)
fun ClassDeclarationContext.toClassDeclaration(): ClassDeclaration =
NormalClassDeclaration(
identifier().toToken(),
typeParameters()?.toTypeParameters(),
typeType()?.toType(),
typeList(0)?.toTypeList(), // TODO: use this.typeList(1) for PERMITS (Java 17)
typeList(0)?.toTypeList(),
classBody().toDeclarations()
)

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

// @todo #165:90m return Block(null, ...). Is it always null?
fun BlockContext.toBlock(): Block {
val blockStmntsLst = ArrayList(this.blockStatement().map { it.toBlockStatement() })
val blockStmnts = BlockStatements(blockStmntsLst.removeFirstOrNull())
blockStmntsLst.forEach { blockStmnts.add(it) }
blockStmnts.blockStatements.removeIf { it == null }
return Block(null /* TODO: always null? */, blockStmnts)
return Block(null, blockStmnts)
}

fun Declaration.toBlockStatement(): BlockStatement = BlockStatement(this)
Expand Down Expand Up @@ -465,6 +467,7 @@ fun ArgumentsContext.toArgList(): ArgumentList {
}
}

// @todo #165:60m Maybe type arguments are somewhere else?
fun MethodCallContext.toExpression(expr: Expression?): Expression {
val exprLst = if (expressionList() == null)
listOf()
Expand All @@ -476,7 +479,7 @@ fun MethodCallContext.toExpression(expr: Expression?): Expression {
return MethodInvocation(
expr,
SUPER() != null,
null, // TODO: type arguments are somewhere else
null,
identifier()?.toToken()
?: if (SUPER() != null) { Token(TokenCode.Super, "super") } else { null }
?: if (THIS() != null) { Token(TokenCode.This, "this") } else { null },
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/polystat/j2eo/util/Naming.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ fun String.eoClassName(): String = genClassName(this)
fun genClassName(javaName: String): String =
"class__$javaName"

// TODO: introduce logic considering packages and classes
// @todo #165:90m introduce logic considering packages and classes
fun CompoundName.eoClassCompoundName(): CompoundName =
CompoundName(names.dropLast(1) + names.last().eoClassName())
5 changes: 3 additions & 2 deletions src/main/kotlin/org/polystat/j2eo/util/StaticGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ import tree.Declaration.NormalClassDeclaration
/**
* Maps all static class members to EO bindings, skipping non-static ones.
*/
// @todo #165:90m dec is ClassDeclaration is not always true
fun generateStatic(clsDec: NormalClassDeclaration, context: Context): List<EOBndExpr> {
return clsDec.body.declarations
.filter { dec: Declaration ->
dec.modifiers?.modifiers?.modifiers?.find { it == TokenCode.Static } != null ||
dec is ConstructorDeclaration ||
dec is ClassDeclaration /* FIXME (IT'S NOT ALWAYS TRUE) */
} // TODO
dec is ClassDeclaration
}
.map { mapClassDeclaration(it, context) }
.flatten()
}

0 comments on commit e40b73a

Please sign in to comment.