use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.
the class ExpressionsTypeInferrer method validateParameters.
/**
* Takes the operation parameter type and performs a lookup for all contained
* type parameters by using the given type parameter inference map.<br>
* The parameter types are validated against the operation call's argument
* types.
*
* @throws TypeParameterInferrenceException
*/
public Map<TypeParameter, InferenceResult> validateParameters(Map<TypeParameter, InferenceResult> typeParameterMapping, Operation operation, List<Expression> args, IValidationIssueAcceptor acceptor) {
List<Parameter> parameters = operation.getParameters();
for (int i = 0; i < parameters.size(); i++) {
if (args.size() > i) {
Parameter parameter = parameters.get(i);
Expression argument = args.get(i);
InferenceResult parameterType = inferTypeDispatch(parameter);
InferenceResult argumentType = inferTypeDispatch(argument);
parameterType = typeParameterInferrer.buildInferenceResult(parameterType, typeParameterMapping, acceptor);
assertAssignable(parameterType, argumentType, String.format(INCOMPATIBLE_TYPES, argumentType, parameterType));
}
}
if (operation.isVariadic() && args.size() - 1 >= operation.getVarArgIndex()) {
Parameter parameter = operation.getParameters().get(operation.getVarArgIndex());
List<Expression> varArgs = args.subList(operation.getVarArgIndex(), args.size() - 1);
InferenceResult parameterType = inferTypeDispatch(parameter);
for (Expression expression : varArgs) {
parameterType = typeParameterInferrer.buildInferenceResult(parameterType, typeParameterMapping, acceptor);
InferenceResult argumentType = inferTypeDispatch(expression);
assertAssignable(parameterType, argumentType, String.format(INCOMPATIBLE_TYPES, argumentType, parameterType));
}
}
return typeParameterMapping;
}
use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.
the class TypeCastExpressionImpl method basicSetOperand.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetOperand(Expression newOperand, NotificationChain msgs) {
Expression oldOperand = operand;
operand = newOperand;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ExpressionsPackage.TYPE_CAST_EXPRESSION__OPERAND, oldOperand, newOperand);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.
the class OperationOverloadingResolver method isCallable.
protected boolean isCallable(Operation operation, ArgumentExpression expression) {
EList<Expression> orderedExpressions = ArgumentSorter.getOrderedExpressions(expression.getArguments(), operation);
List<Type> argumentTypes = orderedExpressions.stream().map(it -> inferrer.infer(it).getType()).filter(t -> t != null).collect(Collectors.toList());
List<Type> parameterTypes = operation.getParameters().stream().map(it -> it.getType()).collect(Collectors.toList());
if (argumentTypes.size() != parameterTypes.size())
return false;
for (int i = 0; i < argumentTypes.size(); i++) {
Type type1 = argumentTypes.get(i);
Type type2 = parameterTypes.get(i);
if (!typeSystem.isSuperType(type2, type1))
return false;
}
return true;
}
use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.
the class ParenthesizedExpressionImpl method basicSetExpression.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetExpression(Expression newExpression, NotificationChain msgs) {
Expression oldExpression = expression;
expression = newExpression;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ExpressionsPackage.PARENTHESIZED_EXPRESSION__EXPRESSION, oldExpression, newExpression);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.
the class ArgumentImpl method basicSetValue.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetValue(Expression newValue, NotificationChain msgs) {
Expression oldValue = value;
value = newValue;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ExpressionsPackage.ARGUMENT__VALUE, oldValue, newValue);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
Aggregations