Package: AstExpressionFactory

AstExpressionFactory

nameinstructionbranchcomplexitylinemethod
AstExpressionFactory()
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%
initExpression(PExp, ILexLocation)
M: 3 C: 6
67%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 3
75%
M: 0 C: 1
100%
initExpressionBinary(SBinaryExp, PExp, ILexToken, PExp)
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%
newAAndBooleanBinaryExp(PExp, PExp)
M: 0 C: 22
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
newAEqualsBinaryExp(PExp, PExp)
M: 0 C: 22
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
newAGreaterNumericBinaryExp(PExp, PExp)
M: 0 C: 22
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
newAImpliesBooleanBinaryExp(PExp, PExp)
M: 0 C: 22
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
newAInSetBinaryExp(PExp, PExp)
M: 0 C: 22
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
newAIsExp(PType, PExp)
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
newALessEqualNumericBinaryExp(PExp, PExp)
M: 22 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
newALessNumericBinaryExp(PExp, PExp)
M: 22 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
newAMkTypeExp(ILexNameToken, PType, List)
M: 0 C: 23
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 7
100%
M: 0 C: 1
100%
newANotEqualBinaryExp(PExp, PExp)
M: 0 C: 22
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
newAOrBooleanBinaryExp(PExp, PExp)
M: 0 C: 22
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
newAPlusNumericBinaryExp(PExp, PExp)
M: 17 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * The Overture Abstract Syntax Tree
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.ast.factory;
23:
24: import java.util.List;
25:
26: import org.overture.ast.expressions.*;
27: import org.overture.ast.intf.lex.ILexLocation;
28: import org.overture.ast.intf.lex.ILexNameToken;
29: import org.overture.ast.intf.lex.ILexToken;
30: import org.overture.ast.lex.LexToken;
31: import org.overture.ast.lex.VDMToken;
32: import org.overture.ast.types.ABooleanBasicType;
33: import org.overture.ast.types.ARecordInvariantType;
34: import org.overture.ast.types.PType;
35:
36: public class AstExpressionFactory
37: {
38:
39:         public static AMkTypeExp newAMkTypeExp(ILexNameToken typeName, PType type,
40:                         List<PExp> arglist)
41:         {
42:                 AMkTypeExp mktype = new AMkTypeExp();
43:                 mktype.setType(type);
44:•                if (type instanceof ARecordInvariantType)
45:                 {
46:                         mktype.setRecordType((ARecordInvariantType) type.clone());
47:                 }
48:
49:                 mktype.setTypeName(typeName);
50:                 mktype.setArgs(arglist);
51:                 return mktype;
52:         }
53:
54:         public static AIsExp newAIsExp(PType type, PExp exp)
55:         {
56:                 AIsExp result = new AIsExp();
57:                 initExpression(result, null);
58:
59:                 result.setBasicType(type);
60:                 result.setTest(exp);
61:
62:                 return result;
63:
64:         }
65:
66:         public static AEqualsBinaryExp newAEqualsBinaryExp(PExp left, PExp right)
67:         {
68:                 AEqualsBinaryExp result = new AEqualsBinaryExp();
69:                 ILexToken op = new LexToken(null, VDMToken.EQUALS);
70:                 initExpressionBinary(result, left, op, right);
71:                 result.setType(new ABooleanBasicType());
72:                 return result;
73:         }
74:
75:         public static AAndBooleanBinaryExp newAAndBooleanBinaryExp(PExp left,
76:                         PExp right)
77:         {
78:                 AAndBooleanBinaryExp result = new AAndBooleanBinaryExp();
79:                 ILexToken op = new LexToken(null, VDMToken.AND);
80:                 initExpressionBinary(result, left, op, right);
81:                 result.setType(new ABooleanBasicType());
82:                 return result;
83:         }
84:
85:         public static APlusNumericBinaryExp newAPlusNumericBinaryExp(PExp left,
86:                         PExp right)
87:         {
88:                 APlusNumericBinaryExp result = new APlusNumericBinaryExp();
89:                 ILexToken op = new LexToken(null, VDMToken.PLUS);
90:                 initExpressionBinary(result, left, op, right);
91:                 return result;
92:         }
93:
94:         public static ALessEqualNumericBinaryExp newALessEqualNumericBinaryExp(
95:                         PExp left, PExp right)
96:         {
97:                 ALessEqualNumericBinaryExp result = new ALessEqualNumericBinaryExp();
98:                 ILexToken op = new LexToken(null, VDMToken.LE);
99:                 initExpressionBinary(result, left, op, right);
100:                 result.setType(new ABooleanBasicType());
101:                 return result;
102:         }
103:
104:         public static ANotEqualBinaryExp newANotEqualBinaryExp(PExp left, PExp right)
105:         {
106:                 ANotEqualBinaryExp result = new ANotEqualBinaryExp();
107:                 ILexToken op = new LexToken(null, VDMToken.NE);
108:                 initExpressionBinary(result, left, op, right);
109:                 result.setType(new ABooleanBasicType());
110:                 return result;
111:         }
112:
113:         public static ALessNumericBinaryExp newALessNumericBinaryExp(PExp left,
114:                         PExp right)
115:         {
116:                 ALessNumericBinaryExp result = new ALessNumericBinaryExp();
117:                 ILexToken op = new LexToken(null, VDMToken.LT);
118:                 initExpressionBinary(result, left, op, right);
119:                 result.setType(new ABooleanBasicType());
120:                 return result;
121:         }
122:
123:         public static AInSetBinaryExp newAInSetBinaryExp(PExp left, PExp right)
124:         {
125:                 AInSetBinaryExp result = new AInSetBinaryExp();
126:                 ILexToken op = new LexToken(null, VDMToken.INSET);
127:                 initExpressionBinary(result, left, op, right);
128:                 result.setType(new ABooleanBasicType());
129:                 return result;
130:         }
131:
132:         public static AOrBooleanBinaryExp newAOrBooleanBinaryExp(PExp left,
133:                         PExp right)
134:         {
135:                 AOrBooleanBinaryExp result = new AOrBooleanBinaryExp();
136:                 ILexToken op = new LexToken(null, VDMToken.OR);
137:                 initExpressionBinary(result, left, op, right);
138:                 result.setType(new ABooleanBasicType());
139:                 return result;
140:         }
141:
142:         public static AImpliesBooleanBinaryExp newAImpliesBooleanBinaryExp(
143:                         PExp left, PExp right)
144:         {
145:                 AImpliesBooleanBinaryExp result = new AImpliesBooleanBinaryExp();
146:                 ILexToken op = new LexToken(null, VDMToken.IMPLIES);
147:                 initExpressionBinary(result, left, op, right);
148:                 result.setType(new ABooleanBasicType());
149:                 return result;
150:         }
151:
152:         public static AGreaterNumericBinaryExp newAGreaterNumericBinaryExp(
153:                         PExp left, PExp right)
154:         {
155:                 AGreaterNumericBinaryExp result = new AGreaterNumericBinaryExp();
156:                 ILexToken op = new LexToken(null, VDMToken.GT);
157:                 initExpressionBinary(result, left, op, right);
158:                 result.setType(new ABooleanBasicType());
159:                 return result;
160:         }
161:
162:         static void initExpressionBinary(SBinaryExp result, PExp left,
163:                         ILexToken op, PExp right)
164:         {
165:                 initExpression(result, op.getLocation());
166:                 result.setLeft(left);
167:                 result.setOp(op);
168:                 result.setRight(right);
169:         }
170:
171:         private static void initExpression(PExp result, ILexLocation location)
172:         {
173:                 result.setLocation(location);
174:•                if (location != null)
175:                 {
176:                         location.executable(true);
177:                 }
178:         }
179:
180: }