This page is no longer maintained — Please continue to the home page at www.scala-lang.org

serializing the type environment for IDE exploration

1 reply
Miguel Garcia
Joined: 2009-06-10,
User offline. Last seen 42 years 45 weeks ago.

I have a question related to one of my write-ups ("Decoding external types
on JVM and CLR" [1]). Although the original motivation is Scala.Net-based,
the mechanism I'm looking for would also be of use under JVM.

As you may have noticed I came up with an idea
http://permalink.gmane.org/gmane.comp.lang.scala.tools/4322
to explore how Scala would represent (at the source code level) the type
information of a .NET assembly. I might develop a quick prototype to test
the idea.

However, the prototype would be redundant in case there were a mechanism
(patch?) to have nsc print out after the typing phase, not the compilation
units, but the contents of the assemblies given by -Xassem-extdirs (printing
them out as type definitions with empty method bodies, save for a dummy
return of the type's default value)

The above "experiment" amounts to serializing into .scala files the type
environment, which could be useful in itself. Anyone been there before?

Miguel

[1]
http://www.sts.tu-harburg.de/people/mi.garcia/ScalaCompilerCorner/TypeDe...

Iulian Dragos 2
Joined: 2009-02-10,
User offline. Last seen 42 years 45 weeks ago.
Re: serializing the type environment for IDE exploration
Here's the code I used privately for debugging symbols. I believe it is straight forward to hook it into the right place and start printing symbols.
iulian

  class SymbolPrinter(out: PrintWriter) extends treePrinters.Printer(out) {     def printClass(sym: Symbol) {      print(sym.toString)      if (!sym.info.typeParams.isEmpty)        printRow[Symbol](sym.info.typeParams, printTypeParam, "[", ", ", "]")       print(" extends ")      printRow[Type](sym.info.parents, (t => print(t.toString)), "", " with ", "")      printColumn(sym.info.decls.toList, printMember, "{", "", "}\n")       flush    }        def printTypeParam(sym: Symbol) {      print(sym.name); print(sym.info.bounds.toString)    }    def printMember(sym: Symbol) {       if (sym.isClass) printClass(sym)      else print(sym.defString)    }      }

On Mon, Mar 29, 2010 at 10:10 AM, Miguel Garcia <miguel [dot] garcia [at] tuhh [dot] de> wrote:

I have a question related to one of my write-ups ("Decoding external types on JVM and CLR" [1]). Although the original motivation is Scala.Net-based, the mechanism I'm looking for would also be of use under JVM.

As you may have noticed I came up with an idea
http://permalink.gmane.org/gmane.comp.lang.scala.tools/4322
to explore how Scala would represent (at the source code level) the type information of a .NET assembly. I might develop a quick prototype to test the idea.

However, the prototype would be redundant in case there were a mechanism (patch?) to have nsc print out after the typing phase, not the compilation units, but the contents of the assemblies given by -Xassem-extdirs (printing them out as type definitions with empty  method bodies, save for a dummy
return of the type's default value)

The above "experiment" amounts to serializing into .scala files the type environment, which could be useful in itself. Anyone been there before?

Miguel


[1]
http://www.sts.tu-harburg.de/people/mi.garcia/ScalaCompilerCorner/TypeDecoding.pdf




--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland