| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | package com.sun.fortress.compiler; |
|---|
| 19 | |
|---|
| 20 | import java.util.HashMap; |
|---|
| 21 | import java.util.Map; |
|---|
| 22 | |
|---|
| 23 | import com.sun.fortress.compiler.index.ApiIndex; |
|---|
| 24 | import com.sun.fortress.compiler.index.ComponentIndex; |
|---|
| 25 | import com.sun.fortress.compiler.typechecker.TypeEnv; |
|---|
| 26 | import com.sun.fortress.exceptions.StaticError; |
|---|
| 27 | import com.sun.fortress.nodes.APIName; |
|---|
| 28 | import com.sun.fortress.nodes.Api; |
|---|
| 29 | import com.sun.fortress.nodes.Component; |
|---|
| 30 | import com.sun.fortress.nodes.Node; |
|---|
| 31 | import com.sun.fortress.nodes_util.Span; |
|---|
| 32 | |
|---|
| 33 | import edu.rice.cs.plt.tuple.Option; |
|---|
| 34 | import edu.rice.cs.plt.tuple.Pair; |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | public final class AnalyzeResult extends StaticPhaseResult { |
|---|
| 38 | |
|---|
| 39 | private final Map<APIName, ApiIndex> _apis; |
|---|
| 40 | private final Map<APIName, ComponentIndex> _components; |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | private final Option<Map<Pair<Node,Span>, TypeEnv>> _typeEnvAtNode; |
|---|
| 44 | |
|---|
| 45 | public AnalyzeResult(Iterable<? extends StaticError> errors) { |
|---|
| 46 | this(new HashMap<APIName, ApiIndex>(), new HashMap<APIName, ComponentIndex>(), errors); |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | public AnalyzeResult(Map<APIName, ApiIndex> apis, |
|---|
| 50 | Map<APIName, ComponentIndex> components, |
|---|
| 51 | Iterable<? extends StaticError> errors) { |
|---|
| 52 | super(errors); |
|---|
| 53 | _apis = apis; |
|---|
| 54 | _components = components; |
|---|
| 55 | _typeEnvAtNode = Option.none(); |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | public AnalyzeResult(Map<APIName, ApiIndex> apis, |
|---|
| 59 | Map<APIName, ComponentIndex> components, |
|---|
| 60 | Iterable<? extends StaticError> errors, Map<Pair<Node,Span>, TypeEnv> typeEnvAtNode) { |
|---|
| 61 | super(errors); |
|---|
| 62 | _apis = apis; |
|---|
| 63 | _components = components; |
|---|
| 64 | _typeEnvAtNode = Option.some(typeEnvAtNode); |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | public AnalyzeResult(AnalyzeResult result, Map<APIName, ApiIndex> apis, |
|---|
| 76 | Map<APIName, ComponentIndex> components, |
|---|
| 77 | Iterable<? extends StaticError> errors) { |
|---|
| 78 | super(errors); |
|---|
| 79 | _apis = apis; |
|---|
| 80 | _components = components; |
|---|
| 81 | _typeEnvAtNode = result._typeEnvAtNode; |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | public Iterable<Api> apiIterator() { |
|---|
| 85 | return new ApiIterable(_apis); |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | public Iterable<Component> componentIterator() { |
|---|
| 89 | return new ComponentIterable(_components); |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | public Map<APIName, ApiIndex> apis() { return _apis; } |
|---|
| 93 | public Map<APIName, ComponentIndex> components() { return _components; } |
|---|
| 94 | |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | public Option<Map<Pair<Node,Span>, TypeEnv>> typeEnvAtNode() { return this._typeEnvAtNode; } |
|---|
| 101 | } |
|---|