| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | package com.sun.fortress.compiler.phases; |
|---|
| 19 | |
|---|
| 20 | import com.sun.fortress.compiler.AnalyzeResult; |
|---|
| 21 | import com.sun.fortress.compiler.GlobalEnvironment; |
|---|
| 22 | import com.sun.fortress.compiler.IndexBuilder; |
|---|
| 23 | import com.sun.fortress.exceptions.MultipleStaticError; |
|---|
| 24 | import com.sun.fortress.exceptions.StaticError; |
|---|
| 25 | import com.sun.fortress.syntax_abstractions.phases.GrammarRewriter; |
|---|
| 26 | import com.sun.fortress.useful.Debug; |
|---|
| 27 | |
|---|
| 28 | import edu.rice.cs.plt.collect.CollectUtil; |
|---|
| 29 | import edu.rice.cs.plt.iter.IterUtil; |
|---|
| 30 | |
|---|
| 31 | public 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 | } |
|---|