use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class And4bExpression 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 And4bExpression 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, expectedValue, referenceChain);
final IValue last2 = value2.getValueRefdLast(timestamp, expectedValue, 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 AndExpression 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_BOOL:
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_BOOL:
value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
value2.getLocation().reportSemanticError(SECONDOPERANDERROR);
setIsErroneous(true);
break;
}
}
}
use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class Setverdict_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
if (myStatementBlock.getMyDefinition() == null) {
location.reportSemanticError(INCONTROLPART);
}
if (verdictValue != null) {
verdictValue.setLoweridToReference(timestamp);
// to force its checking
final IValue last = verdictValue.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
final Type_type temp = verdictValue.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
switch(temp) {
case TYPE_VERDICT:
if (Value_type.VERDICT_VALUE.equals(last.getValuetype()) && Verdict_type.ERROR.equals(((Verdict_Value) last).getValue())) {
verdictValue.getLocation().reportSemanticError(ERRORCANNOTBESET);
}
if (Value_type.VERDICT_VALUE.equals(last.getValuetype()) && !Verdict_type.PASS.equals(((Verdict_Value) last).getValue()) && verdictReason == null) {
getLocation().reportConfigurableSemanticProblem(reportSetverdictWithoutReason, MessageFormat.format(WITHOUT_REASON, ((Verdict_Value) last).getValue()));
}
break;
default:
verdictValue.getLocation().reportSemanticError(OPERANDERROR);
verdictValue.setIsErroneous(true);
break;
}
}
if (verdictReason != null) {
verdictReason.check(timestamp);
}
lastTimeChecked = timestamp;
}
use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class Deactivate_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
if (deactivate == null) {
return;
}
deactivate.setLoweridToReference(timestamp);
final Type_type temporalType = deactivate.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
switch(temporalType) {
case TYPE_DEFAULT:
deactivate.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
return;
default:
location.reportSemanticError(DEFAULTEXPECTED);
return;
}
}
Aggregations