Package: PatternVarPrefixes

PatternVarPrefixes

nameinstructionbranchcomplexitylinemethod
PatternVarPrefixes()
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getBoolPatternPrefix()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getCharPatternPrefix()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getIgnorePatternPrefix()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getIntPatternPrefix()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getMatchFailedMessage(SPatternIR)
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getName(Class)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getNullPatternPrefix()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getQuotePatternPrefix()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getRealPatternPrefix()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getRecordPatternPrefix()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getStringPatternPrefix()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getTuplePatternPrefix()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
patternToString(SPatternIR)
M: 4 C: 48
92%
M: 2 C: 18
90%
M: 2 C: 9
82%
M: 2 C: 19
90%
M: 0 C: 1
100%
setupNameLookup()
M: 0 C: 76
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 12
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.patterns;
23:
24: import java.util.HashMap;
25: import java.util.Map;
26:
27: import org.overture.codegen.ir.SPatternIR;
28: import org.overture.codegen.ir.patterns.ABoolPatternIR;
29: import org.overture.codegen.ir.patterns.ACharPatternIR;
30: import org.overture.codegen.ir.patterns.AIgnorePatternIR;
31: import org.overture.codegen.ir.patterns.AIntPatternIR;
32: import org.overture.codegen.ir.patterns.ANullPatternIR;
33: import org.overture.codegen.ir.patterns.AQuotePatternIR;
34: import org.overture.codegen.ir.patterns.ARealPatternIR;
35: import org.overture.codegen.ir.patterns.ARecordPatternIR;
36: import org.overture.codegen.ir.patterns.AStringPatternIR;
37: import org.overture.codegen.ir.patterns.ATuplePatternIR;
38:
39: public class PatternVarPrefixes
40: {
41:         private Map<Class<? extends SPatternIR>, String> patternNamePrefixes;
42:
43:         public PatternVarPrefixes()
44:         {
45:                 setupNameLookup();
46:         }
47:
48:         private void setupNameLookup()
49:         {
50:                 this.patternNamePrefixes = new HashMap<Class<? extends SPatternIR>, String>();
51:
52:                 this.patternNamePrefixes.put(AIgnorePatternIR.class, getIgnorePatternPrefix());
53:                 this.patternNamePrefixes.put(ABoolPatternIR.class, getBoolPatternPrefix());
54:                 this.patternNamePrefixes.put(ACharPatternIR.class, getCharPatternPrefix());
55:                 this.patternNamePrefixes.put(AIntPatternIR.class, getIntPatternPrefix());
56:                 this.patternNamePrefixes.put(ANullPatternIR.class, getNullPatternPrefix());
57:                 this.patternNamePrefixes.put(AQuotePatternIR.class, getQuotePatternPrefix());
58:                 this.patternNamePrefixes.put(ARealPatternIR.class, getRealPatternPrefix());
59:                 this.patternNamePrefixes.put(AStringPatternIR.class, getStringPatternPrefix());
60:                 this.patternNamePrefixes.put(ATuplePatternIR.class, getTuplePatternPrefix());
61:                 this.patternNamePrefixes.put(ARecordPatternIR.class, getRecordPatternPrefix());
62:         }
63:
64:         public String getName(Class<? extends SPatternIR> patternClass)
65:         {
66:                 return patternNamePrefixes.get(patternClass);
67:         }
68:
69:         public String getIgnorePatternPrefix()
70:         {
71:                 return "ignorePattern_";
72:         }
73:
74:         public String getBoolPatternPrefix()
75:         {
76:                 return "boolPattern_";
77:         }
78:
79:         public String getCharPatternPrefix()
80:         {
81:                 return "charPattern_";
82:         }
83:
84:         public String getIntPatternPrefix()
85:         {
86:                 return "intPattern_";
87:         }
88:
89:         public String getNullPatternPrefix()
90:         {
91:                 return "nullPattern_";
92:         }
93:
94:         public String getQuotePatternPrefix()
95:         {
96:                 return "quotePattern_";
97:         }
98:
99:         public String getRealPatternPrefix()
100:         {
101:                 return "realPattern_";
102:         }
103:
104:         public String getStringPatternPrefix()
105:         {
106:                 return "stringPattern_";
107:         }
108:
109:         public String getTuplePatternPrefix()
110:         {
111:                 return "tuplePattern_";
112:         }
113:
114:         public String getRecordPatternPrefix()
115:         {
116:                 return "recordPattern_";
117:         }
118:
119:         public String getMatchFailedMessage(SPatternIR pattern)
120:         {
121:                 return patternToString(pattern) + " pattern match failed";
122:         }
123:
124:         private String patternToString(SPatternIR pattern)
125:         {
126:•                if (pattern instanceof AIgnorePatternIR)
127:                 {
128:                         return "Ignore";
129:•                } else if (pattern instanceof ABoolPatternIR)
130:                 {
131:                         return "Bool";
132:•                } else if (pattern instanceof ACharPatternIR)
133:                 {
134:                         return "Char";
135:•                } else if (pattern instanceof AIntPatternIR)
136:                 {
137:                         return "Integer";
138:•                } else if (pattern instanceof ANullPatternIR)
139:                 {
140:                         return "Nil";
141:•                } else if (pattern instanceof AQuotePatternIR)
142:                 {
143:                         return "Quote";
144:•                } else if (pattern instanceof ARealPatternIR)
145:                 {
146:                         return "Real";
147:•                } else if (pattern instanceof AStringPatternIR)
148:                 {
149:                         return "String";
150:•                } else if (pattern instanceof ATuplePatternIR)
151:                 {
152:                         return "Tuple";
153:•                } else if (pattern instanceof ARecordPatternIR)
154:                 {
155:                         return "Record";
156:                 } else
157:                 {
158:                         return null;
159:                 }
160:         }
161: }