use of org.eclipse.titan.designer.AST.FieldSubReference in project titan.EclipsePlug-ins by eclipse.
the class Sequence_Value method evaluateIspresent.
@Override
public /**
* {@inheritDoc}
*/
boolean evaluateIspresent(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
return true;
}
if (convertedValue != null && convertedValue != this) {
return convertedValue.evaluateIsbound(timestamp, reference, actualSubReference);
}
final IType type = myGovernor.getTypeRefdLast(timestamp);
if (type.getIsErroneous(timestamp)) {
return false;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
return false;
case fieldSubReference:
final Identifier fieldId = ((FieldSubReference) subreference).getId();
switch(type.getTypetype()) {
case TYPE_TTCN3_SEQUENCE:
if (!((TTCN3_Sequence_Type) type).hasComponentWithName(fieldId.getName())) {
return false;
}
break;
case TYPE_ASN1_SEQUENCE:
if (!((ASN1_Sequence_Type) type).hasComponentWithName(fieldId)) {
return false;
}
break;
default:
return false;
}
if (values.hasNamedValueWithName(fieldId)) {
// we can move on with the check
return values.getNamedValueByName(fieldId).getValue().evaluateIspresent(timestamp, reference, actualSubReference + 1);
}
if (Type_type.TYPE_TTCN3_SEQUENCE.equals(type.getTypetype())) {
return false;
}
final CompField compField = ((ASN1_Sequence_Type) type).getComponentByName(fieldId);
if (compField.isOptional()) {
// create an explicit omit value
final Value result = new Omit_Value();
final BridgingNamedNode bridge = new BridgingNamedNode(this, "." + fieldId.getDisplayName());
result.setFullNameParent(bridge);
result.setMyScope(getMyScope());
return result.evaluateIspresent(timestamp, reference, actualSubReference + 1);
} else if (compField.hasDefault()) {
return compField.getDefault().evaluateIspresent(timestamp, reference, actualSubReference + 1);
}
return false;
case parameterisedSubReference:
return false;
default:
return false;
}
}
use of org.eclipse.titan.designer.AST.FieldSubReference in project titan.EclipsePlug-ins by eclipse.
the class Sequence_Value method evaluateIsbound.
@Override
public /**
* {@inheritDoc}
*/
boolean evaluateIsbound(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
return true;
}
if (convertedValue != null && convertedValue != this) {
return convertedValue.evaluateIsbound(timestamp, reference, actualSubReference);
}
final IType type = myGovernor.getTypeRefdLast(timestamp);
if (type.getIsErroneous(timestamp)) {
return false;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
return false;
case fieldSubReference:
final Identifier fieldId = ((FieldSubReference) subreference).getId();
switch(type.getTypetype()) {
case TYPE_TTCN3_SEQUENCE:
if (!((TTCN3_Sequence_Type) type).hasComponentWithName(fieldId.getName())) {
return false;
}
break;
case TYPE_ASN1_SEQUENCE:
if (!((ASN1_Sequence_Type) type).hasComponentWithName(fieldId)) {
return false;
}
break;
default:
return false;
}
if (values.hasNamedValueWithName(fieldId)) {
// we can move on with the check
return values.getNamedValueByName(fieldId).getValue().evaluateIsbound(timestamp, reference, actualSubReference + 1);
}
if (Type_type.TYPE_TTCN3_SEQUENCE.equals(type.getTypetype())) {
return false;
}
final CompField compField = ((ASN1_Sequence_Type) type).getComponentByName(fieldId);
if (compField.isOptional()) {
// create an explicit omit value
final Value result = new Omit_Value();
final BridgingNamedNode bridge = new BridgingNamedNode(this, "." + fieldId.getDisplayName());
result.setFullNameParent(bridge);
result.setMyScope(getMyScope());
return result.evaluateIsbound(timestamp, reference, actualSubReference + 1);
} else if (compField.hasDefault()) {
return compField.getDefault().evaluateIsbound(timestamp, reference, actualSubReference + 1);
}
return false;
case parameterisedSubReference:
return false;
default:
return false;
}
}
use of org.eclipse.titan.designer.AST.FieldSubReference in project titan.EclipsePlug-ins by eclipse.
the class ObjectIdentifierComponent method checkNameForm.
/**
* Checks that the identifier in name is a valid name form in the actual state.
* Also checks the named form in an OID component.
*
* @param timestamp the timestamp of the actual compilation cycle.
* @param parent the parent value.
* @param refChain the reference chain used to detect cyclic references.
* @param state the state of checking.
*
* @param the new state after this check was done.
*/
private oidState_type checkNameForm(final CompilationTimeStamp timestamp, final Value parent, final IReferenceChain refChain, final oidState_type state, final AtomicInteger result) {
final String nameString = name.getName();
oidState_type actualState = state;
int value = -1;
switch(state) {
case START:
if ("itu__t".equals(nameString) || "ccitt".equals(nameString)) {
actualState = oidState_type.ITU;
value = 0;
} else if ("itu__r".equals(nameString)) {
location.reportSemanticWarning(MessageFormat.format("Identifier `{0}'' should not be used as NameForm", name.getDisplayName()));
actualState = oidState_type.ITU;
value = 0;
} else if ("iso".equals(nameString)) {
actualState = oidState_type.ISO;
value = 1;
} else if ("joint__iso__itu__t".equals(nameString) || "joint__iso__ccitt".equals(nameString)) {
actualState = oidState_type.JOINT;
value = 2;
}
break;
case ITU:
for (int i = 0; i < NAMES_ITU.length; i++) {
if (nameString.equals(NAMES_ITU[i].name)) {
value = NAMES_ITU[i].value;
switch(value) {
case 0:
actualState = oidState_type.ITU_REC;
break;
case 5:
location.reportSemanticWarning(MessageFormat.format("Identifier `{0}'' should not be used as NumberForm", name.getDisplayName()));
actualState = oidState_type.LATER;
break;
default:
actualState = oidState_type.LATER;
break;
}
}
}
break;
case ISO:
for (int i = 0; i < NAMES_ISO.length; i++) {
if (nameString.equals(NAMES_ISO[i].name)) {
value = NAMES_ISO[i].value;
actualState = oidState_type.LATER;
}
}
break;
case JOINT:
for (int i = 0; i < NAMES_JOINT.length; i++) {
if (nameString.equals(NAMES_JOINT[i].name)) {
value = NAMES_JOINT[i].value;
actualState = oidState_type.LATER;
location.reportSemanticWarning(MessageFormat.format("Identifier `{0}'' should not be used as NumberForm", name.getDisplayName()));
}
}
break;
case ITU_REC:
if (nameString.length() == 1) {
final char c = nameString.charAt(0);
if (c >= 'a' && c <= 'z') {
value = c - 'a' + 1;
actualState = oidState_type.LATER;
}
}
break;
default:
break;
}
// now we have detected the name form
if (value < 0) {
final List<ISubReference> newSubreferences = new ArrayList<ISubReference>();
newSubreferences.add(new FieldSubReference(name));
Reference reference;
if (parent.isAsn()) {
reference = new Defined_Reference(null, newSubreferences);
} else {
reference = new Reference(null, newSubreferences);
}
final IValue newDefinedValue = new Referenced_Value(reference);
newDefinedValue.setLocation(this.getLocation());
final ObjectIdentifierComponent component = new ObjectIdentifierComponent(newDefinedValue);
component.setFullNameParent(this);
component.setMyScope(parent.getMyScope());
actualState = component.checkDefdValueOID(timestamp, refChain, actualState);
}
result.set(value);
// the other case is not handled as it would only change a parsed value
return actualState;
}
use of org.eclipse.titan.designer.AST.FieldSubReference in project titan.EclipsePlug-ins by eclipse.
the class Choice_Value method getReferencedSubValue.
@Override
public /**
* {@inheritDoc}
*/
IValue getReferencedSubValue(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final IReferenceChain refChain) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
return this;
}
final IType type = myGovernor.getTypeRefdLast(timestamp);
if (type.getIsErroneous(timestamp)) {
return null;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(ArraySubReference.INVALIDVALUESUBREFERENCE, type.getTypename()));
return null;
case fieldSubReference:
final Identifier fieldId = ((FieldSubReference) subreference).getId();
switch(type.getTypetype()) {
case TYPE_TTCN3_CHOICE:
if (!((TTCN3_Choice_Type) type).hasComponentWithName(fieldId.getName())) {
subreference.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTFIELD, fieldId.getDisplayName(), type.getTypename()));
return null;
}
break;
case TYPE_ASN1_CHOICE:
if (!((ASN1_Choice_Type) type).hasComponentWithName(fieldId)) {
subreference.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTFIELD, fieldId.getDisplayName(), type.getTypename()));
return null;
}
break;
case TYPE_OPENTYPE:
if (!((Open_Type) type).hasComponentWithName(fieldId)) {
subreference.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTFIELD, fieldId.getDisplayName(), type.getTypename()));
return null;
}
break;
default:
return null;
}
if (name.getDisplayName().equals(fieldId.getDisplayName())) {
return value.getReferencedSubValue(timestamp, reference, actualSubReference + 1, refChain);
}
if (!reference.getUsedInIsbound()) {
subreference.getLocation().reportSemanticError(MessageFormat.format(INACTIVEFIELD, fieldId.getDisplayName(), type.getTypename(), name.getDisplayName()));
}
return null;
case parameterisedSubReference:
subreference.getLocation().reportSemanticError(ParameterisedSubReference.INVALIDVALUESUBREFERENCE);
return null;
default:
subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
return null;
}
}
use of org.eclipse.titan.designer.AST.FieldSubReference in project titan.EclipsePlug-ins by eclipse.
the class Choice_Value method evaluateIspresent.
@Override
public /**
* {@inheritDoc}
*/
boolean evaluateIspresent(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
return true;
}
final IType type = myGovernor.getTypeRefdLast(timestamp);
if (type.getIsErroneous(timestamp)) {
return false;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
return false;
case fieldSubReference:
final Identifier fieldId = ((FieldSubReference) subreference).getId();
switch(type.getTypetype()) {
case TYPE_TTCN3_CHOICE:
if (!((TTCN3_Choice_Type) type).hasComponentWithName(fieldId.getName())) {
return false;
}
break;
case TYPE_ASN1_CHOICE:
if (!((ASN1_Choice_Type) type).hasComponentWithName(fieldId)) {
return false;
}
break;
case TYPE_OPENTYPE:
if (!((Open_Type) type).hasComponentWithName(fieldId)) {
return false;
}
break;
default:
return false;
}
if (name.getDisplayName().equals(fieldId.getDisplayName())) {
return value.evaluateIspresent(timestamp, reference, actualSubReference + 1);
}
return false;
case parameterisedSubReference:
return false;
default:
return false;
}
}
Aggregations