diff options
author | Martin Odersky <odersky@gmail.com> | 2005-10-10 12:09:07 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2005-10-10 12:09:07 +0000 |
commit | e093d72b2f4eb1bf65beafbd6aff1023e3dd1511 (patch) | |
tree | f0886fba871334a2af15f6cba41c271e2c135469 | |
parent | bd6070ae783d2be0fe02bdbf2a4b5138f2cbb8a5 (diff) | |
download | scala-e093d72b2f4eb1bf65beafbd6aff1023e3dd1511.tar.gz scala-e093d72b2f4eb1bf65beafbd6aff1023e3dd1511.tar.bz2 scala-e093d72b2f4eb1bf65beafbd6aff1023e3dd1511.zip |
*** empty log message ***
-rwxr-xr-x | sources/scala/reflect/Code.scala | 18 | ||||
-rwxr-xr-x | sources/scala/reflect/Symbol.scala | 51 | ||||
-rwxr-xr-x | sources/scala/reflect/Type.scala | 22 | ||||
-rw-r--r-- | sources/scala/reflect/TypedCode.scala | 13 |
4 files changed, 104 insertions, 0 deletions
diff --git a/sources/scala/reflect/Code.scala b/sources/scala/reflect/Code.scala new file mode 100755 index 0000000000..6122dec396 --- /dev/null +++ b/sources/scala/reflect/Code.scala @@ -0,0 +1,18 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2004, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +** $Id$ +\* */ +package scala.reflect; + +abstract class Code; + +case class Ident(sym: Symbol) extends Code; +case class Apply(fun: Code, args: List[Code]) extends Code; +case class TypeApply(fun: Code, args: List[Type]) extends Code; +case class Select(qual: Code, sym: Symbol) extends Code; +case class Function(params: List[Symbol], body: Code) extends Code; + diff --git a/sources/scala/reflect/Symbol.scala b/sources/scala/reflect/Symbol.scala new file mode 100755 index 0000000000..d0368edd72 --- /dev/null +++ b/sources/scala/reflect/Symbol.scala @@ -0,0 +1,51 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2004, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +** $Id$ +\* */ +package scala.reflect; + +abstract class Symbol { + val owner: Symbol; + val name: String; + val tpe: Type; +} + +abstract class GlobalSymbol(val fullname: String) extends Symbol { + private val pointIndex = fullname.lastIndexOf('.'); + val owner: Symbol = + if (pointIndex < 0) RootSymbol else Class(fullname.substring(0, pointIndex)); + val name: String = + if (pointIndex < 0) fullname else fullname.substring(pointIndex, fullname.length()); +} + +abstract class LocalSymbol extends Symbol {} + +case class Class(override val fullname: String) extends GlobalSymbol(fullname) { + val tpe = TypeIdent(ThisType(owner), this); +} + +case class Method(override val fullname: String, tpe: Type) extends GlobalSymbol(fullname); + +case class Field(override val fullname: String, tpe: Type) extends GlobalSymbol(fullname); + +case class TypeField(override val fullname: String, tpe: Type) extends GlobalSymbol(fullname); + +case class LocalValue(owner: Symbol, name: String, tpe: Type) extends LocalSymbol; + +case class LocalMethod(owner: Symbol, name: String, tpe: Type) extends LocalSymbol; + +case object NoSymbol extends Symbol { + val owner = null; + val name = null; + val tpe = NoType +} + +case object RootSymbol extends Symbol { + val owner = NoSymbol; + val name = "<root>"; + val tpe = TypeIdent(NoPrefix, this) +} diff --git a/sources/scala/reflect/Type.scala b/sources/scala/reflect/Type.scala new file mode 100755 index 0000000000..9b4c4d2e1b --- /dev/null +++ b/sources/scala/reflect/Type.scala @@ -0,0 +1,22 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2004, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +** $Id$ +\* */ +package scala.reflect; + +abstract class Type; + +case object NoPrefix extends Type; +case object NoType extends Type; + +case class TypeIdent(pre: Type, sym: Symbol) extends Type; +case class SingleType(pre: Type, sym: Symbol) extends Type; +case class ThisType(clazz: Symbol) extends Type; +case class AppliedType(tpe: Type, args: List[Type]) extends Type; +case class TypeBounds(lo: Type, hi: Type) extends Type; +case class MethodType(formals: List[Type], restpe: Type) extends Type; +class ImplicitMethodType(formals: List[Type], restpe: Type) extends MethodType(formals, restpe); diff --git a/sources/scala/reflect/TypedCode.scala b/sources/scala/reflect/TypedCode.scala new file mode 100644 index 0000000000..38ce0512c7 --- /dev/null +++ b/sources/scala/reflect/TypedCode.scala @@ -0,0 +1,13 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2004, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +** $Id$ +\* */ +package scala.reflect; + +class TypedCode[T](val code: Code) { +} + |