Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed May 25, 2022
2 parents 616f79e + 70e741d commit 675dcf2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 33 deletions.
20 changes: 10 additions & 10 deletions src/main/java/translator/Blocks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ import tree.Statement.BlockStatement
*/
fun mapBlock(block: Block,
name: String? = null,
additionalStmt: Pair<String, List<EOBndExpr>>? = null): List<EOBndExpr> {
firstStmts: List<Pair<String, List<EOBndExpr>>>? = null,
lastStmts: List<Pair<String, List<EOBndExpr>>>? = null): List<EOBndExpr> {
if (name != null) {
return listOf(
EOBndExpr(
EOObject(
listOf(),
None,
mapBlock(block, additionalStmt = additionalStmt)
mapBlock(block, firstStmts = firstStmts, lastStmts = lastStmts)
),
name
)
Expand All @@ -35,24 +36,23 @@ fun mapBlock(block: Block,
EOBndExpr(
EOCopy(
"seq",
if (additionalStmt != null) {
listOf(additionalStmt.first.eoDot())
} else {
listOf()
} +
(firstStmts?.map { it.first.eoDot() } ?: listOf()) +
if (parsedStatements.isNotEmpty())
parsedStatements.keys.map { it.eoDot() }
else {
if (additionalStmt == null) {
if (firstStmts == null && lastStmts == null) {
listOf("TRUE".eoDot())
} else {
listOf()
}
}
} +
(lastStmts?.map { it.first.eoDot() } ?: listOf())
),
"@"
)
) + (additionalStmt?.second ?: listOf()) + parsedStatements.values.toList().flatten()
) + (firstStmts?.map { it.second }?.flatten() ?: listOf()) +
parsedStatements.values.toList().flatten() +
(lastStmts?.map { it.second }?.flatten() ?: listOf())
}


Expand Down
4 changes: 2 additions & 2 deletions src/main/java/translator/MethodInvocations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ fun mapMethodInvocation(methodInvocation: MethodInvocation, name: String): List<
if (methodQualifier.compoundName.names.size > 0)
methodQualifier.compoundName.names.eoDot()
else
"this".eoDot()
if (!methodInvocation.superSign) "this".eoDot() else listOf("this", "super").eoDot()
is FieldAccess -> getFullIdentifier(methodQualifier).eoDot()
null -> "this".eoDot()
null -> if (!methodInvocation.superSign) "this".eoDot() else listOf("this", "super").eoDot()
else -> {
util.logger.warn { "Unsupported method qualifier $methodQualifier; falling back to unsupported_qualifier" }
"unsupported_qualifier".eoDot()
Expand Down
45 changes: 25 additions & 20 deletions src/main/java/translator/Methods.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@ import tree.Declaration.ConstructorDeclaration
import tree.Declaration.MethodDeclaration
import tree.Declaration.ParameterDeclaration

fun genInit(): EOBndExpr =
EOBndExpr(
EOObject(
listOf(),
None,
listOf(
EOBndExpr(
EOCopy(
listOf("this", "init").eoDot(),
"this".eoDot()
),
"@"
)
)
),
"initialization"
)

fun mapMethodDeclaration(dec: MethodDeclaration): EOBndExpr {
val isStatic = dec.modifiers != null &&
dec.modifiers.modifiers.modifiers.find { it == TokenCode.Static } != null
Expand Down Expand Up @@ -40,26 +58,13 @@ fun mapMethodDeclaration(dec: MethodDeclaration): EOBndExpr {
if (dec.methodBody != null) {
mapBlock(
dec.methodBody,
additionalStmt = if (dec is ConstructorDeclaration) {
"initialization" to listOf(
EOBndExpr(
EOObject(
listOf(),
None,
listOf(
EOBndExpr(
EOCopy(
listOf("this", "init").eoDot(),
"this".eoDot()
),
"@"
)
)
),
"initialization"
)

)
firstStmts = if (dec is ConstructorDeclaration) {
listOf("initialization" to listOf(genInit()))
} else {
null
},
lastStmts = if (dec is ConstructorDeclaration) {
listOf("this" to listOf())
} else {
null
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/translator/preprocessor/Preprocessor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ private fun preprocessStmt(state: PreprocessorState, stmt: Statement) {
}

private fun preprocessVarDecl(state: PreprocessorState, varDecl: VariableDeclaration) {
preprocessInitializer(state, varDecl.initializer)
if (varDecl.initializer != null) {
preprocessInitializer(state, varDecl.initializer)
}
when (varDecl.type) {
is TypeName -> {
preprocessType(state, varDecl.type)
Expand Down

1 comment on commit 675dcf2

@0pdd
Copy link
Member

@0pdd 0pdd commented on 675dcf2 May 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to retrieve PDD puzzles from the code base and submit them to GitHub. If you think that it's a bug on our side, please submit it to yegor256/0pdd:

set -x && set -e && set -o pipefail && cd /tmp/0pdd20220303-12-17lwdzx/polystat/j2eo && pdd -v -f /tmp/20220525-4146-1st8x87 [1]: + set -e + set -o pipefail + cd /tmp/0pdd20220303-12-17lwdzx/polystat/j2eo + pdd -v -f /tmp/20220525-4146-1st8x87 My version is 0.20.6 Ruby version is 2.6.0 at...

Please, copy and paste this stack trace to GitHub:

UserError
set -x && set -e && set -o pipefail && cd /tmp/0pdd20220303-12-17lwdzx/polystat/j2eo && pdd -v -f /tmp/20220525-4146-1st8x87 [1]:
+ set -e
+ set -o pipefail
+ cd /tmp/0pdd20220303-12-17lwdzx/polystat/j2eo
+ pdd -v -f /tmp/20220525-4146-1st8x87

My version is 0.20.6
Ruby version is 2.6.0 at x86_64-linux
Reading /tmp/0pdd20220303-12-17lwdzx/polystat/j2eo
1041 file(s) found, 223 excluded
/tmp/0pdd20220303-12-17lwdzx/polystat/j2eo/gradle/wrapper/gradle-wrapper.jar is a binary file (59203 bytes)
/tmp/0pdd20220303-12-17lwdzx/polystat/j2eo/src/test/resources/polystat_tests/test1/static_eo/test.eo is a binary file (0 bytes)
Reading .gitignore...
Reading README.md...
Reading .rultor.yml...
Reading settings.gradle.kts...
Reading .dockerignore...
Reading CITATION.cff...
Reading config/checkstyle/checkstyle.xml...
Reading config/xsl/checkstyle-simple.xsl...
Reading .github/workflows/gradle-build.yml...
Reading polystat_check/check.sh...
Reading polystat_check/PolystatTest.java...
Reading gradlew.bat...
Reading test_candidates.sh...
Reading CHANGELOG.md...
Reading gradlew...
Reading gradle/wrapper/gradle-wrapper.properties...
Reading build.gradle.kts...
Reading test-kafka.sh...
Reading build.sh...
Reading src/main/resources/stdlib/primitives/prim__double.eo...
Reading src/main/resources/stdlib/primitives/prim__byte.eo...
Reading src/main/resources/stdlib/primitives/prin__long.eo...
Reading src/main/resources/stdlib/primitives/prim__float.eo...
Reading src/main/resources/stdlib/primitives/prim__num.eo...
Reading src/main/resources/stdlib/primitives/prim__char.eo...
Reading src/main/resources/stdlib/primitives/prim__int.eo...
Reading src/main/resources/stdlib/primitives/prim__short.eo...
Reading src/main/resources/stdlib/primitives/prim__boolean.eo...
Reading src/main/resources/stdlib/io/class__PrintStream.eo...
Reading src/main/resources/stdlib/lang/class__System.eo...
Reading src/main/resources/stdlib/lang/class__String.eo...
Reading src/main/resources/stdlib/lang/class__Object.eo...
Reading src/main/resources/stdlib/util/class__Random.eo...
Reading src/main/resources/Java_16_Grammar.y...
Reading src/main/java/main/Main2.kt...
Reading src/main/java/eotree/EODot.kt...
Reading src/main/java/eotree/EOBndExpr.kt...
Reading src/main/java/eotree/EODotObject.kt...
Reading src/main/java/eotree/EOExpr.kt...
Reading src/main/java/eotree/EOMetaObjects.kt...
ERROR: src/main/java/eotree/EOMetaObjects.kt; puzzle at line #15; TODO found, but puzzle can't be parsed, most probably because TODO is not followed by a puzzle marker, as this page explains: https://github.com/yegor256/pdd#how-to-format
If you can't understand the cause of this issue or you don't know how to fix it, please submit a GitHub issue, we will try to help you: https://github.com/yegor256/pdd/issues. This tool is still in its beta version and we will appreciate your feedback. Here is where you can find more documentation: https://github.com/yegor256/pdd/blob/master/README.md.
Exit code is 1

/app/objects/git_repo.rb:66:in `rescue in block in xml'
/app/objects/git_repo.rb:63:in `block in xml'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/tempfile.rb:295:in `open'
/app/objects/git_repo.rb:62:in `xml'
/app/objects/puzzles.rb:36:in `deploy'
/app/objects/job.rb:38:in `proceed'
/app/objects/job_starred.rb:33:in `proceed'
/app/objects/job_recorded.rb:32:in `proceed'
/app/objects/job_emailed.rb:35:in `proceed'
/app/objects/job_commiterrors.rb:36:in `proceed'
/app/objects/job_detached.rb:48:in `exclusive'
/app/objects/job_detached.rb:36:in `block in proceed'
/app/objects/job_detached.rb:36:in `fork'
/app/objects/job_detached.rb:36:in `proceed'
/app/0pdd.rb:366:in `block in <top (required)>'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1675:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1675:in `block in compile!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1013:in `block (3 levels) in route!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1032:in `route_eval'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1013:in `block (2 levels) in route!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1061:in `block in process_route'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1059:in `catch'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1059:in `process_route'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1011:in `block in route!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1008:in `each'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1008:in `route!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1129:in `block in dispatch!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `block in invoke'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `catch'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `invoke'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1124:in `dispatch!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:939:in `block in call!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `block in invoke'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `catch'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `invoke'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:939:in `call!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:929:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/xss_header.rb:18:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/path_traversal.rb:16:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/json_csrf.rb:26:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/base.rb:50:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/base.rb:50:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/frame_options.rb:31:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/logger.rb:17:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/common_logger.rb:38:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:253:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:246:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/head.rb:12:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/method_override.rb:24:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:216:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1991:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1542:in `block in call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1769:in `synchronize'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1542:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/handler/webrick.rb:95:in `service'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/webrick/httpserver.rb:140:in `service'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/webrick/httpserver.rb:96:in `run'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/webrick/server.rb:307:in `block in start_thread'

Please sign in to comment.