use of org.eclipse.titan.designer.AST.TTCN3.values.IndexedValue in project titan.EclipsePlug-ins by eclipse.
the class Array_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) || !Type_type.TYPE_ARRAY.equals(type.getTypetype())) {
return null;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
final Value arrayIndex = ((ArraySubReference) subreference).getValue();
final IValue valueIndex = arrayIndex.getValueRefdLast(timestamp, refChain);
if (valueIndex.isUnfoldable(timestamp)) {
return null;
}
if (Value_type.INTEGER_VALUE.equals(valueIndex.getValuetype())) {
final ArrayDimension dimension = ((Array_Type) type).getDimension();
dimension.checkIndex(timestamp, valueIndex, Expected_Value_type.EXPECTED_CONSTANT);
if (dimension.getIsErroneous(timestamp)) {
return null;
}
final int index = ((Integer_Value) valueIndex).intValue() - (int) dimension.getOffset();
if (isIndexed()) {
for (int i = 0; i < values.getNofIndexedValues(); i++) {
IValue indexedValue = values.getIndexedValueByIndex(i).getIndex().getValue();
indexedValue = indexedValue.getValueRefdLast(timestamp, refChain);
if (Value_type.INTEGER_VALUE.equals(indexedValue.getValuetype()) && ((Integer_Value) indexedValue).intValue() == index) {
return values.getIndexedValueByIndex(i).getValue().getReferencedSubValue(timestamp, reference, actualSubReference + 1, refChain);
}
}
arrayIndex.getLocation().reportSemanticError(MessageFormat.format(NOINDEX, index, values.getFullName()));
} else if (index < 0 || index >= values.getNofValues()) {
// the error was already reported
} else {
return values.getValueByIndex(index).getReferencedSubValue(timestamp, reference, actualSubReference + 1, refChain);
}
return null;
}
arrayIndex.getLocation().reportSemanticError(ArraySubReference.INTEGERINDEXEXPECTED);
return null;
case fieldSubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), type.getTypename()));
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.TTCN3.values.IndexedValue in project titan.EclipsePlug-ins by eclipse.
the class Indexed_Template_List method getValue.
@Override
public /**
* {@inheritDoc}
*/
IValue getValue() {
if (asValue != null) {
return asValue;
}
final Values values = new Values(true);
for (int i = 0, size = getNofTemplates(); i < size; i++) {
final IndexedTemplate indexedTemplate = indexedTemplates.getTemplateByIndex(i);
final IndexedValue indexedValue = new IndexedValue(indexedTemplate.getIndex(), indexedTemplate.getTemplate().getValue());
indexedValue.setLocation(indexedTemplate.getLocation());
values.addIndexedValue(indexedValue);
}
asValue = new SequenceOf_Value(values);
asValue.setLocation(getLocation());
asValue.setMyScope(getMyScope());
asValue.setFullNameParent(getNameParent());
asValue.setMyGovernor(getMyGovernor());
return asValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.IndexedValue in project titan.EclipsePlug-ins by eclipse.
the class Values method updateSyntax.
/**
* Handles the incremental parsing of this value list.
*
* @param reparser the parser doing the incremental parsing.
* @param isDamaged true if the location contains the damaged area, false if only its' location needs to be updated.
*/
@Override
public /**
* {@inheritDoc}
*/
void updateSyntax(final TTCN3ReparseUpdater reparser, final boolean isDamaged) throws ReParseException {
if (isDamaged) {
throw new ReParseException();
}
if (isIndexed) {
for (int i = 0, size = indexedValues.size(); i < size; i++) {
final IndexedValue indexedValue = indexedValues.get(i);
indexedValue.updateSyntax(reparser, false);
reparser.updateLocation(indexedValue.getLocation());
}
} else {
for (int i = 0, size = values.size(); i < size; i++) {
final IValue value = values.get(i);
if (value instanceof IIncrementallyUpdateable) {
((IIncrementallyUpdateable) value).updateSyntax(reparser, false);
reparser.updateLocation(value.getLocation());
} else {
throw new ReParseException();
}
}
}
}
Aggregations