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

Revision 2406, 2.2 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.AnalyzeResult;
21import com.sun.fortress.compiler.GlobalEnvironment;
22import com.sun.fortress.compiler.IndexBuilder;
23import com.sun.fortress.exceptions.MultipleStaticError;
24import com.sun.fortress.exceptions.StaticError;
25import com.sun.fortress.syntax_abstractions.phases.GrammarRewriter;
26import com.sun.fortress.useful.Debug;
27
28import edu.rice.cs.plt.collect.CollectUtil;
29import edu.rice.cs.plt.iter.IterUtil;
30
31public class GrammarPhase extends Phase {
32
33        public GrammarPhase(Phase parentPhase) {
34                super(parentPhase);
35        }
36       
37        @Override
38        public AnalyzeResult execute() throws StaticError {
39        Debug.debug( Debug.Type.FORTRESS, 1, "Start phase GrammarPhase" );             
40                AnalyzeResult previous = parentPhase.getResult();                       
41
42                GlobalEnvironment apiEnv =
43                        new GlobalEnvironment.FromMap(CollectUtil.union(repository.apis(),
44                                        previous.apis()));
45
46                GrammarRewriter.ApiResult apiID = GrammarRewriter.rewriteApis(previous.apis(), apiEnv);
47                if (!apiID.isSuccessful()) {
48                        throw new MultipleStaticError(apiID.errors());
49                }
50
51                IndexBuilder.ApiResult apiDone = IndexBuilder.buildApis(apiID.apis(), lastModified);
52                if (!apiDone.isSuccessful()) {
53                        throw new MultipleStaticError(apiDone.errors());
54                }
55
56                return new AnalyzeResult(apiDone.apis(), previous.components(),
57                                IterUtil.<StaticError>empty(), previous.typeEnvAtNode());       
58        }
59
60}
Note: See TracBrowser for help on using the browser.