aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-02-15 15:51:07 +0100
committerMartin Odersky <odersky@gmail.com>2013-02-15 15:51:07 +0100
commit626f3ef1c2b1c874bab88ff8b43f7fa7a42e9e4b (patch)
treefbaf64571f0ce9811135127ebe0dbc9097a8ef8d /src
parent48076bb9c287d82a1259885dccfa424df16fe912 (diff)
downloaddotty-626f3ef1c2b1c874bab88ff8b43f7fa7a42e9e4b.tar.gz
dotty-626f3ef1c2b1c874bab88ff8b43f7fa7a42e9e4b.tar.bz2
dotty-626f3ef1c2b1c874bab88ff8b43f7fa7a42e9e4b.zip
More annotation constructors.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/core/Annotations.scala35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/core/Annotations.scala b/src/dotty/tools/dotc/core/Annotations.scala
index 1bd6fc31f..fae8082bd 100644
--- a/src/dotty/tools/dotc/core/Annotations.scala
+++ b/src/dotty/tools/dotc/core/Annotations.scala
@@ -1,6 +1,6 @@
package dotty.tools.dotc.core
-import Symbols._, Trees._, Types._, Positions._, Contexts._
+import Symbols._, Trees._, Types._, Positions._, Contexts._, Constants._
object Annotations {
@@ -15,14 +15,37 @@ object Annotations {
object Annotation {
+ def apply(cls: ClassSymbol, arg: TypedTree)(implicit ctx: Context): Annotation =
+ apply(cls, arg :: Nil)
+
+ def apply(cls: ClassSymbol, arg1: TypedTree, arg2: TypedTree)(implicit ctx: Context): Annotation =
+ apply(cls, arg1 :: arg2 :: Nil)
+
def apply(cls: ClassSymbol, args: List[TypedTree])(implicit ctx: Context): Annotation =
- ConcreteAnnotation(makeTypedTree.New(cls.typeConstructor, args))
+ apply(cls.typeConstructor, args)
- def makeAlias(sym: TermSymbol)(implicit ctx: Context) =
- apply(defn.AliasAnnot, List(makeTypedTree.Ident(TermRef(sym.owner.thisType, sym))))
+ def apply(atp: Type, arg: TypedTree)(implicit ctx: Context): Annotation =
+ apply(atp, arg :: Nil)
+
+ def apply(atp: Type, arg1: TypedTree, arg2: TypedTree)(implicit ctx: Context): Annotation =
+ apply(atp, arg1 :: arg2 :: Nil)
+
+ def apply(atp: Type, args: List[TypedTree])(implicit ctx: Context): Annotation =
+ ConcreteAnnotation(makeTypedTree.New(atp, args))
- def makeChild(sym: ClassSymbol)(implicit ctx: Context) =
- apply(defn.ChildAnnot, List(makeTypedTree.Ident(TypeRef(sym.owner.thisType, sym))))
+ def makeAlias(sym: TermSymbol)(implicit ctx: Context) =
+ apply(defn.AliasAnnot, List(makeTypedTree.Ident(TermRef(sym.owner.thisType, sym.name, sym.signature))))
+ def makeChild(sym: Symbol)(implicit ctx: Context) =
+ apply(defn.ChildAnnot, List(makeTypedTree.Ident(NamedType(sym.owner.thisType, sym.name))))
}
+
+ def makeLiteralAnnotArg(const: Constant): TypedTree = ???
+
+ def makeArrayAnnotArg(elems: Array[TypedTree]): TypedTree = ???
+
+ def makeNestedAnnotArg(annot: Annotation): TypedTree = annot.tree
+
+ def ThrowsAnnotation(cls: ClassSymbol)(implicit ctx: Context) =
+ Annotation(defn.ThrowsAnnot, makeTypedTree.Ident(TypeRef(cls.owner.thisType, cls.name)))
} \ No newline at end of file