use of org.eclipse.titan.designer.AST.Identifier 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.Identifier in project titan.EclipsePlug-ins by eclipse.
the class NamedValue method getDeclaration.
@Override
public /**
* {@inheritDoc}
*/
Declaration getDeclaration() {
INamedNode inamedNode = getNameParent();
while (!(inamedNode instanceof IValue)) {
if (inamedNode == null) {
// FIXME: this is just a temp solution! find the reason!
return null;
}
inamedNode = inamedNode.getNameParent();
}
final IValue iValue = (IValue) inamedNode;
IType type = iValue.getMyGovernor();
if (type == null) {
return null;
}
type = type.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
if (type instanceof ITypeWithComponents) {
final Identifier id = ((ITypeWithComponents) type).getComponentIdentifierByName(getName());
return Declaration.createInstance(type.getDefiningAssignment(), id);
}
return null;
}
use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class ObjectIdentifierComponent method getExpectedNameForNumber.
/**
* Searches for the appropriate name belonging to the provided number.
*
* @param number the number to use in the search.
* @param asn1 should the found identifier be reported in ASN.1 or TTCN-3 form.
* @param names the list to search in.
*
* @return the name belonging to the provided number.
*/
private String getExpectedNameForNumber(final int number, final boolean asn1, final Nameform[] names) {
final StringBuilder builder = new StringBuilder();
for (int i = 0; i < names.length; i++) {
if (number == names[i].value) {
if (i > 0) {
builder.append(" or ");
}
builder.append('`');
final Identifier identifier = new Identifier(Identifier_type.ID_NAME, names[i].name);
if (asn1) {
builder.append(identifier.getAsnName());
} else {
builder.append(identifier.getTtcnName());
}
builder.append('\'');
}
}
return builder.toString();
}
use of org.eclipse.titan.designer.AST.Identifier 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.Identifier 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