use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Set_Type method getFieldType.
// This is the same as in ASN1_Sequence_Type
@Override
public /**
* {@inheritDoc}
*/
IType getFieldType(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final Expected_Value_type expectedIndex, final IReferenceChain refChain, final boolean interruptIfOptional) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (subreferences.size() <= actualSubReference) {
return this;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(ArraySubReference.INVALIDSUBREFERENCE, getTypename()));
return null;
case fieldSubReference:
final Identifier id = subreference.getId();
final CompField compField = components.getCompByName(id);
if (compField == null) {
subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.NONEXISTENTSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), getTypename()));
return null;
}
if (interruptIfOptional && compField.isOptional()) {
return null;
}
final Expected_Value_type internalExpectation = (expectedIndex == Expected_Value_type.EXPECTED_TEMPLATE) ? Expected_Value_type.EXPECTED_DYNAMIC_VALUE : expectedIndex;
return compField.getType().getFieldType(timestamp, reference, actualSubReference + 1, internalExpectation, refChain, interruptIfOptional);
case parameterisedSubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((ParameterisedSubReference) subreference).getId().getDisplayName(), getTypename()));
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 Open_Type method checkThisValueChoice.
private boolean checkThisValueChoice(final CompilationTimeStamp timestamp, final Choice_Value value, final Assignment lhs, final Expected_Value_type expectedValue, final boolean incompleteAllowed, final boolean strElem) {
boolean selfReference = false;
final Identifier name = value.getName();
final CompField field = getComponentByName(name);
if (field == null) {
if (value.isAsn()) {
value.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTCHOICE, name.getDisplayName(), getFullName()));
} else {
value.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTUNION, name.getDisplayName(), getFullName()));
}
} else {
IValue alternativeValue = value.getValue();
if (null == alternativeValue) {
return selfReference;
}
final Type alternativeType = field.getType();
alternativeValue.setMyGovernor(alternativeType);
alternativeValue = alternativeType.checkThisValueRef(timestamp, alternativeValue);
selfReference = alternativeType.checkThisValue(timestamp, alternativeValue, lhs, new ValueCheckingOptions(expectedValue, incompleteAllowed, false, true, false, strElem));
}
value.setLastTimeChecked(timestamp);
return selfReference;
}
use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class Embedded_PDV_Type method getTypeRefd.
@Override
public /**
* {@inheritDoc}
*/
IType getTypeRefd(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
if (null == myScope) {
setIsErroneous(true);
return this;
}
final Identifier identifier = new Identifier(Identifier_type.ID_ASN, EMBEDDED_PDV);
final Assignments assignments = myScope.getAssignmentsScope();
if (!assignments.hasAssignmentWithId(timestamp, identifier)) {
setIsErroneous(true);
return this;
}
final Assignment assignment = assignments.getLocalAssignmentByID(timestamp, identifier);
if (null == assignment || null == assignment.getType(timestamp)) {
setIsErroneous(true);
return this;
}
return assignment.getType(timestamp);
}
use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class External_Type method getTypeRefd.
@Override
public /**
* {@inheritDoc}
*/
IType getTypeRefd(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
if (null == myScope) {
setIsErroneous(true);
return this;
}
final Identifier identifier = new Identifier(Identifier_type.ID_ASN, "EXTERNAL");
final Assignments assignments = myScope.getAssignmentsScope();
if (!assignments.hasAssignmentWithId(timestamp, identifier)) {
setIsErroneous(true);
return this;
}
final Assignment assignment = assignments.getLocalAssignmentByID(timestamp, identifier);
if (null == assignment || null == assignment.getType(timestamp)) {
setIsErroneous(true);
return this;
}
return assignment.getType(timestamp);
}
use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class Sequence_Value method checkEquality.
@Override
public /**
* {@inheritDoc}
*/
boolean checkEquality(final CompilationTimeStamp timestamp, final IValue other) {
if (convertedValue != null && convertedValue != this) {
return convertedValue.checkEquality(timestamp, other);
}
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = other.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (!Value_type.SEQUENCE_VALUE.equals(last.getValuetype())) {
return false;
}
if (myGovernor == null) {
return false;
}
final Sequence_Value otherSequence = (Sequence_Value) last;
if (values.getSize() != otherSequence.values.getSize()) {
return false;
}
int nofComps = 0;
final IType leftGovernor = myGovernor.getTypeRefdLast(timestamp);
switch(leftGovernor.getTypetype()) {
case TYPE_TTCN3_SEQUENCE:
nofComps = ((TTCN3_Sequence_Type) leftGovernor).getNofComponents();
break;
case TYPE_ASN1_SEQUENCE:
nofComps = ((ASN1_Sequence_Type) leftGovernor).getNofComponents(timestamp);
break;
default:
return false;
}
CompField compField = null;
for (int i = 0; i < nofComps; i++) {
switch(leftGovernor.getTypetype()) {
case TYPE_TTCN3_SEQUENCE:
compField = ((TTCN3_Sequence_Type) leftGovernor).getComponentByIndex(i);
break;
case TYPE_ASN1_SEQUENCE:
compField = ((ASN1_Sequence_Type) leftGovernor).getComponentByIndex(i);
break;
default:
return false;
}
final Identifier fieldName = compField.getIdentifier();
if (hasComponentWithName(fieldName)) {
final IValue leftValue = getComponentByName(fieldName).getValue();
if (otherSequence.hasComponentWithName(fieldName)) {
final IValue otherValue = otherSequence.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 (otherSequence.hasComponentWithName(fieldName)) {
final IValue otherValue = otherSequence.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;
}
Aggregations