use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class ShiftLeftExpression 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;
long stringSize = 0;
long shiftSize = 0;
IValue tempValue;
if (value1 != null) {
value1.setLoweridToReference(timestamp);
tempType1 = value1.getExpressionReturntype(timestamp, expectedValue);
switch(tempType1) {
case TYPE_BITSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.BITSTRING_VALUE.equals(tempValue.getValuetype())) {
stringSize = ((Bitstring_Value) tempValue).getValueLength();
}
break;
case TYPE_HEXSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.HEXSTRING_VALUE.equals(tempValue.getValuetype())) {
stringSize = ((Hexstring_Value) tempValue).getValueLength();
}
break;
case TYPE_OCTETSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.OCTETSTRING_VALUE.equals(tempValue.getValuetype())) {
stringSize = ((Octetstring_Value) tempValue).getValueLength();
}
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_INTEGER:
tempValue = value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.INTEGER_VALUE.equals(tempValue.getValuetype()) && !getIsErroneous(timestamp)) {
if (!((Integer_Value) tempValue).isNative()) {
value2.getLocation().reportSemanticError(MessageFormat.format(LARGEINTEGERSECONDOPERANDERROR, ((Integer_Value) tempValue).getValueValue()));
setIsErroneous(true);
break;
}
shiftSize = ((Integer_Value) tempValue).getValue();
if (value1 != null && !value1.isUnfoldable(timestamp)) {
final String severity = Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTINCORRECTSHIFTROTATESIZE, GeneralConstants.WARNING, null);
if (shiftSize < 0) {
location.reportConfigurableSemanticProblem(severity, NEGATIVESHIFTPROBLEM);
} else if (shiftSize == 0) {
location.reportConfigurableSemanticProblem(severity, ZEROSHIFTPROBLEM);
} else if (shiftSize > stringSize) {
location.reportConfigurableSemanticProblem(severity, MessageFormat.format(TOOBIGSHIFTPROBLEM, stringSize, shiftSize));
}
}
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
location.reportSemanticError(SECONDOPERANDERROR);
setIsErroneous(true);
break;
}
}
}
use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class ShiftRightExpression 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;
long stringSize = 0;
long shiftSize = 0;
IValue tempValue;
if (value1 != null) {
value1.setLoweridToReference(timestamp);
tempType1 = value1.getExpressionReturntype(timestamp, expectedValue);
switch(tempType1) {
case TYPE_BITSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.BITSTRING_VALUE.equals(tempValue.getValuetype())) {
stringSize = ((Bitstring_Value) tempValue).getValueLength();
}
break;
case TYPE_HEXSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.HEXSTRING_VALUE.equals(tempValue.getValuetype())) {
stringSize = ((Hexstring_Value) tempValue).getValueLength();
}
break;
case TYPE_OCTETSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.OCTETSTRING_VALUE.equals(tempValue.getValuetype())) {
stringSize = ((Octetstring_Value) tempValue).getValueLength();
}
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_INTEGER:
tempValue = value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.INTEGER_VALUE.equals(tempValue.getValuetype()) && !getIsErroneous(timestamp)) {
if (!((Integer_Value) tempValue).isNative()) {
value2.getLocation().reportSemanticError(MessageFormat.format(LARGEINTEGERSECONDOPERANDERROR, ((Integer_Value) tempValue).getValueValue()));
setIsErroneous(true);
break;
}
shiftSize = ((Integer_Value) tempValue).getValue();
if (value1 != null && !value1.isUnfoldable(timestamp)) {
final String severity = Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTINCORRECTSHIFTROTATESIZE, GeneralConstants.WARNING, null);
if (shiftSize < 0) {
location.reportConfigurableSemanticProblem(severity, NEGATIVESHIFTPROBLEM);
} else if (shiftSize == 0) {
location.reportConfigurableSemanticProblem(severity, ZEROSHIFTPROBLEM);
} else if (shiftSize > stringSize) {
location.reportConfigurableSemanticProblem(severity, MessageFormat.format(TOOBIGSHIFTPROBLEM, stringSize, shiftSize));
}
}
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
location.reportSemanticError(SECONDOPERANDERROR);
setIsErroneous(true);
break;
}
}
}
use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class ShiftRightExpression 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 == null || 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 Str2BitExpression 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:
final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last.isUnfoldable(timestamp)) {
final String string = ((Charstring_Value) last).getValue();
final byte[] bytes = string.getBytes();
for (int i = 0; i < bytes.length; i++) {
if (bytes[i] != '0' && bytes[i] != '1') {
value.getLocation().reportSemanticError(OPERANDERROR2);
setIsErroneous(true);
return;
}
}
}
return;
case TYPE_UNDEFINED:
setIsErroneous(true);
return;
default:
if (!isErroneous) {
location.reportSemanticError(OPERANDERROR1);
setIsErroneous(true);
}
return;
}
}
use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class Str2HexExpression 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:
final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last.isUnfoldable(timestamp)) {
final String string = ((Charstring_Value) last).getValue();
final byte[] bytes = string.getBytes();
for (int i = 0; i < bytes.length; i++) {
final byte c = bytes[i];
final boolean isLetter = (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f');
final boolean isDigit = c >= '0' && c <= '9';
if (!(isLetter || isDigit)) {
value.getLocation().reportSemanticError(OPERANDERROR2);
setIsErroneous(true);
return;
}
}
}
return;
case TYPE_UNDEFINED:
setIsErroneous(true);
return;
default:
if (!isErroneous) {
location.reportSemanticError(OPERANDERROR1);
setIsErroneous(true);
}
return;
}
}
Aggregations