use of org.eclipse.n4js.n4JS.AdditiveOperator in project n4js by eclipse.
the class AdditiveExpressionImpl method setOp.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setOp(AdditiveOperator newOp) {
AdditiveOperator oldOp = op;
op = newOp == null ? OP_EDEFAULT : newOp;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, N4JSPackage.ADDITIVE_EXPRESSION__OP, oldOp, op));
}
use of org.eclipse.n4js.n4JS.AdditiveOperator in project n4js by eclipse.
the class InternalTypeSystem method applyRuleTypeAdditiveExpression.
protected Result<TypeRef> applyRuleTypeAdditiveExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final AdditiveExpression expr) throws RuleFailedException {
// output parameter
TypeRef T = null;
AdditiveOperator _op = expr.getOp();
boolean _equals = Objects.equal(_op, AdditiveOperator.ADD);
if (_equals) {
/* G |- expr.lhs: var TypeRef l */
Expression _lhs = expr.getLhs();
TypeRef l = null;
Result<TypeRef> result = typeInternal(G, _trace_, _lhs);
checkAssignableTo(result.getFirst(), TypeRef.class);
l = (TypeRef) result.getFirst();
/* G |- expr.rhs: var TypeRef r */
Expression _rhs = expr.getRhs();
TypeRef r = null;
Result<TypeRef> result_1 = typeInternal(G, _trace_, _rhs);
checkAssignableTo(result_1.getFirst(), TypeRef.class);
r = (TypeRef) result_1.getFirst();
final boolean lunknown = (l instanceof UnknownTypeRef);
final boolean runknown = (r instanceof UnknownTypeRef);
if ((lunknown && runknown)) {
T = this.typeSystemHelper.createUnionType(G, RuleEnvironmentExtensions.numberTypeRef(G), RuleEnvironmentExtensions.stringTypeRef(G));
} else {
final boolean lnum = RuleEnvironmentExtensions.isNumericOperand(G, l);
final boolean rnum = RuleEnvironmentExtensions.isNumericOperand(G, r);
if ((lnum && rnum)) {
T = RuleEnvironmentExtensions.numberTypeRef(G);
} else {
if (((lunknown || runknown) && (lnum || rnum))) {
T = this.typeSystemHelper.createUnionType(G, RuleEnvironmentExtensions.numberTypeRef(G), RuleEnvironmentExtensions.stringTypeRef(G));
} else {
final boolean lMayNum = (((lnum || RuleEnvironmentExtensions.containsNumericOperand(G, l)) || RuleEnvironmentExtensions.isAny(G, l)) || RuleEnvironmentExtensions.isSymbol(G, l));
final boolean rMayNum = (((rnum || RuleEnvironmentExtensions.containsNumericOperand(G, r)) || RuleEnvironmentExtensions.isAny(G, r)) || RuleEnvironmentExtensions.isSymbol(G, r));
if ((lMayNum && rMayNum)) {
T = this.typeSystemHelper.createUnionType(G, RuleEnvironmentExtensions.numberTypeRef(G), RuleEnvironmentExtensions.stringTypeRef(G));
} else {
T = RuleEnvironmentExtensions.stringTypeRef(G);
}
}
}
}
} else {
T = RuleEnvironmentExtensions.numberTypeRef(G);
}
return new Result<TypeRef>(T);
}
Aggregations