Skip to content

Commit 5a6ee33

Browse files
author
Alexey Romanov
committed
Add an option to emit explicit types for vals in ScalaCodegen
1 parent e9e9e32 commit 5a6ee33

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/internal/Config.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ trait Config {
55
val verbosity = System.getProperty("lms.verbosity","0").toInt
66
val sourceinfo = System.getProperty("lms.sourceinfo","0").toInt
77
val addControlDeps = System.getProperty("lms.controldeps","true").toBoolean
8+
9+
val scalaExplicitTypes = System.getProperty("lms.scala.explicitTypes","false").toBoolean
810

911
// memory management type for C++ target (refcnt or gc)
1012
val cppMemMgr = System.getProperty("lms.cpp.memmgr","malloc")

src/internal/ScalaCodegen.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ trait ScalaCodegen extends GenericCodegen with Config {
9595
val context = sym.pos(0)
9696
" // " + relativePath(context.fileName) + ":" + context.line
9797
}
98-
stream.println("val " + quote(sym) + " = " + rhs + extra)
98+
val typeSignature = if (scalaExplicitTypes) ": " + remap(sym.tp) else ""
99+
stream.println("val " + quote(sym) + typeSignature + " = " + rhs + extra)
99100
}
100101

101102
def emitVarDef(sym: Sym[Variable[Any]], rhs: String): Unit = {

0 commit comments

Comments
 (0)