use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class SubstractExpression method evaluateValue.
@Override
public /**
* {@inheritDoc}
*/
IValue evaluateValue(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return lastValue;
}
isErroneous = false;
lastTimeChecked = timestamp;
lastValue = this;
if (value1 == null || value2 == null) {
return lastValue;
}
checkExpressionOperands(timestamp, expectedValue, referenceChain);
if (getIsErroneous(timestamp) || isUnfoldable(timestamp, referenceChain)) {
return lastValue;
}
final IValue last1 = value1.getValueRefdLast(timestamp, referenceChain);
final IValue last2 = value2.getValueRefdLast(timestamp, referenceChain);
if (last1.getIsErroneous(timestamp) || last2.getIsErroneous(timestamp)) {
setIsErroneous(true);
return lastValue;
}
switch(last1.getValuetype()) {
case INTEGER_VALUE:
// If the operands exist they must be of the same type.
lastValue = ((Integer_Value) last1).subtract((Integer_Value) last2);
lastValue.copyGeneralProperties(this);
break;
case REAL_VALUE:
final double f1 = ((Real_Value) last1).getValue();
final double f2 = ((Real_Value) last2).getValue();
lastValue = new Real_Value(f1 - f2);
lastValue.copyGeneralProperties(this);
break;
default:
setIsErroneous(true);
break;
}
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class TestcasenameExpression method evaluateValue.
@Override
public /**
* {@inheritDoc}
*/
IValue evaluateValue(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return lastValue;
}
isErroneous = false;
lastTimeChecked = timestamp;
lastValue = this;
// unqualified name or "".
if (myScope != null) {
if (myScope instanceof StatementBlock) {
final StatementBlock block = (StatementBlock) myScope;
final Definition definition = block.getMyDefinition();
if (definition == null) {
// An error would be better here.
lastValue = new Charstring_Value("");
lastValue.copyGeneralProperties(this);
} else {
if (Assignment_type.A_TESTCASE.semanticallyEquals(definition.getAssignmentType())) {
lastValue = new Charstring_Value(definition.getIdentifier().getDisplayName());
lastValue.copyGeneralProperties(this);
}
}
}
}
// Run-time evaluation.
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class TimerRunningExpression method checkExpressionOperands.
/**
* Checks the parameters of the expression and if they are valid in
* their position in the expression or not.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param expectedValue
* the kind of value expected.
* @param referenceChain
* a reference chain to detect cyclic references.
*/
private void checkExpressionOperands(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (reference == null) {
return;
}
final Assignment assignment = reference.getRefdAssignment(timestamp, true);
if (assignment == null) {
setIsErroneous(true);
return;
}
switch(assignment.getAssignmentType()) {
case A_TIMER:
{
final ArrayDimensions dimensions = ((Def_Timer) assignment).getDimensions();
if (dimensions != null) {
dimensions.checkIndices(timestamp, reference, "timer", false, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
} else if (reference.getSubreferences().size() > 1) {
reference.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR, assignment.getIdentifier().getDisplayName()));
}
break;
}
case A_PAR_TIMER:
if (reference.getSubreferences().size() > 1) {
reference.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR, assignment.getIdentifier().getDisplayName()));
}
break;
default:
reference.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR2, assignment.getDescription()));
setIsErroneous(true);
break;
}
checkExpressionDynamicPart(expectedValue, OPERATIONNAME, true, true, false);
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class UndefRunningExpression method checkExpressionOperands.
/**
* Checks the parameters of the expression and if they are valid in
* their position in the expression or not.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param expectedValue
* the kind of value expected.
* @param referenceChain
* a reference chain to detect cyclic references.
*/
private void checkExpressionOperands(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
setIsErroneous(false);
if (reference == null) {
return;
}
final Assignment assignment = reference.getRefdAssignment(timestamp, true);
if (assignment == null) {
setIsErroneous(true);
return;
}
switch(assignment.getAssignmentType()) {
case A_TIMER:
case A_PAR_TIMER:
{
realExpression = new TimerRunningExpression(reference);
realExpression.setMyScope(getMyScope());
realExpression.setFullNameParent(this);
realExpression.setLocation(getLocation());
realExpression.evaluateValue(timestamp, expectedValue, referenceChain);
break;
}
case A_CONST:
case A_EXT_CONST:
case A_MODULEPAR:
case A_VAR:
case A_FUNCTION_RVAL:
case A_EXT_FUNCTION_RVAL:
case A_PAR_VAL:
case A_PAR_VAL_IN:
case A_PAR_VAL_OUT:
case A_PAR_VAL_INOUT:
{
final Referenced_Value value = new Referenced_Value(reference);
value.setMyScope(getMyScope());
value.setFullNameParent(this);
value.getValueRefdLast(timestamp, referenceChain);
realExpression = new ComponentRunnningExpression(value);
realExpression.setMyScope(getMyScope());
realExpression.setFullNameParent(this);
realExpression.setLocation(getLocation());
realExpression.evaluateValue(timestamp, expectedValue, referenceChain);
break;
}
default:
reference.getLocation().reportSemanticError(MessageFormat.format("First operand of operation `<timer or component> running'' should be timer or component reference instead of {0}", assignment.getDescription()));
setIsErroneous(true);
break;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class Unichar2CharExpression method checkExpressionOperands.
/**
* Checks the parameters of the expression and if they are valid in
* their position in the expression or not.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param expectedValue
* the kind of value expected.
* @param referenceChain
* a reference chain to detect cyclic references.
*/
private void checkExpressionOperands(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (value == null) {
return;
}
value.setLoweridToReference(timestamp);
final Type_type tempType = value.getExpressionReturntype(timestamp, expectedValue);
switch(tempType) {
case TYPE_UCHARSTRING:
final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last.isUnfoldable(timestamp)) {
UniversalCharstring string;
if (last instanceof Charstring_Value) {
// check not necessary, trivial case
return;
} else if (last instanceof UniversalCharstring_Value) {
string = ((UniversalCharstring_Value) last).getValue();
if (string == null) {
setIsErroneous(true);
return;
}
} else {
value.getLocation().reportSemanticError(OPERANDERROR1);
setIsErroneous(true);
return;
}
for (int i = 0; i < string.length(); i++) {
final UniversalChar uchar = string.get(i);
if (uchar.group() != 0 || uchar.plane() != 0 || uchar.row() != 0 || uchar.cell() > 127) {
value.getLocation().reportSemanticError(OPERANDERROR2);
setIsErroneous(true);
return;
}
}
}
return;
case TYPE_CHARSTRING:
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
if (!isErroneous) {
location.reportSemanticError(OPERANDERROR1);
setIsErroneous(true);
}
return;
}
}
Aggregations