Skip to content

Commit

Permalink
config.WithHiddenLocation added
Browse files Browse the repository at this point in the history
  • Loading branch information
antonkolotaev committed Feb 3, 2014
1 parent 0679c61 commit 3faf340
Show file tree
Hide file tree
Showing 10 changed files with 540 additions and 1,601 deletions.
263 changes: 0 additions & 263 deletions marketsim/gen/.output/names.failed.sc

Large diffs are not rendered by default.

262 changes: 0 additions & 262 deletions marketsim/gen/.output/names.sc

Large diffs are not rendered by default.

263 changes: 0 additions & 263 deletions marketsim/gen/.output/typed.failed.sc

Large diffs are not rendered by default.

262 changes: 0 additions & 262 deletions marketsim/gen/.output/typed.sc

Large diffs are not rendered by default.

524 changes: 262 additions & 262 deletions marketsim/gen/.parsed/.output/names.pretty-printed.sc

Large diffs are not rendered by default.

524 changes: 262 additions & 262 deletions marketsim/gen/.parsed/.output/typed.pretty-printed.sc

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions marketsim/gen/src/main/scala/Runner.scala
Expand Up @@ -139,7 +139,7 @@ object Runner extends syntax.scala.Parser {
val names_failed_file = ".output/names.failed.sc"

for (output <- managed(new PrintWriter(names_file))) {
output.println(names)
config.WithHiddenLocation({ output.println(names) })
}

if (config.check_names)
Expand All @@ -149,7 +149,7 @@ object Runner extends syntax.scala.Parser {
}) map { names_2 =>
if (names_2 != names) {
for (output <- managed(new PrintWriter(names_failed_file))) {
output.println(names_2)
config.WithHiddenLocation({ output.println(names_2) })
}
println(s"Re-parsed names differ from original ones. Compare files '$names_file' and '$names_failed_file'")
}
Expand All @@ -174,7 +174,7 @@ object Runner extends syntax.scala.Parser {
val typed_failed_file = ".output/typed.failed.sc"

for (output <- managed(new PrintWriter(typed_file))) {
output.println(typed)
config.WithHiddenLocation({ output.println(typed) })
}

if (config.check_typed)
Expand All @@ -185,7 +185,7 @@ object Runner extends syntax.scala.Parser {
}) map { typed_2 =>
if (typed != typed_2) {
for (output <- managed(new PrintWriter(typed_failed_file))) {
output.println(typed_2)
config.WithHiddenLocation({ output.println(typed_2) })
}
println(s"Re-parsed names differ from original ones. Compare files '$typed_file' and '$typed_failed_file'")
}
Expand Down
10 changes: 10 additions & 0 deletions marketsim/gen/src/main/scala/config.scala
Expand Up @@ -18,6 +18,16 @@ package object config
def catch_errors = !instance.get.skip_errors
def verbose = instance.get.verbose

var show_location : Boolean = true

def WithHiddenLocation[T](f : => T) = {
val old = show_location
show_location = false
val x = f
show_location = old
x
}

def With(args: Array[String])(f : => Unit)
{
val parser = new scopt.OptionParser[Config]("gen")
Expand Down
23 changes: 1 addition & 22 deletions marketsim/gen/src/main/scala/predef.scala
Expand Up @@ -170,30 +170,9 @@ package object predef {
def asCode : Code
}

sealed abstract class PrintMode

case object ScalaMode extends PrintMode

object ScPyPrintable
{
var printMode : PrintMode = ScalaMode
}

trait ScPyPrintable extends ScPrintable with PyPrintable
{
override def toString = ScPyPrintable.printMode match {
case ScalaMode => toScala
}

def as(m : PrintMode) = {
val old_mode = ScPyPrintable.printMode
ScPyPrintable.printMode = m
val ret = toString
ScPyPrintable.printMode = old_mode
ret
}

def asScala = as(ScalaMode)
def asScala = toScala
}

}
Expand Down
2 changes: 1 addition & 1 deletion marketsim/gen/src/main/scala/syntax/scala/Printer.scala
Expand Up @@ -212,7 +212,7 @@ package object Printer
def printBody : String

protected def toScala = {
(crlf + s"// defined at $filename: " + pos + crlf
(crlf + (if (config.show_location) s"// defined at $filename: " + pos + crlf else "")
+ ifSome(docstring)
+ decorators.map({_ + crlf}).mkString("")
+ "def " + name
Expand Down

0 comments on commit 3faf340

Please sign in to comment.