summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorGilles Dubochet <gilles.dubochet@epfl.ch>2006-03-27 19:39:38 +0000
committerGilles Dubochet <gilles.dubochet@epfl.ch>2006-03-27 19:39:38 +0000
commit6b46664e637ff526507bd31b5bd2fb3cea1e715e (patch)
tree33174339dc79f34e77c093f16d5a1bd7ef52cfaa /src/library
parenta959828b60b7bacbdeff23f0ac1b7304d416df54 (diff)
downloadscala-6b46664e637ff526507bd31b5bd2fb3cea1e715e.tar.gz
scala-6b46664e637ff526507bd31b5bd2fb3cea1e715e.tar.bz2
scala-6b46664e637ff526507bd31b5bd2fb3cea1e715e.zip
Moved codification to its own phase.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/reflect/Code.scala18
-rw-r--r--src/library/scala/reflect/Print.scala16
-rwxr-xr-xsrc/library/scala/reflect/Tree.scala29
-rw-r--r--src/library/scala/reflect/TypedCode.scala4
4 files changed, 43 insertions, 24 deletions
diff --git a/src/library/scala/reflect/Code.scala b/src/library/scala/reflect/Code.scala
index 9132adf3f8..226e9ffc1a 100644
--- a/src/library/scala/reflect/Code.scala
+++ b/src/library/scala/reflect/Code.scala
@@ -12,18 +12,8 @@
package scala.reflect;
-abstract class Code;
+class Code[Type](val tree: Tree) {}
-case class Ident(sym: Symbol) extends Code;
-case class Select(qual: Code, sym: Symbol) extends Code;
-case class Literal(value: Any) extends Code;
-case class Apply(fun: Code, args: List[Code]) extends Code;
-case class TypeApply(fun: Code, args: List[Type]) extends Code;
-case class Function(params: List[Symbol], body: Code) extends Code;
-case class This(sym: Symbol) extends Code;
-case class Block(stats: List[Code], expr: Code) extends Code;
-case class New(sym: Code) extends Code;
-case class If(condition: Code, trueCase: Code, falseCase: Code) extends Code;
-case class Assign(destination: Code, source: Code) extends Code;
-case class Target(sym: LabelSymbol, body: Code) extends Code;
-case class Goto(target: LabelSymbol) extends Code;
+object Code {
+ def lift[A](tree: A): Code[A] = throw new Error("Code was not lifted by compiler")
+} \ No newline at end of file
diff --git a/src/library/scala/reflect/Print.scala b/src/library/scala/reflect/Print.scala
index 3318dcc5af..c4f1a2fdc6 100644
--- a/src/library/scala/reflect/Print.scala
+++ b/src/library/scala/reflect/Print.scala
@@ -15,10 +15,10 @@ package scala.reflect;
object Print extends Function1[Any, String] {
def apply (any: Any): String = {
- if (any.isInstanceOf[TypedCode[Any]])
- apply(any.asInstanceOf[TypedCode[Any]])
- else if (any.isInstanceOf[Code])
- apply(any.asInstanceOf[Code])
+ if (any.isInstanceOf[Code[Any]])
+ apply(any.asInstanceOf[Code[Any]])
+ else if (any.isInstanceOf[Tree])
+ apply(any.asInstanceOf[Tree])
else if (any.isInstanceOf[Symbol])
apply(any.asInstanceOf[Symbol])
else if (any.isInstanceOf[Type])
@@ -26,10 +26,10 @@ object Print extends Function1[Any, String] {
else "UnknownAny"
}
- def apply (typedCode: TypedCode[Any]): String =
- Print(typedCode.code);
+ def apply (code: Code[Any]): String =
+ Print(code.tree);
- def apply (code: Code): String = code match {
+ def apply (tree: Tree): String = tree match {
case reflect.Ident(sym) => Print(sym)
case reflect.Select(qual, sym) => Print(qual) + "." + Print(sym)
case reflect.Literal(value) => value match {
@@ -43,7 +43,7 @@ object Print extends Function1[Any, String] {
case reflect.Block(stats, expr) => (stats ::: List(expr)).map(Print).mkString("{\n", ";\n", "\n}")
case reflect.New(tpt) => "new " + Print(tpt)
case reflect.If(condition, trueCase, falseCase) => "if (" + Print(condition) + ") " + Print(trueCase) + " else " + Print(falseCase)
- case reflect.Assign(destination: Code, source: Code) => Print(destination) + " = " + Print(source)
+ case reflect.Assign(destination: Tree, source: Tree) => Print(destination) + " = " + Print(source)
case reflect.Target(sym, body) => "target " + Print(sym) + " {\n" + Print(body) + "\n}"
case reflect.Goto(target) => "goto " + Print(target)
case _ => "???"
diff --git a/src/library/scala/reflect/Tree.scala b/src/library/scala/reflect/Tree.scala
new file mode 100755
index 0000000000..053f8119b5
--- /dev/null
+++ b/src/library/scala/reflect/Tree.scala
@@ -0,0 +1,29 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id: Tree.scala 5880 2006-03-03 00:05:17 +0100 (Fri, 03 Mar 2006) mihaylov $
+
+
+package scala.reflect;
+
+
+abstract class Tree;
+
+case class Ident(sym: Symbol) extends Tree;
+case class Select(qual: Tree, sym: Symbol) extends Tree;
+case class Literal(value: Any) extends Tree;
+case class Apply(fun: Tree, args: List[Tree]) extends Tree;
+case class TypeApply(fun: Tree, args: List[Type]) extends Tree;
+case class Function(params: List[Symbol], body: Tree) extends Tree;
+case class This(sym: Symbol) extends Tree;
+case class Block(stats: List[Tree], expr: Tree) extends Tree;
+case class New(sym: Tree) extends Tree;
+case class If(condition: Tree, trueCase: Tree, falseCase: Tree) extends Tree;
+case class Assign(destination: Tree, source: Tree) extends Tree;
+case class Target(sym: LabelSymbol, body: Tree) extends Tree;
+case class Goto(target: LabelSymbol) extends Tree;
diff --git a/src/library/scala/reflect/TypedCode.scala b/src/library/scala/reflect/TypedCode.scala
index 97066bc60f..b2acd81cae 100644
--- a/src/library/scala/reflect/TypedCode.scala
+++ b/src/library/scala/reflect/TypedCode.scala
@@ -11,5 +11,5 @@
package scala.reflect;
-
-class TypedCode[T](val code: Code) {}
+// This file is OBSOLETE, delete when build bootstraps without it
+class TypedCode[T](val code: Any) {}