use of org.eclipse.titan.designer.AST.IReferencingType in project titan.EclipsePlug-ins by eclipse.
the class UnusedStartedFuncRetVal method process.
@Override
public void process(final IVisitableNode node, final Problems problems) {
if (node instanceof Start_Component_Statement) {
final CompilationTimeStamp timestamp = CompilationTimeStamp.getBaseTimestamp();
final Start_Component_Statement s = (Start_Component_Statement) node;
final Component_Type compType = Port_Utility.checkComponentReference(timestamp, s, s.getComponent(), false, false);
final Assignment assignment = s.getFunctionInstanceReference().getRefdAssignment(timestamp, false);
if (assignment == null) {
return;
}
switch(assignment.getAssignmentType()) {
case A_FUNCTION:
case A_FUNCTION_RTEMP:
case A_FUNCTION_RVAL:
break;
default:
return;
}
final Def_Function function = (Def_Function) assignment;
final IType runsOnType = function.getRunsOnType(timestamp);
if (compType == null || runsOnType == null || !function.isStartable()) {
return;
}
switch(function.getAssignmentType()) {
case A_FUNCTION_RTEMP:
break;
case A_FUNCTION_RVAL:
IType type = function.getType(timestamp);
boolean returnTypeCorrect = false;
while (!returnTypeCorrect) {
if (type.hasDoneAttribute()) {
returnTypeCorrect = true;
break;
}
if (type instanceof IReferencingType) {
final IReferenceChain refChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IType refd = ((IReferencingType) type).getTypeRefd(timestamp, refChain);
refChain.release();
if (type != refd) {
type = refd;
} else {
break;
}
} else {
break;
}
}
if (!returnTypeCorrect) {
final String msg = MessageFormat.format(PROBLEM, function.getDescription(), function.getType(timestamp).getTypename());
problems.report(s.getFunctionInstanceReference().getLocation(), msg);
}
break;
default:
break;
}
}
}
use of org.eclipse.titan.designer.AST.IReferencingType in project titan.EclipsePlug-ins by eclipse.
the class Address_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 lastType = this;
while (lastType != null && lastType instanceof IReferencingType && !lastType.getIsErroneous(timestamp)) {
lastType = ((IReferencingType) lastType).getTypeRefd(timestamp, tempReferenceChain);
}
if (newChain) {
tempReferenceChain.release();
}
if (lastType != null && lastType.getIsErroneous(timestamp)) {
setIsErroneous(true);
}
return lastType;
}
use of org.eclipse.titan.designer.AST.IReferencingType in project titan.EclipsePlug-ins by eclipse.
the class TTCN3Template method checkLengthRestriction.
/**
* Checks that if there is a length restriction applied to this
* template, it is semantically correct.
*
* @param timestamp
* the time stamp of the actual semantic check cycle.
* @param type
* the type the template is being checked against.
*/
protected void checkLengthRestriction(final CompilationTimeStamp timestamp, final IType type) {
if (lengthRestriction == null) {
return;
}
lengthRestriction.setMyScope(myScope);
lengthRestriction.check(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (type instanceof IReferencingType) {
final IReferenceChain refChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IType last = ((IReferencingType) type).getTypeRefd(timestamp, refChain);
refChain.release();
if (!last.getIsErroneous(timestamp)) {
checkLengthRestriction(timestamp, last);
}
return;
}
if (type.getIsErroneous(timestamp)) {
return;
}
final Type_type typeType = type.getTypetypeTtcn3();
switch(typeType) {
case TYPE_PORT:
// the error was already reported.
return;
case TYPE_ARRAY:
lengthRestriction.checkArraySize(timestamp, ((Array_Type) type).getDimension());
break;
case TYPE_BITSTRING:
case TYPE_HEXSTRING:
case TYPE_OCTETSTRING:
case TYPE_CHARSTRING:
case TYPE_UCHARSTRING:
case TYPE_SEQUENCE_OF:
case TYPE_SET_OF:
break;
default:
lengthRestriction.getLocation().reportSemanticError(MessageFormat.format("Length restriction cannot be used in template of type `{0}''", type.getTypename()));
return;
}
checkTemplateSpecificLengthRestriction(timestamp, typeType);
}
Aggregations