diff options
author | paltherr <paltherr@epfl.ch> | 2003-03-21 16:42:56 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2003-03-21 16:42:56 +0000 |
commit | e2a09f258a66f71ea90e65b645d8a03b1a64be71 (patch) | |
tree | 22c62210a3cfc5fa5eb28d657399e560cf738e1d /sources/scalac | |
parent | 787d4bb9dbc540a61632c1f234a54ab74a69609c (diff) | |
download | scala-e2a09f258a66f71ea90e65b645d8a03b1a64be71.tar.gz scala-e2a09f258a66f71ea90e65b645d8a03b1a64be71.tar.bz2 scala-e2a09f258a66f71ea90e65b645d8a03b1a64be71.zip |
- Removed method createPhase in class PhaseDesc...
- Removed method createPhase in class PhaseDescriptor Made method apply
- abstract in class PhaseDescriptor Implemented method apply in all
- subclasses of class PhaseDescriptor
Diffstat (limited to 'sources/scalac')
-rw-r--r-- | sources/scalac/Global.java | 2 | ||||
-rw-r--r-- | sources/scalac/PhaseDescriptor.java | 22 | ||||
-rw-r--r-- | sources/scalac/ast/parser/ParserPhase.java | 44 | ||||
-rw-r--r-- | sources/scalac/backend/jvm/GenJVMPhase.java | 5 | ||||
-rw-r--r-- | sources/scalac/backend/msil/GenMSILPhase.java | 5 | ||||
-rw-r--r-- | sources/scalac/symtab/SourceCompleter.java | 8 | ||||
-rw-r--r-- | sources/scalac/transformer/AddAccessorsPhase.java | 5 | ||||
-rw-r--r-- | sources/scalac/transformer/AddConstructorsPhase.java | 5 | ||||
-rw-r--r-- | sources/scalac/transformer/AddInterfacesPhase.java | 5 | ||||
-rw-r--r-- | sources/scalac/transformer/ErasurePhase.java | 4 | ||||
-rw-r--r-- | sources/scalac/transformer/ExpandMixinsPhase.java | 5 | ||||
-rw-r--r-- | sources/scalac/transformer/ExplicitOuterClassesPhase.java | 5 | ||||
-rw-r--r-- | sources/scalac/transformer/LambdaLiftPhase.java | 5 | ||||
-rw-r--r-- | sources/scalac/transformer/TransMatchPhase.java | 8 | ||||
-rw-r--r-- | sources/scalac/transformer/UnCurryPhase.java | 8 | ||||
-rw-r--r-- | sources/scalac/typechecker/AnalyzerPhase.java | 12 | ||||
-rw-r--r-- | sources/scalac/typechecker/RefCheckPhase.java | 8 |
17 files changed, 57 insertions, 99 deletions
diff --git a/sources/scalac/Global.java b/sources/scalac/Global.java index 5c5b94ccc2..f068ec201f 100644 --- a/sources/scalac/Global.java +++ b/sources/scalac/Global.java @@ -266,7 +266,9 @@ public class Global { if ((currentPhase.flags & PhaseDescriptor.SKIP) != 0) { operation("skipping phase " + currentPhase.name()); } else { + start(); currentPhase.apply(this); + stop(currentPhase.taskDescription()); } if ((currentPhase.flags & PhaseDescriptor.PRINT) != 0) currentPhase.print(this); diff --git a/sources/scalac/PhaseDescriptor.java b/sources/scalac/PhaseDescriptor.java index 0316a80215..6597dc9e5e 100644 --- a/sources/scalac/PhaseDescriptor.java +++ b/sources/scalac/PhaseDescriptor.java @@ -2,10 +2,10 @@ ** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** ** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** ** /_____/\____/\___/\____/____/ ** -** ** -** $Id$ \* */ +// $Id$ + package scalac; import java.util.*; @@ -33,10 +33,6 @@ public abstract class PhaseDescriptor { return "initializing compiler"; } - public Phase createPhase(Global global) { - return null; - } - /** apply phase to all compilation units */ public void apply(Global global) {} @@ -52,10 +48,6 @@ public abstract class PhaseDescriptor { return "compilation terminated "; } - public Phase createPhase(Global global) { - return null; - } - /** apply phase to all compilation units */ public void apply(Global global) {} @@ -97,10 +89,6 @@ public abstract class PhaseDescriptor { this.id = id; } - /** create a phase - */ - public abstract Phase createPhase(Global global); - /** Assume that `tp' is the info of symbol `sym' before this phase. * Return the info of `sym' after the phase. */ @@ -110,11 +98,7 @@ public abstract class PhaseDescriptor { /** apply phase to all compilation units */ - public void apply(Global global) { - global.start(); - createPhase(global).apply(); - global.stop(taskDescription()); - } + public abstract void apply(Global global); /** check all compilation units */ diff --git a/sources/scalac/ast/parser/ParserPhase.java b/sources/scalac/ast/parser/ParserPhase.java index 204fb2b925..1a1dde1ffe 100644 --- a/sources/scalac/ast/parser/ParserPhase.java +++ b/sources/scalac/ast/parser/ParserPhase.java @@ -2,14 +2,15 @@ ** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** ** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** ** /_____/\____/\___/\____/____/ ** -** -** $Id$ \* */ +// $Id$ + package scalac.ast.parser; -import java.io.*; -import scalac.*; +import scalac.Global; +import scalac.Unit; +import scalac.PhaseDescriptor; public class ParserPhase extends PhaseDescriptor { @@ -25,39 +26,14 @@ public class ParserPhase extends PhaseDescriptor { return "parsed"; } - public Phase createPhase(Global global) { - return new ParserWorker(global, this); - } -} - -public class ParserWorker extends Phase { - - /** constructor - */ - public ParserWorker(Global global, PhaseDescriptor descr) { - super(global, descr); - } - - /** apply this phase to all compilation units - */ - public void apply() { - super.apply(); - int count = 0; - for (int i = 0; i < global.units.length; i++) { - if (global.units[i].body != null) count++; - } - Unit[] units = new Unit[count]; - for (int i = 0, j = 0; i < global.units.length; i++) { - if (global.units[i].body != null) units[j++] = global.units[i]; - } - global.units = units; + public void apply(Global global) { + for (int i = 0; i < global.units.length; i++) apply(global.units[i]); } - /** apply this phase to the given compilation unit - */ public void apply(Unit unit) { - global.start(); + unit.global.start(); unit.body = new Parser(unit).parse(); - global.stop("parsed " + unit.source); + unit.global.stop("parsed " + unit.source); } + } diff --git a/sources/scalac/backend/jvm/GenJVMPhase.java b/sources/scalac/backend/jvm/GenJVMPhase.java index 9511e3f770..bdfb7bc02f 100644 --- a/sources/scalac/backend/jvm/GenJVMPhase.java +++ b/sources/scalac/backend/jvm/GenJVMPhase.java @@ -2,7 +2,6 @@ ** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** ** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** ** /_____/\____/\___/\____/____/ ** -** ** \* */ // $OldId: GenJVMPhase.java,v 1.1 2002/09/03 12:13:08 schinz Exp $ @@ -31,8 +30,8 @@ public class GenJVMPhase extends PhaseDescriptor { return "generated JVM code"; } - public Phase createPhase(Global global) { - return new GenJVM(global, this); + public void apply(Global global) { + new GenJVM(global, this).apply(); } } diff --git a/sources/scalac/backend/msil/GenMSILPhase.java b/sources/scalac/backend/msil/GenMSILPhase.java index 9239fdf625..3156db748d 100644 --- a/sources/scalac/backend/msil/GenMSILPhase.java +++ b/sources/scalac/backend/msil/GenMSILPhase.java @@ -2,7 +2,6 @@ ** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** ** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** ** /_____/\____/\___/\____/____/ ** -** ** \* */ // $Id$ @@ -38,8 +37,8 @@ public class GenMSILPhase extends PhaseDescriptor { return "generated MSIL code"; } - public Phase createPhase(Global global) { - return new GenMSIL(global, this); + public void apply(Global global) { + new GenMSIL(global, this).apply(); } } diff --git a/sources/scalac/symtab/SourceCompleter.java b/sources/scalac/symtab/SourceCompleter.java index def4a80c9e..fefe00ab16 100644 --- a/sources/scalac/symtab/SourceCompleter.java +++ b/sources/scalac/symtab/SourceCompleter.java @@ -2,10 +2,10 @@ ** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** ** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** ** /_____/\____/\___/\____/____/ ** -** ** -** $Id$ \* */ +// $Id$ + package scalac.symtab; import scalac.*; @@ -38,8 +38,8 @@ public class SourceCompleter extends Type.LazyType { long msec = System.currentTimeMillis(); Unit unit = new Unit(global, new Sourcefile(filename), false); filename = null; - global.PHASE.PARSER.createPhase(global).apply(unit); - ((Analyzer)global.PHASE.ANALYZER.createPhase(global)).lateEnter(unit, c); + global.PHASE.PARSER.apply(unit); + global.PHASE.ANALYZER.lateEnter(global, unit, c); global.operation("added " + fname + " in " + (System.currentTimeMillis() - msec) + "ms"); } catch (IOException e) { diff --git a/sources/scalac/transformer/AddAccessorsPhase.java b/sources/scalac/transformer/AddAccessorsPhase.java index 7b65699989..1fdd55a963 100644 --- a/sources/scalac/transformer/AddAccessorsPhase.java +++ b/sources/scalac/transformer/AddAccessorsPhase.java @@ -2,7 +2,6 @@ ** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** ** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** ** /_____/\____/\___/\____/____/ ** -** ** \* */ // $OldId: AddAccessorsPhase.java,v 1.1 2002/10/17 12:27:11 schinz Exp $ @@ -28,8 +27,8 @@ public class AddAccessorsPhase extends PhaseDescriptor { return "added accessors"; } - public Phase createPhase(Global global) { - return new AddAccessors(global, this); + public void apply(Global global) { + new AddAccessors(global, this).apply(); } public Checker[] postCheckers(Global global) { diff --git a/sources/scalac/transformer/AddConstructorsPhase.java b/sources/scalac/transformer/AddConstructorsPhase.java index 7ea83ae584..73f8f652fd 100644 --- a/sources/scalac/transformer/AddConstructorsPhase.java +++ b/sources/scalac/transformer/AddConstructorsPhase.java @@ -2,7 +2,6 @@ ** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** ** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** ** /_____/\____/\___/\____/____/ ** -** ** \* */ // $Id$ @@ -35,8 +34,8 @@ public class AddConstructorsPhase extends PhaseDescriptor { return "added constructors"; } - public Phase createPhase(Global global) { - return new AddConstructors(global, this, constructors); + public void apply(Global global) { + new AddConstructors(global, this, constructors).apply(); } public Checker[] postCheckers(Global global) { diff --git a/sources/scalac/transformer/AddInterfacesPhase.java b/sources/scalac/transformer/AddInterfacesPhase.java index 9f5caf9238..3aa92b225d 100644 --- a/sources/scalac/transformer/AddInterfacesPhase.java +++ b/sources/scalac/transformer/AddInterfacesPhase.java @@ -2,7 +2,6 @@ ** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** ** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** ** /_____/\____/\___/\____/____/ ** -** ** \* */ // $OldId: AddInterfacesPhase.java,v 1.9 2002/04/19 10:55:15 schinz Exp $ @@ -40,8 +39,8 @@ public class AddInterfacesPhase extends PhaseDescriptor { return "added interfaces"; } - public Phase createPhase(Global global) { - return new AddInterfaces(global, this); + public void apply(Global global) { + new AddInterfaces(global, this).apply(); } public Checker[] postCheckers(Global global) { diff --git a/sources/scalac/transformer/ErasurePhase.java b/sources/scalac/transformer/ErasurePhase.java index 2810ebf26b..20d641c994 100644 --- a/sources/scalac/transformer/ErasurePhase.java +++ b/sources/scalac/transformer/ErasurePhase.java @@ -43,9 +43,9 @@ public class ErasurePhase extends PhaseDescriptor { return "erased types"; } - public Phase createPhase(Global global) { + public void apply(Global global) { this.definitions = global.definitions; - return new Erasure(global, this); + new Erasure(global, this).apply(); } private Type eraseParams(Type tp) { diff --git a/sources/scalac/transformer/ExpandMixinsPhase.java b/sources/scalac/transformer/ExpandMixinsPhase.java index a1168b98cd..3d637dbf10 100644 --- a/sources/scalac/transformer/ExpandMixinsPhase.java +++ b/sources/scalac/transformer/ExpandMixinsPhase.java @@ -2,7 +2,6 @@ ** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** ** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** ** /_____/\____/\___/\____/____/ ** -** ** \* */ // $OldId: ExpandMixinsPhase.java,v 1.8 2002/05/02 10:59:35 schinz Exp $ @@ -31,8 +30,8 @@ public class ExpandMixinsPhase extends PhaseDescriptor { return "expanded mixins"; } - public Phase createPhase(Global global) { - return new ExpandMixins(global, this); + public void apply(Global global) { + new ExpandMixins(global, this).apply(); } public Checker[] postCheckers(Global global) { diff --git a/sources/scalac/transformer/ExplicitOuterClassesPhase.java b/sources/scalac/transformer/ExplicitOuterClassesPhase.java index d481ef329c..4f6692c33e 100644 --- a/sources/scalac/transformer/ExplicitOuterClassesPhase.java +++ b/sources/scalac/transformer/ExplicitOuterClassesPhase.java @@ -2,7 +2,6 @@ ** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** ** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** ** /_____/\____/\___/\____/____/ ** -** ** \* */ // $Id$ @@ -26,8 +25,8 @@ public class ExplicitOuterClassesPhase extends PhaseDescriptor { return "made outer links explicit"; } - public Phase createPhase(Global global) { - return new ExplicitOuterClasses(global, this); + public void apply(Global global) { + new ExplicitOuterClasses(global, this).apply(); } public Checker[] postCheckers(Global global) { diff --git a/sources/scalac/transformer/LambdaLiftPhase.java b/sources/scalac/transformer/LambdaLiftPhase.java index 65c96dd231..11141db9b2 100644 --- a/sources/scalac/transformer/LambdaLiftPhase.java +++ b/sources/scalac/transformer/LambdaLiftPhase.java @@ -2,7 +2,6 @@ ** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** ** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** ** /_____/\____/\___/\____/____/ ** -** ** \* */ // $Id$ @@ -38,8 +37,8 @@ public class LambdaLiftPhase extends PhaseDescriptor implements Kinds, Modifiers return "lambda lifting"; } - public Phase createPhase(Global global) { - return new LambdaLift(global, this); + public void apply(Global global) { + new LambdaLift(global, this).apply(); } public Type transformInfo(Symbol sym, Type tp) { diff --git a/sources/scalac/transformer/TransMatchPhase.java b/sources/scalac/transformer/TransMatchPhase.java index 8c5692db91..d5be21b9fe 100644 --- a/sources/scalac/transformer/TransMatchPhase.java +++ b/sources/scalac/transformer/TransMatchPhase.java @@ -2,10 +2,10 @@ ** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** ** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** ** /_____/\____/\___/\____/____/ ** -** ** -** $Id$ \* */ +// $Id$ + package scalac.transformer; import scalac.*; @@ -25,8 +25,8 @@ public class TransMatchPhase extends PhaseDescriptor { return "translated pattern matching"; } - public Phase createPhase(Global global) { - return new TransMatch(global, this); + public void apply(Global global) { + new TransMatch(global, this).apply(); } public Checker[] postCheckers(Global global) { diff --git a/sources/scalac/transformer/UnCurryPhase.java b/sources/scalac/transformer/UnCurryPhase.java index 1b78f5d207..3cf87f7ef0 100644 --- a/sources/scalac/transformer/UnCurryPhase.java +++ b/sources/scalac/transformer/UnCurryPhase.java @@ -2,10 +2,10 @@ ** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** ** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** ** /_____/\____/\___/\____/____/ ** -** ** -** $Id$ \* */ +// $Id$ + package scalac.transformer; import scalac.*; @@ -35,8 +35,8 @@ public class UnCurryPhase extends PhaseDescriptor implements Modifiers { return "uncurried"; } - public Phase createPhase(Global global) { - return new UnCurry(global, this); + public void apply(Global global) { + new UnCurry(global, this).apply(); } /** - return symbol's transformed type, diff --git a/sources/scalac/typechecker/AnalyzerPhase.java b/sources/scalac/typechecker/AnalyzerPhase.java index d5601da0dd..3b34892fbe 100644 --- a/sources/scalac/typechecker/AnalyzerPhase.java +++ b/sources/scalac/typechecker/AnalyzerPhase.java @@ -2,10 +2,10 @@ ** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** ** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** ** /_____/\____/\___/\____/____/ ** -** -** $Id$ \* */ +// $Id$ + package scalac.typechecker; import scalac.*; @@ -114,8 +114,12 @@ public class AnalyzerPhase extends PhaseDescriptor { return "type checking"; } - public Phase createPhase(Global global) { - return new Analyzer(global, this); + public void apply(Global global) { + new Analyzer(global, this).apply(); + } + + public void lateEnter(Global global, Unit unit, Symbol symbol) { + new Analyzer(global, this).lateEnter(unit, symbol); } public Checker[] postCheckers(Global global) { diff --git a/sources/scalac/typechecker/RefCheckPhase.java b/sources/scalac/typechecker/RefCheckPhase.java index 855731f450..90179e719c 100644 --- a/sources/scalac/typechecker/RefCheckPhase.java +++ b/sources/scalac/typechecker/RefCheckPhase.java @@ -2,10 +2,10 @@ ** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** ** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** ** /_____/\____/\___/\____/____/ ** -** -** $Id$ \* */ +// $Id$ + package scalac.typechecker; import scalac.*; @@ -26,8 +26,8 @@ public class RefCheckPhase extends PhaseDescriptor { return "reference checking"; } - public Phase createPhase(Global global) { - return new RefCheck(global, this); + public void apply(Global global) { + new RefCheck(global, this).apply(); } public Checker[] postCheckers(Global global) { |