use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class DecvalueUnicharExpression method checkExpressionOperand3.
/**
* Checks the 3rd operand
* in charstring (optional)
* @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 checkExpressionOperand3(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (value3 == null) {
return;
}
value3.setLoweridToReference(timestamp);
final Type_type tempType = value3.getExpressionReturntype(timestamp, expectedValue);
switch(tempType) {
case TYPE_CHARSTRING:
final IValue last = value3.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last.isUnfoldable(timestamp)) {
final String originalString = ((Charstring_Value) last).getValue();
final CharstringExtractor cs = new CharstringExtractor(originalString);
if (cs.isErrorneous()) {
value3.getLocation().reportSemanticError(cs.getErrorMessage());
setIsErroneous(true);
}
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
if (!isErroneous) {
location.reportSemanticError(OPERAND3_ERROR1);
setIsErroneous(true);
}
break;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class EncodeBase64Expression 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 (value == null) {
return lastValue;
}
checkExpressionOperands(timestamp, expectedValue, referenceChain);
if (getIsErroneous(timestamp)) {
return lastValue;
}
if (isUnfoldable(timestamp, referenceChain)) {
return lastValue;
}
final IValue last = value.getValueRefdLast(timestamp, referenceChain);
if (last.getIsErroneous(timestamp)) {
setIsErroneous(true);
return lastValue;
}
switch(last.getValuetype()) {
case OCTETSTRING_VALUE:
{
final String octetString = ((Octetstring_Value) last).getValue();
lastValue = new Charstring_Value(calculateValue(octetString));
lastValue.copyGeneralProperties(this);
break;
}
default:
setIsErroneous(true);
break;
}
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class EncodeExpression 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 the value to be 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 (templateInstance == null) {
setIsErroneous(true);
return;
}
final Expected_Value_type internalExpectation = Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue) ? Expected_Value_type.EXPECTED_TEMPLATE : expectedValue;
IType type = templateInstance.getExpressionGovernor(timestamp, internalExpectation);
ITTCN3Template template = templateInstance.getTemplateBody();
if (type == null) {
template = template.setLoweridToReference(timestamp);
type = template.getExpressionGovernor(timestamp, internalExpectation);
}
if (type == null) {
if (!template.getIsErroneous(timestamp)) {
templateInstance.getLocation().reportSemanticError(OPERANDERROR1);
}
setIsErroneous(true);
return;
}
IsValueExpression.checkExpressionTemplateInstance(timestamp, this, templateInstance, type, referenceChain, expectedValue);
if (getIsErroneous(timestamp)) {
return;
}
template.checkSpecificValue(timestamp, false);
type = type.getTypeRefdLast(timestamp);
switch(type.getTypetype()) {
case TYPE_UNDEFINED:
case TYPE_NULL:
case TYPE_REFERENCED:
case TYPE_VERDICT:
case TYPE_PORT:
case TYPE_COMPONENT:
case TYPE_DEFAULT:
case TYPE_SIGNATURE:
case TYPE_FUNCTION:
case TYPE_ALTSTEP:
case TYPE_TESTCASE:
if (!isErroneous) {
location.reportSemanticError(OPERANDERROR2);
setIsErroneous(true);
}
break;
default:
break;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class EncvalueUnicharExpression method checkExpressionOperand1.
/**
* Checks the 1st operand
* in template (value) any_type
* @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 checkExpressionOperand1(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (templateInstance1 == null) {
setIsErroneous(true);
return;
}
final Expected_Value_type internalExpectation = Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue) ? Expected_Value_type.EXPECTED_TEMPLATE : expectedValue;
IType type = templateInstance1.getExpressionGovernor(timestamp, internalExpectation);
ITTCN3Template template = templateInstance1.getTemplateBody();
if (type == null) {
template = template.setLoweridToReference(timestamp);
type = template.getExpressionGovernor(timestamp, internalExpectation);
}
if (type == null) {
if (!template.getIsErroneous(timestamp)) {
templateInstance1.getLocation().reportSemanticError(OPERAND1_ERROR1);
}
setIsErroneous(true);
return;
}
IsValueExpression.checkExpressionTemplateInstance(timestamp, this, templateInstance1, type, referenceChain, expectedValue);
if (getIsErroneous(timestamp)) {
return;
}
template.checkSpecificValue(timestamp, false);
type = type.getTypeRefdLast(timestamp);
switch(type.getTypetype()) {
case TYPE_UNDEFINED:
case TYPE_NULL:
case TYPE_REFERENCED:
case TYPE_VERDICT:
case TYPE_PORT:
case TYPE_COMPONENT:
case TYPE_DEFAULT:
case TYPE_SIGNATURE:
case TYPE_FUNCTION:
case TYPE_ALTSTEP:
case TYPE_TESTCASE:
if (!isErroneous) {
location.reportSemanticError(OPERAND1_ERROR2);
setIsErroneous(true);
}
break;
default:
break;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class Enum2IntExpression 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 (value == null) {
return lastValue;
}
checkExpressionOperands(timestamp, expectedValue, referenceChain);
if (getIsErroneous(timestamp)) {
return lastValue;
}
if (isUnfoldable(timestamp, referenceChain)) {
return lastValue;
}
final IValue last = value.getValueRefdLast(timestamp, referenceChain);
if (last == null || last.getIsErroneous(timestamp)) {
setIsErroneous(true);
return lastValue;
}
IType type = last.getExpressionGovernor(timestamp, expectedValue);
type = type.getTypeRefdLast(timestamp);
switch(type.getTypetype()) {
case TYPE_ASN1_ENUMERATED:
{
final EnumItem item = ((ASN1_Enumerated_Type) type).getEnumItemWithName(((Enumerated_Value) last).getValue());
lastValue = new Integer_Value(((Integer_Value) item.getValue()).getValue());
lastValue.copyGeneralProperties(this);
break;
}
case TYPE_TTCN3_ENUMERATED:
{
final EnumItem item = ((TTCN3_Enumerated_Type) type).getEnumItemWithName(((Enumerated_Value) last).getValue());
lastValue = new Integer_Value(((Integer_Value) item.getValue()).getValue());
lastValue.copyGeneralProperties(this);
break;
}
default:
setIsErroneous(true);
break;
}
return lastValue;
}
Aggregations