use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class Embedded_PDV_Type method getTypeRefdLast.
@Override
public /**
* {@inheritDoc}
*/
IType getTypeRefdLast(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
final boolean newChain = null == referenceChain;
IReferenceChain tempReferenceChain;
if (newChain) {
tempReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
} else {
tempReferenceChain = referenceChain;
}
IType t = this;
while (t != null && t instanceof IReferencingType && !t.getIsErroneous(timestamp)) {
t = ((IReferencingType) t).getTypeRefd(timestamp, tempReferenceChain);
}
if (newChain) {
tempReferenceChain.release();
}
if (t != null && t.getIsErroneous(timestamp)) {
setIsErroneous(true);
}
return t;
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class AbstractOfType method checkThisValueSetOf.
/**
* Checks the SequenceOf_value kind value against this type.
* SequenceOf_value kinds have to be converted before calling this
* function.
* <p>
* Please note, that this function can only be called once we know for
* sure that the value is of set-of type.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param value
* the value to be checked
* @param expectedValue
* the kind of value expected here.
* @param incompleteAllowed
* wheather incomplete value is allowed or not.
* @param implicitOmit
* true if the implicit omit optional attribute was set
* for the value, false otherwise
*/
public boolean checkThisValueSetOf(final CompilationTimeStamp timestamp, final SetOf_Value value, final Assignment lhs, final Expected_Value_type expectedValue, final boolean incompleteAllowed, final boolean implicitOmit, final boolean strElem) {
boolean selfReference = false;
if (value.isIndexed()) {
boolean checkHoles = Expected_Value_type.EXPECTED_CONSTANT.equals(expectedValue);
BigInteger maxIndex = BigInteger.valueOf(-1);
final Map<BigInteger, Integer> indexMap = new HashMap<BigInteger, Integer>(value.getNofComponents());
for (int i = 0, size = value.getNofComponents(); i < size; i++) {
final IValue component = value.getValueByIndex(i);
final Value index = value.getIndexByIndex(i);
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue indexLast = index.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (indexLast.getIsErroneous(timestamp) || !Value_type.INTEGER_VALUE.equals(indexLast.getValuetype())) {
checkHoles = false;
} else {
final BigInteger tempIndex = ((Integer_Value) indexLast).getValueValue();
if (tempIndex.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) == 1) {
index.getLocation().reportSemanticError(MessageFormat.format("A integer value less than `{0}'' was expected for indexing type `{1}'' instead of `{2}''", Integer.MAX_VALUE, getTypename(), tempIndex));
checkHoles = false;
} else if (tempIndex.compareTo(BigInteger.ZERO) == -1) {
index.getLocation().reportSemanticError(MessageFormat.format("A non-negative integer value was expected for indexing type `{0}'' instead of `{1}''", getTypename(), tempIndex));
checkHoles = false;
} else if (indexMap.containsKey(tempIndex)) {
index.getLocation().reportSemanticError(MessageFormat.format("Duplicate index value `{0}'' for components {1} and {2}", tempIndex, indexMap.get(tempIndex), i + 1));
checkHoles = false;
} else {
indexMap.put(tempIndex, Integer.valueOf(i + 1));
if (maxIndex.compareTo(tempIndex) == -1) {
maxIndex = tempIndex;
}
}
}
component.setMyGovernor(getOfType());
final IValue tempValue2 = getOfType().checkThisValueRef(timestamp, component);
selfReference |= getOfType().checkThisValue(timestamp, tempValue2, lhs, new ValueCheckingOptions(expectedValue, incompleteAllowed, false, true, implicitOmit, strElem));
}
if (checkHoles && maxIndex.compareTo(BigInteger.valueOf(indexMap.size() - 1)) != 0) {
value.getLocation().reportSemanticError("It's not allowed to create hole(s) in constant values");
}
} else {
for (int i = 0, size = value.getNofComponents(); i < size; i++) {
final IValue component = value.getValueByIndex(i);
component.setMyGovernor(getOfType());
if (Value_type.NOTUSED_VALUE.equals(component.getValuetype())) {
if (!incompleteAllowed) {
component.getLocation().reportSemanticError(INCOMPLETEPRESENTERROR);
}
} else {
final IValue tempValue2 = getOfType().checkThisValueRef(timestamp, component);
selfReference |= getOfType().checkThisValue(timestamp, tempValue2, lhs, new ValueCheckingOptions(expectedValue, incompleteAllowed, false, true, implicitOmit, strElem));
}
}
}
value.setLastTimeChecked(timestamp);
return selfReference;
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class Address_Type method checkThisValueRef.
@Override
public /**
* {@inheritDoc}
*/
IValue checkThisValueRef(final CompilationTimeStamp timestamp, final IValue value) {
if (Value_type.UNDEFINED_LOWERIDENTIFIER_VALUE.equals(value.getValuetype())) {
final IReferenceChain tempReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IType refd = getTypeRefd(timestamp, tempReferenceChain);
tempReferenceChain.release();
if (refd == null || this.equals(refd)) {
return value;
}
return refd.checkThisValueRef(timestamp, value);
}
return value;
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class Address_Type method checkRecursions.
@Override
public /**
* {@inheritDoc}
*/
void checkRecursions(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
if (referenceChain.add(this)) {
final IReferenceChain tempReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IType lastType = getTypeRefd(timestamp, tempReferenceChain);
tempReferenceChain.release();
if (lastType != null && !lastType.getIsErroneous(timestamp) && !this.equals(lastType)) {
lastType.checkRecursions(timestamp, referenceChain);
}
}
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class Referenced_Type method checkRecursions.
@Override
public /**
* {@inheritDoc}
*/
void checkRecursions(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
if (referenceChain.add(this)) {
final IReferenceChain tempReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IType t = getTypeRefd(timestamp, tempReferenceChain);
tempReferenceChain.release();
if (t != null && !t.getIsErroneous(timestamp) && !this.equals(t)) {
t.checkRecursions(timestamp, referenceChain);
}
}
}
Aggregations