From 97d8a84895c9fefeec108668d555f55eea665eb4 Mon Sep 17 00:00:00 2001 From: paltherr Date: Sun, 7 Sep 2003 10:53:24 +0000 Subject: - Added method mkIdents - Added method mkTypeIdents - Removed method mkTypeIdent without pos - Added methods mkApply --- sources/scalac/ast/TreeGen.java | 47 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) (limited to 'sources/scalac/ast/TreeGen.java') diff --git a/sources/scalac/ast/TreeGen.java b/sources/scalac/ast/TreeGen.java index 7ffcf347ea..d6f85f15f3 100644 --- a/sources/scalac/ast/TreeGen.java +++ b/sources/scalac/ast/TreeGen.java @@ -116,7 +116,27 @@ public class TreeGen implements Kinds, Modifiers, TypeTags { } } - /** Build and attribute type ident node with given symbol. + /** Build and attribute ident nodes with given symbols. + */ + public Tree[] mkIdents(int pos, Symbol[] syms) { + if (syms.length == 0) return Tree.EMPTY_ARRAY; + Tree[] trees = new Tree[syms.length]; + for (int i = 0; i < trees.length; i++) + trees[i] = Ident(pos, syms[i]); + return trees; + } + + /** Build and attribute type idents with given symbols. + */ + public Tree[] mkTypeIdents(int pos, Symbol[] syms) { + if (syms.length == 0) return Tree.EMPTY_ARRAY; + Tree[] trees = new Tree[syms.length]; + for (int i = 0; i < trees.length; i++) + trees[i] = mkTypeIdent(pos, syms[i]); + return trees; + } + + /** Build and attribute type ident with given symbol. */ public Tree mkTypeIdent(int pos, Symbol sym) { assert sym.kind == TYPE: Debug.show(sym); @@ -124,10 +144,6 @@ public class TreeGen implements Kinds, Modifiers, TypeTags { return mkType(pos, sym.nextType()); } - public Tree mkTypeIdent(Symbol sym) { - return Ident(sym.pos, sym); - } - /** Build and attribute tree corresponding to given type. */ public Tree mkType(int pos, Type type) { @@ -416,6 +432,27 @@ public class TreeGen implements Kinds, Modifiers, TypeTags { return New(pos, pre, clazz, Type.EMPTY_ARRAY, args); } + /** Build application with given function, type args and value + * args. + */ + public Tree mkApply(int pos, Tree fn, Type[] targs, Tree[] args) { + if (targs.length != 0) fn = TypeApply(pos, fn, mkTypes(pos, targs)); + return Apply(pos, fn, args); + } + + public Tree mkApply(Tree fn, Type[] targs, Tree[] args) { + return mkApply(fn.pos, fn, targs, args); + } + + public Tree mkApply(int pos, Tree fn, Tree[] targs, Tree[] args) { + if (targs.length != 0) fn = TypeApply(pos, fn, targs); + return Apply(pos, fn, args); + } + + public Tree mkApply(Tree fn, Tree[] targs, Tree[] args) { + return mkApply(fn.pos, fn, targs, args); + } + /** Build and attribute application node with given function * and argument trees. */ -- cgit v1.2.3