Package: ComposeTypeCollector

ComposeTypeCollector

nameinstructionbranchcomplexitylinemethod
ComposeTypeCollector()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
caseABracketType(ABracketType)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAFunctionType(AFunctionType)
M: 0 C: 35
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
caseAInMapMapType(AInMapMapType)
M: 0 C: 24
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
caseAMapMapType(AMapMapType)
M: 0 C: 24
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
caseAOperationType(AOperationType)
M: 0 C: 35
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
caseAOptionalType(AOptionalType)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAProductType(AProductType)
M: 0 C: 26
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseARecordInvariantType(ARecordInvariantType)
M: 0 C: 36
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
caseASeq1SeqType(ASeq1SeqType)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseASeqSeqType(ASeqSeqType)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAUnionType(AUnionType)
M: 0 C: 26
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
createNewReturnValue(INode)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
createNewReturnValue(Object)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
defaultSSetType(SSetType)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * #%~
3: * The VDM Type Checker
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.typechecker.utilities;
23:
24: import org.overture.ast.analysis.AnalysisException;
25: import org.overture.ast.analysis.AnswerAdaptor;
26: import org.overture.ast.assistant.pattern.PTypeList;
27: import org.overture.ast.node.INode;
28: import org.overture.ast.types.ABracketType;
29: import org.overture.ast.types.AFieldField;
30: import org.overture.ast.types.AFunctionType;
31: import org.overture.ast.types.AInMapMapType;
32: import org.overture.ast.types.AMapMapType;
33: import org.overture.ast.types.AOperationType;
34: import org.overture.ast.types.AOptionalType;
35: import org.overture.ast.types.AProductType;
36: import org.overture.ast.types.ARecordInvariantType;
37: import org.overture.ast.types.ASeq1SeqType;
38: import org.overture.ast.types.ASeqSeqType;
39: import org.overture.ast.types.SSetType;
40: import org.overture.ast.types.AUnionType;
41: import org.overture.ast.types.PType;
42:
43: /**
44: * This class implements a way to collect compose types from a node in the AST
45: *
46: * @author Nick Battle
47: */
48: public class ComposeTypeCollector extends AnswerAdaptor<PTypeList>
49: {
50:         public ComposeTypeCollector()
51:         {
52:         }
53:
54:         @Override
55:         public PTypeList createNewReturnValue(INode node) throws AnalysisException
56:         {
57:                 return new PTypeList();
58:         }
59:
60:         @Override
61:         public PTypeList createNewReturnValue(Object node) throws AnalysisException
62:         {
63:                 return new PTypeList();
64:         }
65:
66:         @Override
67:         public PTypeList caseABracketType(ABracketType node)
68:                         throws AnalysisException
69:         {
70:                 return node.getType().apply(THIS);
71:         }
72:
73:         @Override
74:         public PTypeList caseAOptionalType(AOptionalType node)
75:                         throws AnalysisException
76:         {
77:                 return node.getType().apply(THIS);
78:         }
79:
80:         @Override
81:         public PTypeList caseASeqSeqType(ASeqSeqType node) throws AnalysisException
82:         {
83:                 return node.getSeqof().apply(THIS);
84:         }
85:
86:         @Override
87:         public PTypeList caseASeq1SeqType(ASeq1SeqType node)
88:                         throws AnalysisException
89:         {
90:                 return node.getSeqof().apply(THIS);
91:         }
92:
93:         @Override
94:         public PTypeList defaultSSetType(SSetType node) throws AnalysisException
95:         {
96:                 return node.getSetof().apply(THIS);
97:         }
98:
99:         @Override
100:         public PTypeList caseAProductType(AProductType node)
101:                         throws AnalysisException
102:         {
103:                 PTypeList list = new PTypeList();
104:
105:•                for (PType ptype : node.getTypes())
106:                 {
107:                         list.addAll(ptype.apply(THIS));
108:                 }
109:
110:                 return list;
111:         }
112:
113:         @Override
114:         public PTypeList caseAUnionType(AUnionType node) throws AnalysisException
115:         {
116:                 PTypeList list = new PTypeList();
117:
118:•                for (PType ptype : node.getTypes())
119:                 {
120:                         list.addAll(ptype.apply(THIS));
121:                 }
122:
123:                 return list;
124:         }
125:
126:         @Override
127:         public PTypeList caseAFunctionType(AFunctionType node)
128:                         throws AnalysisException
129:         {
130:                 PTypeList list = new PTypeList();
131:
132:•                for (PType ptype : node.getParameters())
133:                 {
134:                         list.addAll(ptype.apply(THIS));
135:                 }
136:
137:                 list.addAll(node.getResult().apply(THIS));
138:                 return list;
139:         }
140:
141:         @Override
142:         public PTypeList caseAInMapMapType(AInMapMapType node)
143:                         throws AnalysisException
144:         {
145:                 PTypeList list = new PTypeList();
146:                 list.addAll(node.getFrom().apply(THIS));
147:                 list.addAll(node.getTo().apply(THIS));
148:                 return list;
149:         }
150:
151:         @Override
152:         public PTypeList caseAMapMapType(AMapMapType node) throws AnalysisException
153:         {
154:                 PTypeList list = new PTypeList();
155:                 list.addAll(node.getFrom().apply(THIS));
156:                 list.addAll(node.getTo().apply(THIS));
157:                 return list;
158:         }
159:
160:         @Override
161:         public PTypeList caseAOperationType(AOperationType node)
162:                         throws AnalysisException
163:         {
164:                 PTypeList list = new PTypeList();
165:
166:•                for (PType ptype : node.getParameters())
167:                 {
168:                         list.addAll(ptype.apply(THIS));
169:                 }
170:
171:                 list.addAll(node.getResult().apply(THIS));
172:                 return list;
173:         }
174:
175:         @Override
176:         public PTypeList caseARecordInvariantType(ARecordInvariantType node)
177:                         throws AnalysisException
178:         {
179:•                if (node.getComposed())
180:                 {
181:                         PTypeList types = new PTypeList(node);
182:
183:•                        for (AFieldField f : node.getFields())
184:                         {
185:                                 types.addAll(f.getType().apply(THIS));
186:                         }
187:
188:                         return types;
189:                 } else
190:                 {
191:                         return new PTypeList();
192:                 }
193:         }
194: }