use of org.eclipse.titan.designer.AST.TTCN3.values.Set_Value in project titan.EclipsePlug-ins by eclipse.
the class ASN1_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 temporalValue = (SequenceOf_Value) last;
if (temporalValue.getNofComponents() == 0) {
if (getNofComponents(timestamp) == 0) {
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);
}
value.setLastTimeChecked(timestamp);
return selfReference;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Set_Value in project titan.EclipsePlug-ins by eclipse.
the class Set_Value method checkEquality.
@Override
public /**
* {@inheritDoc}
*/
boolean checkEquality(final CompilationTimeStamp timestamp, final IValue other) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = other.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (!Value_type.SET_VALUE.equals(last.getValuetype())) {
return false;
}
if (myGovernor == null) {
return false;
}
final Set_Value otherSet = (Set_Value) last;
if (values.getSize() != otherSet.values.getSize()) {
return false;
}
int nofComps = 0;
final IType leftGovernor = myGovernor.getTypeRefdLast(timestamp);
switch(leftGovernor.getTypetype()) {
case TYPE_TTCN3_SET:
nofComps = ((TTCN3_Set_Type) leftGovernor).getNofComponents();
break;
case TYPE_ASN1_SET:
nofComps = ((ASN1_Set_Type) leftGovernor).getNofComponents(timestamp);
break;
default:
return false;
}
CompField compField = null;
for (int i = 0; i < nofComps; i++) {
switch(leftGovernor.getTypetype()) {
case TYPE_TTCN3_SET:
compField = ((TTCN3_Set_Type) leftGovernor).getComponentByIndex(i);
break;
case TYPE_ASN1_SET:
compField = ((ASN1_Set_Type) leftGovernor).getComponentByIndex(i);
break;
default:
return false;
}
final Identifier fieldName = compField.getIdentifier();
if (hasComponentWithName(fieldName)) {
final IValue leftValue = getComponentByName(fieldName).getValue();
if (otherSet.hasComponentWithName(fieldName)) {
final IValue otherValue = otherSet.getComponentByName(fieldName).getValue();
if ((Value_type.OMIT_VALUE.equals(leftValue.getValuetype()) && !Value_type.OMIT_VALUE.equals(otherValue.getValuetype())) || (!Value_type.OMIT_VALUE.equals(leftValue.getValuetype()) && Value_type.OMIT_VALUE.equals(otherValue.getValuetype()))) {
return false;
}
if (!leftValue.checkEquality(timestamp, otherValue)) {
return false;
}
} else {
if (compField.hasDefault()) {
if (!leftValue.checkEquality(timestamp, compField.getDefault())) {
return false;
}
} else {
if (!Value_type.OMIT_VALUE.equals(leftValue.getValuetype())) {
return false;
}
}
}
} else {
if (otherSet.hasComponentWithName(fieldName)) {
final IValue otherValue = otherSet.getComponentByName(fieldName).getValue();
if (compField.hasDefault()) {
if (Value_type.OMIT_VALUE.equals(otherValue.getValuetype())) {
return false;
}
if (!compField.getDefault().checkEquality(timestamp, otherValue)) {
return false;
}
}
}
}
}
return true;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Set_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;
}
Aggregations