Project

General

Profile

Revision 10

Added by Willibald K. over 8 years ago

restrict list casts to something useful - i.e. inner type sizes must not change; this is in preparation for faster dynamic list support in momut; deep casts now need to be done manually by the user via fold operations or can be added again to the ooas compiler as a more expensive, special cast operator; also more cleaning of Qualitative Action System stuff

View differences:

OoaPrologExpression.java
186 186
		case minus:  // T_MINUS:
187 187
			return "-";
188 188
		case less:
189
			return resultingType.kind() == TypeKind.QrType || !isNumericBinary(expression) ? "<" : "#<";
189
			return !isNumericBinary(expression) ? "<" : "#<";
190 190
		case lessequal:
191
			return resultingType.kind() == TypeKind.QrType || !isNumericBinary(expression) ? "=<" : "#=<";
191
			return !isNumericBinary(expression) ? "=<" : "#=<";
192 192
		case greater:
193
			return resultingType.kind() == TypeKind.QrType || !isNumericBinary(expression) ? ">" : "#>";
193
			return !isNumericBinary(expression) ? ">" : "#>";
194 194
		case greaterequal:
195
			return resultingType.kind() == TypeKind.QrType || !isNumericBinary(expression) ? ">=" : "#>=";
195
			return !isNumericBinary(expression) ? ">=" : "#>=";
196 196
		case equal:
197
			return resultingType.kind() == TypeKind.QrType || !isNumericBinary(expression) ? "==" : "#=";
197
			return !isNumericBinary(expression) ? "==" : "#=";
198 198
		case notequal:
199
			return resultingType.kind() == TypeKind.QrType || !isNumericBinary(expression) ? "\\=" : "#\\=";
199
			return !isNumericBinary(expression) ? "\\=" : "#\\=";
200 200
		case and:    // T_AND:
201 201
			throw new NotImplementedException(); // implemented in binaryoperator
202 202
		case or:     // T_OR:
......
282 282
	@Override
283 283
	public void visit(TypeExpression typeExpression)
284 284
	{
285
		if (typeExpression.type().kind() != TypeKind.QrType &&
286
				typeExpression.type().kind() != TypeKind.EnumeratedType)
285
		if (typeExpression.type().kind() != TypeKind.EnumeratedType)
287 286
		{
288 287
			m_emitter.Append(GetIdentifierString(typeExpression.type().identifier()));
289 288
		}
......
412 411
	@Override
413 412
	public void visit(AccessExpression accessExpression)
414 413
	{
415
		if (accessExpression.left().type().kind() != TypeKind.QrType &&
416
				accessExpression.left().type().kind() != TypeKind.EnumeratedType &&
417
				!(accessExpression.right().kind() == ExpressionKind.Identifier &&
418
				((IdentifierExpression)accessExpression.right()).identifier().kind() == IdentifierKind.AttributeIdentifier))
414
		if (accessExpression.left().type().kind() != TypeKind.EnumeratedType &&
415
		    !(accessExpression.right().kind() == ExpressionKind.Identifier &&
416
		    ((IdentifierExpression)accessExpression.right()).identifier().kind() == IdentifierKind.AttributeIdentifier))
419 417
		{
420 418
			assert(m_tmpVars.size() == 0);
421 419
			// enums and qr types are directly (statically) converted to nums...
......
541 539
		default:
542 540
			m_emitter.Append(leftcode.toString());
543 541
			m_emitter.Append(rightcode.toString());
544
			if (binaryOperator.left().type().kind() == TypeKind.QrType)
545
				m_emitter.Append("qEval");
546 542
			//m_emitter.Append("(");
547 543
			if (binaryOperator.type().kind() == TypeKind.IntType)
548 544
				m_emitter.AppendLine(String.format(" %s #= (%s %s %s), ",

Also available in: Unified diff