summaryrefslogtreecommitdiff
path: root/sources/scalac/ast/Transformer.java.tmpl
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2003-04-15 09:26:25 +0000
committerpaltherr <paltherr@epfl.ch>2003-04-15 09:26:25 +0000
commit09402976e725b21f516ba67279e1e8088002daa3 (patch)
treec5de3e1a76367f9042fde9226b953b61fc98077b /sources/scalac/ast/Transformer.java.tmpl
parentf9534fc128aef38f9849a65dd2a40cd86de68a81 (diff)
downloadscala-09402976e725b21f516ba67279e1e8088002daa3.tar.gz
scala-09402976e725b21f516ba67279e1e8088002daa3.tar.bz2
scala-09402976e725b21f516ba67279e1e8088002daa3.zip
- Added automatic generation of Traverser
- Added automatic generation of Transformer
Diffstat (limited to 'sources/scalac/ast/Transformer.java.tmpl')
-rw-r--r--sources/scalac/ast/Transformer.java.tmpl81
1 files changed, 81 insertions, 0 deletions
diff --git a/sources/scalac/ast/Transformer.java.tmpl b/sources/scalac/ast/Transformer.java.tmpl
new file mode 100644
index 0000000000..9e83e34b18
--- /dev/null
+++ b/sources/scalac/ast/Transformer.java.tmpl
@@ -0,0 +1,81 @@
+/* ____ ____ ____ ____ ______ *\
+** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
+** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
+** /_____/\____/\___/\____/____/ **
+\* */
+
+// $Id$
+
+package scalac.ast;
+
+import scalac.Global;
+import scalac.Unit;
+{#Imports#}
+
+/**
+ * A default transformer class. This class traverses the abstract
+ * syntax tree but does not do any transformations.
+ */
+public class Transformer {
+
+ //########################################################################
+ // Public Fields
+
+ /** The global environment */
+ public final Global global;
+
+ /** The tree factory */
+ public final TreeFactory make;
+
+ /** The tree copier */
+ public final TreeCopier copy;
+
+ /** A tree generator */
+ public final TreeGen gen;
+
+ //########################################################################
+ // Public Constructors
+
+ public Transformer(Global global) {
+ this(global, global.make);
+ }
+
+ public Transformer(Global global, TreeFactory make) {
+ this(global, make, new LazyTreeCopier(make));
+ }
+
+ public Transformer(Global global, TreeFactory make, TreeCopier copy) {
+ this.global = global;
+ this.make = make;
+ this.copy = copy;
+ this.gen = global.treeGen;
+ }
+
+ //########################################################################
+ // Public Methods
+
+ public void apply() {
+ apply(global.units);
+ }
+
+ public void apply(Unit[] units) {
+ for (int i = 0; i < units.length; i++) apply(units[i]);
+ }
+
+ public void apply(Unit unit) {
+ unit.global.log("transforming " + unit);
+ unit.body = transform(unit.body);
+ }
+
+ public Tree transform(Tree tree) {
+ {#TreeSwitch#}
+ }
+
+ public Template transform(Template tree) {
+ return (Template)transform((Tree)tree);
+ }
+
+ {#TransformArrays#}
+
+ //########################################################################
+}