use of org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value in project titan.EclipsePlug-ins by eclipse.
the class TTCN3_Set_Type method checkThisValue.
@Override
public /**
* {@inheritDoc}
*/
boolean checkThisValue(final CompilationTimeStamp timestamp, final IValue value, final Assignment lhs, final ValueCheckingOptions valueCheckingOptions) {
if (getIsErroneous(timestamp)) {
return false;
}
boolean selfReference = super.checkThisValue(timestamp, value, lhs, valueCheckingOptions);
IValue last = value.getValueRefdLast(timestamp, valueCheckingOptions.expected_value, null);
if (last == null || last.getIsErroneous(timestamp)) {
return selfReference;
}
// already handled ones
switch(value.getValuetype()) {
case OMIT_VALUE:
case REFERENCED_VALUE:
return selfReference;
case UNDEFINED_LOWERIDENTIFIER_VALUE:
if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
return selfReference;
}
break;
default:
break;
}
switch(last.getValuetype()) {
case SEQUENCE_VALUE:
last = last.setValuetype(timestamp, Value_type.SET_VALUE);
if (last.isAsn()) {
selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
} else {
selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
}
break;
case SEQUENCEOF_VALUE:
if (((SequenceOf_Value) last).isIndexed()) {
value.getLocation().reportSemanticError(MessageFormat.format("Indexed assignment notation cannot be used for set type `{0}''", getFullName()));
value.setIsErroneous(true);
} else {
final SequenceOf_Value tempValue = (SequenceOf_Value) last;
if (tempValue.getNofComponents() == 0) {
if (compFieldMap != null && compFieldMap.getComponentFieldMap(timestamp).isEmpty()) {
last = last.setValuetype(timestamp, Value_type.SET_VALUE);
} else {
value.getLocation().reportSemanticError(MessageFormat.format(NONEMPTYEXPECTED, getFullName()));
value.setIsErroneous(true);
}
} else {
value.getLocation().reportSemanticError(MessageFormat.format(last.isAsn() ? VALUELISTNOTATIONERRORASN1 : VALUELISTNOTATIONERRORTTCN3, getFullName()));
value.setIsErroneous(true);
}
}
break;
case SET_VALUE:
if (last.isAsn()) {
selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
} else {
selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
}
break;
case UNDEFINED_BLOCK:
last = last.setValuetype(timestamp, Value_type.SET_VALUE);
selfReference = checkThisValueSet(timestamp, (Set_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
break;
case EXPRESSION_VALUE:
case MACRO_VALUE:
// already checked
break;
default:
value.getLocation().reportSemanticError(MessageFormat.format(last.isAsn() ? SETVALUEXPECTEDASN1 : SETVALUEXPECTEDTTCN3, getFullName()));
value.setIsErroneous(true);
}
if (valueCheckingOptions.sub_check) {
// there is no parent type to check
if (subType != null) {
subType.checkThisValue(timestamp, last);
}
}
value.setLastTimeChecked(timestamp);
return selfReference;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value in project titan.EclipsePlug-ins by eclipse.
the class SpecificValue_Template method checkTemplateSpecificLengthRestriction.
@Override
protected /**
* {@inheritDoc}
*/
void checkTemplateSpecificLengthRestriction(final CompilationTimeStamp timestamp, final Type_type typeType) {
IValue value = getValue();
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
value = value.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
switch(value.getValuetype()) {
case BITSTRING_VALUE:
if (Type_type.TYPE_BITSTRING.equals(typeType)) {
lengthRestriction.checkNofElements(timestamp, ((Bitstring_Value) value).getValueLength(), false, false, false, this);
}
break;
case HEXSTRING_VALUE:
if (Type_type.TYPE_HEXSTRING.equals(typeType)) {
lengthRestriction.checkNofElements(timestamp, ((Hexstring_Value) value).getValueLength(), false, false, false, this);
}
break;
case OCTETSTRING_VALUE:
if (Type_type.TYPE_OCTETSTRING.equals(typeType)) {
lengthRestriction.checkNofElements(timestamp, ((Octetstring_Value) value).getValueLength(), false, false, false, this);
}
break;
case CHARSTRING_VALUE:
if (Type_type.TYPE_CHARSTRING.equals(typeType)) {
lengthRestriction.checkNofElements(timestamp, ((Charstring_Value) value).getValueLength(), false, false, false, this);
} else if (Type_type.TYPE_UCHARSTRING.equals(typeType)) {
value = value.setValuetype(timestamp, Value_type.UNIVERSALCHARSTRING_VALUE);
lengthRestriction.checkNofElements(timestamp, ((UniversalCharstring_Value) value).getValueLength(), false, false, false, this);
}
break;
case UNIVERSALCHARSTRING_VALUE:
if (Type_type.TYPE_UCHARSTRING.equals(typeType)) {
lengthRestriction.checkNofElements(timestamp, ((UniversalCharstring_Value) value).getValueLength(), false, false, false, this);
}
break;
case SEQUENCEOF_VALUE:
if (Type_type.TYPE_SEQUENCE_OF.equals(typeType)) {
lengthRestriction.checkNofElements(timestamp, ((SequenceOf_Value) value).getNofComponents(), false, false, false, this);
}
break;
case SETOF_VALUE:
if (Type_type.TYPE_SET_OF.equals(typeType)) {
lengthRestriction.checkNofElements(timestamp, ((SetOf_Value) value).getNofComponents(), false, false, false, this);
}
break;
case OMIT_VALUE:
lengthRestriction.getLocation().reportSemanticError("Length restriction cannot be used with omit value");
break;
default:
// they are either correct or not applicable to the type
break;
}
}
Aggregations