diff options
author | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2005-12-18 18:33:03 +0000 |
---|---|---|
committer | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2005-12-18 18:33:03 +0000 |
commit | d3819b93ab8b2de3d5cc35c33b8258ccdb5a931a (patch) | |
tree | dfc6f7f497e58ea3321e6f687b11313d2afa86b5 /sources/meta/scalac | |
parent | 0e82079908655682e5140ad521cef0572cb6d2a4 (diff) | |
download | scala-d3819b93ab8b2de3d5cc35c33b8258ccdb5a931a.tar.gz scala-d3819b93ab8b2de3d5cc35c33b8258ccdb5a931a.tar.bz2 scala-d3819b93ab8b2de3d5cc35c33b8258ccdb5a931a.zip |
Removed old Scalac code in sources and various ...
Removed old Scalac code in sources and various other obsolete elements.
Diffstat (limited to 'sources/meta/scalac')
20 files changed, 0 insertions, 1791 deletions
diff --git a/sources/meta/scalac/Phase.java b/sources/meta/scalac/Phase.java deleted file mode 100644 index 8092d6125b..0000000000 --- a/sources/meta/scalac/Phase.java +++ /dev/null @@ -1,46 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package meta.scalac; - -/** A representation for Scala compiler phases. */ -public class Phase { - - //######################################################################## - // Public Constants - - public static final Phase - START = new Phase("start", null), - PARSER = new Phase("parser", "PARSER"), - DESUGARIZER = new Phase("desugarizer", "ANALYZER"), - ANALYZER = new Phase("analyzer", "ANALYZER"), - REFCHECK = new Phase("refcheck", "REFCHECK"), - UNCURRY = new Phase("uncurry", "UNCURRY"), - TRANSMATCH = new Phase("transmatch", "TRANSMATCH"), - LAMBDALIFT = new Phase("lambdalift", "LAMBDALIFT"), - EXPLICITOUTER = new Phase("explicitouter", "EXPLICITOUTER"), - ERASURE = new Phase("erasure", "ERASURE"), - UNKNOWN = new Phase("? !!!", null), - END = new Phase("-", null); - - //######################################################################## - // Public Fields - - public final String name; - public final String constant; - - //######################################################################## - // Public Constructors - - public Phase(String name, String constant) { - this.name = name; - this.constant = constant; - } - - //######################################################################## -} diff --git a/sources/meta/scalac/ast/AbstractTreeCaseExpander.java b/sources/meta/scalac/ast/AbstractTreeCaseExpander.java deleted file mode 100644 index c7e023c16f..0000000000 --- a/sources/meta/scalac/ast/AbstractTreeCaseExpander.java +++ /dev/null @@ -1,62 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package meta.scalac.ast; - -/** A base class for expanders that generate switches on tree nodes. */ -public abstract class AbstractTreeCaseExpander extends AbstractTreeExpander { - - //######################################################################## - // Public Constructors - - public AbstractTreeCaseExpander() { - writer.importType(t_Debug); - } - - //######################################################################## - // Public Methods - - public void printTreeSwitch() { - writer.println("switch (tree) {"); - writer.println(); - printTreeCases(); - writer.println("default:"); - writer.indent(); - writer.print("throw ").print(t_Debug). - println(".abort(\"unknown tree\", tree);"); - writer.undent(); - writer.println("}"); - } - - public void printTreeCases() { - for (int i = 0; i < tree.nodes.length; i++) { - printTreeCase(tree.nodes[i]); - writer.println(); - } - } - - public void printTreeCase(TreeNode node) { - printTreeCaseHeader(node); - writer.println().indent(); - printTreeCaseBody(node); - printTreeCaseFooter(node); - writer.undent(); - } - - public void printTreeCaseHeader(TreeNode node) { - node.printCase(writer, false); - } - - public abstract void printTreeCaseBody(TreeNode node); - - public void printTreeCaseFooter(TreeNode node) { - // do nothing - } - - //######################################################################## -} diff --git a/sources/meta/scalac/ast/AbstractTreeExpander.java b/sources/meta/scalac/ast/AbstractTreeExpander.java deleted file mode 100644 index 503a9651a2..0000000000 --- a/sources/meta/scalac/ast/AbstractTreeExpander.java +++ /dev/null @@ -1,41 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package meta.scalac.ast; - -import meta.java.Type; -import meta.java.AbstractJavaExpander; - -/** A base class for expanders that handle tree nodes. */ -public abstract class AbstractTreeExpander extends AbstractJavaExpander { - - //######################################################################## - // Public Fields - - public final Type t_Debug; - public final Tree tree; - - //######################################################################## - // Public Constructors - - public AbstractTreeExpander() { - this.t_Debug = TreeType.Reference("scalac.util", "Debug"); - this.tree = new Tree(); - writer.importFrom(t_Debug); - writer.importFrom(tree.getType(0)); - for (int i = 0; i < tree.nodes.length; i++) { - if (tree.nodes[i].fields != null) - for (int j = 0; j < tree.nodes[i].fields.length; j++) - writer.importType(tree.nodes[i].fields[j].type); - if (tree.nodes[i].hasSymbol()) - writer.importType(tree.nodes[i].getSymbol().type); - } - } - - //######################################################################## -} diff --git a/sources/meta/scalac/ast/AbstractTreeMethodExpander.java b/sources/meta/scalac/ast/AbstractTreeMethodExpander.java deleted file mode 100644 index 7444759111..0000000000 --- a/sources/meta/scalac/ast/AbstractTreeMethodExpander.java +++ /dev/null @@ -1,31 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package meta.scalac.ast; - -/** A base class for expanders that generate one method per tree node. */ -public abstract class AbstractTreeMethodExpander extends AbstractTreeExpander { - - //######################################################################## - // Public Methods - - public void printTreeMethods() { - for (int i = 0; i < tree.nodes.length; i++) { - if (tree.nodes[i].fields != null) { - printTreeMethod(tree.nodes[i], false); - if (tree.nodes[i].hasSymbol()) - printTreeMethod(tree.nodes[i], true); - } - writer.println(); - } - } - - public abstract void printTreeMethod(TreeNode node, boolean withSymbol); - - //######################################################################## -} diff --git a/sources/meta/scalac/ast/MetaDefaultTreeFactory.java b/sources/meta/scalac/ast/MetaDefaultTreeFactory.java deleted file mode 100644 index fde4fe7773..0000000000 --- a/sources/meta/scalac/ast/MetaDefaultTreeFactory.java +++ /dev/null @@ -1,25 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package meta.scalac.ast; - -public class MetaDefaultTreeFactory extends AbstractTreeMethodExpander { - - //######################################################################## - // Public Methods - - public void printTreeMethod(TreeNode node, boolean withSymbol) { - node.printMethod(writer, "int pos", withSymbol).lbrace(); - node.printNew(writer.print(node + " t = "), withSymbol).println(";"); - writer.println("t.pos = pos;"); - writer.println("return t;"); - writer.rbrace(); - } - - //######################################################################## -} diff --git a/sources/meta/scalac/ast/MetaLazyTreeCopier.java b/sources/meta/scalac/ast/MetaLazyTreeCopier.java deleted file mode 100644 index c389ab9404..0000000000 --- a/sources/meta/scalac/ast/MetaLazyTreeCopier.java +++ /dev/null @@ -1,51 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package meta.scalac.ast; - -public class MetaLazyTreeCopier extends AbstractTreeMethodExpander { - - //######################################################################## - // Public Methods - - public void printTreeMethod(TreeNode node, boolean withSymbol) { - TreeField symbol = node.getSymbol(); - node.printMethod(writer, tree.getFormal("tree"), withSymbol).lbrace(); - if (!withSymbol && node.hasLinkedFields()) - writer.println("assert tree.symbol() == null : "+ - "\"tree's symbol is not null\";"); - writer.print(node.getType(0)).print(" t = ("). - print(node.getType(0)).println(")tree;"); - TreeField[] fields = node.getFields(withSymbol); - // !!! why do we copy if there is no symbol and no field - if (withSymbol || node.fields.length > 0) { - writer.print("if (").indent(); - if (withSymbol) writer.print("t.symbol() == " + symbol); - for (int i = 0; i < fields.length; i++) { - if (i > 0 ? true : withSymbol) writer.println(" &&"); - writer.print("t." + fields[i] + " == " + fields[i]); - } - writer.println(")"); - writer.println("return t;").undent(); - } - writer.print("return copier."); - node.printCall(writer, "tree", withSymbol).println(";"); - writer.rbrace(); - - if (withSymbol && node.hasLinkedFields()) { - node.printMethod(writer, tree.getFormal("tree"), false, true); - writer.lbrace(); - symbol.print(writer, true).println(" = tree.symbol();"); - node.printCall(writer.print("return "), "tree", true).println(";"); - writer.rbrace(); - return; - } - } - - //######################################################################## -} diff --git a/sources/meta/scalac/ast/MetaStrictTreeCopier.java b/sources/meta/scalac/ast/MetaStrictTreeCopier.java deleted file mode 100644 index 62823377dd..0000000000 --- a/sources/meta/scalac/ast/MetaStrictTreeCopier.java +++ /dev/null @@ -1,44 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package meta.scalac.ast; - -public class MetaStrictTreeCopier extends AbstractTreeMethodExpander { - - //######################################################################## - // Public Methods - - public void printTreeMethod(TreeNode node, boolean withSymbol) { - TreeField symbol = node.getSymbol(); - node.printMethod(writer, tree.getFormal("tree"), withSymbol).lbrace(); - if (!withSymbol && node.hasLinkedFields()) - writer.println("assert tree.symbol() == null : "+ - "\"tree's symbol is not null\";"); - writer.print(node.getType(0)).print(" t = make."); - node.printCall(writer, "tree.pos", withSymbol).println(";"); - writer.println("t.type = tree.type;"); - if (!withSymbol && node.hasSymbol() && !node.hasLinkedFields()) { - symbol.print(writer, true).println(" = tree.symbol();"); - writer.println("if ("+symbol+" != null) t.setSymbol("+symbol+");"); - } - writer.println("return t;"); - writer.rbrace(); - - if (withSymbol && node.hasLinkedFields()) { - node.printMethod(writer, tree.getFormal("tree"), false, true); - writer.lbrace(); - symbol.print(writer, true).println(" = tree.symbol();"); - node.printCall(writer.print("return "), "tree", true).println(";"); - writer.rbrace(); - } - } - - //######################################################################## -} - - diff --git a/sources/meta/scalac/ast/MetaTransformer.java b/sources/meta/scalac/ast/MetaTransformer.java deleted file mode 100644 index 79ebebaf2f..0000000000 --- a/sources/meta/scalac/ast/MetaTransformer.java +++ /dev/null @@ -1,77 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package meta.scalac.ast; - -import meta.java.Type; - -public class MetaTransformer extends AbstractTreeCaseExpander { - - //######################################################################## - // Public Methods - - public void printTreeCaseBody(TreeNode node) { - if (node.fields == null) { - writer.println("return tree;"); - } else { - if (node.hasSymbol()) { - writer.print("if (tree.symbol() != null)").lbrace(); - printTransformNode(node, true); - writer.undent().print("} else").lbrace(); - } - printTransformNode(node, false); - if (node.hasSymbol()) writer.rbrace(); - } - } - - public void printTransformNode(TreeNode node, boolean withSymbol) { - TreeField[] fields = node.getFields(withSymbol); - writer.print("return copy." + node + "(tree"); - if (withSymbol) writer.print(", tree.symbol()"); - for (int i = 0; i < fields.length; i++) { - writer.print(", "); - if (Tree.isTree(fields[i].type)) - writer.print("transform(" + fields[i].name + ")"); - else - writer.print(fields[i].name); - } - writer.println(");"); - } - - public void printTransformArrays() { - for (int j = 1; j <= tree.arrays; j++) - printTransformArray(tree.getType(j), false); - for (int i = 0; i < tree.nodes.length; i++) - for (int j = 1; j <= tree.nodes[i].arrays; j++) - printTransformArray(tree.nodes[i].getType(j), j == 1); - } - - public void printTransformArray(Type type, boolean needCast) { - Type item = type.getItemType(); - Type erased = needCast ? tree.getType(0) : item; - String cast = needCast ? "(" + item + ")" : ""; - writer.print("public ").print(type).print(" transform"). - print("(").print(type).print(" ts)").lbrace(); - writer.print("for (int i = 0; i < ts.length; i++)").lbrace(); - writer.println(erased + " t = transform(ts[i]);"); - writer.print("if (t != ts[i])").lbrace(); - writer.println(type+" res = new "+item.newArray("[ts.length]")+";"); - writer.println("System.arraycopy(ts, 0, res, 0, i);"); - writer.println("res[i++] = "+cast+"t;"); - writer.print("for (; i < ts.length; i++)"). - println("res[i] = "+cast+"transform(ts[i]);"); - writer.println("return res;"); - writer.rbrace(); - writer.rbrace(); - writer.println("return ts;"); - writer.rbrace(); - writer.line(); - } - - //######################################################################## -} diff --git a/sources/meta/scalac/ast/MetaTraverser.java b/sources/meta/scalac/ast/MetaTraverser.java deleted file mode 100644 index 0f166510db..0000000000 --- a/sources/meta/scalac/ast/MetaTraverser.java +++ /dev/null @@ -1,44 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package meta.scalac.ast; - -import meta.java.Type; - -public class MetaTraverser extends AbstractTreeCaseExpander { - - //######################################################################## - // Public Methods - - public void printTreeCaseBody(TreeNode node) { - if (node.fields != null) - for (int i = 0; i < node.fields.length; i++) - if (Tree.isTree(node.fields[i].type)) - writer.println("traverse(" + node.fields[i] + ");"); - writer.println("return;"); - } - - public void printTraverseArrays() { - int max = tree.arrays; - for (int i = 0; i < tree.nodes.length; i++) - max = Math.max(max, tree.nodes[i].arrays); - for (int i = 1; i <= max; i++) - printTraverseArray(tree.getType(i)); - } - - public void printTraverseArray(Type type) { - writer.print("public void traverse"). - print("(").print(type).print(" trees)").lbrace(); - writer.print("for (int i = 0; i < trees.length; i++) "). - println("traverse(trees[i]);"); - writer.rbrace(); - writer.line(); - } - - //######################################################################## -} diff --git a/sources/meta/scalac/ast/MetaTree.java b/sources/meta/scalac/ast/MetaTree.java deleted file mode 100644 index 31b98d1d4b..0000000000 --- a/sources/meta/scalac/ast/MetaTree.java +++ /dev/null @@ -1,218 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package meta.scalac.ast; - -import meta.java.Type; - -public class MetaTree extends AbstractTreeExpander { - - //######################################################################## - // Public Methods - - public void printEmptyArrays() { - printEmptyArrays(tree.getType(0), "EMPTY", tree.arrays); - for (int i = 0; i < tree.nodes.length; i++) { - TreeNode node = tree.nodes[i]; - printEmptyArrays(node.getType(0), node + "_EMPTY", node.arrays); - } - } - - public void printEmptyArrays(Type base, String prefix, int maxRank) { - Type type = base; - for (int rank = 1; rank <= maxRank; rank++) { - type = Type.Array(type); - writer.print("public static final ").print(type).print(" "+prefix); - for (int i = 0; i < rank; i++) writer.print("_ARRAY"); - writer.print(" = new ").print(base).print("[0]"); - for (int i = 1; i < rank; i++) writer.print("[]"); - writer.println(";"); - } - } - - public void printTreeCases() { - for (int i = 0; i < tree.nodes.length; i++) - printTreeCase(tree.nodes[i]); - } - - private void printTreeCase(TreeNode node) { - writer.printDescription(new String[] { - node.description, - "- kind : " + description(node.kind), - "- symbol : " + description(node.symbol), - "- introduced by: " + node.start.name, - "- eliminated by: " + node.stop.name, - }); - node.printDecl(writer.print("public case "), null, false); - if (node.fields != null) { - writer.lbrace(); - writer.println("assert CheckTreeNodes.instance.checkNode(this);"); - writer.rbrace(); - } else { - writer.println(";"); - } - if (node == tree.n_Empty) - writer.print("static { " + node + ".type = Type.NoType; }"); - writer.println(); - } - - private String description(TreeKind kind) { - switch (kind) { - case Any : return "this tree is of any kind"; - case Type: return "this tree is a type"; - case Term: return "this tree is a term"; - case Dual: return "this tree is a type or a term"; - case Test: return "this tree is a type or a term " + - "(determined by the kind of the name field)"; - case None: return "this tree is neither a type nor a term"; - default : throw new Error(kind.getClass().getName()); - } - } - - private String description(TreeSymbol symbol) { - switch (symbol) { - case NoSym : return "this tree has no symbol"; - case HasSym(_, false): return "this tree references a symbol"; - case HasSym(_, true ): return "this tree defines a symbol"; - default : throw new Error(symbol.getClass().getName()); - } - } - - public void printIsKind() { - printIsKind(tree.nodes, TreeKind.Type); - printIsKind(tree.nodes, TreeKind.Term); - } - - private void printIsKind(TreeNode[] nodes, TreeKind kind) { - writer.println("/** Returns true if this tree is a " + - kind.toString().toLowerCase() + ". */"); - writer.print("public boolean is" + kind + "()").lbrace(); - writer.println("switch (this) {"); - - for (int i = 0; i < nodes.length; i++) - if (nodes[i].kind != TreeKind.Test && nodes[i].kind.isA(kind)) - nodes[i].printCase(writer, true).println(); - writer.indent().println("return true;").undent(); - - for (int i = 0; i < nodes.length; i++) { - if (nodes[i].kind != TreeKind.Test) continue; - writer.print("case " + nodes[i].name + "("); - for (int j = 0; j < nodes[i].fields.length; j++) { - if (j > 0) writer.print(", "); - switch (nodes[i].fields[j].type) { - case TreeType.Name(Test): - writer.print(nodes[i].fields[j].type + " name"); - break; - default: - writer.print("_"); - break; - } - } - writer.println("):"); - writer.indent().print("return "); - switch (kind) { - case TreeKind.Type: - writer.print("name.isTypeName() && (symbol() == null || !symbol().isConstructor()) || name == Names.ERROR"); - break; - case TreeKind.Term: - writer.print("name.isTermName() || (symbol() != null && symbol().isConstructor())"); - break; - default: - throw new Error("unexpected kind " + kind); - } - writer.println(";").undent(); - } - - writer.println("default:"); - writer.indent().println("return false;").undent(); - - writer.println("}"); - writer.rbrace(); - writer.println(); - } - - public void printExtClasses() { - for (int i = 0;i < tree.nodes.length;i++) printExtClass(tree.nodes[i]); - } - - private void printExtClass(TreeNode node) { - TreeField symbol = node.getSymbol(); - if (symbol == null) return; - writer.print("public static class Ext"+node+" extends "+node).lbrace(); - symbol.print(writer.print("private "), true).println(";"); - writer.println(); - - printExtConstructor(node, false); - printExtConstructor(node, true); - writer.println(); - - writer.print("public boolean hasSymbol()").lbrace(); - writer.println("return true;"); - writer.rbrace(); - writer.println(); - - if (node.definesSymbol()) { - writer.print("public boolean definesSymbol()").lbrace(); - writer.println("return true;"); - writer.rbrace(); - writer.println(); - } - - writer.print("public ").print(symbol.type).print(" symbol()"); - writer.lbrace(); - writer.println("return " + symbol + ";"); - writer.rbrace(); - writer.println(); - - writer.print("public ").print(tree.getType(0)).print(" setSymbol"); - symbol.print(writer.print("("), true).print(")").lbrace(); - printSetSymbol(symbol); - for (int i = 0; i < node.fields.length; i++) { - TreeField field = node.fields[i]; - TreeFieldLink link = field.link; - if (link == null) continue; - link.print(writer.print("this."+field+" = "),symbol).println(";"); - } - writer.println("return this;"); - writer.rbrace(); - - writer.rbrace(); - writer.println(); - } - - private void printExtConstructor(TreeNode node, boolean withSymbol) { - node.printDecl(writer.print("public Ext"), null, withSymbol).lbrace(); - TreeField symbol = node.getSymbol(); - writer.print("super("); - for (int i = 0; i < node.fields.length; i++) { - if (i > 0) writer.print(", "); - if (withSymbol && node.fields[i].link != null) { - node.fields[i].link.print(writer, symbol); - } else { - writer.print(node.fields[i].name); - } - } - writer.println(");"); - if (withSymbol) printSetSymbol(symbol); - writer.rbrace(); - } - - private void printSetSymbol(TreeField symbol) { - writer.println("assert " + symbol + " != null : \"null symbol\";"); - writer.println("this." + symbol + " = " + symbol + ";"); - } - - public void printEmptyCases() { - for (int i = 0;i < tree.nodes.length;i++) { - tree.nodes[i].printCase(writer, false).println(); - writer.println(); - } - } - - //######################################################################## -} diff --git a/sources/meta/scalac/ast/MetaTreeCopier.java b/sources/meta/scalac/ast/MetaTreeCopier.java deleted file mode 100644 index 785c3a99da..0000000000 --- a/sources/meta/scalac/ast/MetaTreeCopier.java +++ /dev/null @@ -1,26 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package meta.scalac.ast; - -public class MetaTreeCopier extends AbstractTreeMethodExpander { - - //######################################################################## - // Public Methods - - public void printTreeMethod(TreeNode node, boolean withSymbol) { - node.printMethod(writer,tree.getFormal("tree"),withSymbol); - writer.println(";"); - if (withSymbol && node.hasLinkedFields()) { - node.printMethod(writer, tree.getFormal("tree"), false, true); - writer.println(";"); - } - } - - //######################################################################## -} diff --git a/sources/meta/scalac/ast/MetaTreeFactory.java b/sources/meta/scalac/ast/MetaTreeFactory.java deleted file mode 100644 index 28b1f381c9..0000000000 --- a/sources/meta/scalac/ast/MetaTreeFactory.java +++ /dev/null @@ -1,21 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package meta.scalac.ast; - -public class MetaTreeFactory extends AbstractTreeMethodExpander { - - //######################################################################## - // Public Methods - - public void printTreeMethod(TreeNode node, boolean withSymbol) { - node.printMethod(writer, "int pos", withSymbol).println(";"); - } - - //######################################################################## -} diff --git a/sources/meta/scalac/ast/Tree.java b/sources/meta/scalac/ast/Tree.java deleted file mode 100644 index 492461bc59..0000000000 --- a/sources/meta/scalac/ast/Tree.java +++ /dev/null @@ -1,441 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package meta.scalac.ast; - -import java.util.List; -import java.util.ArrayList; - -import meta.java.Type; -import meta.scalac.Phase; - -/** This class describes all tree nodes. */ -public class Tree { - - //######################################################################## - // Private Fields - - private final TreeKind - Any = TreeKind.Any, - Type = TreeKind.Type, - Term = TreeKind.Term, - Dual = TreeKind.Dual, - Test = TreeKind.Test, - None = TreeKind.None; - - private final Type - t_int = TreeType.INT, - t_ints = TreeType.Array(t_int), - t_Object = TreeType.Reference(null, "Object"), - t_String = TreeType.Reference(null, "String"), - t_Global = TreeType.Reference("scalac", "Global"), - t_Unit = TreeType.Reference("scalac", "Unit"), - t_TreeGen = TreeType.Reference("scalac.ast", "TreeGen"), - t_AConstant = TreeType.Reference("scalac.atree", "AConstant"), - t_Symbol = TreeType.Reference("scalac.symtab", "Symbol"), - t_Type = TreeType.Reference("scalac.symtab", "Type"), - t_Name = TreeType.Name(Any), - t_TypeName = TreeType.Name(Type), - t_TermName = TreeType.Name(Term), - t_TestName = TreeType.Name(Test), - t_Names = TreeType.Array(t_Name), - t_Tree = getType(0), - t_TypeTree = getType(0, Type), - t_TermTree = getType(0, Term), - t_Trees = getType(1), - t_TypeTrees = getType(1, Type), - t_TermTrees = getType(1, Term); - - private final TreeFieldLink - SymFlags = TreeFieldLink.SymFlags, - SymName = TreeFieldLink.SymName; - - private final TreeField - tree_symbol = new TreeField(t_Symbol, "symbol"); - - private final TreeSymbol - NoSym = TreeSymbol.NoSym, - HasSym = TreeSymbol.HasSym(tree_symbol, false), - DefSym = TreeSymbol.HasSym(tree_symbol, true); - - private final List list - = new ArrayList(); - - //######################################################################## - // Public Fields - - public final TreeNode - n_Empty = node("Empty" , Any , NoSym), - n_Attributed = node("Attributed" , None, NoSym), - n_DocDef = node("DocDef" , None, NoSym), - n_ClassDef = node("ClassDef" , None, DefSym), - n_PackageDef = node("PackageDef" , None, NoSym), - n_ModuleDef = node("ModuleDef" , None, DefSym), - n_ValDef = node("ValDef" , None, DefSym), - n_PatDef = node("PatDef" , None, NoSym), - n_DefDef = node("DefDef" , None, DefSym), - n_AbsTypeDef = node("AbsTypeDef" , None, DefSym), - n_AliasTypeDef = node("AliasTypeDef" , None, DefSym), - n_Import = node("Import" , None, HasSym), - n_CaseDef = node("CaseDef" , None, NoSym), - n_Template = node("Template" , None, HasSym), - n_LabelDef = node("LabelDef" , Term, DefSym), - n_Block = node("Block" , Term, NoSym), - n_Sequence = node("Sequence" , Term, NoSym), - n_Alternative = node("Alternative" , Term, NoSym), - n_Bind = node("Bind" , Term, DefSym), - n_Visitor = node("Visitor" , Term, NoSym), - n_Function = node("Function" , Term, NoSym), - n_Assign = node("Assign" , Term, NoSym), - n_If = node("If" , Term, NoSym), - n_Switch = node("Switch" , Term, NoSym), - n_Return = node("Return" , Term, HasSym), - n_Throw = node("Throw" , Term, NoSym), - n_New = node("New" , Term, NoSym), - n_Create = node("Create" , Term, HasSym), - n_Typed = node("Typed" , Term, NoSym), - n_TypeApply = node("TypeApply" , Term, NoSym), - n_Apply = node("Apply" , Term, NoSym), - n_Super = node("Super" , Term, HasSym), - n_This = node("This" , Term, HasSym), - n_Select = node("Select" , Test, HasSym), - n_Ident = node("Ident" , Test, HasSym), - n_Literal = node("Literal" , Term, NoSym), - n_TypeTerm = node("TypeTerm" , Type, NoSym), - n_SingletonType = node("SingletonType" , Type, NoSym), - n_SelectFromType = node("SelectFromType", Type, HasSym), - n_FunType = node("FunType" , Type, NoSym), - n_CompoundType = node("CompoundType" , Type, NoSym), - n_AppliedType = node("AppliedType" , Type, NoSym), - n_Try = node("Try" , Term, NoSym); - - public final TreeNode[] nodes; - public int arrays; - - //######################################################################## - // Public Constructors - - public Tree() { - nodes = (TreeNode[])list.toArray(new TreeNode[list.size()]); - - n_Empty. - setDescription("A tree node for the absence of a tree"). - setRange(Phase.PARSER, Phase.UNKNOWN). - noFields(); - - n_Attributed. - setDescription("Attributed definition"). - setRange(Phase.PARSER, Phase.ANALYZER). - addField(t_Tree, "attribute"). - addField(t_Tree, "definition"); - - n_DocDef. - setDescription("Documented definition"). - setRange(Phase.PARSER, Phase.ANALYZER). - addField(t_String, "comment"). - addField(t_Tree, "definition"); - - n_ClassDef. - setDescription("Class and data declaration"). - setRange(Phase.PARSER, Phase.END). - addField(t_int, "mods", SymFlags). - addField(t_TypeName, "name", SymName). - addField(n_AbsTypeDef.getType(1), "tparams"). - addField(n_ValDef.getType(2), "vparams"). - addField(t_TypeTree, "tpe"). - addField(n_Template.getType(0), "impl"); - - n_PackageDef. - setDescription("Package declaration"). - setRange(Phase.PARSER, Phase.UNKNOWN). - addField(t_TermTree, "packaged"). - addField(n_Template.getType(0), "impl"); - - n_ModuleDef. - setDescription("Module declaration"). - setRange(Phase.PARSER, Phase.REFCHECK). - addField(t_int, "mods", SymFlags). - addField(t_TermName, "name", SymName). - addField(t_TypeTree, "tpe"). - addField(n_Template.getType(0), "impl"); - - n_ValDef. - setDescription("Value declaration (var or let)"). - setRange(Phase.PARSER, Phase.END). - addField(t_int, "mods", SymFlags). - addField(t_TermName, "name", SymName). - addField(t_TypeTree, "tpe"). - addField(t_TermTree, "rhs"); - - - n_PatDef. - setDescription("Value declaration with patterns (val)"). - setRange(Phase.PARSER, Phase.DESUGARIZER). - addField(t_int, "mods"). - addField(t_TermTree, "pat"). - addField(t_TermTree, "rhs"); - - n_DefDef. - setDescription("Function declaration (def)"). - setRange(Phase.PARSER, Phase.END). - addField(t_int, "mods", SymFlags). - addField(t_TermName, "name", SymName). - addField(n_AbsTypeDef.getType(1), "tparams"). - addField(n_ValDef.getType(2), "vparams"). - addField(t_TypeTree, "tpe"). - addField(t_TermTree, "rhs"); - - n_AbsTypeDef. - setDescription("Type declaration"). - setRange(Phase.PARSER, Phase.END). // !!! needed for type params - addField(t_int, "mods", SymFlags). - addField(t_TypeName, "name", SymName). - addField(t_TypeTree, "rhs"). - addField(t_TypeTree, "lobound"); - - n_AliasTypeDef. - setDescription("Type alias"). - setRange(Phase.PARSER, Phase.EXPLICITOUTER). - addField(t_int, "mods", SymFlags). - addField(t_TypeName, "name", SymName). - addField(n_AbsTypeDef.getType(1), "tparams"). - addField(t_TypeTree, "rhs"); - - n_Import. - setDescription("Import declaration"). - setRange(Phase.PARSER, Phase.ANALYZER). - addField(t_TermTree, "expr"). - addField(t_Names, "selectors"); - - n_CaseDef. - setDescription("Case declaration"). - setRange(Phase.PARSER, Phase.TRANSMATCH). - addField(t_TermTree, "pat"). - addField(t_TermTree, "guard"). - addField(t_TermTree, "body"); - - n_Template. - setDescription("Instantiation templates"). - setRange(Phase.PARSER, Phase.END). - addField(t_TermTrees, "parents"). - addField(t_Trees, "body"); - - n_LabelDef. - setDescription("Labelled expression - the symbols in the array (must be Idents!) are those the label takes as argument"). - setRange(Phase.PARSER, Phase.END). - addField(t_TermName, "name", SymName). - addField(n_Ident.getType(1), "params"). - addField(t_TermTree, "rhs"); - - n_Block. - setDescription("Block of expressions " + - "(semicolon separated expressions)"). - setRange(Phase.PARSER, Phase.END). - addField(t_Trees, "stats"). - addField(t_TermTree, "expr"); - - n_Sequence. - setDescription("Sequence of expressions (comma separated expressions)"). - setRange(Phase.PARSER, Phase.TRANSMATCH). - addField(t_TermTrees, "trees"); - - n_Alternative. - setDescription("Alternatives of expressions/patterns"). - setRange(Phase.PARSER, Phase.TRANSMATCH). - addField(t_TermTrees, "trees"); - - n_Bind. - setDescription("Bind of a variable to a rhs pattern, possibly recursive"). - setRange(Phase.PARSER, Phase.TRANSMATCH). - addField(t_TermName, "name", SymName). - addField(t_TermTree, "rhs"); - - - n_Visitor. - setDescription("Visitor (a sequence of cases)"). - setRange(Phase.PARSER, Phase.TRANSMATCH). - addField(n_CaseDef.getType(1), "cases"); - - - n_Function. - setDescription("Anonymous function"). - setRange(Phase.PARSER, Phase.ANALYZER). - addField(n_ValDef.getType(1), "vparams"). - addField(t_TermTree, "body"); - - n_Assign. - setDescription("Assignment"). - setRange(Phase.PARSER, Phase.END). - addField(t_TermTree, "lhs"). - addField(t_TermTree, "rhs"); - - n_If. - setDescription("Conditional expression"). - setRange(Phase.PARSER, Phase.END). - addField(t_TermTree, "cond"). - addField(t_TermTree, "thenp"). - addField(t_TermTree, "elsep"); - - n_Switch. - setDescription("Switch"). - setRange(Phase.REFCHECK, Phase.END). - addField(t_TermTree, "test"). - addField(t_ints, "tags"). - addField(t_TermTrees, "bodies"). - addField(t_TermTree, "otherwise"); - - n_Return. - setDescription("Return"). - setRange(Phase.PARSER, Phase.END). - addField(t_TermTree, "expr"); - - n_Throw. - setDescription("Throw"). - setRange(Phase.PARSER, Phase.ANALYZER). - addField(t_TermTree, "expr"); - - n_New. - setDescription("Instantiation"). - setRange(Phase.PARSER, Phase.END). - addField(t_TermTree, "init"); - - n_Create. - setDescription("Instance creation"). - setRange(Phase.ANALYZER, Phase.END). - addField(t_TermTree, "qualifier"). - addField(t_TypeTrees, "targs"); - - n_Typed. - setDescription("Type annotation"). - setRange(Phase.PARSER, Phase.EXPLICITOUTER). - addField(t_TermTree, "expr"). - addField(t_TypeTree, "tpe"); - - - n_TypeApply. - setDescription("Type application"). - setRange(Phase.PARSER, Phase.END). - addField(t_Tree, "fun"). - addField(t_TypeTrees, "args"); - - n_Apply. - setDescription("Value application"). - setRange(Phase.PARSER, Phase.END). - addField(t_Tree, "fun"). // !!! should be t_TermTree - addField(t_TermTrees, "args"); - - n_Super. - setDescription("Super reference"). - setRange(Phase.PARSER, Phase.END). - addField(t_TypeName, "qualifier", SymName). - addField(t_TypeName, "mixin"); - - n_This. - setDescription("Self reference"). - setRange(Phase.PARSER, Phase.END). - addField(t_TypeName, "qualifier", SymName); - - n_Select. - setDescription("Designator"). - setRange(Phase.PARSER, Phase.END). - addField(t_TermTree, "qualifier"). - addField(t_TestName, "selector", SymName); - - n_Ident. - setDescription("Identifier"). - setRange(Phase.PARSER, Phase.END). - addField(t_TestName, "name", SymName); - - n_Literal. - setDescription("Literal"). - setRange(Phase.PARSER, Phase.END). - addField(t_AConstant, "value"); - - n_TypeTerm. - setDescription("TypeTerm"). - setRange(Phase.PARSER, Phase.END); - - n_SingletonType. - setDescription("Singleton type"). - setRange(Phase.PARSER, Phase.REFCHECK). - addField(t_TermTree, "ref"); - - n_SelectFromType. - setDescription("Type selection"). - setRange(Phase.PARSER, Phase.REFCHECK). - addField(t_TypeTree, "qualifier"). - addField(t_TypeName, "selector", SymName); - - n_FunType. - setDescription("Function type"). - setRange(Phase.PARSER, Phase.REFCHECK). - addField(t_TypeTrees, "argtpes"). - addField(t_TypeTree, "restpe"); - - n_CompoundType. - setDescription("Object type (~ Template)"). - setRange(Phase.PARSER, Phase.REFCHECK). - addField(t_TypeTrees, "parents"). - addField(t_Trees, "refinements"); - - n_AppliedType. - setDescription("Applied type"). - setRange(Phase.PARSER, Phase.REFCHECK). - addField(t_TypeTree, "tpe"). - addField(t_TypeTrees, "args"); - - n_Try. - setDescription("Try Expression"). - setRange(Phase.PARSER, Phase.END). - addField(t_TermTree, "block"). - addField(t_TermTree, "catcher"). - addField(t_TermTree, "finalizer"); - } - - //######################################################################## - // Public Functions - - public static boolean isTree(Type type) { - switch (type) { - case Array(Type item): - return isTree(item); - case TreeType.Tree(_): - case TreeType.Node(_): - return true; - default: - return false; - } - } - - //######################################################################## - // Public Methods - - public Type getType(int rank) { - return getType(rank, Any); - } - - public Type getType(int rank, TreeKind kind) { - arrays = Math.max(arrays , rank); - return rank==0 ? TreeType.Tree(kind) : TreeType.Array(getType(rank-1)); - } - - public String getFormal(String name) { - return getType(0) + " " + name; - } - - //######################################################################## - // Private Methods - - private TreeNode node(String name, TreeKind kind, TreeSymbol symbol) { - TreeNode node = new TreeNode(name, kind, symbol); - list.add(node); - return node; - } - - //######################################################################## -} diff --git a/sources/meta/scalac/ast/TreeField.java b/sources/meta/scalac/ast/TreeField.java deleted file mode 100644 index 19df9cb42e..0000000000 --- a/sources/meta/scalac/ast/TreeField.java +++ /dev/null @@ -1,63 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package meta.scalac.ast; - -import meta.java.Type; -import meta.java.JavaWriter; - -/** This class describes a tree node field. */ -public class TreeField { - - //######################################################################## - // Public Fields - - public final Type type; - public final String name; - public final TreeFieldLink link; - - //######################################################################## - // Public Constructors - - public TreeField(Type type, String name) { - this(type, name, null); - } - - public TreeField(Type type, String name, TreeFieldLink link) { - this.type = type; - this.name = name; - this.link = link; - } - - //######################################################################## - // Public Function - - public static JavaWriter print(JavaWriter writer, TreeField[] fields, - boolean withType) - { - for (int i = 0; i < fields.length; i++) { - if (i > 0) writer.print(", "); - fields[i].print(writer, withType); - } - return writer; - } - - //######################################################################## - // Public Methods - - public JavaWriter print(JavaWriter writer, boolean withType) { - if (withType) writer.print(type).space(); - return writer.print(name); - } - - public String toString() { - return name; - } - - //######################################################################## -} diff --git a/sources/meta/scalac/ast/TreeFieldLink.java b/sources/meta/scalac/ast/TreeFieldLink.java deleted file mode 100644 index 62e8dcfb10..0000000000 --- a/sources/meta/scalac/ast/TreeFieldLink.java +++ /dev/null @@ -1,60 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package meta.scalac.ast; - -import meta.java.JavaWriter; - -/** - * This class describes the possible links between a given field of a - * tree and the symbol of that tree. - */ -public class TreeFieldLink { - - //######################################################################## - // Public Cases - - /** Field is linked to the symbol's flags */ - public case SymFlags; - - /** Field is linked to the symbol's name */ - public case SymName; - - //######################################################################## - // Public Methods - - /** Returns the field or method to invoke to get the linked value. */ - public String getLink() { - switch (this) { - case SymFlags: - return "flags"; - case SymName: - return "name"; - default: - throw new Error("unknown case: " + this); - } - } - - /** Returns the name of this link. */ - public String toString() { - switch (this) { - case SymFlags: - return "flags"; - case SymName: - return "name"; - default: - throw new Error("unknown case: " + this); - } - } - - public JavaWriter print(JavaWriter writer, TreeField symbol) { - return writer.print(symbol.name).print('.').print(getLink()); - } - - //######################################################################## -} diff --git a/sources/meta/scalac/ast/TreeKind.java b/sources/meta/scalac/ast/TreeKind.java deleted file mode 100644 index 35dcd0dd55..0000000000 --- a/sources/meta/scalac/ast/TreeKind.java +++ /dev/null @@ -1,63 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package meta.scalac.ast; - -/** This class enumerates the different kinds of tree nodes. */ -public class TreeKind { - - //######################################################################## - // Public Cases - - /** Designates a type, a term or anything else. */ - public case Any; - - /** Designates a type. */ - public case Type; - - /** Designates a term. */ - public case Term; - - /** Designates either a type or a term. */ - public case Dual; - - /** Designates either a type or a term (a test may indicate which one). */ - public case Test; - - /** Designates neither a type nor a term. */ - public case None; - - //######################################################################## - // Public Method - - public boolean isA(TreeKind that) { - switch (this) { - case Any : return true; - case Type: return that == Type; - case Term: return that == Term; - case Dual: return that == Type || that == Term || that == Dual; - case Test: return that == Type || that == Term || that == Dual; - case None: return that == None; - default : throw new Error(); - } - } - - public String toString() { - switch(this) { - case Any : return "Any"; - case Type: return "Type"; - case Term: return "Term"; - case Dual: return "Dual"; - case Test: return "Test"; - case None: return "None"; - default : throw new Error(); - } - } - - //######################################################################## -} diff --git a/sources/meta/scalac/ast/TreeNode.java b/sources/meta/scalac/ast/TreeNode.java deleted file mode 100644 index 340eaa8109..0000000000 --- a/sources/meta/scalac/ast/TreeNode.java +++ /dev/null @@ -1,231 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package meta.scalac.ast; - -import meta.java.Type; -import meta.java.JavaWriter; -import meta.scalac.Phase; - -/** This class describes a tree node. */ -public class TreeNode { - - //######################################################################## - // Public Fields - - public final String name; - public final TreeKind kind; - public final TreeSymbol symbol; - public String description; - public Phase start; - public Phase stop; - public TreeField[] fields; - public int arrays; - - //######################################################################## - // Public Constructors - - public TreeNode(String name, TreeKind kind, TreeSymbol symbol) { - this(name, kind, symbol, new TreeField[0]); - } - - public TreeNode(String name, TreeKind kind, TreeSymbol symbol, - TreeField[] fields) - { - this.name = name; - this.kind = kind; - this.symbol = symbol; - this.fields = fields; - } - - //######################################################################## - // Public Methods - Initializing - - public TreeNode setDescription(String description) { - this.description = description; - return this; - } - - public TreeNode setRange(Phase start, Phase stop) { - this.start = start; - this.stop = stop; - return this; - } - - public TreeNode noFields() { - fields = null; - return this; - } - - public TreeNode addField(Type type, String name) { - return addField(type, name, null); - } - - public TreeNode addField(Type type, String name, TreeFieldLink link) { - if (link != null && !hasSymbol()) - throw new Error("node "+this+" may not have linked fields"); - TreeField[] array = new TreeField[fields.length + 1]; - for (int i = 0; i < fields.length; i++) array[i] = fields[i]; - array[fields.length] = new TreeField(type, name, link); - fields = array; - return this; - } - - //######################################################################## - // Public Methods - Querying - - public Type getType(int rank) { - arrays = Math.max(arrays , rank); - return rank == 0 ? TreeType.Node(this) : Type.Array(getType(rank - 1)); - } - - public boolean hasExtClass() { - return hasSymbol(); - } - - public boolean hasSymbol() { - switch (symbol) { - case TreeSymbol.HasSym(_, _): - return true; - default: - return false; - } - } - - public boolean definesSymbol() { - switch (symbol) { - case TreeSymbol.HasSym(_, true): - return true; - default: - return false; - } - } - - public TreeField getSymbol() { - switch (symbol) { - case TreeSymbol.HasSym(TreeField field, _): - return field; - default: - return null; - } - } - - public boolean hasLinkedFields() { - for (int i = 0; i < fields.length; i++) - if (fields[i].link != null) return true; - return false; - } - - public TreeField[] getFields(boolean withoutLinkedFields) { - if (fields == null || !withoutLinkedFields) return fields; - int count = 0;; - for (int i = 0; i < fields.length; i++) - if (fields[i].link == null) count++; - TreeField[] array = new TreeField[count]; - for (int i = 0, j = 0; i < fields.length; i++) - if (fields[i].link == null) array[j++] = fields[i]; - return array; - } - - public String toString() { - return name; - } - - //######################################################################## - // Public Methods - Printing - - public JavaWriter printCase(JavaWriter writer, boolean withWildcards) { - writer.print("case "); - if (fields != null && withWildcards) { - writer.print(name).print('('); - for (int i = 0; i < fields.length; i++) { - if (i > 0) writer.print(", "); - writer.print("_"); - } - writer.print(')'); - } else { - printDecl(writer, null, false); - } - return writer.print(":").space(); - } - - public JavaWriter printNew(JavaWriter writer, boolean withSymbol) { - writer.print("new "); - if (hasExtClass()) writer.print("Ext"); - return printCall(writer, null, withSymbol); - } - - public JavaWriter printMethod(JavaWriter writer, String prefix, - boolean withSymbol) - { - return printMethod(writer, prefix, withSymbol, withSymbol); - } - - public JavaWriter printMethod(JavaWriter writer, String prefix, - boolean withSymbol, boolean withoutLinkedFields) - { - writer.print("public ").print(name).space(); - return printDecl(writer, prefix, withSymbol, withoutLinkedFields); - } - - public JavaWriter printDecl(JavaWriter writer, String prefix, - boolean withSymbol) - { - return printDecl(writer, prefix, withSymbol, withSymbol); - } - - public JavaWriter printDecl(JavaWriter writer, String prefix, - boolean withSymbol, boolean withoutLinkedFields) - { - return printPattern(writer,true,prefix,withSymbol,withoutLinkedFields); - } - - public JavaWriter printCall(JavaWriter writer, String prefix, - boolean withSymbol) - { - return printCall(writer, prefix, withSymbol, withSymbol); - } - - public JavaWriter printCall(JavaWriter writer, String prefix, - boolean withSymbol, boolean withoutLinkedFields) - { - return printPattern( - writer, false, prefix, withSymbol, withoutLinkedFields); - } - - public JavaWriter printPattern(JavaWriter writer, boolean withType, - String prefix, boolean withSymbol, boolean withoutLinkedFields) - { - writer.print(name); - if (fields != null || prefix != null || withSymbol) { - writer.print('('); - printFields(writer,withType,prefix,withSymbol,withoutLinkedFields); - writer.print(')'); - } - return writer; - } - - public JavaWriter printFields(JavaWriter writer, boolean withType, - String prefix, boolean withSymbol, boolean withoutLinkedFields) - { - TreeField[] fields = getFields(withoutLinkedFields); - if (prefix != null) { - writer.print(prefix); - if (withSymbol || (fields != null && fields.length > 0)) - writer.print(", "); - } - if (withSymbol) { - getSymbol().print(writer, withType); - if (fields != null && fields.length > 0) writer.print(", "); - } - TreeField.print(writer, fields, withType); - return writer; - } - - //######################################################################## -} diff --git a/sources/meta/scalac/ast/TreeSymbol.java b/sources/meta/scalac/ast/TreeSymbol.java deleted file mode 100644 index 1e53be4013..0000000000 --- a/sources/meta/scalac/ast/TreeSymbol.java +++ /dev/null @@ -1,24 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package meta.scalac.ast; - -/** This class describes the symbol stored in some tree nodes. */ -public class TreeSymbol { - - //######################################################################## - // Public Cases - - /** Indicates the absence of symbol. */ - public case NoSym; - - /** Indicates the presence of a symbol. */ - public case HasSym(TreeField field, boolean isDef); - - //######################################################################## -} diff --git a/sources/meta/scalac/ast/TreeType.java b/sources/meta/scalac/ast/TreeType.java deleted file mode 100644 index 52c2e6d9b3..0000000000 --- a/sources/meta/scalac/ast/TreeType.java +++ /dev/null @@ -1,65 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package meta.scalac.ast; - -import meta.java.Type; - -/** This class describes types used in tree nodes. */ -public class TreeType extends Type { - - //######################################################################## - // Private Constants - - private static final String NAME_PACKAGE = "scalac.util"; - private static final String NAME_NAME = "Name"; - private static final String NAME_FULLNAME = NAME_PACKAGE + "." + NAME_NAME; - private static final String TREE_PACKAGE = "scalac.ast"; - private static final String TREE_NAME = "Tree"; - private static final String TREE_FULLNAME = TREE_PACKAGE + "." + TREE_NAME; - - //######################################################################## - // Public Cases - - public case Name(TreeKind kind); - public case Tree(TreeKind kind); - public case Node(TreeNode node); - - //######################################################################## - // Public Methods - - /** Returns the type's (possibly fully qualified) name. */ - public String getName(boolean qualified) { - switch (this) { - case Name(_): - return qualified ? NAME_FULLNAME : NAME_NAME; - case Tree(_): - return qualified ? TREE_FULLNAME : TREE_NAME; - case Node(TreeNode node): - return qualified ? TREE_FULLNAME + "." + node.name : node.name; - default: - return super.getName(qualified); - } - } - - /** Returns the type's owner (its package or enclosing type). */ - public String getOwner() { - switch (this) { - case Name(_): - return NAME_PACKAGE; - case Tree(_): - return TREE_PACKAGE; - case Node(TreeNode node): - return TREE_FULLNAME; - default: - return super.getOwner(); - } - } - - //######################################################################## -} diff --git a/sources/meta/scalac/checkers/MetaCheckTreeNodes.java b/sources/meta/scalac/checkers/MetaCheckTreeNodes.java deleted file mode 100644 index 11ad75d77a..0000000000 --- a/sources/meta/scalac/checkers/MetaCheckTreeNodes.java +++ /dev/null @@ -1,158 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package meta.scalac.checkers; - -import meta.java.Type; -import meta.scalac.ast.AbstractTreeCaseExpander; -import meta.scalac.ast.TreeKind; -import meta.scalac.ast.TreeType; -import meta.scalac.ast.TreeNode; -import meta.scalac.ast.TreeField; -import meta.scalac.ast.TreeFieldLink; - -public class MetaCheckTreeNodes extends AbstractTreeCaseExpander { - - //######################################################################## - // Public Methods - - public void printTreeCaseBody(TreeNode node) { - if (node.fields != null) { - for (int i = 0; i < node.fields.length; i++) { - TreeField field = node.fields[i]; - printCheckField(node, field.type, field.name, "i"); - } - if (node.hasLinkedFields()) { - writer.println("Symbol symbol = tree.symbol();"); - writer.print("if (symbol != null)").lbrace(); - for (int i = 0; i < node.fields.length; i++) - if (node.fields[i].link != null) - printCheckFieldLink(node.fields[i]); - writer.rbrace(); - } - } - printCheckNode(node); - writer.println("return;"); - } - - private void printCheckNode(TreeNode node) { - if (node.start.constant != null) { - writer.println("assert global.currentPhase.id >= " + - "phases."+node.start.constant + ".id() :").indent(); - writer.println("\"cannot create instance of " + node.name + - " before phase " + node.start.name + ", \" +"); - writer.println( - "\"current phase is \" + " + "global.currentPhase;").undent(); - } - if (node.stop.constant != null) { - writer.println("assert global.currentPhase.id <= " + - "phases."+node.stop.constant + ".id() :").indent(); - writer.println("\"cannot create instance of " + node.name + - " after phase " + node.stop.name + ", \" +"); - writer.println( - "\"current phase is \" + " + "global.currentPhase;").undent(); - } - } - - private void printCheckField(TreeNode node,Type type,String name,String i){ - if (type.isPrimitive()) return; - writer.println("assert " + name + " != null :").indent(); - printNullValue(node, name); - writer.println(";").undent(); - switch (type) { - case Reference(_, _): - break; - - case Array(Type item): - writer.print( - "for (int "+i+" = 0; "+i+" < "+name+".length; "+i+"++)"); - writer.lbrace(); - printCheckField(node, item, name+"["+i+"]", i+"i"); - writer.rbrace(); - break; - - case TreeType.Name(TreeKind kind): - if (kind != TreeKind.Any && kind != TreeKind.Test) { - writer.println("assert " + name + ".is" + kind + "Name() :") - .indent(); - printWrongKind(node, name, kind); - writer.println(";").undent(); - } - break; - - case TreeType.Tree(TreeKind kind): - if (kind != TreeKind.Any) { - writer.println("assert " + - name + ".is" + kind + "() :").indent(); - printWrongKind(node, name, kind); - writer.println(";").undent(); - } - break; - - case TreeType.Node(_): - break; - - default: - throw new Error(type.getClass().getName()); - } - } - - private void printCheckFieldLink(TreeField field) { - String getter = field.link.getLink(); - writer.println("assert symbol." +getter+ " == " +field+ " :").indent(); - writer.println("\"symbol and tree " + field.link + " differ: \"+" + - "symbol." + getter + "+\" != \"+" +field+ ";"); - writer.undent(); - } - - private void printNullValue(TreeNode node, String field) { - String expanded = getExpandedField(field); - writer.print("\"field " +expanded+ " of class " +node+ " is null\""); - } - - private void printWrongKind(TreeNode node, String field, TreeKind kind) { - String expanded = getExpandedField(field); - writer.println("\"field " + expanded + " of class " + node + - " is not of kind " + kind + ", \" +"); - writer.print("\"found: \" + Debug.show("+field+")"); - // !!! " + \" of kind \" + kind("+field+")"; - } - - private String getExpandedField(String field) { - int begin = field.indexOf('['); - if (begin < 0) return field; - StringBuffer buffer = new StringBuffer(field.substring(0, begin)); - for (int end; (end = field.indexOf(']', begin)) >= 0; begin = end + 1){ - String index = field.substring(begin + 1, end); - buffer.append("[\"+").append(index).append("+\"]"); - } - return buffer.toString(); - } - - //######################################################################## -} - - -/* !!! - - protected static String kind(Tree tree) { - switch (tree) { - case Select(_, Name name): return kind(name); - case Ident(Name name): return kind(name); - } - return "unknown"; - } - - protected static String kind(Name name) { - if (name.isTypeName()) return "Type"; - if (name.isTermName()) return "Term"; - if (name.isConstrName()) return "Constr"; - return "unknown"; - } - -*/ |