| 1 | package com.sun.fortress.compiler.phases; |
|---|
| 2 | |
|---|
| 3 | import com.sun.fortress.compiler.AnalyzeResult; |
|---|
| 4 | import com.sun.fortress.compiler.environments.TopLevelEnvGen; |
|---|
| 5 | import com.sun.fortress.exceptions.MultipleStaticError; |
|---|
| 6 | import com.sun.fortress.exceptions.StaticError; |
|---|
| 7 | import com.sun.fortress.useful.Debug; |
|---|
| 8 | |
|---|
| 9 | import edu.rice.cs.plt.iter.IterUtil; |
|---|
| 10 | |
|---|
| 11 | public class CodeGenerationPhase extends Phase { |
|---|
| 12 | |
|---|
| 13 | public CodeGenerationPhase(Phase parentPhase) { |
|---|
| 14 | super(parentPhase); |
|---|
| 15 | } |
|---|
| 16 | |
|---|
| 17 | @Override |
|---|
| 18 | public AnalyzeResult execute() throws StaticError { |
|---|
| 19 | Debug.debug( Debug.Type.FORTRESS, 1, "Start phase CodeGeneration" ); |
|---|
| 20 | AnalyzeResult previous = parentPhase.getResult(); |
|---|
| 21 | |
|---|
| 22 | TopLevelEnvGen.CompilationUnitResult apiGR = TopLevelEnvGen |
|---|
| 23 | .generateApiEnvs(previous.apis()); |
|---|
| 24 | |
|---|
| 25 | if (!apiGR.isSuccessful()) { |
|---|
| 26 | throw new MultipleStaticError(apiGR.errors()); |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | TopLevelEnvGen.CompilationUnitResult componentGR = TopLevelEnvGen |
|---|
| 31 | .generateComponentEnvs(previous.components()); |
|---|
| 32 | |
|---|
| 33 | if (!componentGR.isSuccessful()) { |
|---|
| 34 | throw new MultipleStaticError(componentGR.errors()); |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | return new AnalyzeResult(previous.apis(), previous.components(), |
|---|
| 38 | IterUtil.<StaticError> empty(), previous.typeEnvAtNode()); |
|---|
| 39 | |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | } |
|---|