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

Revision 2406, 2.8 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 java.util.Map;
21
22import com.sun.fortress.compiler.AnalyzeResult;
23import com.sun.fortress.compiler.GlobalEnvironment;
24import com.sun.fortress.compiler.IndexBuilder;
25import com.sun.fortress.compiler.StaticChecker;
26import com.sun.fortress.compiler.typechecker.TypeEnv;
27import com.sun.fortress.exceptions.MultipleStaticError;
28import com.sun.fortress.exceptions.StaticError;
29import com.sun.fortress.nodes.Node;
30import com.sun.fortress.nodes_util.Span;
31import com.sun.fortress.useful.Debug;
32
33import edu.rice.cs.plt.collect.CollectUtil;
34import edu.rice.cs.plt.iter.IterUtil;
35import edu.rice.cs.plt.tuple.Option;
36import edu.rice.cs.plt.tuple.Pair;
37
38public class TypeCheckPhase extends Phase {
39       
40    public TypeCheckPhase(Phase parentPhase) {
41                super(parentPhase);
42        }
43
44        @Override
45    public AnalyzeResult execute( ) throws StaticError {
46        Debug.debug( Debug.Type.FORTRESS, 1, "Start phase TypeCheck" );
47                AnalyzeResult previous = parentPhase.getResult();       
48
49        IndexBuilder.ApiResult apiIndex = IndexBuilder.buildApis(previous.apiIterator(), lastModified);
50        IndexBuilder.ComponentResult componentIndex = IndexBuilder.buildComponents(previous.componentIterator(), lastModified);
51        GlobalEnvironment apiEnv = new GlobalEnvironment.FromMap(CollectUtil.union(repository.apis(),
52                                                     apiIndex.apis()));
53
54        StaticChecker.ApiResult apiSR = StaticChecker.checkApis( apiIndex.apis(), apiEnv );
55
56        if ( !apiSR.isSuccessful() ){
57                throw new MultipleStaticError(apiSR.errors());
58        }
59
60        StaticChecker.ComponentResult componentSR =
61                StaticChecker.checkComponents( componentIndex.components(), env);
62
63        if ( !componentSR.isSuccessful() ){
64                throw new MultipleStaticError(componentSR.errors());
65        }
66
67        return new AnalyzeResult(apiSR.apis(), componentSR.components(),
68                        IterUtil.<StaticError> empty(),
69                        Option.<Map<Pair<Node,Span>, TypeEnv>>some(componentSR.typeEnvAtNode()));
70    }
71
72}
Note: See TracBrowser for help on using the browser.