From d6a43aabe39d14a5f05d8136edcebeb2a7761b1f Mon Sep 17 00:00:00 2001 From: CrescentonC <43136427+CrescentonC@users.noreply.github.com> Date: Sun, 1 Dec 2024 00:01:50 +0800 Subject: [PATCH] cleanup --- .../scala/hkmc2/codegen/js/JSBuilder.scala | 28 ++++--------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/hkmc2/shared/src/main/scala/hkmc2/codegen/js/JSBuilder.scala b/hkmc2/shared/src/main/scala/hkmc2/codegen/js/JSBuilder.scala index 361d02cef..c8b20e285 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/codegen/js/JSBuilder.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/codegen/js/JSBuilder.scala @@ -225,18 +225,8 @@ class JSBuilder(using Elaborator.State, Elaborator.Ctx) extends CodeBuilder: doc" # const $proxy = this; # ${res.stripBreaks}${returningTerm(rst)}" case _ => doc"$res${returningTerm(rst)}" doc" # ${resJS}" - case Return(res, true) => - // val resSym = semantics.TempSymbol(N, "res") - // val resStr = scope.allocateName(resSym) - // doc" # const $resStr = ${result(res)}; # Predef.TraceLogger.indent = prevIndent; # Predef.TraceLogger.log(${JSBuilder.makeStringLiteral("return ")} + $resStr); # ${resStr}" - doc" # ${result(res)}" - case Return(res, false) => - // val resSym = semantics.TempSymbol(N, "res") - // val resStr = scope.allocateName(resSym) - // // doc" # const $resStr = ${result(res)}; # return ${resStr}" - // doc" # const $resStr = ${result(res)}; # Predef.TraceLogger.indent = prevIndent; # Predef.TraceLogger.log(${JSBuilder.makeStringLiteral("return ")} + $resStr); # return ${resStr}" - // // doc" # return ${result(res)};" - setupReturn(res) + case Return(res, true) => doc" # ${result(res)}" + case Return(res, false) => doc" # return ${result(res)};" // TODO factor out common logic case Match(scrut, Case.Lit(syntax.Tree.BoolLit(true)) -> trm :: Nil, els, rest) => @@ -329,14 +319,10 @@ class JSBuilder(using Elaborator.State, Elaborator.Ctx) extends CodeBuilder: val v = doc"this.${getVar(i._1)}" doc"""$v = await import("${i._2.toString }"); # if ($v.default !== undefined) $v = $v.default;""" - // val traceLoggerSymbol = semantics.TempSymbol(N, "traceLogger") - // val traceLoggerStr = Scope.scope.allocateName(traceLoggerSymbol) - imps.mkDocument(doc" # ") :: - (if !compilingFile && false then doc"let = new Predef.TraceLogger(); # " else "") :/: - block(p.main) :: ( - exprt match - case S(e) => doc"\nexport default ${e};\n" - case N => doc"" + imps.mkDocument(doc" # ") :/: block(p.main) :: ( + exprt match + case S(e) => doc"\nexport default ${e};\n" + case N => doc"" ) def block(t: Block)(using Raise, Scope): Document = @@ -362,8 +348,6 @@ class JSBuilder(using Elaborator.State, Elaborator.Ctx) extends CodeBuilder: doc" # return ${result(res)};" - def setupCall(bases: Document, args: Document)(using Raise, Scope): Document = - doc"${bases}(${args})" object JSBuilder: import scala.util.matching.Regex