use of org.eclipse.titan.designer.AST.IType in project titan.EclipsePlug-ins by eclipse.
the class RegexpExpression 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;
setIsErroneous(false);
if (templateInstance1 != null) {
IType governor1 = templateInstance1.getExpressionGovernor(timestamp, internalExpectation);
ITTCN3Template template = templateInstance1.getTemplateBody();
if (governor1 == null) {
template = template.setLoweridToReference(timestamp);
governor1 = template.getExpressionGovernor(timestamp, internalExpectation);
}
if (governor1 == null) {
if (!template.getIsErroneous(timestamp)) {
templateInstance1.getLocation().reportSemanticError(CANNOT_DETERMINE_ARG_TYPE);
}
setIsErroneous(true);
return;
}
IsValueExpression.checkExpressionTemplateInstance(timestamp, this, templateInstance1, governor1, referenceChain, expectedValue);
if (getIsErroneous(timestamp)) {
return;
}
final ITTCN3Template temp = template.setLoweridToReference(timestamp);
temp.checkSpecificValue(timestamp, false);
switch(governor1.getTypeRefdLast(timestamp).getTypetypeTtcn3()) {
case TYPE_CHARSTRING:
case TYPE_UCHARSTRING:
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
location.reportSemanticError(OPERANDERROR1);
setIsErroneous(true);
break;
}
}
if (templateInstance2 != null) {
IType governor2 = templateInstance2.getExpressionGovernor(timestamp, internalExpectation);
ITTCN3Template temp = templateInstance2.getTemplateBody();
if (governor2 == null) {
temp = temp.setLoweridToReference(timestamp);
governor2 = temp.getExpressionGovernor(timestamp, internalExpectation);
}
if (governor2 == null) {
if (!temp.getIsErroneous(timestamp)) {
templateInstance2.getLocation().reportSemanticError(CANNOT_DETERMINE_ARG_TYPE);
}
setIsErroneous(true);
return;
}
IsValueExpression.checkExpressionTemplateInstance(timestamp, this, templateInstance2, governor2, referenceChain, expectedValue);
if (getIsErroneous(timestamp)) {
return;
}
switch(governor2.getTypeRefdLast(timestamp).getTypetype()) {
case TYPE_CHARSTRING:
case TYPE_UCHARSTRING:
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
location.reportSemanticError(OPERANDERROR2);
setIsErroneous(true);
break;
}
}
if (value3 != null) {
final IValue temp = value3.setLoweridToReference(timestamp);
final Type_type tempType3 = temp.getExpressionReturntype(timestamp, expectedValue);
switch(tempType3) {
case TYPE_INTEGER:
final IValue last3 = temp.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(OPERANDERROR4);
setIsErroneous(true);
}
} else {
value3.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR5, ((Integer_Value) last3).getValueValue()));
setIsErroneous(true);
}
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
location.reportSemanticError(OPERANDERROR3);
setIsErroneous(true);
break;
}
}
// TODO add regexp specific checks once patterns become
// supported
}
use of org.eclipse.titan.designer.AST.IType in project titan.EclipsePlug-ins by eclipse.
the class RegexpExpression method getExpressionGovernor.
@Override
public /**
* {@inheritDoc}
*/
IType getExpressionGovernor(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue) {
final IType governor = super.getMyGovernor();
if (governor != null) {
return governor;
}
if (templateInstance1 == null) {
return null;
}
IType tempType;
if (Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue)) {
tempType = templateInstance1.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
} else {
tempType = templateInstance1.getExpressionGovernor(timestamp, expectedValue);
}
if (tempType != null) {
tempType = tempType.getTypeRefdLast(timestamp);
}
return tempType;
}
use of org.eclipse.titan.designer.AST.IType in project titan.EclipsePlug-ins by eclipse.
the class ReplaceExpression method getExpressionGovernor.
@Override
public /**
* {@inheritDoc}
*/
IType getExpressionGovernor(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue) {
final IType governor = super.getMyGovernor();
if (governor != null) {
return governor;
}
if (templateInstance1 == null) {
return null;
}
IType tempType;
if (Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue)) {
tempType = templateInstance1.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
} else {
tempType = templateInstance1.getExpressionGovernor(timestamp, expectedValue);
}
if (tempType != null) {
tempType = tempType.getTypeRefdLast(timestamp);
}
return tempType;
}
use of org.eclipse.titan.designer.AST.IType in project titan.EclipsePlug-ins by eclipse.
the class IsValueExpression 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 referenceChain
* the referencechain to detect circular references.
* @param expectedValue
* the expected value of the template instance.
*/
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);
checkExpressionTemplateInstance(timestamp, this, templateInstance, governor, referenceChain, expectedValue);
}
}
use of org.eclipse.titan.designer.AST.IType in project titan.EclipsePlug-ins by eclipse.
the class LessThanExpression 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 (value1 == null || value2 == null) {
return lastValue;
}
checkExpressionOperands(timestamp, expectedValue, referenceChain);
if (getIsErroneous(timestamp) || isUnfoldable(timestamp, referenceChain)) {
return lastValue;
}
final IValue last1 = value1.getValueRefdLast(timestamp, referenceChain);
final IValue last2 = value2.getValueRefdLast(timestamp, referenceChain);
if (last1.getIsErroneous(timestamp) || last2.getIsErroneous(timestamp)) {
setIsErroneous(true);
return lastValue;
}
switch(last1.getValuetype()) {
case INTEGER_VALUE:
{
lastValue = new Boolean_Value(((Integer_Value) last1).compareTo((Integer_Value) last2) < 0);
lastValue.copyGeneralProperties(this);
break;
}
case REAL_VALUE:
{
final double float1 = ((Real_Value) last1).getValue();
final double float2 = ((Real_Value) last2).getValue();
lastValue = new Boolean_Value(Double.compare(float1, float2) < 0);
lastValue.copyGeneralProperties(this);
break;
}
case ENUMERATED_VALUE:
{
IType governor1 = last1.getExpressionGovernor(timestamp, expectedValue);
governor1 = governor1.getTypeRefdLast(timestamp);
IType governor2 = last2.getExpressionGovernor(timestamp, expectedValue);
governor2 = governor2.getTypeRefdLast(timestamp);
if (governor1 instanceof TTCN3_Enumerated_Type) {
final EnumItem item1 = ((TTCN3_Enumerated_Type) governor1).getEnumItemWithName(((Enumerated_Value) last1).getValue());
final EnumItem item2 = ((TTCN3_Enumerated_Type) governor2).getEnumItemWithName(((Enumerated_Value) last2).getValue());
lastValue = new Boolean_Value(((Integer_Value) item1.getValue()).intValue() < ((Integer_Value) item2.getValue()).intValue());
lastValue.copyGeneralProperties(this);
} else {
final EnumItem item1 = ((ASN1_Enumerated_Type) governor1).getEnumItemWithName(((Enumerated_Value) last1).getValue());
final EnumItem item2 = ((ASN1_Enumerated_Type) governor2).getEnumItemWithName(((Enumerated_Value) last2).getValue());
lastValue = new Boolean_Value(((Integer_Value) item1.getValue()).intValue() < ((Integer_Value) item2.getValue()).intValue());
lastValue.copyGeneralProperties(this);
}
break;
}
default:
setIsErroneous(true);
}
return lastValue;
}
Aggregations