use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class UnusedStartedRefFuncRetVal method process.
@Override
public void process(final IVisitableNode node, final Problems problems) {
if (node instanceof Start_Referenced_Component_Statement) {
final CompilationTimeStamp timestamp = CompilationTimeStamp.getBaseTimestamp();
final Start_Referenced_Component_Statement s = (Start_Referenced_Component_Statement) node;
final Value dereferredValue = s.getDereferredValue();
if (dereferredValue == null) {
return;
}
switch(dereferredValue.getValuetype()) {
case EXPRESSION_VALUE:
if (Operation_type.REFERS_OPERATION.equals(((Expression_Value) dereferredValue).getOperationType())) {
return;
}
break;
case TTCN3_NULL_VALUE:
case FAT_NULL_VALUE:
return;
default:
break;
}
IType type = dereferredValue.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (type != null) {
type = type.getTypeRefdLast(timestamp);
}
if (type == null || type.getIsErroneous(timestamp)) {
return;
}
if (!(type instanceof Function_Type)) {
return;
}
final Function_Type functionType = (Function_Type) type;
if (functionType.isRunsOnSelf()) {
return;
}
if (!functionType.isStartable(timestamp)) {
return;
}
final IType returnType = functionType.getReturnType();
if (returnType == null) {
return;
}
if (functionType.returnsTemplate()) {
return;
}
IType lastType = returnType;
boolean returnTypeCorrect = false;
while (!returnTypeCorrect) {
if (lastType.hasDoneAttribute()) {
returnTypeCorrect = true;
break;
}
if (lastType instanceof IReferencingType) {
final IReferenceChain refChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IType refd = ((IReferencingType) lastType).getTypeRefd(timestamp, refChain);
refChain.release();
if (lastType != refd) {
lastType = refd;
} else {
break;
}
} else {
break;
}
}
if (!returnTypeCorrect) {
final String msg = MessageFormat.format(PROBLEM, functionType.getTypename(), returnType.getTypename());
problems.report(dereferredValue.getLocation(), msg);
}
}
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Integer_Type method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (null != lastTimeChecked && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
if (null != myScope) {
final Module module = myScope.getModuleScope();
if (null != module) {
if (module.getSkippedFromSemanticChecking()) {
return;
}
}
}
isErroneous = false;
if (null == namedNumbers) {
parseBlockInt();
}
if (isErroneous || null == namedNumbers) {
return;
}
/* check named numbers */
final Map<String, Identifier> nameMap = new HashMap<String, Identifier>();
for (int i = 0, size = namedNumbers.getSize(); i < size; i++) {
final NamedValue namedValue = namedNumbers.getNamedValueByIndex(i);
final Identifier identifier = namedValue.getName();
if (nameMap.containsKey(identifier.getName())) {
final Location tempLocation = nameMap.get(identifier.getName()).getLocation();
tempLocation.reportSingularSemanticError(MessageFormat.format(Assignments.DUPLICATEDEFINITIONFIRST, identifier.getDisplayName()));
identifier.getLocation().reportSemanticError(MessageFormat.format(Assignments.DUPLICATEDEFINITIONREPEATED, identifier.getDisplayName()));
} else {
nameMap.put(identifier.getName(), identifier);
}
}
final Map<Integer, NamedValue> valueMap = new HashMap<Integer, NamedValue>();
for (int i = 0, size = namedNumbers.getSize(); i < size; i++) {
final NamedValue namedValue = namedNumbers.getNamedValueByIndex(i);
final IValue value = namedValue.getValue();
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = value.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (last.getIsErroneous(timestamp)) {
continue;
}
switch(last.getValuetype()) {
case INTEGER_VALUE:
{
final Integer_Value integerValue = (Integer_Value) last;
if (integerValue.isNative()) {
final Integer intValue = Integer.valueOf(integerValue.intValue());
if (valueMap.containsKey(intValue)) {
value.getLocation().reportSemanticError(MessageFormat.format("Duplicate number {0} for name `{1}''", intValue, namedValue.getName().getDisplayName()));
final NamedValue temp = valueMap.get(intValue);
temp.getLocation().reportSemanticError(MessageFormat.format("Number {0} is already assigned to name `{1}''", intValue, temp.getName().getDisplayName()));
} else {
valueMap.put(intValue, namedValue);
}
} else {
value.getLocation().reportSemanticError(MessageFormat.format("Integer value `{0}'' is too big to be used as a named number", integerValue.getValueValue()));
value.setIsErroneous(true);
}
break;
}
default:
namedValue.getLocation().reportSemanticError(MessageFormat.format("INTEGER value was expected for named number `{0}''", namedValue.getName().getDisplayName()));
value.setIsErroneous(true);
break;
}
}
nameMap.clear();
if (null != constraints) {
constraints.check(timestamp);
}
if (myScope != null) {
checkEncode(timestamp);
checkVariants(timestamp);
}
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Sequence_Type method trCompsof.
/**
* Check the components of member to reveal possible recursive
* referencing.
*
* @param timestamp
* the actual compilation cycle.
* @param referenceChain
* the reference chain used to detect recursive
* referencing
*/
public void trCompsof(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
if (trCompsofTimestamp != null && !trCompsofTimestamp.isLess(timestamp)) {
return;
}
if (referenceChain != null) {
components.trCompsof(timestamp, referenceChain, false);
} else {
final IReferenceChain temporalReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
components.trCompsof(timestamp, temporalReferenceChain, false);
temporalReferenceChain.release();
}
trCompsofTimestamp = timestamp;
components.trCompsof(timestamp, null, true);
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Set_Type method trCompsof.
/**
* Check the components of member to reveal possible recursive
* referencing.
*
* @param timestamp
* the actual compilation cycle.
* @param referenceChain
* the reference chain used to detect recursive
* referencing
*/
public void trCompsof(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
if (trCompsofTimestamp != null && !trCompsofTimestamp.isLess(timestamp)) {
return;
}
if (referenceChain != null) {
components.trCompsof(timestamp, referenceChain, false);
} else {
final IReferenceChain temporalReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
components.trCompsof(timestamp, temporalReferenceChain, false);
temporalReferenceChain.release();
}
trCompsofTimestamp = timestamp;
components.trCompsof(timestamp, null, true);
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class ObjectClassField_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 (null == refd) {
return value;
}
return refd.checkThisValueRef(timestamp, value);
}
return value;
}
Aggregations