use of org.eclipse.titan.designer.AST.IType 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.IType in project titan.EclipsePlug-ins by eclipse.
the class ObjectIdentifierComponent method checkDefdValueOID.
/**
* Checks the defined value form in an OID component.
*
* @param timestamp the timestamp of the actual compilation cycle.
* @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 checkDefdValueOID(final CompilationTimeStamp timestamp, final IReferenceChain refChain, final oidState_type state) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue value = definedValue.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (value.getIsErroneous(timestamp)) {
return oidState_type.LATER;
}
switch(value.getValuetype()) {
case INTEGER_VALUE:
final ObjectIdentifierComponent temp = new ObjectIdentifierComponent(null, definedValue);
temp.setFullNameParent(this);
temp.setMyScope(myScope);
return temp.checkNumberFormOID(timestamp, state);
case OBJECTID_VALUE:
if (!oidState_type.START.equals(state)) {
definedValue.getLocation().reportSemanticError("INTEGER or RELATIVE-OID value was expected");
}
((ObjectIdentifier_Value) value).checkOID(timestamp, refChain);
return oidState_type.LATER;
case RELATIVEOBJECTIDENTIFIER_VALUE:
switch(state) {
case ITU_REC:
return oidState_type.LATER;
case LATER:
return oidState_type.LATER;
default:
definedValue.getLocation().reportSemanticError(MessageFormat.format("RELATIVE-OID value cannot be used as the {0} component of an OBJECTIDENTIFIER value", oidState_type.START.equals(state) ? "first" : "second"));
return oidState_type.LATER;
}
case REFERENCED_VALUE:
{
final Reference reference = ((Referenced_Value) value).getReference();
final Assignment assignment = reference.getRefdAssignment(timestamp, false);
final IType type = assignment.getType(timestamp).getTypeRefdLast(timestamp);
if (type.getTypetype() == Type_type.TYPE_INTEGER) {
// FIXME implement handling of the variable form
} else {
definedValue.getLocation().reportSemanticError("INTEGER variable was expected");
}
return oidState_type.LATER;
}
default:
if (oidState_type.START.equals(state)) {
definedValue.getLocation().reportSemanticError("INTEGER or OBJECT IDENTIFIER value was expected for the first component");
} else {
definedValue.getLocation().reportSemanticError("INTEGER or RELATIVE-OID value was expected");
}
return oidState_type.LATER;
}
}
use of org.eclipse.titan.designer.AST.IType 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.IType 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.IType in project titan.EclipsePlug-ins by eclipse.
the class Array_Value method setGenNameRecursive.
@Override
public /**
* {@inheritDoc}
*/
void setGenNameRecursive(final String parameterGenName) {
super.setGenNameRecursive(parameterGenName);
IType governor = myGovernor;
if (governor == null) {
governor = getExpressionGovernor(CompilationTimeStamp.getBaseTimestamp(), Expected_Value_type.EXPECTED_TEMPLATE);
}
if (governor == null) {
governor = myLastSetGovernor;
}
if (governor == null) {
return;
}
final IType type = governor.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
if (!Type_type.TYPE_ARRAY.equals(type.getTypetype())) {
return;
}
final long offset = ((Array_Type) type).getDimension().getOffset();
if (isIndexed()) {
for (int i = 0; i < values.getNofIndexedValues(); i++) {
final StringBuilder embeddedName = new StringBuilder(parameterGenName);
embeddedName.append(".getAt(").append(offset + i).append(')');
values.getIndexedValueByIndex(i).getValue().setGenNameRecursive(embeddedName.toString());
}
} else {
for (int i = 0; i < values.getNofValues(); i++) {
final StringBuilder embeddedName = new StringBuilder(parameterGenName);
embeddedName.append(".getAt(").append(offset + i).append(')');
values.getValueByIndex(i).setGenNameRecursive(embeddedName.toString());
}
}
}
Aggregations