Package: IRStatus

IRStatus

nameinstructionbranchcomplexitylinemethod
IRStatus(INode, Set)
M: 0 C: 14
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
IRStatus(INode, String, PIR, Set)
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
IRStatus(INode, String, PIR, Set, Set)
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
addTransformationWarnings(Set)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
canBeGenerated()
M: 0 C: 8
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
extract(IRStatus)
M: 0 C: 24
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
extract(IRStatus, Class)
M: 0 C: 37
100%
M: 2 C: 4
67%
M: 2 C: 2
50%
M: 0 C: 8
100%
M: 0 C: 1
100%
extract(List)
M: 0 C: 26
100%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 7
100%
M: 0 C: 1
100%
extract(List, Class)
M: 0 C: 27
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
getIrNode()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getIrNodeName()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getTransformationWarnings()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getUnsupportedInIr()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getVdmNode()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
setIrNode(PIR)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
setIrNodeName(String)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setTransformationWarnings(Set)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setVdmNode(INode)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
toString()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * VDM Code Generator
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.codegen.ir;
23:
24: import java.util.HashSet;
25: import java.util.LinkedList;
26: import java.util.List;
27: import java.util.Set;
28:
29: import org.overture.ast.node.INode;
30:
31: public final class IRStatus<T extends PIR>
32: {
33:         protected INode vdmNode;
34:         protected String irNodeName;
35:         protected T node;
36:         protected Set<VdmNodeInfo> unsupportedInIr;
37:         protected Set<IrNodeInfo> transformationWarnings;
38:
39:         public IRStatus(INode vdmNode, Set<VdmNodeInfo> unsupportedInIr)
40:         {
41:                 this.vdmNode = vdmNode;
42:                 this.unsupportedInIr = unsupportedInIr;
43:                 this.transformationWarnings = new HashSet<IrNodeInfo>();
44:         }
45:
46:         public IRStatus(INode vdmNode, String nodeName, T node,
47:                         Set<VdmNodeInfo> unsupportedNodes)
48:         {
49:                 this(vdmNode, unsupportedNodes);
50:                 this.irNodeName = nodeName;
51:                 this.node = node;
52:         }
53:
54:         public IRStatus(INode vdmNode, String nodeName, T node,
55:                         Set<VdmNodeInfo> unsupportedNodes,
56:                         Set<IrNodeInfo> transformationWarnings)
57:         {
58:                 this(vdmNode, nodeName, node, unsupportedNodes);
59:                 this.transformationWarnings = transformationWarnings;
60:         }
61:
62:         public Set<VdmNodeInfo> getUnsupportedInIr()
63:         {
64:                 return unsupportedInIr;
65:         }
66:
67:         public void addTransformationWarnings(
68:                         Set<IrNodeInfo> transformationWarnings)
69:         {
70:                 this.transformationWarnings.addAll(transformationWarnings);
71:         }
72:
73:         public boolean canBeGenerated()
74:         {
75:•                return unsupportedInIr.size() == 0;
76:         }
77:
78:         public Set<IrNodeInfo> getTransformationWarnings()
79:         {
80:                 return transformationWarnings;
81:         }
82:
83:         public void setTransformationWarnings(
84:                         Set<IrNodeInfo> transformationWarnings)
85:         {
86:                 this.transformationWarnings = transformationWarnings;
87:         }
88:
89:         public INode getVdmNode()
90:         {
91:                 return vdmNode;
92:         }
93:
94:         public void setVdmNode(INode vdmNode)
95:         {
96:                 this.vdmNode = vdmNode;
97:         }
98:
99:         public T getIrNode()
100:         {
101:                 return node;
102:         }
103:
104:         public void setIrNode(T newNode)
105:         {
106:                 this.node = newNode;
107:         }
108:
109:         public String getIrNodeName()
110:         {
111:                 return irNodeName;
112:         }
113:
114:         public void setIrNodeName(String irNodeName)
115:         {
116:                 this.irNodeName = irNodeName;
117:         }
118:
119:         @Override
120:         public String toString()
121:         {
122:                 return getIrNodeName();
123:         }
124:
125:         public static <T extends PIR> IRStatus<T> extract(IRStatus<PIR> inputStatus,
126:                         Class<T> type)
127:         {
128:                 String name = inputStatus.getIrNodeName();
129:                 INode vdmNode = inputStatus.getVdmNode();
130:                 PIR node = inputStatus.getIrNode();
131:                 Set<VdmNodeInfo> unsupportedInIr = inputStatus.getUnsupportedInIr();
132:                 Set<IrNodeInfo> warnings = inputStatus.getTransformationWarnings();
133:
134:•                if (node != null && type != null && type.isInstance(node))
135:                 {
136:                         return new IRStatus<T>(vdmNode, name, type.cast(node), unsupportedInIr, warnings);
137:                 } else
138:                 {
139:                         return null;
140:                 }
141:         }
142:
143:         public static <T extends PIR> List<IRStatus<T>> extract(
144:                         List<IRStatus<PIR>> inputStatuses, Class<T> type)
145:         {
146:                 List<IRStatus<T>> outputStatuses = new LinkedList<IRStatus<T>>();
147:
148:•                for (IRStatus<PIR> status : inputStatuses)
149:                 {
150:                         IRStatus<T> converted = extract(status, type);
151:
152:•                        if (converted != null)
153:                         {
154:                                 outputStatuses.add(converted);
155:                         }
156:                 }
157:
158:                 return outputStatuses;
159:         }
160:
161:         public static <T extends PIR> IRStatus<PIR> extract(IRStatus<T> inputStatus)
162:         {
163:                 String name = inputStatus.getIrNodeName();
164:                 INode vdmNode = inputStatus.getVdmNode();
165:                 PIR node = inputStatus.getIrNode();
166:                 Set<VdmNodeInfo> unsupportedInIr = inputStatus.getUnsupportedInIr();
167:                 Set<IrNodeInfo> warnings = inputStatus.getTransformationWarnings();
168:
169:                 return new IRStatus<PIR>(vdmNode, name, node, unsupportedInIr, warnings);
170:         }
171:
172:         public static <T extends PIR> List<IRStatus<PIR>> extract(
173:                         List<IRStatus<T>> inputStatuses)
174:         {
175:                 List<IRStatus<PIR>> outputStatuses = new LinkedList<IRStatus<PIR>>();
176:
177:•                for (IRStatus<T> status : inputStatuses)
178:                 {
179:                         IRStatus<PIR> converted = extract(status);
180:
181:•                        if (converted != null)
182:                         {
183:                                 outputStatuses.add(converted);
184:                         }
185:                 }
186:
187:                 return outputStatuses;
188:         }
189: }