Package: MapCompStrategy

MapCompStrategy

nameinstructionbranchcomplexitylinemethod
MapCompStrategy(TransAssistantIR, AMapletExpIR, SExpIR, String, STypeIR, ILanguageIterator, ITempVarGen, IterationVarPrefixes)
M: 0 C: 13
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getConditionalAdd(AIdentifierVarExpIR, List, SPatternIR)
M: 0 C: 39
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
getEmptyCollection()
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%

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.trans.comp;
23:
24: import java.util.List;
25:
26: import org.overture.codegen.ir.ITempVarGen;
27: import org.overture.codegen.ir.SExpIR;
28: import org.overture.codegen.ir.SPatternIR;
29: import org.overture.codegen.ir.SStmIR;
30: import org.overture.codegen.ir.STypeIR;
31: import org.overture.codegen.ir.expressions.AEnumMapExpIR;
32: import org.overture.codegen.ir.expressions.AIdentifierVarExpIR;
33: import org.overture.codegen.ir.expressions.AMapletExpIR;
34: import org.overture.codegen.ir.statements.AMapCompAddStmIR;
35: import org.overture.codegen.trans.IterationVarPrefixes;
36: import org.overture.codegen.trans.assistants.TransAssistantIR;
37: import org.overture.codegen.trans.iterator.ILanguageIterator;
38:
39: public class MapCompStrategy extends ComplexCompStrategy
40: {
41:         protected AMapletExpIR first;
42:
43:         public MapCompStrategy(TransAssistantIR transformationAssitant,
44:                         AMapletExpIR first, SExpIR predicate, String var, STypeIR compType,
45:                         ILanguageIterator langIterator, ITempVarGen tempGen,
46:                         IterationVarPrefixes iteVarPrefixes)
47:         {
48:                 super(transformationAssitant, predicate, var, compType, langIterator, tempGen, iteVarPrefixes);
49:
50:                 this.first = first;
51:         }
52:
53:         @Override
54:         protected SExpIR getEmptyCollection()
55:         {
56:                 return new AEnumMapExpIR();
57:         }
58:
59:         @Override
60:         protected List<SStmIR> getConditionalAdd(AIdentifierVarExpIR setVar,
61:                         List<SPatternIR> patterns, SPatternIR pattern)
62:         {
63:                 AIdentifierVarExpIR mapCompResult = new AIdentifierVarExpIR();
64:                 mapCompResult.setType(compType.clone());
65:                 mapCompResult.setName(idPattern.getName());
66:                 mapCompResult.setIsLambda(false);
67:                 mapCompResult.setIsLocal(true);
68:
69:                 AMapCompAddStmIR add = new AMapCompAddStmIR();
70:                 add.setMap(mapCompResult);
71:                 add.setElement(first.clone());
72:
73:                 return consConditionalAdd(mapCompResult, add);
74:         }
75: }