Revision 9
Added by Willibald K. over 8 years ago
JavaExpression.java | ||
---|---|---|
39 | 39 |
import org.momut.ooas.ast.expressions.ListConstructor; |
40 | 40 |
import org.momut.ooas.ast.expressions.MapConstructor; |
41 | 41 |
import org.momut.ooas.ast.expressions.ObjectConstructor; |
42 |
import org.momut.ooas.ast.expressions.QValConstructor; |
|
43 | 42 |
import org.momut.ooas.ast.expressions.SetConstructor; |
44 | 43 |
import org.momut.ooas.ast.expressions.TernaryOperator; |
45 | 44 |
import org.momut.ooas.ast.expressions.TupleConstructor; |
... | ... | |
48 | 47 |
import org.momut.ooas.ast.expressions.UnaryOperator; |
49 | 48 |
import org.momut.ooas.ast.expressions.UnresolvedIdentifierExpression; |
50 | 49 |
import org.momut.ooas.ast.expressions.ValueExpression; |
51 |
import org.momut.ooas.ast.expressions.QValConstructor.QValDeriv; |
|
52 | 50 |
import org.momut.ooas.ast.identifiers.EnumIdentifier; |
53 | 51 |
import org.momut.ooas.ast.identifiers.Identifier; |
54 | 52 |
import org.momut.ooas.ast.identifiers.IdentifierKind; |
55 |
import org.momut.ooas.ast.identifiers.LandmarkIdentifier; |
|
56 |
import org.momut.ooas.ast.types.QrType; |
|
57 | 53 |
import org.momut.ooas.ast.types.TypeKind; |
58 |
import org.momut.ooas.ast.types.UlyssesType;
|
|
54 |
import org.momut.ooas.ast.types.Type; |
|
59 | 55 |
import org.momut.ooas.codegen.OoasCodeEmitter; |
60 | 56 |
import org.momut.ooas.utils.UnsignedHelper; |
61 | 57 |
import org.momut.ooas.utils.exceptions.NotImplementedException; |
... | ... | |
176 | 172 |
@Override |
177 | 173 |
public void visit(IdentifierExpression identifierExpression) |
178 | 174 |
{ |
179 |
if (identifierExpression.identifier().kind() == IdentifierKind.LandmarkIdentifier) |
|
180 |
{ |
|
181 |
final LandmarkIdentifier lmid = (LandmarkIdentifier)identifierExpression.identifier(); |
|
182 |
final QrType qr = (QrType)lmid.type(); |
|
183 |
m_emitter.Append(qr.landmarks().indexOf(lmid)); |
|
184 |
return; |
|
185 |
} |
|
186 |
|
|
187 | 175 |
if (identifierExpression.identifier().kind() == IdentifierKind.EnumIdentifier) |
188 | 176 |
{ |
189 | 177 |
m_emitter.Append(GetIdentifierString(((EnumIdentifier)identifierExpression.identifier()).type().identifier().tokenText())); |
... | ... | |
241 | 229 |
helperEmitter.AppendLine(String.format("for (%s %s = %s; %s <= %s; %s++) {", |
242 | 230 |
atype.toString(), |
243 | 231 |
JavaIdentifier.GetIdentifierString(sym.tokenText()), |
244 |
UlyssesType.Low(sym.type()),
|
|
232 |
Type.Low(sym.type()), |
|
245 | 233 |
JavaIdentifier.GetIdentifierString(sym.tokenText()), |
246 |
UlyssesType.High(sym.type()),
|
|
234 |
Type.High(sym.type()), |
|
247 | 235 |
JavaIdentifier.GetIdentifierString(sym.tokenText()))); |
248 | 236 |
else |
249 | 237 |
throw new NotImplementedException(); |
... | ... | |
326 | 314 |
} |
327 | 315 |
|
328 | 316 |
@Override |
329 |
public void visit(QValConstructor qValConstructor) |
|
330 |
{ |
|
331 |
final StringBuilder helpers = new StringBuilder(); |
|
332 |
|
|
333 |
String landmarkOne = "null"; |
|
334 |
if (qValConstructor.value().length >= 1 && qValConstructor.value()[0] != null) |
|
335 |
{ |
|
336 |
final JavaExpression lndmrk1 = new JavaExpression(helpers, m_data); |
|
337 |
qValConstructor.value()[0].Accept(lndmrk1); |
|
338 |
landmarkOne = lndmrk1.toString(); |
|
339 |
} |
|
340 |
String landmarkTwo = "null"; |
|
341 |
if (qValConstructor.value().length >= 2 && qValConstructor.value()[1] != null) |
|
342 |
{ |
|
343 |
final JavaExpression lndmrk = new JavaExpression(helpers, m_data); |
|
344 |
qValConstructor.value()[1].Accept(lndmrk); |
|
345 |
landmarkTwo = lndmrk.toString(); |
|
346 |
} |
|
347 |
String derivation = "null"; |
|
348 |
if (qValConstructor.valueDeriv() != QValDeriv.DonTCare) |
|
349 |
{ |
|
350 |
derivation = Integer.toString(qValConstructor.valueDeriv().ordinal()); |
|
351 |
//derivation = Enum.Format(typeof(QValDeriv), qValConstructor.valueDeriv, "d"); |
|
352 |
} |
|
353 |
|
|
354 |
m_helpers.append(helpers.toString()); |
|
355 |
m_emitter.Append(String.format("new QualitativeValue(%s,%s,%s)", landmarkOne, landmarkTwo, derivation)); |
|
356 |
} |
|
357 |
|
|
358 |
@Override |
|
359 | 317 |
public void visit(AccessExpression accessExpression) |
360 | 318 |
{ |
361 | 319 |
if (accessExpression.left().type().kind() != TypeKind.QrType && |
Also available in: Unified diff
remove support for Qualitative Action Systems, rename UlyssesType to Type