Revision 9
Added by Willibald K. over 8 years ago
OoaResolveExpressionsVisitor.java | ||
---|---|---|
45 | 45 |
import org.momut.ooas.ast.expressions.LeafExpression; |
46 | 46 |
import org.momut.ooas.ast.expressions.ListConstructor; |
47 | 47 |
import org.momut.ooas.ast.expressions.MapConstructor; |
48 |
import org.momut.ooas.ast.expressions.QValConstructor; |
|
49 | 48 |
import org.momut.ooas.ast.expressions.SetConstructor; |
50 | 49 |
import org.momut.ooas.ast.expressions.TernaryOperator; |
51 | 50 |
import org.momut.ooas.ast.expressions.TupleConstructor; |
... | ... | |
80 | 79 |
import org.momut.ooas.ast.types.MapType; |
81 | 80 |
import org.momut.ooas.ast.types.NullType; |
82 | 81 |
import org.momut.ooas.ast.types.OoActionSystemType; |
83 |
import org.momut.ooas.ast.types.QrType; |
|
84 | 82 |
import org.momut.ooas.ast.types.TupleType; |
85 | 83 |
import org.momut.ooas.ast.types.TypeKind; |
86 |
import org.momut.ooas.ast.types.UlyssesType;
|
|
84 |
import org.momut.ooas.ast.types.Type; |
|
87 | 85 |
import org.momut.ooas.ast.types.ValuedEnumType; |
88 | 86 |
import org.momut.ooas.parser.ParserError; |
89 | 87 |
import org.momut.ooas.parser.ParserMessage; |
... | ... | |
258 | 256 |
if (mid.type() == null || right.type() == null) |
259 | 257 |
return Error(expression, "Conditional: Then or Else branch has void-type"); |
260 | 258 |
|
261 |
final UlyssesType acover = UlyssesType.CoverType(mid.type(), right.type());
|
|
259 |
final Type acover = Type.CoverType(mid.type(), right.type());
|
|
262 | 260 |
|
263 | 261 |
if (acover == null) |
264 | 262 |
return Error(expression, String.format( |
265 | 263 |
"Conditional: Then and Else branch must be of same type. (%s <> %s)", |
266 | 264 |
mid.type().toString(), right.type().toString())); |
267 | 265 |
|
268 |
if (!UlyssesType.TypeEqual(acover, mid.type()))
|
|
266 |
if (!Type.TypeEqual(acover, mid.type())) |
|
269 | 267 |
{ |
270 | 268 |
mid = new UnaryOperator(ExpressionKind.Cast, mid, mid.line(), mid.pos()); |
271 | 269 |
mid.SetType(acover); |
272 | 270 |
} |
273 |
if (!UlyssesType.TypeEqual(acover, right.type()))
|
|
271 |
if (!Type.TypeEqual(acover, right.type())) |
|
274 | 272 |
{ |
275 | 273 |
right = new UnaryOperator(ExpressionKind.Cast, right, right.line(), right.pos()); |
276 | 274 |
right.SetType(acover); |
... | ... | |
322 | 320 |
if (!isMap) |
323 | 321 |
{ |
324 | 322 |
final int nextToLast = funType.parameter().size() - 2; |
325 |
final UlyssesType initCover = UlyssesType.CoverType(funType.parameter().get(nextToLast), mid.type());
|
|
323 |
final Type initCover = Type.CoverType(funType.parameter().get(nextToLast), mid.type());
|
|
326 | 324 |
if (initCover == null) |
327 | 325 |
return Error(expression, "Next to last parameter does not match initializer type in map operation."); |
328 |
if (!UlyssesType.TypeEqual(mid.type(), initCover))
|
|
326 |
if (!Type.TypeEqual(mid.type(), initCover)) |
|
329 | 327 |
mid = new UnaryOperator(ExpressionKind.Cast, mid, mid.line(), mid.pos()); |
330 | 328 |
mid.SetType(initCover); |
331 | 329 |
|
... | ... | |
336 | 334 |
} |
337 | 335 |
// UlyssesType listCover = UlyssesType.CoverType(funType.parameter.Last.Value, ((ListType)right.type).innerType); |
338 | 336 |
// if (listCover == null) |
339 |
if (!UlyssesType.TypeEqual(funType.parameter().peekLast(), ((ListType)right.type()).innerType()))
|
|
337 |
if (!Type.TypeEqual(funType.parameter().peekLast(), ((ListType)right.type()).innerType())) |
|
340 | 338 |
return Error(expression, "Last paramter does not match inner-type of list in fold/map operation"); |
341 | 339 |
|
342 | 340 |
expression.SetLeftChild(leftcall); |
... | ... | |
372 | 370 |
} |
373 | 371 |
private Expression ResolveExpression(ListConstructor expression) |
374 | 372 |
{ |
375 |
UlyssesType type = null;
|
|
373 |
Type type = null; |
|
376 | 374 |
ListType restype = null; |
377 | 375 |
Expression comprehension = null; |
378 | 376 |
if (expression.comprehension() != null) |
... | ... | |
426 | 424 |
if (type == null) |
427 | 425 |
type = element.type(); |
428 | 426 |
|
429 |
type = UlyssesType.CoverType(type, element.type());
|
|
427 |
type = Type.CoverType(type, element.type()); |
|
430 | 428 |
if (type == null) |
431 | 429 |
return Error(expression, "List constructor needs matching types"); |
432 | 430 |
|
... | ... | |
436 | 434 |
// now we have the resulting type - we still need to insert casts that might be necessary |
437 | 435 |
for (final Expression item: tmpitems) |
438 | 436 |
{ |
439 |
if (!UlyssesType.TypeEqual(item.type(), type))
|
|
437 |
if (!Type.TypeEqual(item.type(), type)) |
|
440 | 438 |
{ |
441 | 439 |
final Expression cast = new UnaryOperator(ExpressionKind.Cast, item, item.line(), item.pos()); |
442 | 440 |
cast.SetType(type); |
... | ... | |
458 | 456 |
} |
459 | 457 |
private Expression ResolveExpression(SetConstructor expression) |
460 | 458 |
{ |
461 |
UlyssesType type = null;
|
|
459 |
Type type = null; |
|
462 | 460 |
ListType restype = null; |
463 | 461 |
Expression comprehension = null; |
464 | 462 |
if (expression.comprehension() != null) |
... | ... | |
492 | 490 |
|
493 | 491 |
if (type == null) |
494 | 492 |
type = element.type(); |
495 |
type = UlyssesType.CoverType(type, element.type());
|
|
493 |
type = Type.CoverType(type, element.type()); |
|
496 | 494 |
if (type == null) |
497 | 495 |
return Error(expression, "Set initializer needs matching types"); |
498 | 496 |
|
... | ... | |
506 | 504 |
} |
507 | 505 |
private Expression ResolveExpression(MapConstructor expression) |
508 | 506 |
{ |
509 |
UlyssesType domain = null;
|
|
510 |
UlyssesType range = null;
|
|
507 |
Type domain = null; |
|
508 |
Type range = null; |
|
511 | 509 |
final ArrayList<MapConstructor.MapItem> newitems = new ArrayList<MapConstructor.MapItem>(); |
512 | 510 |
|
513 | 511 |
for(final MapItem item: expression.items()) |
... | ... | |
532 | 530 |
if (range == null) |
533 | 531 |
range = rangeexpr.type(); |
534 | 532 |
|
535 |
domain = UlyssesType.CoverType(domain, domexpr.type());
|
|
536 |
range = UlyssesType.CoverType(range, rangeexpr.type());
|
|
533 |
domain = Type.CoverType(domain, domexpr.type()); |
|
534 |
range = Type.CoverType(range, rangeexpr.type()); |
|
537 | 535 |
if (domain == null) |
538 | 536 |
return Error(expression, "Types of domain expressions do not match"); |
539 | 537 |
|
... | ... | |
559 | 557 |
//TupleType resulttype = new TupleType(null); |
560 | 558 |
final ArrayList<Expression> newvalexprs = new ArrayList<Expression>(); |
561 | 559 |
|
562 |
final Iterator<UlyssesType> innerTargetType = typeToConstruct.innerTypes().iterator();
|
|
560 |
final Iterator<Type> innerTargetType = typeToConstruct.innerTypes().iterator(); |
|
563 | 561 |
int freeVarCount = 0; |
564 | 562 |
for (final Expression initexpr: expression.values()) |
565 | 563 |
{ |
566 |
final UlyssesType innerTargetTypeValue = innerTargetType.next();
|
|
564 |
final Type innerTargetTypeValue = innerTargetType.next(); |
|
567 | 565 |
Expression newval = ResolveExpression(initexpr); |
568 | 566 |
if (newval == null) |
569 | 567 |
return null; |
... | ... | |
580 | 578 |
} |
581 | 579 |
else |
582 | 580 |
{ |
583 |
final UlyssesType acover = UlyssesType.CoverType(innerTargetTypeValue, newval.type());
|
|
584 |
if (acover == null || !UlyssesType.TypeEqualByKind(innerTargetTypeValue, acover))
|
|
581 |
final Type acover = Type.CoverType(innerTargetTypeValue, newval.type());
|
|
582 |
if (acover == null || !Type.TypeEqualByKind(innerTargetTypeValue, acover)) |
|
585 | 583 |
return Error(expression, |
586 | 584 |
String.format("Element in tuple constructor has non-matching type (%s <> %s)", |
587 | 585 |
innerTargetTypeValue.toString(), newval.type().toString())); |
588 | 586 |
|
589 |
if (!UlyssesType.TypeEqual(acover, newval.type()))
|
|
587 |
if (!Type.TypeEqual(acover, newval.type())) |
|
590 | 588 |
{ |
591 | 589 |
newval = new UnaryOperator(ExpressionKind.Cast, newval, newval.line(), newval.pos()); |
592 | 590 |
newval.SetType(acover); |
593 | 591 |
} |
594 |
if (UlyssesType.FirstTypeLessRange(innerTargetTypeValue, acover)) {
|
|
592 |
if (Type.FirstTypeLessRange(innerTargetTypeValue, acover)) { |
|
595 | 593 |
Warning(expression, |
596 | 594 |
String.format("Tuple constructor may over/underflow: %s := %s", |
597 | 595 |
innerTargetTypeValue.toString(), acover.toString())); |
... | ... | |
621 | 619 |
return expression; |
622 | 620 |
} |
623 | 621 |
|
624 |
private Expression ResolveExpression(QValConstructor expression) |
|
625 |
{ |
|
626 |
Expression basevalue = null; |
|
627 |
Expression rangevalue = null; |
|
628 |
|
|
629 |
basevalue = ResolveExpression(expression.value()[0]); |
|
630 |
if (basevalue == null || basevalue.kind() != ExpressionKind.Access |
|
631 |
|| basevalue.type() == null || basevalue.type().kind() != TypeKind.QrType) |
|
632 |
return Error(expression, "Landmark expected."); |
|
633 |
expression.SetType(basevalue.type()); |
|
634 |
expression.SetValue(basevalue); |
|
635 |
|
|
636 |
if (expression.value().length == 2) |
|
637 |
{ |
|
638 |
rangevalue = ResolveExpression(expression.value()[1]); |
|
639 |
if (rangevalue == null || rangevalue.kind() != ExpressionKind.Access |
|
640 |
|| rangevalue.type() == null || rangevalue.type().kind() != TypeKind.QrType) |
|
641 |
return Error(expression, "Landmark expected."); |
|
642 |
if (!UlyssesType.TypeEqual(basevalue.type(), rangevalue.type())) |
|
643 |
return Error(expression, String.format("Quantity spaces do not match: %s <> %s", |
|
644 |
basevalue.type().toString(), |
|
645 |
rangevalue.type().toString())); |
|
646 |
expression.AddRange(rangevalue); |
|
647 |
} |
|
648 |
return expression; |
|
649 |
} |
|
650 |
|
|
651 | 622 |
private Expression ResolveExpression(IdentifierExpression expression) |
652 | 623 |
{ |
653 | 624 |
// nothing to do here, since we do not have any consts that may be |
... | ... | |
836 | 807 |
} |
837 | 808 |
|
838 | 809 |
final ArrayList<Expression> newargs = new ArrayList<Expression>(); |
839 |
final Iterator<UlyssesType> demandedArgType = funtype.parameter().iterator();
|
|
810 |
final Iterator<Type> demandedArgType = funtype.parameter().iterator(); |
|
840 | 811 |
for (final Expression arg: expression.arguments()) |
841 | 812 |
{ |
842 |
final UlyssesType demandedArgTypeValue = demandedArgType.next();
|
|
813 |
final Type demandedArgTypeValue = demandedArgType.next(); |
|
843 | 814 |
Expression newarg = ResolveExpression(arg); |
844 | 815 |
if (newarg == null) |
845 | 816 |
return null; |
... | ... | |
850 | 821 |
|
851 | 822 |
final Expression constantvalue = newarg.kind() == ExpressionKind.Value ? newarg : null; |
852 | 823 |
|
853 |
final UlyssesType acover = UlyssesType.CoverType(newarg.type(), demandedArgTypeValue);
|
|
854 |
if (acover == null || !UlyssesType.TypeEqualByKind(demandedArgTypeValue, acover))
|
|
824 |
final Type acover = Type.CoverType(newarg.type(), demandedArgTypeValue);
|
|
825 |
if (acover == null || !Type.TypeEqualByKind(demandedArgTypeValue, acover)) |
|
855 | 826 |
return Error(arg, String.format("Argument type does not match; expected: %s delivered: %s", |
856 | 827 |
demandedArgTypeValue.toString(), newarg.type().toString())); |
857 | 828 |
|
858 | 829 |
newarg = UnaryOperator.TryCoerceUp(newarg, acover); |
859 | 830 |
|
860 |
if (UlyssesType.FirstTypeLessRange(demandedArgTypeValue, acover))
|
|
831 |
if (Type.FirstTypeLessRange(demandedArgTypeValue, acover)) |
|
861 | 832 |
{ |
862 | 833 |
if (constantvalue == null) |
863 | 834 |
{ |
... | ... | |
898 | 869 |
final boolean staticAccess = lhs.kind() == ExpressionKind.Type; |
899 | 870 |
final UnresolvedIdentifierExpression access = (UnresolvedIdentifierExpression)expression.right(); |
900 | 871 |
// atype could be null... |
901 |
UlyssesType atype = lhs.type();
|
|
872 |
Type atype = lhs.type(); |
|
902 | 873 |
if ((lhs.kind() == ExpressionKind.Call) && (atype == null)) |
903 | 874 |
{ |
904 | 875 |
return Error(access, "Can not access return type of void-function"); |
... | ... | |
984 | 955 |
return Error(access, String.format("%s not contained in enum %s", |
985 | 956 |
access.tokenText(), anEnum.identifier().tokenText())); |
986 | 957 |
break; |
987 |
case QrType: |
|
988 |
final QrType aQualitativeType = (QrType)atype; |
|
989 |
if (!staticAccess) |
|
990 |
{ |
|
991 |
return Error(access, "QSpace values can only be accessed statically."); |
|
992 |
} |
|
993 |
if (aQualitativeType.symbolTable().Defined(access.tokenText())) |
|
994 |
{ |
|
995 |
final Identifier landmark = aQualitativeType.symbolTable().Get(access.tokenText()); |
|
996 |
final IdentifierExpression newrhs = new IdentifierExpression(landmark, access.line(), access.pos()); |
|
997 |
expression.SetRightChild(newrhs); |
|
998 |
} |
|
999 |
else |
|
1000 |
return Error(access, String.format("%s not contained in qspace %s", |
|
1001 |
access.tokenText(), aQualitativeType.identifier().tokenText())); |
|
1002 |
break; |
|
1003 | 958 |
default: |
1004 | 959 |
/*error, we can not access an element with '.' in any other type*/ |
1005 | 960 |
return Error(expression, "Expected: System, Enum, Func, or QR type"); |
... | ... | |
1174 | 1129 |
if ((lhs == null) || (rhs == null)) |
1175 | 1130 |
return null; |
1176 | 1131 |
|
1177 |
final UlyssesType lt = lhs.type();
|
|
1178 |
final UlyssesType rt = rhs.type();
|
|
1132 |
final Type lt = lhs.type(); |
|
1133 |
final Type rt = rhs.type(); |
|
1179 | 1134 |
|
1180 | 1135 |
if ((lt == null) || (rt == null)) |
1181 | 1136 |
return Error(expression, "Binary operator not applicable to void-type subexpression."); |
... | ... | |
1192 | 1147 |
return Error(expression, "Domain restriction operator expects map on RHS"); |
1193 | 1148 |
ListType domlist = (ListType)lt; |
1194 | 1149 |
MapType domMap = (MapType)rt; |
1195 |
if (!UlyssesType.TypeEqual(domlist.innerType(), domMap.fromType()))
|
|
1150 |
if (!Type.TypeEqual(domlist.innerType(), domMap.fromType())) |
|
1196 | 1151 |
return Error(expression, "Inner type of list and domain-type of map do not match"); |
1197 | 1152 |
// since this is a restriction, maxnumofelems is ok |
1198 | 1153 |
expression.SetType(domMap); |
... | ... | |
1205 | 1160 |
return Error(expression, "Rangle restriction operator expects list on RHS"); |
1206 | 1161 |
final ListType rangelist = (ListType)rt; |
1207 | 1162 |
domMap = (MapType)lt; |
1208 |
if (!UlyssesType.TypeEqual(rangelist.innerType(), domMap.fromType()))
|
|
1163 |
if (!Type.TypeEqual(rangelist.innerType(), domMap.fromType())) |
|
1209 | 1164 |
return Error(expression, "Inner type of list and rangle-type of map do not match"); |
1210 | 1165 |
// since this is a restriction, maxnumofelems is ok |
1211 | 1166 |
expression.SetType(domMap); |
... | ... | |
1216 | 1171 |
return Error(expression, "Map union expects maps on LHS and RHS"); |
1217 | 1172 |
domMap = (MapType)lt; |
1218 | 1173 |
MapType rngMap = (MapType)rt; |
1219 |
if (!UlyssesType.TypeEqual(domMap.fromType(), rngMap.fromType()) ||
|
|
1220 |
!UlyssesType.TypeEqual(domMap.toType(), rngMap.toType()))
|
|
1174 |
if (!Type.TypeEqual(domMap.fromType(), rngMap.fromType()) || |
|
1175 |
!Type.TypeEqual(domMap.toType(), rngMap.toType())) |
|
1221 | 1176 |
return Error(expression, "Domain and Range types of maps must be equal"); |
1222 | 1177 |
// union may change maximum number of elements.. |
1223 | 1178 |
final MapType resMap = new MapType(domMap.fromType(), domMap.toType(), |
... | ... | |
1236 | 1191 |
return lhs; |
1237 | 1192 |
if (la.innerType().kind() == TypeKind.Null || la.maxNumberOfElements() == 0) |
1238 | 1193 |
return rhs; |
1239 |
if (!UlyssesType.TypeEqual(la.innerType(), lb.innerType()))
|
|
1194 |
if (!Type.TypeEqual(la.innerType(), lb.innerType())) |
|
1240 | 1195 |
return Error(expression, String.format("Set/List concatenation expects two lists of same type. (%s <> %s)", la.toString(), lb.toString())); |
1241 | 1196 |
ListType resultList = new ListType(la.innerType(), |
1242 | 1197 |
la.maxNumberOfElements() + lb.maxNumberOfElements(), null); |
... | ... | |
1248 | 1203 |
return Error(expression, "Set difference expects two lists."); |
1249 | 1204 |
la = (ListType)lt; |
1250 | 1205 |
lb = (ListType)rt; |
1251 |
if (!UlyssesType.TypeEqual(la.innerType(), lb.innerType()))
|
|
1206 |
if (!Type.TypeEqual(la.innerType(), lb.innerType())) |
|
1252 | 1207 |
return Error(expression, "Set difference expects two lists of same type."); |
1253 | 1208 |
expression.SetType(la); |
1254 | 1209 |
break; |
... | ... | |
1258 | 1213 |
return Error(expression, "Set intersection expects two lists."); |
1259 | 1214 |
la = (ListType)lt; |
1260 | 1215 |
lb = (ListType)rt; |
1261 |
if (!UlyssesType.TypeEqual(la.innerType(), lb.innerType()))
|
|
1216 |
if (!Type.TypeEqual(la.innerType(), lb.innerType())) |
|
1262 | 1217 |
return Error(expression, "Set intersection expects two lists of same type."); |
1263 | 1218 |
expression.SetType(la.maxNumberOfElements() > lb.maxNumberOfElements() ? la : lb); |
1264 | 1219 |
break; |
... | ... | |
1269 | 1224 |
lb = (ListType)rt; |
1270 | 1225 |
if (lhs.kind() == ExpressionKind.Value) |
1271 | 1226 |
lhs = UnaryOperator.TryCoerceUp(lhs, lb.innerType()); |
1272 |
final UlyssesType leftType = lhs.type();
|
|
1273 |
if (!UlyssesType.TypeEqual(leftType, lb.innerType()))
|
|
1227 |
final Type leftType = lhs.type(); |
|
1228 |
if (!Type.TypeEqual(leftType, lb.innerType())) |
|
1274 | 1229 |
return Error(expression, String.format("List and element must be of same type: %s in %s", |
1275 | 1230 |
lt == null ? "<null>" : lt.toString(), lb ==null || lb.innerType() == null ? "<null>" : lb.innerType().toString())); |
1276 | 1231 |
expression.SetType(new BoolType(null)); |
... | ... | |
1281 | 1236 |
return Error(expression, "Subset operation expects two lists."); |
1282 | 1237 |
la = (ListType)lt; |
1283 | 1238 |
lb = (ListType)rt; |
1284 |
if (!UlyssesType.TypeEqual(la.innerType(), lb.innerType()))
|
|
1239 |
if (!Type.TypeEqual(la.innerType(), lb.innerType())) |
|
1285 | 1240 |
return Error(expression, "Subset operation expects two lists of same type."); |
1286 | 1241 |
expression.SetType(new BoolType(null)); |
1287 | 1242 |
break; |
... | ... | |
1297 | 1252 |
if (lb.innerType().kind() == TypeKind.Null || lb.maxNumberOfElements() == 0) |
1298 | 1253 |
return lhs; |
1299 | 1254 |
|
1300 |
if (!UlyssesType.TypeEqual(la.innerType(), lb.innerType()))
|
|
1255 |
if (!Type.TypeEqual(la.innerType(), lb.innerType())) |
|
1301 | 1256 |
return Error(expression, "Set union expects two lists of same type."); |
1302 | 1257 |
resultList = new ListType(la.innerType(), |
1303 | 1258 |
la.maxNumberOfElements() + lb.maxNumberOfElements(), null); |
... | ... | |
1334 | 1289 |
lhs = UnaryOperator.TryCoerceUp(lhs, ((ValuedEnumType)lhs.type()).getIntType()); |
1335 | 1290 |
if (rhs.type() instanceof ValuedEnumType) |
1336 | 1291 |
rhs = UnaryOperator.TryCoerceUp(rhs, ((ValuedEnumType)rhs.type()).getIntType()); |
1337 |
UlyssesType cover = Expression.ArithmeticCover(lt, rt, expression.kind());
|
|
1292 |
Type cover = Expression.ArithmeticCover(lt, rt, expression.kind()); |
|
1338 | 1293 |
expression.SetType(cover); |
1339 | 1294 |
break; |
1340 | 1295 |
case minus: |
... | ... | |
1373 | 1328 |
case lessequal: |
1374 | 1329 |
if (!((rt.IsNumeric() && lt.IsNumeric()) || (rt.IsQualitative() && lt.IsQualitative()))) |
1375 | 1330 |
return Error(expression, "Operator expects LHS and RHS to be numeric or qualitative"); |
1376 |
cover = UlyssesType.CoverType(lt, rt);
|
|
1331 |
cover = Type.CoverType(lt, rt); |
|
1377 | 1332 |
if (cover != null) |
1378 | 1333 |
{ |
1379 | 1334 |
lhs = UnaryOperator.TryCoerceUp(lhs, cover); |
... | ... | |
1434 | 1389 |
/*other binary*/ |
1435 | 1390 |
case equal: |
1436 | 1391 |
case notequal: |
1437 |
cover = UlyssesType.CoverType(lt, rt);
|
|
1392 |
cover = Type.CoverType(lt, rt); |
|
1438 | 1393 |
if (cover != null) |
1439 | 1394 |
{ |
1440 | 1395 |
/* see whether we have a tuple-matcher on one side.. */ |
... | ... | |
1476 | 1431 |
rngMap = (MapType)rt; |
1477 | 1432 |
if (rngMap.fromType().kind() != TypeKind.IntType) |
1478 | 1433 |
return Error(expression, "Domain of map has to be integer"); |
1479 |
if (!UlyssesType.TypeEqual(domlist.innerType(), rngMap.toType()))
|
|
1434 |
if (!Type.TypeEqual(domlist.innerType(), rngMap.toType())) |
|
1480 | 1435 |
return Error(expression, "Type of list expected to match range of map"); |
1481 | 1436 |
// since we only replace elements in the list (by matching ones from the map), |
1482 | 1437 |
// we're save to return the original list.. |
... | ... | |
1487 | 1442 |
{ |
1488 | 1443 |
domMap = (MapType)lt; |
1489 | 1444 |
rngMap = (MapType)rt; |
1490 |
if (!UlyssesType.TypeEqual(domMap.fromType(), rngMap.fromType()) ||
|
|
1491 |
!UlyssesType.TypeEqual(domMap.toType(), rngMap.toType()))
|
|
1445 |
if (!Type.TypeEqual(domMap.fromType(), rngMap.fromType()) || |
|
1446 |
!Type.TypeEqual(domMap.toType(), rngMap.toType())) |
|
1492 | 1447 |
return Error(expression, "Maps need same domain and range types"); |
1493 | 1448 |
// since we override entries in the first map: |
1494 | 1449 |
expression.SetType(domMap); |
... | ... | |
1835 | 1790 |
case ObjectConstr: |
1836 | 1791 |
result = expression; |
1837 | 1792 |
break; |
1838 |
case QValConstr: |
|
1839 |
result = ResolveExpression((QValConstructor)expression); |
|
1840 |
break; |
|
1841 | 1793 |
|
1842 | 1794 |
/* identifiers */ |
1843 | 1795 |
case Identifier: |
... | ... | |
1869 | 1821 |
return Error(cast, String.format("Cast operator needs class type as argument. (Expected: OoActionSystemType, Found: %s)", cast.type().kind().name())); |
1870 | 1822 |
|
1871 | 1823 |
cast.SetChild(ResolveExpression(cast.child())); |
1872 |
final UlyssesType acover = UlyssesType.CoverType(cast.type(), cast.child().type());
|
|
1873 |
final boolean upcast = UlyssesType.TypeEqual(acover, cast.type()); // the cast is safe; Mostly used in list constructors..
|
|
1874 |
final boolean downcast = UlyssesType.TypeEqual(acover, cast.child().type()); // downcast, unsafe.
|
|
1824 |
final Type acover = Type.CoverType(cast.type(), cast.child().type());
|
|
1825 |
final boolean upcast = Type.TypeEqual(acover, cast.type()); // the cast is safe; Mostly used in list constructors.. |
|
1826 |
final boolean downcast = Type.TypeEqual(acover, cast.child().type()); // downcast, unsafe. |
|
1875 | 1827 |
if (downcast) |
1876 | 1828 |
Info(cast, String.format("Potentially unsafe downcast: %s as %s (cover: %s)", |
1877 | 1829 |
cast.child().type().toString(), cast.type().toString(), acover.toString())); |
Also available in: Unified diff
remove support for Qualitative Action Systems, rename UlyssesType to Type