use of edu.uah.rsesc.aadlsimulator.xtext.inputConstraint.NegativeExpression in project AGREE by loonwerks.
the class InputConstraintSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == InputConstraintPackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case InputConstraintPackage.BINARY_EXPRESSION:
sequence_AddSub_MultDiv(context, (BinaryExpression) semanticObject);
return;
case InputConstraintPackage.BOOLEAN_LITERAL:
sequence_BooleanLiteral(context, (BooleanLiteral) semanticObject);
return;
case InputConstraintPackage.CONST_REF_EXPRESSION:
sequence_ConstRef(context, (ConstRefExpression) semanticObject);
return;
case InputConstraintPackage.ELEMENT_REF_EXPRESSION:
sequence_ElementRef(context, (ElementRefExpression) semanticObject);
return;
case InputConstraintPackage.INTEGER_LITERAL:
sequence_IntegerLiteral(context, (IntegerLiteral) semanticObject);
return;
case InputConstraintPackage.INTERVAL_EXPRESSION:
sequence_Interval(context, (IntervalExpression) semanticObject);
return;
case InputConstraintPackage.NEGATIVE_EXPRESSION:
sequence_Negative(context, (NegativeExpression) semanticObject);
return;
case InputConstraintPackage.PRE_EXPRESSION:
sequence_Pre(context, (PreExpression) semanticObject);
return;
case InputConstraintPackage.RANDOM_ELEMENT_EXPRESSION:
sequence_RandomElement(context, (RandomElementExpression) semanticObject);
return;
case InputConstraintPackage.RANDOM_INTEGER_EXPRESSION:
sequence_RandomInteger(context, (RandomIntegerExpression) semanticObject);
return;
case InputConstraintPackage.RANDOM_REAL_EXPRESSION:
sequence_RandomReal(context, (RandomRealExpression) semanticObject);
return;
case InputConstraintPackage.REAL_LITERAL:
sequence_RealLiteral(context, (RealLiteral) semanticObject);
return;
case InputConstraintPackage.SET_EXPRESSION:
sequence_Set(context, (SetExpression) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of edu.uah.rsesc.aadlsimulator.xtext.inputConstraint.NegativeExpression in project AGREE by loonwerks.
the class ExpressionFactory method createReal.
public static ScalarExpression createReal(final BigInteger value) {
final boolean isNegative = value.signum() < 0;
BigDecimal decValue = new BigDecimal(value);
// Negative values arnen't allowed
if (isNegative) {
decValue = decValue.negate();
}
// Adjust scale. Decimal values with a scale less than 1 do not serialize properly.
if (decValue.scale() < 1) {
decValue = decValue.setScale(1);
}
final RealLiteral realLiteral = InputConstraintFactory.eINSTANCE.createRealLiteral();
realLiteral.setValue(decValue);
final ScalarExpression scalarExpression;
if (isNegative) {
final NegativeExpression negExpr = InputConstraintFactory.eINSTANCE.createNegativeExpression();
negExpr.setValue(realLiteral);
scalarExpression = negExpr;
} else {
scalarExpression = realLiteral;
}
return scalarExpression;
}
Aggregations