use of org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance 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.TemplateInstance 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.TemplateInstance 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.TemplateInstance in project titan.EclipsePlug-ins by eclipse.
the class SizeOfExpression 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;
}
final long i = checkExpressionOperands(timestamp, expectedValue, referenceChain);
if (i != -1) {
lastValue = new Integer_Value(i);
lastValue.copyGeneralProperties(this);
}
if (getIsErroneous(timestamp) || isUnfoldable(timestamp, referenceChain)) {
return lastValue;
}
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance 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