use of org.eclipse.titan.designer.AST.IReferencingType 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.IReferencingType in project titan.EclipsePlug-ins by eclipse.
the class Selection_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 type = this;
while (null != type && type instanceof IReferencingType && !type.getIsErroneous(timestamp)) {
type = ((IReferencingType) type).getTypeRefd(timestamp, tempReferenceChain);
}
if (newChain) {
tempReferenceChain.release();
}
return type;
}
use of org.eclipse.titan.designer.AST.IReferencingType in project titan.EclipsePlug-ins by eclipse.
the class External_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.IReferencingType in project titan.EclipsePlug-ins by eclipse.
the class Start_Component_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
final Component_Type componentType = Port_Utility.checkComponentReference(timestamp, this, componentReference, false, false);
final Assignment assignment = functionInstanceReference.getRefdAssignment(timestamp, true);
if (assignment == null) {
return;
}
switch(assignment.getAssignmentType()) {
case A_FUNCTION:
case A_FUNCTION_RTEMP:
case A_FUNCTION_RVAL:
break;
default:
functionInstanceReference.getLocation().reportSemanticError(MessageFormat.format(REFERENCETOFUNCTIONWASEXPECTED, assignment.getDescription()));
return;
}
final Def_Function function = (Def_Function) assignment;
if (!function.checkStartable(timestamp, getLocation())) {
return;
}
final IType runsOnType = function.getRunsOnType(timestamp);
if (componentType == null || runsOnType == null) {
return;
}
if (!runsOnType.isCompatible(timestamp, componentType, null, null, null)) {
componentReference.getLocation().reportSemanticError(MessageFormat.format(COMPONENTTYPEMISMATCH, componentType.getTypename(), function.getDescription(), runsOnType.getTypename()));
}
switch(function.getAssignmentType()) {
case A_FUNCTION_RTEMP:
functionInstanceReference.getLocation().reportSemanticWarning(MessageFormat.format(TEMPLATERETURN, function.getFullName(), function.getType(timestamp).getTypename()));
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 message = MessageFormat.format(RETURNWITHOUTDONE, function.getDescription(), function.getType(timestamp).getTypename());
functionInstanceReference.getLocation().reportSemanticWarning(message);
}
break;
}
default:
break;
}
}
use of org.eclipse.titan.designer.AST.IReferencingType in project titan.EclipsePlug-ins by eclipse.
the class Done_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
Port_Utility.checkComponentReference(timestamp, this, componentreference, false, false);
if (componentreference == null) {
lastTimeChecked = timestamp;
return;
}
if (doneMatch != null) {
final boolean[] valueRedirectChecked = new boolean[] { false };
final IType returnType = Port_Utility.getIncomingType(timestamp, doneMatch, redirect, valueRedirectChecked);
if (returnType == null) {
doneMatch.getLocation().reportSemanticError("Cannot determine the return type for value returning done");
} else {
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) {
location.reportSemanticError(MessageFormat.format("Return type `{0}'' does not have `done'' extension attibute", returnType.getTypename()));
returnType.setIsErroneous(true);
}
doneMatch.check(timestamp, returnType);
if (!valueRedirectChecked[0]) {
Port_Utility.checkValueRedirect(timestamp, redirect, returnType);
}
}
} else if (redirect != null) {
redirect.getLocation().reportSemanticError("Redirect cannot be used for the return value without a matching template");
Port_Utility.checkValueRedirect(timestamp, redirect, null);
redirect.setUsedOnLeftHandSide();
}
lastTimeChecked = timestamp;
}
Aggregations