use of org.eclipse.titan.designer.AST.ISubReference in project titan.EclipsePlug-ins by eclipse.
the class Notused_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);
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(ArraySubReference.INVALIDVALUESUBREFERENCE, type.getTypename()));
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.ISubReference 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.ISubReference in project titan.EclipsePlug-ins by eclipse.
the class ObjectIdentifier_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);
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(ArraySubReference.INVALIDVALUESUBREFERENCE, type.getTypename()));
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.ISubReference in project titan.EclipsePlug-ins by eclipse.
the class Array_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) || !Type_type.TYPE_ARRAY.equals(type.getTypetype())) {
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 (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 < 0 || index >= values.getNofValues()) {
// the error was already reported
} 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.ISubReference 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;
}
}
Aggregations