Permalink
Browse files

Merge branch 'master' of

ssh://git@github.com/kaptoxic/scala-ide-insynth-integration.git

Conflicts:
	ch.epfl.insynth.build/README.rst
  • Loading branch information...
2 parents b257d3d + 45f46a8 commit f5afdb472ed014eb9795aba4084f8815c49421e6 @kaptoxic committed Jul 30, 2012
Showing with 1,406 additions and 1,310 deletions.
  1. +1 −1 InSynth_CompilerPlugin/src/insynth/Config.scala
  2. +9 −3 InSynth_CompilerPlugin/src/insynth/InSynthPlugin.scala
  3. +1 −1 InSynth_CompilerPlugin/src/insynth/TraverseComponent.scala
  4. +42 −4 InSynth_HoFSearchPlugin/src/main/scala/search/TraverseComponent.scala
  5. +1 −1 ch.epfl.insynth.build/README.rst
  6. BIN ch.epfl.insynth.build/ch.epfl.insynth/.cache
  7. +46 −2 ch.epfl.insynth.reconstruction/src/ch/epfl/insynth/Config.scala
  8. +26 −12 ch.epfl.insynth.reconstruction/src/ch/epfl/insynth/combinator/Combinator.scala
  9. +40 −38 ch.epfl.insynth.reconstruction/src/ch/epfl/insynth/combinator/CombinatorStructures.scala
  10. +68 −68 ch.epfl.insynth.reconstruction/src/ch/epfl/insynth/combinator/PrunedTrees.scala
  11. +69 −68 ch.epfl.insynth.reconstruction/src/ch/epfl/insynth/env/Trees.scala
  12. +388 −382 ch.epfl.insynth.reconstruction/src/ch/epfl/insynth/reconstruction/CodeGenerator.scala
  13. +412 −408 ch.epfl.insynth.reconstruction/src/ch/epfl/insynth/reconstruction/IntermediateTransformer.scala
  14. +9 −6 ch.epfl.insynth.reconstruction/src/ch/epfl/insynth/reconstruction/Reconstructor.scala
  15. +2 −1 ch.epfl.insynth.reconstruction/src/ch/epfl/insynth/reconstruction/trees/Trees.scala
  16. +124 −124 ch.epfl.insynth.reconstruction/src/ch/epfl/insynth/trees/Trees.scala
  17. +28 −1 ch.epfl.insynth.reconstruction/src/ch/epfl/scala/trees/Trees.scala
  18. +21 −97 ch.epfl.insynth.reconstruction/test/ch/epfl/test/CodeGenTest.scala
  19. +3 −83 ch.epfl.insynth.reconstruction/test/ch/epfl/test/IntermediateReconstructionTest.scala
  20. +12 −10 ch.epfl.insynth.reconstruction/test/ch/epfl/test/ReconstructorTest.scala
  21. +104 −0 ch.epfl.insynth.reconstruction/test/ch/epfl/test/TreeExample.scala
