root/trunk/ProjectFortress/src/com/sun/fortress/compiler/phases/PhaseOrder.java @ 2406

Revision 2406, 2.4 KB (checked in by mspiegel, 16 months ago)

Added copyright notices.

Line 
1/*******************************************************************************
2  Copyright 2008 Sun Microsystems, Inc.,
3  4150 Network Circle, Santa Clara, California 95054, U.S.A.
4  All rights reserved.
5
6  U.S. Government Rights - Commercial software.
7  Government users are subject to the Sun Microsystems, Inc. standard
8  license agreement and applicable provisions of the FAR and its supplements.
9
10  Use is subject to license terms.
11
12  This distribution may include materials developed by third parties.
13
14  Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
15  trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
16  ******************************************************************************/
17
18package com.sun.fortress.compiler.phases;
19
20import com.sun.fortress.compiler.GlobalEnvironment;
21import com.sun.fortress.exceptions.InterpreterBug;
22import com.sun.fortress.exceptions.StaticError;
23import com.sun.fortress.nodes.Api;
24import com.sun.fortress.nodes.Component;
25import com.sun.fortress.repository.FortressRepository;
26
27public enum PhaseOrder {
28        EMPTY("Empty Phase"),
29        DISAMBIGUATE("Disambiguation"),
30        GRAMMAR("Grammar Rewriting"),   
31        TYPECHECK("Typechecking"),
32        DESUGAR("Desugaring"), 
33        CODEGEN("Code generation");
34       
35        private String phaseName;
36
37        PhaseOrder(String phaseName) {
38                this.phaseName = phaseName;
39        }
40       
41        public Phase makePhase(FortressRepository repository, GlobalEnvironment env,
42                        Iterable<Api> apis, Iterable<Component> components, long lastModified) throws StaticError {
43                Phase empty = new EmptyPhase(repository,env,apis,components,lastModified);
44                switch(this) {
45                        case EMPTY: return empty;
46                        default: return makePhaseHelper(empty);
47                }
48        }
49       
50        private Phase makePhaseHelper(Phase emptyPhase) {
51                switch(this) {
52                        case EMPTY: return emptyPhase;
53                        case DISAMBIGUATE: return new DisambiguatePhase(EMPTY.makePhaseHelper(emptyPhase));
54                        case GRAMMAR: return new GrammarPhase(DISAMBIGUATE.makePhaseHelper(emptyPhase));
55                        case TYPECHECK: return new TypeCheckPhase(GRAMMAR.makePhaseHelper(emptyPhase));
56                        case DESUGAR: return new DesugarPhase(TYPECHECK.makePhaseHelper(emptyPhase));
57                        case CODEGEN: return new CodeGenerationPhase(DESUGAR.makePhaseHelper(emptyPhase));
58                        default: return InterpreterBug.bug("Unknown static analysis phase: " + phaseName);
59                }
60        }
61       
62        @Override
63        public String toString() {
64                return phaseName;
65        }
66                       
67}
Note: See TracBrowser for help on using the browser.