use of org.eclipse.titan.designer.AST.IType.ValueCheckingOptions in project titan.EclipsePlug-ins by eclipse.
the class MatchExpression 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 || templateInstance == null) {
setIsErroneous(true);
return;
}
if (value.getIsErroneous(timestamp) || templateInstance.getTemplateBody().getIsErroneous(timestamp)) {
setIsErroneous(true);
return;
}
final Expected_Value_type internalExpectation = Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue) ? Expected_Value_type.EXPECTED_TEMPLATE : expectedValue;
// Start
IType localGovernor = value.getExpressionGovernor(timestamp, expectedValue);
if (localGovernor == null) {
localGovernor = templateInstance.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
}
ITTCN3Template template = templateInstance.getTemplateBody();
if (localGovernor == null) {
template = template.setLoweridToReference(timestamp);
localGovernor = template.getExpressionGovernor(timestamp, internalExpectation);
}
if (localGovernor == null) {
// Start again:
value.setLoweridToReference(timestamp);
localGovernor = value.getExpressionGovernor(timestamp, expectedValue);
}
if (localGovernor == null) {
if (!template.getIsErroneous(timestamp)) {
getLocation().reportSemanticError("Cannot determine the type of arguments in `match()' operation");
}
setIsErroneous(true);
return;
}
value.setMyGovernor(localGovernor);
final IValue temporalValue = localGovernor.checkThisValueRef(timestamp, value);
localGovernor.checkThisValue(timestamp, temporalValue, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false, false, true, false, false));
// FIXME check value against governor
template.checkThisTemplateGeneric(timestamp, localGovernor, templateInstance.getDerivedReference() != null, false, false, true, false, null);
try {
ExpressionUtilities.checkExpressionOperatorCompatibility(timestamp, this, referenceChain, Expected_Value_type.EXPECTED_TEMPLATE, value, templateInstance);
} catch (StackOverflowError e) {
ErrorReporter.logExceptionStackTrace("Stack overflow was detected while analysing `" + getFullName() + "'", e.getCause());
getLocation().reportSemanticError("Titan was unable to analyse this statement");
setIsErroneous(true);
}
if (getIsErroneous(timestamp)) {
return;
}
value.getValueRefdLast(timestamp, expectedValue, referenceChain);
templateInstance.getTemplateBody().getTemplateReferencedLast(timestamp, referenceChain);
templateInstance.check(timestamp, localGovernor);
}
use of org.eclipse.titan.designer.AST.IType.ValueCheckingOptions in project titan.EclipsePlug-ins by eclipse.
the class StringConcatenationExpression 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;
boolean v1_string = false;
boolean v2_string = false;
if (value1 != null) {
value1.setLoweridToReference(timestamp);
tempType1 = value1.getExpressionReturntype(timestamp, expectedValue);
switch(tempType1) {
case TYPE_BITSTRING:
case TYPE_HEXSTRING:
case TYPE_OCTETSTRING:
case TYPE_CHARSTRING:
case TYPE_UCHARSTRING:
v1_string = true;
value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
break;
case TYPE_SEQUENCE_OF:
case TYPE_SET_OF:
value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
break;
case TYPE_UNDEFINED:
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:
case TYPE_CHARSTRING:
case TYPE_UCHARSTRING:
v2_string = true;
value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
break;
case TYPE_SEQUENCE_OF:
case TYPE_SET_OF:
value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
break;
case TYPE_UNDEFINED:
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;
}
if (v1_string && v2_string) {
if (!((Type_type.TYPE_CHARSTRING.equals(tempType1) && Type_type.TYPE_UCHARSTRING.equals(tempType2)) || (Type_type.TYPE_CHARSTRING.equals(tempType2) && Type_type.TYPE_UCHARSTRING.equals(tempType1))) && tempType1 != tempType2) {
location.reportSemanticError(SAMEOPERANDERROR);
setIsErroneous(true);
}
return;
}
final IType v1_gov = value1.getExpressionGovernor(timestamp, expectedValue);
IType v2_gov = value2.getExpressionGovernor(timestamp, expectedValue);
if (v1_gov == null) {
getLocation().reportSemanticError("Cannot determine the type of the left operand of `&' operation");
setIsErroneous(true);
return;
} else {
final IValue tempValue = v1_gov.checkThisValueRef(timestamp, value1);
v1_gov.checkThisValue(timestamp, tempValue, null, new ValueCheckingOptions(expectedValue, false, false, true, false, false));
}
if (v2_gov == null) {
v2_gov = v1_gov;
value2.setMyGovernor(v1_gov);
}
final IValue tempValue = v2_gov.checkThisValueRef(timestamp, value2);
v2_gov.checkThisValue(timestamp, tempValue, null, new ValueCheckingOptions(expectedValue, false, false, true, false, false));
// 7.1.2 says that we shouldn't allow type compatibility.
if (!v1_gov.isCompatible(timestamp, v2_gov, null, null, null) && !v2_gov.isCompatible(timestamp, v1_gov, null, null, null)) {
getLocation().reportSemanticError("The operands of `&' operation should be of compatible types");
setIsErroneous(true);
}
}
}
use of org.eclipse.titan.designer.AST.IType.ValueCheckingOptions in project titan.EclipsePlug-ins by eclipse.
the class CompField method check.
/**
* Does the semantic checking of this field.
*
* @param timestamp the timestamp of the actual semantic check cycle.
*/
public void check(final CompilationTimeStamp timestamp) {
if (type == null) {
return;
}
type.check(timestamp);
type.checkEmbedded(timestamp, type.getLocation(), true, "embedded into another type");
if (defaultValue == null) {
return;
}
defaultValue.setMyGovernor(type);
final IType lastType = type.getTypeRefdLast(timestamp);
final IValue tempValue = lastType.checkThisValueRef(timestamp, defaultValue);
lastType.checkThisValue(timestamp, tempValue, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_CONSTANT, false, false, true, false, false));
defaultValue.setCodeSection(CodeSectionType.CS_PRE_INIT);
}
use of org.eclipse.titan.designer.AST.IType.ValueCheckingOptions in project titan.EclipsePlug-ins by eclipse.
the class SingleLenghtRestriction method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
if (value == null) {
return;
}
final Integer_Type integer = new Integer_Type();
value.setMyGovernor(integer);
IValue last = integer.checkThisValueRef(timestamp, value);
integer.checkThisValue(timestamp, last, null, new ValueCheckingOptions(expectedValue, false, false, true, false, false));
final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
last = last.getValueRefdLast(timestamp, chain);
chain.release();
if (last.getIsErroneous(timestamp)) {
return;
}
switch(last.getValuetype()) {
case INTEGER_VALUE:
{
final BigInteger temp = ((Integer_Value) last).getValueValue();
if (temp.compareTo(BigInteger.ZERO) == -1) {
value.getLocation().reportSemanticError(MessageFormat.format("The length restriction must be a non-negative integer value instead of {0}", temp));
value.setIsErroneous(true);
}
break;
}
default:
break;
}
}
Aggregations