use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class SequenceOf_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 (lastTimeChecked == null || lastTimeChecked.isLess(timestamp)) {
convertedValue = null;
}
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:
final Value arrayIndex = ((ArraySubReference) subreference).getValue();
IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue valueIndex = arrayIndex.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (valueIndex.isUnfoldable(timestamp)) {
return false;
}
if (Value_type.INTEGER_VALUE.equals(valueIndex.getValuetype())) {
final int index = ((Integer_Value) valueIndex).intValue();
if (index < 0) {
return false;
}
if (isIndexed()) {
for (int i = 0; i < values.getNofIndexedValues(); i++) {
IValue indexedValue = values.getIndexedValueByIndex(i).getIndex().getValue();
referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
indexedValue = indexedValue.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (Value_type.INTEGER_VALUE.equals(indexedValue.getValuetype()) && ((Integer_Value) indexedValue).intValue() == index) {
return values.getIndexedValueByIndex(i).getValue().evaluateIsbound(timestamp, reference, actualSubReference + 1);
}
}
} else if (index >= values.getNofValues()) {
if (!reference.getUsedInIsbound()) {
arrayIndex.getLocation().reportSemanticError(MessageFormat.format(INDEXOVERFLOW, type.getTypename(), index, values.getNofValues()));
}
} else {
return values.getValueByIndex(index).evaluateIsbound(timestamp, reference, actualSubReference + 1);
}
return false;
}
return false;
case fieldSubReference:
return false;
case parameterisedSubReference:
return false;
default:
return false;
}
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class SequenceOf_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 (lastTimeChecked == null || lastTimeChecked.isLess(timestamp)) {
convertedValue = null;
}
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:
final Value arrayIndex = ((ArraySubReference) subreference).getValue();
IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue valueIndex = arrayIndex.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (valueIndex.isUnfoldable(timestamp)) {
return false;
}
if (Value_type.INTEGER_VALUE.equals(valueIndex.getValuetype())) {
final int index = ((Integer_Value) valueIndex).intValue();
if (index < 0) {
return false;
}
if (isIndexed()) {
for (int i = 0; i < values.getNofIndexedValues(); i++) {
IValue indexedValue = values.getIndexedValueByIndex(i).getIndex().getValue();
referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
indexedValue = indexedValue.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (Value_type.INTEGER_VALUE.equals(indexedValue.getValuetype()) && ((Integer_Value) indexedValue).intValue() == index) {
return values.getIndexedValueByIndex(i).getValue().evaluateIspresent(timestamp, reference, actualSubReference + 1);
}
}
} else if (index >= values.getNofValues()) {
if (!reference.getUsedInIsbound()) {
arrayIndex.getLocation().reportSemanticError(MessageFormat.format(INDEXOVERFLOW, type.getTypename(), index, values.getNofValues()));
}
} else {
return values.getValueByIndex(index).evaluateIspresent(timestamp, reference, actualSubReference + 1);
}
return false;
}
return false;
case fieldSubReference:
return false;
case parameterisedSubReference:
return false;
default:
return false;
}
}
use of org.eclipse.titan.designer.AST.IReferenceChain 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;
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class SetOf_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:
final Value arrayIndex = ((ArraySubReference) subreference).getValue();
IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue valueIndex = arrayIndex.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (valueIndex.isUnfoldable(timestamp)) {
return false;
}
if (Value_type.INTEGER_VALUE.equals(valueIndex.getValuetype())) {
final int index = ((Integer_Value) valueIndex).intValue();
if (index < 0) {
return false;
}
if (isIndexed()) {
for (int i = 0; i < values.getNofIndexedValues(); i++) {
IValue indexedValue = values.getIndexedValueByIndex(i).getIndex().getValue();
referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
indexedValue = indexedValue.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (Value_type.INTEGER_VALUE.equals(indexedValue.getValuetype()) && ((Integer_Value) indexedValue).intValue() == index) {
return values.getIndexedValueByIndex(i).getValue().evaluateIspresent(timestamp, reference, actualSubReference + 1);
}
}
arrayIndex.getLocation().reportSemanticError(MessageFormat.format(NOINDEX, index, values.getFullName()));
} else if (index >= values.getNofValues()) {
arrayIndex.getLocation().reportSemanticError(MessageFormat.format(INDEXOVERFLOW, type.getTypename(), index, values.getNofValues()));
} else {
return values.getValueByIndex(index).evaluateIspresent(timestamp, reference, actualSubReference + 1);
}
return false;
}
return false;
case fieldSubReference:
return false;
case parameterisedSubReference:
return false;
default:
return false;
}
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class SetOf_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;
}
final IType type = myGovernor.getTypeRefdLast(timestamp);
if (type.getIsErroneous(timestamp)) {
return false;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
final Value arrayIndex = ((ArraySubReference) subreference).getValue();
IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue valueIndex = arrayIndex.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (valueIndex.isUnfoldable(timestamp)) {
return false;
}
if (Value_type.INTEGER_VALUE.equals(valueIndex.getValuetype())) {
final int index = ((Integer_Value) valueIndex).intValue();
if (index < 0) {
return false;
}
if (isIndexed()) {
for (int i = 0; i < values.getNofIndexedValues(); i++) {
IValue indexedValue = values.getIndexedValueByIndex(i).getIndex().getValue();
referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
indexedValue = indexedValue.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (Value_type.INTEGER_VALUE.equals(indexedValue.getValuetype()) && ((Integer_Value) indexedValue).intValue() == index) {
return values.getIndexedValueByIndex(i).getValue().evaluateIsbound(timestamp, reference, actualSubReference + 1);
}
}
arrayIndex.getLocation().reportSemanticError(MessageFormat.format(NOINDEX, index, values.getFullName()));
} else if (index >= values.getNofValues()) {
arrayIndex.getLocation().reportSemanticError(MessageFormat.format(INDEXOVERFLOW, type.getTypename(), index, values.getNofValues()));
} else {
return values.getValueByIndex(index).evaluateIsbound(timestamp, reference, actualSubReference + 1);
}
return false;
}
return false;
case fieldSubReference:
return false;
case parameterisedSubReference:
return false;
default:
return false;
}
}
Aggregations