use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class Notused_Value method checkEquality.
@Override
public /**
* {@inheritDoc}
*/
boolean checkEquality(final CompilationTimeStamp timestamp, final IValue other) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = other.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
return getValuetype().equals(last.getValuetype());
}
use of org.eclipse.titan.designer.AST.IReferenceChain 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.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class ObjectIdentifierComponent method checkNameAndNumberForm.
/**
* Checks if the object identifier component in name and value form is valid.
*
* @param timestamp the timestamp of the actual compilation cycle.
* @param state the state of checking.
*
* @param the new state after this check was done.
*/
private oidState_type checkNameAndNumberForm(final CompilationTimeStamp timestamp, final oidState_type state) {
oidState_type actualState = state;
actualState = checkNumberFormOID(timestamp, actualState);
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = number.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (last.getIsErroneous(timestamp)) {
return actualState;
}
if (!Value_type.INTEGER_VALUE.equals(last.getValuetype())) {
return actualState;
}
final BigInteger value = ((Integer_Value) last).getValueValue();
if (value.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) == 1) {
return actualState;
}
final String tempName = this.name.getName();
final int tempInt = value.intValue();
switch(state) {
case START:
if (!isValidNameForNumber(tempName, tempInt, NAMES_ROOT)) {
number.getLocation().reportSemanticWarning(MessageFormat.format("Identifier {0} was expected instead of `{1}'' for number {2} in the NameAndNumberForm as the first OBJECT IDENTIFIER component", getExpectedNameForNumber(tempInt, number.isAsn(), NAMES_ROOT), name.getDisplayName(), value));
}
break;
case ITU:
if (!isValidNameForNumber(tempName, tempInt, NAMES_ITU)) {
number.getLocation().reportSemanticWarning(MessageFormat.format("Identifier {0} was expected instead of `{1}'' for number {2} in the NameAndNumberForm as the second OBJECT IDENTIFIER component", getExpectedNameForNumber(tempInt, number.isAsn(), NAMES_ITU), name.getDisplayName(), value));
}
break;
case ISO:
if (!isValidNameForNumber(tempName, tempInt, NAMES_ISO)) {
number.getLocation().reportSemanticWarning(MessageFormat.format("Identifier {0} was expected instead of `{1}'' for number {2} in the NameAndNumberForm as the second OBJECT IDENTIFIER component", getExpectedNameForNumber(tempInt, number.isAsn(), NAMES_ISO), name.getDisplayName(), value));
}
break;
case JOINT:
if (!isValidNameForNumber(tempName, tempInt, NAMES_JOINT)) {
number.getLocation().reportSemanticWarning(MessageFormat.format("Identifier {0} was expected instead of `{1}'' for number {2} in the NameAndNumberForm as the second OBJECT IDENTIFIER component", getExpectedNameForNumber(tempInt, number.isAsn(), NAMES_JOINT), name.getDisplayName(), value));
}
break;
case ITU_REC:
if (tempInt >= 1 && tempInt <= 26 && (tempName.length() != 1 || tempName.getBytes()[0] != 'a' + tempInt - 1)) {
number.getLocation().reportSemanticWarning(MessageFormat.format("Identifier {0} was expected instead of `{1}'' for number {2} in the NameAndNumberForm as the third OBJECT IDENTIFIER component", ('a' + tempInt - 1), name.getDisplayName(), value));
}
break;
default:
break;
}
return actualState;
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class ObjectIdentifierComponent method checkDefdValueROID.
/**
* Checks the defined value form in an ROID component.
*
* @param timestamp the timestamp of the actual compilation cycle.
* @param refChain the reference chain used to detect cyclic references.
*
* @param the new state after this check was done.
*/
private void checkDefdValueROID(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue value = definedValue.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (value.getIsErroneous(timestamp)) {
return;
}
switch(value.getValuetype()) {
case INTEGER_VALUE:
final ObjectIdentifierComponent temp = new ObjectIdentifierComponent(null, definedValue);
temp.setFullNameParent(this);
temp.setMyScope(myScope);
temp.checkNumberFormROID(timestamp);
break;
case RELATIVEOBJECTIDENTIFIER_VALUE:
((RelativeObjectIdentifier_Value) value).checkROID(timestamp, referenceChain);
break;
default:
definedValue.getLocation().reportSemanticError("INTEGER or RELATIVE-OID value was expected");
break;
}
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class ObjectIdentifier_Value method checkEquality.
@Override
public /**
* {@inheritDoc}
*/
boolean checkEquality(final CompilationTimeStamp timestamp, final IValue other) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = other.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (!Value_type.OBJECTID_VALUE.equals(last.getValuetype())) {
return false;
}
final ObjectIdentifier_Value otherObjid = (ObjectIdentifier_Value) last;
if (objectIdComponents.size() != otherObjid.objectIdComponents.size()) {
return false;
}
for (int i = 0, size = objectIdComponents.size(); i < size; i++) {
if (objectIdComponents.get(i) != otherObjid.objectIdComponents.get(i)) {
return false;
}
}
return true;
}
Aggregations