@@ -5,7 +5,7 @@ import java.util.logging._
object Config {
// logging
- val outputFilename = "/home/ivcha/git/scala-ide-insynth-integration/InSynth_CompilerPlugin/out/output.txt"
+ var outputFilename = "/home/ivcha/git/scala-ide-insynth-integration/InSynth_CompilerPlugin/out/output.txt"
// defines loggers
val logger = Logger.getLogger("insynth.plugin")
@@ -17,13 +17,19 @@ class InSynthPlugin(val global: Global) extends Plugin {
/** A short description of the plugin, read from the properties file */
val description = PluginProperties.pluginDescription
- /** @todo A description of the plugin's options */
override val optionsHelp = Some(
- " -P:"+ name +":option sets some option for this plugin")
+ " -appStatFile:"+ name +":option sets a filename for statistics to be written")
- /** @todo Implement parsing of plugin options */
+ /** get file to write statistics */
override def processOptions(options: List[String], error: String => Unit) {
super.processOptions(options, error)
+ for (option <- options) {
+ if (option.startsWith("appStatFile:")) {
+ Config.outputFilename = option.substring("appStatFile:".length)
+ } else {
+ error("Option not recognized: " + option)
+ }
+ }
}
/** The compiler components that will be applied when running
@@ -12,7 +12,7 @@ import scala.collection.mutable.MutableList
class TraverseComponent (val global: Global) extends PluginComponent {
import global._
import global.definitions._
-
+
lazy val logger = Config.logger
val runsAfter = List[String]("refchecks")
@@ -73,10 +73,45 @@ class TraverseComponent(val global: Global) extends PluginComponent {
(t, level)
}
}
-
+
+ def getApplicationInfo(tpe: Type): Boolean = {
+
+ def isPolymorphic(tpe: Type): Boolean = tpe match {
+ case TypeRef(pre: Type, sym: Symbol, args: List[Type]) if (!sym.isMonomorphicType && !args.isEmpty) =>
+ false
+ case TypeRef(pre: Type, sym: Symbol, args: List[Type]) if (sym.isTypeParameter) =>
+ true
+ case TypeRef(pre: Type, sym: Symbol, args: List[Type]) =>
+ (false /: args) { (res, arg) => res || isPolymorphic(arg) }
+ case _ => false
+ }
+
+ def getApplicationInfoMethodRec(methodType: Type): Boolean = methodType match {
+ case m:MethodType if (m.isHigherKinded) => true
+ case MethodType(params, resultType) => {
+ if ((false /: params) { (res, param) => res || isPolymorphic(param.tpe) } )
+ true
+ else
+ getApplicationInfoMethodRec(resultType)
+ }
+ case t => getApplicationInfoFunctionRec(t)
+ }
+
+ def getApplicationInfoFunctionRec(functionType: Type): Boolean = functionType match {
+ case TypeRef(pre: Type, sym: Symbol, args: List[Type]) if(definitions.isFunctionType(functionType)) =>
+ if ((false /: args.init) { (res, param) => res || isPolymorphic(param) } )
+ true
+ else
+ getApplicationInfoFunctionRec(args.last)
+ case t => false
+ }
+
+ getApplicationInfoMethodRec(tpe)
+ }
+
def isPolymorphic(tpe: Type): Boolean = tpe match {
case TypeRef(pre: Type, sym: Symbol, args: List[Type]) if (!sym.isMonomorphicType && !args.isEmpty) =>
- true
+ false
case TypeRef(pre: Type, sym: Symbol, args: List[Type]) if (sym.isTypeParameter) =>
true
case _ => false
@@ -115,13 +150,16 @@ class TraverseComponent(val global: Global) extends PluginComponent {
// logger.fine("definitions.isFunctionType(fun.symbol.tpe) " + definitions.isFunctionType(fun.symbol.tpe))
logger.fine("App tree: " + fun + " tree position " + tree.pos)
- val isPolymorphicRes = (false /: args) { (res, arg) => res || isPolymorphic(arg.tpe) }
+ val isPolymorphicRes = (fun.toString.contains("[") /: args) {
+ (res, arg) => res || arg.toString.contains("[")
+ }
+ //(false /: args) { (res, arg) => res || isPolymorphic(arg.tpe) }
logger.info("isPolymorphic =" + isPolymorphicRes)
val isCandidate = (false /: args) {
(result, arg) => result || checkIfFunctionType(arg.tpe)
}
- if (isCandidate)
+ if (isCandidate && !isPolymorphicRes)
appendToFile(Config.outputFilename,
tree.symbol.name + "...=" + tree.pos.source.path + ":" + tree.pos.line)
}
@@ -26,4 +26,4 @@ InSynth user documentation
A short user documentation can be found at the project's `Wiki`_ pages.
-.. _Wiki: https://github.com/kaptoxic/scala-ide-insynth-integration/wiki
+.. _Wiki: https://github.com/kaptoxic/scala-ide-insynth-integration/wiki
Binary file not shown.
@@ -1,14 +1,58 @@
package ch.epfl.insynth
+import java.util.logging._
+
object Config {
final val getTimeOutSlot = 500
final val loadPredefs = true
- final val numberOfSnippets = 15
+ final val numberOfSnippets = 1
+
+ val logCombinatorInputProofTreeLevel = 6
final val outputFileName = "/home/ivcha/development/workspace_gsoc/Insynth_core_svn/insynthOutput.txt"
final val errorFileName = "/home/ivcha/development/workspace_gsoc/Insynth_core_svn/insynthError.txt"
- final val debugFileName = "/home/ivcha/development/workspace_gsoc/Insynth_core_svn/insynthDebug.txt"
+ final val debugFileName = "/home/ivcha/development/workspace_gsoc/Insynth_core_svn/insynthDebug.txt"
+
+ // logging for code generation phase
+
+ // defines loggers
+ val logger = Logger.getLogger("reconstruction.combination")
+ val logStructures = Logger.getLogger("reconstruction.combination.structures")
+ val logApply = Logger.getLogger("reconstruction.combination.apply")
+ val logPQAdding = Logger.getLogger("reconstruction.combination.apply.pqadding")
+
+ val logExtractor = Logger.getLogger("reconstruction.extractor")
+
+ val isLogging = true
+
+ // static code for loggers setup
+ {
+ val array = Array(logger, logStructures, logApply, logExtractor, logPQAdding)
+
+ // remove all handlers
+ for (logger <- array)
+ for (handler <- logger.getHandlers)
+ logger.removeHandler(handler)
+
+ Logger.getLogger("reconstruction.combination").setLevel(Level.FINE)
+ Logger.getLogger("reconstruction.combination.apply").setLevel(Level.FINE)
+ Logger.getLogger("reconstruction.combination.structures").setLevel(Level.INFO)
+ logPQAdding.setLevel(Level.FINEST)
+
+ logExtractor.setLevel(Level.FINEST)
+
+ val handler = new FileHandler("%h/combinator%u.log");
+ val handlerEx = new FileHandler("%h/extractor%u.log");
+ handler.setFormatter(new SimpleFormatter)
+ handlerEx.setFormatter(new SimpleFormatter)
+ // PUBLISH this level
+ handler.setLevel(Level.FINEST);
+ logger.addHandler(handler);
+ logExtractor.addHandler(handlerEx)
+// Logger.getLogger("reconstruction.combination.apply").addHandler(handler);
+// Logger.getLogger("reconstruction.combination.structures").addHandler(handler);
+ }
}
@@ -7,6 +7,7 @@ import java.util.logging.Logger
import java.util.logging.ConsoleHandler
import ch.epfl.insynth.env.FormatNode
import java.util.logging.Level
+import ch.epfl.insynth.Config
/**
* object which application transforms an InSynth representation input
@@ -16,6 +17,7 @@ object Combinator extends ((InSynth.SimpleNode, Int) => Node) {
val logger = Rules.logger
val logApply = Rules.logApply//(logger.getName + ".apply")
+ val logPQAdding = Config.logPQAdding
// // predefined default number of combinations
// val predefinedNeededCombinations = 15
@@ -30,7 +32,7 @@ object Combinator extends ((InSynth.SimpleNode, Int) => Node) {
// logging
if (Rules.isLogging) {
logApply.entering(getClass.getName, "apply")
- //logApply.finest("Entering combinator step (root: "+ FormatNode(root) + ", combinations: " + neededCombinations)
+ logApply.finest("Entering combinator step (root: "+ FormatNode(root, Config.logCombinatorInputProofTreeLevel) + ", combinations: " + neededCombinations)
}
// import transformer from InSynth to intermediate declaration
@@ -72,18 +74,18 @@ object Combinator extends ((InSynth.SimpleNode, Int) => Node) {
// if current declaration is pruned or already visited on this path, log
if (currentDeclaration.isPruned) {
- logApply.fine("Declaration with " + FormatNode(currentDeclaration.getAssociatedNode, true) + " pruned")
+ logApply.fine("Declaration with " + FormatNode(currentDeclaration.getAssociatedNode, 0) + " pruned")
}
if (visited.contains(currentDeclaration.getAssociatedNode)) {
- logApply.fine("Stumbled upon a cycle (discarding the node: " + FormatNode(currentDeclaration.getAssociatedNode, true) + ")")
+ logApply.fine("Stumbled upon a cycle (discarding the node: " + FormatNode(currentDeclaration.getAssociatedNode, 0) + ")")
}
// additional pruning conditions
if (currentDeclaration.getAssociatedTree.isPruned) {
- logApply.fine("!Declaration with " + FormatNode(currentDeclaration.getAssociatedNode, true) + " pruned")
+ logApply.fine("!Declaration " + currentDeclaration + " pruned")
}
if (Rules.doPruning && currentDeclaration.getAssociatedTree.checkIfPruned(currentDeclaration.getTraversalWeight)) {
- logApply.fine("!!Declaration with " + FormatNode(currentDeclaration.getAssociatedNode, true) + " pruned")
+ logApply.fine("!!Declaration " + currentDeclaration + " pruned")
}
if (Rules.doPruning)
@@ -130,8 +132,14 @@ object Combinator extends ((InSynth.SimpleNode, Int) => Node) {
for (dec <- node.getDecls;
// optimization - only consider those nodes that have less weight than
// all trees up to the tree
- if !(Rules.doPruning && paramTree.checkIfPruned(dec.getWeight.getValue
- + paramTree.getTraversalWeight))
+ val notConsider = Rules.doPruning && paramTree.checkIfPruned(dec.getWeight.getValue
+ + paramTree.getTraversalWeight);
+ // logging
+ val dummy =
+ if (Config.isLogging && notConsider) {
+ logPQAdding.info("Decl " + dec.getSimpleName + " is not considered")
+ }
+ if !notConsider
) // for
{
@@ -144,19 +152,25 @@ object Combinator extends ((InSynth.SimpleNode, Int) => Node) {
// logging
if (Rules.isLogging)
- logApply.finer("Adding simple " + dec.getSimpleName + " to the queue")
+ logPQAdding.finer("Adding " + newPair._1 + " to the queue")
// add new pair to the queue
pq += newPair
}
// if there are parameters insert composite nodes
} else {
// for each of its declarations
- for (dec <- node.getDecls
+ for (dec <- node.getDecls;
// optimization - only consider those nodes that have less weight than
// all trees up to the tree
- if !(Rules.doPruning && paramTree.checkIfPruned(dec.getWeight.getValue
- + paramTree.getTraversalWeight))
+ val notConsider = Rules.doPruning && paramTree.checkIfPruned(dec.getWeight.getValue
+ + paramTree.getTraversalWeight);
+ // logging
+ val dummy =
+ if (Config.isLogging && notConsider) {
+ logPQAdding.info("Decl " + dec.getSimpleName + " is not considered")
+ }
+ if !(notConsider)
) // for
{
// new pair of simple expression and extended path
@@ -168,7 +182,7 @@ object Combinator extends ((InSynth.SimpleNode, Int) => Node) {
// logging
if (Rules.isLogging)
- logApply.finer("Adding composite " + dec.getSimpleName + " to the queue")
+ logPQAdding.finer("Adding " + newPair._1 + " to the queue")
// add new pair to the queue
pq += newPair
Oops, something went wrong.

0 comments on commit f5afdb4

Please sign in to comment.