use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class Unichar2OctExpression 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:
// TODO: implement missing part if range check is needed
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
if (!value.getIsErroneous(timestamp)) {
location.reportSemanticError(OPERANDERROR1);
setIsErroneous(true);
}
break;
}
if (code_string == null) {
return;
}
code_string.setLoweridToReference(timestamp);
final Type_type tempType2 = code_string.getExpressionReturntype(timestamp, expectedValue);
switch(tempType2) {
case TYPE_CHARSTRING:
// TODO: implement missing part if range check is needed
return;
case TYPE_UNDEFINED:
setIsErroneous(true);
return;
default:
if (!code_string.getIsErroneous(timestamp)) {
location.reportSemanticError(OPERANDERROR2);
setIsErroneous(true);
}
return;
}
}
use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class Xor4bExpression 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_BITSTRING:
case TYPE_HEXSTRING:
case TYPE_OCTETSTRING:
value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
location.reportSemanticError(FIRSTOPERANDERROR);
setIsErroneous(true);
break;
}
}
if (value2 != null) {
value2.setLoweridToReference(timestamp);
tempType2 = value2.getExpressionReturntype(timestamp, expectedValue);
switch(tempType2) {
case TYPE_BITSTRING:
case TYPE_HEXSTRING:
case TYPE_OCTETSTRING:
value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
location.reportSemanticError(SECONDOPERANDERROR);
setIsErroneous(true);
break;
}
}
if (value1 != null && value2 != null && !getIsErroneous(timestamp)) {
if (value1.getIsErroneous(timestamp) || value2.getIsErroneous(timestamp)) {
setIsErroneous(true);
return;
}
// the operands must be of the same kind
if (tempType1 != tempType2) {
location.reportSemanticError(SAMEOPERANDERROR);
setIsErroneous(true);
return;
}
if (value1.isUnfoldable(timestamp) || value2.isUnfoldable(timestamp)) {
return;
}
// the operands must have the same length
final IValue last1 = value1.getValueRefdLast(timestamp, referenceChain);
final IValue last2 = value2.getValueRefdLast(timestamp, referenceChain);
switch(last1.getValuetype()) {
case BITSTRING_VALUE:
if (((Bitstring_Value) last1).getValueLength() != ((Bitstring_Value) last2).getValueLength()) {
location.reportSemanticError(SAMEOPERANDLENGTHERROR);
setIsErroneous(true);
}
break;
case HEXSTRING_VALUE:
if (((Hexstring_Value) last1).getValueLength() != ((Hexstring_Value) last2).getValueLength()) {
location.reportSemanticError(SAMEOPERANDLENGTHERROR);
setIsErroneous(true);
}
break;
case OCTETSTRING_VALUE:
if (((Octetstring_Value) last1).getValueLength() != ((Octetstring_Value) last2).getValueLength()) {
location.reportSemanticError(SAMEOPERANDLENGTHERROR);
setIsErroneous(true);
}
break;
default:
setIsErroneous(true);
}
}
}
use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class Xor4bExpression method getExpressionReturntype.
@Override
public /**
* {@inheritDoc}
*/
Type_type getExpressionReturntype(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue) {
final IValue last = getValueRefdLast(timestamp, expectedValue, null);
if (last.getIsErroneous(timestamp) || value1 == null) {
return Type_type.TYPE_UNDEFINED;
}
if (last.getIsErroneous(timestamp)) {
setIsErroneous(true);
return Type_type.TYPE_UNDEFINED;
}
value1.setLoweridToReference(timestamp);
final Type_type tempType = value1.getExpressionReturntype(timestamp, expectedValue);
switch(tempType) {
case TYPE_BITSTRING:
case TYPE_HEXSTRING:
case TYPE_OCTETSTRING:
return tempType;
case TYPE_UNDEFINED:
return tempType;
default:
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 RNDWithValueExpression 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_REAL:
{
final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last.isUnfoldable(timestamp)) {
final Real_Value real = (Real_Value) last;
if (real.isSpecialFloat()) {
value.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR2, real.createStringRepresentation()));
setIsErroneous(true);
}
}
break;
}
case TYPE_UNDEFINED:
setIsErroneous(true);
return;
default:
if (!isErroneous) {
location.reportSemanticError(OPERANDERROR);
setIsErroneous(true);
}
return;
}
checkExpressionDynamicPart(expectedValue, OPERATIONNAME, true, true, false);
}
use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class RemainderExpression 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_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:
final IValue lastValue = value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (lastValue != null && !lastValue.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(lastValue.getValuetype())) {
if (((Integer_Value) lastValue).equals(new Integer_Value(0))) {
value2.getLocation().reportSemanticError(ZEROOPERANDERROR);
setIsErroneous(true);
}
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
value2.getLocation().reportSemanticError(SECONDOPERANDERROR);
setIsErroneous(true);
break;
}
}
}
Aggregations