use of org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template in project titan.EclipsePlug-ins by eclipse.
the class LengthofExpression 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) {
final Expected_Value_type internalExpectation = Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue) ? Expected_Value_type.EXPECTED_TEMPLATE : expectedValue;
IType governor = templateInstance.getExpressionGovernor(timestamp, internalExpectation);
ITTCN3Template template = templateInstance.getTemplateBody();
if (governor == null) {
template = template.setLoweridToReference(timestamp);
governor = template.getExpressionGovernor(timestamp, internalExpectation);
}
if (governor == null) {
if (!template.getIsErroneous(timestamp)) {
templateInstance.getLocation().reportSemanticError(OPERANDERROR);
}
setIsErroneous(true);
return;
}
final Type_type typetype = templateInstance.getExpressionReturntype(timestamp, internalExpectation);
switch(typetype) {
case TYPE_CHARSTRING:
case TYPE_UCHARSTRING:
case TYPE_BITSTRING:
case TYPE_HEXSTRING:
case TYPE_OCTETSTRING:
case TYPE_SEQUENCE_OF:
case TYPE_SET_OF:
case TYPE_ARRAY:
break;
case TYPE_UNDEFINED:
break;
default:
templateInstance.getLocation().reportSemanticError(UNEXPECTEDOPERAND);
setIsErroneous(true);
return;
}
IsValueExpression.checkExpressionTemplateInstance(timestamp, this, templateInstance, governor, referenceChain, expectedValue);
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template in project titan.EclipsePlug-ins by eclipse.
the class LengthofExpression method evaluateValue.
@Override
public /**
* {@inheritDoc}
*/
IValue evaluateValue(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return lastValue;
}
isErroneous = false;
lastTimeChecked = timestamp;
lastValue = this;
if (templateInstance == null) {
return lastValue;
}
checkExpressionOperands(timestamp, expectedValue, referenceChain);
if (getIsErroneous(timestamp)) {
return lastValue;
}
if (isUnfoldable(timestamp, referenceChain)) {
return lastValue;
}
final ITTCN3Template template = templateInstance.getTemplateBody();
final IValue value = ((SpecificValue_Template) template).getSpecificValue().getValueRefdLast(timestamp, referenceChain);
int length;
switch(value.getValuetype()) {
case CHARSTRING_VALUE:
length = ((Charstring_Value) value).getValueLength();
break;
case UNIVERSALCHARSTRING_VALUE:
length = ((UniversalCharstring_Value) value).getValueLength();
break;
case BITSTRING_VALUE:
length = ((Bitstring_Value) value).getValueLength();
break;
case HEXSTRING_VALUE:
length = ((Hexstring_Value) value).getValueLength();
break;
case OCTETSTRING_VALUE:
length = ((Octetstring_Value) value).getValueLength();
break;
case SEQUENCEOF_VALUE:
length = ((SequenceOf_Value) value).getNofComponents();
break;
case SETOF_VALUE:
length = ((SetOf_Value) value).getNofComponents();
break;
case ARRAY_VALUE:
length = ((Array_Value) value).getNofComponents();
break;
default:
setIsErroneous(true);
return lastValue;
}
lastValue = new Integer_Value(length);
lastValue.copyGeneralProperties(this);
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template 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.TTCN3.templates.ITTCN3Template in project titan.EclipsePlug-ins by eclipse.
the class SubstrExpression 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) {
final Expected_Value_type internalExpectation = Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue) ? Expected_Value_type.EXPECTED_TEMPLATE : expectedValue;
Type_type tempType1 = null;
Type_type tempType2 = null;
Type_type tempType3 = null;
IValue value1 = null;
if (templateInstance1 != null) {
final ITTCN3Template temp = templateInstance1.getTemplateBody();
if (!Template_type.SPECIFIC_VALUE.equals(temp.getTemplatetype())) {
templateInstance1.getLocation().reportSemanticError(OPERANDERROR1);
setIsErroneous(true);
}
value1 = ((SpecificValue_Template) temp).getSpecificValue();
value1.setLoweridToReference(timestamp);
tempType1 = value1.getExpressionReturntype(timestamp, internalExpectation);
switch(tempType1) {
case TYPE_BITSTRING:
case TYPE_HEXSTRING:
case TYPE_OCTETSTRING:
case TYPE_CHARSTRING:
case TYPE_UCHARSTRING:
case TYPE_SET_OF:
case TYPE_SEQUENCE_OF:
value1.getValueRefdLast(timestamp, internalExpectation, referenceChain);
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
templateInstance1.getLocation().reportSemanticError(OPERANDERROR1);
setIsErroneous(true);
break;
}
}
if (value2 != null) {
value2.setLoweridToReference(timestamp);
tempType2 = value2.getExpressionReturntype(timestamp, expectedValue);
switch(tempType2) {
case TYPE_INTEGER:
final IValue last2 = value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last2.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(last2.getValuetype())) {
if (((Integer_Value) last2).isNative()) {
final long i = ((Integer_Value) last2).getValue();
if (i < 0) {
value2.getLocation().reportSemanticError(OPERANDERROR3);
setIsErroneous(true);
}
} else {
value2.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR9, ((Integer_Value) last2).getValueValue()));
setIsErroneous(true);
}
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
location.reportSemanticError(OPERANDERROR2);
setIsErroneous(true);
break;
}
}
if (value3 != null) {
value3.setLoweridToReference(timestamp);
tempType3 = value3.getExpressionReturntype(timestamp, expectedValue);
switch(tempType3) {
case TYPE_INTEGER:
final IValue last3 = value3.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last3.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(last3.getValuetype())) {
if (((Integer_Value) last3).isNative()) {
final long i = ((Integer_Value) last3).getValue();
if (i < 0) {
value3.getLocation().reportSemanticError(OPERANDERROR5);
setIsErroneous(true);
}
} else {
value3.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR10, ((Integer_Value) last3).getValueValue()));
setIsErroneous(true);
}
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
location.reportSemanticError(OPERANDERROR4);
setIsErroneous(true);
break;
}
}
checkExpressionOperandsHelper(timestamp, value1, expectedValue, referenceChain);
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template in project titan.EclipsePlug-ins by eclipse.
the class Ttcn2StringExpression 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) {
final Expected_Value_type internalExpectation = Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue) ? Expected_Value_type.EXPECTED_TEMPLATE : expectedValue;
IType governor = templateInstance.getExpressionGovernor(timestamp, internalExpectation);
ITTCN3Template template = templateInstance.getTemplateBody();
if (governor == null) {
template = template.setLoweridToReference(timestamp);
governor = template.getExpressionGovernor(timestamp, internalExpectation);
}
if (governor == null) {
if (!template.getIsErroneous(timestamp)) {
templateInstance.getLocation().reportSemanticError(OPERANDERROR);
}
setIsErroneous(true);
} else {
templateInstance.getExpressionReturntype(timestamp, internalExpectation);
IsValueExpression.checkExpressionTemplateInstance(timestamp, this, templateInstance, governor, referenceChain, expectedValue);
}
}
Aggregations