From b9ff893fdfcca3f97c5c953ba46461cf623c4b14 Mon Sep 17 00:00:00 2001 From: schinz Date: Wed, 14 May 2003 13:00:43 +0000 Subject: - modified mkParentConstr(s) to make it possibl... - modified mkParentConstr(s) to make it possible to pass arguments to the parent constructor --- sources/scalac/ast/TreeGen.java | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'sources/scalac') diff --git a/sources/scalac/ast/TreeGen.java b/sources/scalac/ast/TreeGen.java index 5d11c4b1f1..12c6926769 100644 --- a/sources/scalac/ast/TreeGen.java +++ b/sources/scalac/ast/TreeGen.java @@ -179,27 +179,37 @@ public class TreeGen implements Kinds, Modifiers { /** Build a tree to be used as a base class constructor for a template. */ - public Tree mkParentConstr(int pos, Type parentType) { + public Tree mkParentConstr(int pos, Type parentType, Tree[] parentArgs) { switch (parentType) { case TypeRef(Type pre, Symbol sym, Type[] args): Tree ref = mkRef(pos, pre, sym.constructor()); Tree constr = (args.length == 0) ? ref : TypeApply(ref, mkTypes(sym.pos, args)); - return Apply(constr, Tree.EMPTY_ARRAY); + return Apply(constr, parentArgs); default: throw global.fail("invalid parent type", parentType); } } + public Tree mkParentConstr(int pos, Type parentType) { + return mkParentConstr(pos, parentType, Tree.EMPTY_ARRAY); + } + /** Build an array of trees to be used as base classes for a template. */ - public Tree[] mkParentConstrs(int pos, Type[] parents) { + public Tree[] mkParentConstrs(int pos, Type[] parents, Tree[][] parentArgs) { Tree[] constrs = new Tree[parents.length]; for (int i = 0; i < parents.length; ++i) - constrs[i] = mkParentConstr(pos, parents[i]); + constrs[i] = (parentArgs == null ? + mkParentConstr(pos, parents[i]) + : mkParentConstr(pos, parents[i], parentArgs[i])); return constrs; } + public Tree[] mkParentConstrs(int pos, Type[] parents) { + return mkParentConstrs(pos, parents, null); + } + /** Build parameter sections corresponding to type. */ public ValDef[][] mkParams(int pos, Type type) { @@ -257,7 +267,7 @@ public class TreeGen implements Kinds, Modifiers { .setSymbol(sym).setType(definitions.UNIT_TYPE); } - public Tree TypeDef(Symbol sym) { + public TypeDef TypeDef(Symbol sym) { return TypeDef(sym.pos, sym); } -- cgit v1.2.3