| 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.Desugarer; |
|---|
| 22 | import com.sun.fortress.compiler.GlobalEnvironment; |
|---|
| 23 | import com.sun.fortress.exceptions.MultipleStaticError; |
|---|
| 24 | import com.sun.fortress.exceptions.StaticError; |
|---|
| 25 | import com.sun.fortress.useful.Debug; |
|---|
| 26 | |
|---|
| 27 | import edu.rice.cs.plt.collect.CollectUtil; |
|---|
| 28 | import edu.rice.cs.plt.iter.IterUtil; |
|---|
| 29 | |
|---|
| 30 | public 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 | } |
|---|