| 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.Disambiguator; |
|---|
| 22 | import com.sun.fortress.compiler.GlobalEnvironment; |
|---|
| 23 | import com.sun.fortress.compiler.IndexBuilder; |
|---|
| 24 | import com.sun.fortress.exceptions.MultipleStaticError; |
|---|
| 25 | import com.sun.fortress.exceptions.StaticError; |
|---|
| 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 DisambiguatePhase extends Phase { |
|---|
| 32 | |
|---|
| 33 | public DisambiguatePhase(Phase parentPhase) { |
|---|
| 34 | super(parentPhase); |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | @Override |
|---|
| 38 | public AnalyzeResult execute( ) throws StaticError { |
|---|
| 39 | Debug.debug( Debug.Type.FORTRESS, 1, "Start phase Disambiguate" ); |
|---|
| 40 | AnalyzeResult previous = parentPhase.getResult(); |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | GlobalEnvironment rawApiEnv = |
|---|
| 47 | new GlobalEnvironment.FromMap(CollectUtil.union(repository.apis(), |
|---|
| 48 | previous.apis())); |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | Disambiguator.ApiResult apiDR = |
|---|
| 54 | Disambiguator.disambiguateApis(previous.apiIterator(), rawApiEnv, repository.apis()); |
|---|
| 55 | if (!apiDR.isSuccessful()) { |
|---|
| 56 | throw new MultipleStaticError(apiDR.errors()); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | IndexBuilder.ApiResult apiIR = |
|---|
| 61 | IndexBuilder.buildApis(apiDR.apis(), lastModified); |
|---|
| 62 | if (!apiIR.isSuccessful()) { |
|---|
| 63 | throw new MultipleStaticError(apiIR.errors()); |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | GlobalEnvironment apiEnv = |
|---|
| 68 | new GlobalEnvironment.FromMap(CollectUtil.union(repository.apis(), |
|---|
| 69 | apiIR.apis())); |
|---|
| 70 | |
|---|
| 71 | Disambiguator.ComponentResult componentDR = |
|---|
| 72 | Disambiguator.disambiguateComponents(previous.componentIterator(), apiEnv, |
|---|
| 73 | previous.components()); |
|---|
| 74 | if (!componentDR.isSuccessful()) { |
|---|
| 75 | throw new MultipleStaticError(componentDR.errors()); |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | IndexBuilder.ComponentResult componentsDone = |
|---|
| 80 | IndexBuilder.buildComponents(componentDR.components(), lastModified); |
|---|
| 81 | if (!componentsDone.isSuccessful()) { |
|---|
| 82 | throw new MultipleStaticError(componentsDone.errors()); |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | return new AnalyzeResult(apiIR.apis(), componentsDone.components(), |
|---|
| 86 | IterUtil.<StaticError>empty(), previous.typeEnvAtNode()); |
|---|
| 87 | |
|---|
| 88 | } |
|---|
| 89 | |
|---|
| 90 | } |
|---|