use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class Char2OctExpression 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_CHARSTRING:
value.getValueRefdLast(timestamp, expectedValue, referenceChain);
return;
case TYPE_UNDEFINED:
setIsErroneous(true);
return;
default:
if (!isErroneous) {
location.reportSemanticError(OPERANDERROR);
setIsErroneous(true);
}
return;
}
}
use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class ArrayDimension method checkIndex.
/**
* Check the array index against this dimension of the actual array type.
*
* @param timestamp the timestamp of the actual semantic check cycle.
* @param index the index of the array index sub reference.
* @param expectedValue the kind of value expected here
*/
public final void checkIndex(final CompilationTimeStamp timestamp, final IValue index, final Expected_Value_type expectedValue) {
check(timestamp);
if (index == null) {
return;
}
index.setLoweridToReference(timestamp);
final Type_type temporalType = index.getExpressionReturntype(timestamp, expectedValue);
switch(temporalType) {
case TYPE_INTEGER:
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
index.getLocation().reportSemanticError(INTEGEREXPECTED);
setIsErroneous(true);
break;
}
if (getIsErroneous(timestamp) || index.isUnfoldable(timestamp)) {
return;
}
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = index.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
final long indexValue = ((Integer_Value) last).getValue();
if (indexValue < getOffset()) {
index.getLocation().reportSemanticError(MessageFormat.format(INDEXUNDERFLOW, getOffset(), indexValue));
index.setIsErroneous(true);
} else if (indexValue >= getOffset() + getSize()) {
index.getLocation().reportSemanticError(MessageFormat.format(INDEXOVERFLOW, getOffset() + getSize() - 1, indexValue));
index.setIsErroneous(true);
}
}
use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class AddExpression method getExpressionReturntype.
@Override
public /**
* {@inheritDoc}
*/
Type_type getExpressionReturntype(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue) {
if (value1 == null) {
return Type_type.TYPE_UNDEFINED;
}
value1.setLoweridToReference(timestamp);
final Type_type tempType = value1.getExpressionReturntype(timestamp, expectedValue);
switch(tempType) {
case TYPE_INTEGER:
case TYPE_REAL:
return tempType;
case TYPE_UNDEFINED:
return tempType;
default:
getValueRefdLast(timestamp, expectedValue, null);
setIsErroneous(true);
return Type_type.TYPE_UNDEFINED;
}
}
use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class AddExpression 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) {
Type_type tempType1 = null;
Type_type tempType2 = null;
if (value1 != null) {
value1.setLoweridToReference(timestamp);
tempType1 = value1.getExpressionReturntype(timestamp, expectedValue);
switch(tempType1) {
case TYPE_INTEGER:
value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
break;
case TYPE_REAL:
value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
value1.getLocation().reportSemanticError(FIRSTOPERANDERROR);
setIsErroneous(true);
break;
}
}
if (value2 != null) {
value2.setLoweridToReference(timestamp);
tempType2 = value2.getExpressionReturntype(timestamp, expectedValue);
switch(tempType2) {
case TYPE_INTEGER:
value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
break;
case TYPE_REAL:
value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
value2.getLocation().reportSemanticError(SECONDOPERANDERROR);
setIsErroneous(true);
break;
}
}
if (value1 != null && value2 != null && !getIsErroneous(timestamp)) {
if (value1.getIsErroneous(timestamp) || value2.getIsErroneous(timestamp)) {
setIsErroneous(true);
return;
}
if (tempType1 != tempType2) {
location.reportSemanticError(SAMEOPERANDERROR);
setIsErroneous(true);
}
}
}
use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class AllPortCheckSateExpression method checkExpressionOperand1.
/**
* Checks the operand
* in charstring (mandatory)
* @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 checkExpressionOperand1(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (value == null) {
setIsErroneous(true);
return;
}
value.setLoweridToReference(timestamp);
final Type_type tempType = value.getExpressionReturntype(timestamp, expectedValue);
switch(tempType) {
case TYPE_CHARSTRING:
final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last.isUnfoldable(timestamp)) {
final String originalString = ((Charstring_Value) last).getValue();
final CharstringExtractor cs = new CharstringExtractor(originalString);
if (cs.isErrorneous()) {
value.getLocation().reportSemanticError(cs.getErrorMessage());
setIsErroneous(true);
}
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
if (!isErroneous) {
location.reportSemanticError(OPERAND1_ERROR1);
setIsErroneous(true);
}
break;
}
}
Aggregations