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