Skip to content

Commit

Permalink
js legacy exception (#679)
Browse files Browse the repository at this point in the history
Throw exception on JS and canvas, and no flag on legacy-ir compiler
  • Loading branch information
ilgonmic authored and woainikk committed Sep 20, 2023
1 parent f277f98 commit 53fb857
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ class CompilerRestController(private val kotlinProjectExecutor: KotlinProjectExe
@PostMapping("/translate")
fun translateKotlinProjectEndpoint(
@RequestBody project: Project,
@RequestParam(defaultValue = "false") ir: Boolean,
@RequestParam(defaultValue = "js") compiler: String
): TranslationResultWithJsCode {
if (!ir) {
return kotlinProjectExecutor.convertToJs(project)
}
return when (KotlinTranslatableCompiler.valueOf(compiler.uppercase())) {
KotlinTranslatableCompiler.JS -> kotlinProjectExecutor.convertToJsIr(project)
KotlinTranslatableCompiler.WASM -> kotlinProjectExecutor.convertToWasm(project)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.compiler.server.controllers

import com.compiler.server.exceptions.LegacyJsException
import com.compiler.server.model.Project
import com.compiler.server.model.ProjectType
import com.compiler.server.service.KotlinProjectExecutor
Expand Down Expand Up @@ -39,7 +40,7 @@ class KotlinPlaygroundRestController(private val kotlinProjectExecutor: KotlinPr
"run" -> {
when (project.confType) {
ProjectType.JAVA -> kotlinProjectExecutor.run(project)
ProjectType.JS, ProjectType.CANVAS -> kotlinProjectExecutor.convertToJs(project)
ProjectType.JS, ProjectType.CANVAS -> throw LegacyJsException()
ProjectType.JS_IR -> kotlinProjectExecutor.convertToJsIr(project)
ProjectType.WASM -> kotlinProjectExecutor.convertToWasm(project)
ProjectType.JUNIT -> kotlinProjectExecutor.test(project)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.compiler.server.exceptions

import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.ResponseStatus

@ResponseStatus(value = HttpStatus.BAD_REQUEST)
class LegacyJsException : RuntimeException()

0 comments on commit 53fb857

Please sign in to comment.