use of org.eclipse.titan.designer.AST.TTCN3.types.Function_Type in project titan.EclipsePlug-ins by eclipse.
the class Invoke_Template method checkInvoke.
public void checkInvoke(final CompilationTimeStamp timestamp) {
if (getIsErroneous(timestamp) || actualParameterList == null || value == null) {
return;
}
value.setLoweridToReference(timestamp);
IType type = value.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (type != null) {
type = type.getTypeRefdLast(timestamp);
}
if (type == null) {
if (!value.getIsErroneous(timestamp)) {
value.getLocation().reportSemanticError("A value of type function was expected in the argument");
}
setIsErroneous(true);
return;
}
if (!Type_type.TYPE_FUNCTION.equals(type.getTypetype())) {
value.getLocation().reportSemanticError(MessageFormat.format("A value of type function was expected in the argument instead of `{0}''", type.getTypename()));
setIsErroneous(true);
return;
}
if (myScope == null) {
return;
}
myScope.checkRunsOnScope(timestamp, type, this, "call");
final FormalParameterList formalParameterList = ((Function_Type) type).getFormalParameters();
actualParameter_list = new ActualParameterList();
if (!formalParameterList.checkActualParameterList(timestamp, actualParameterList, actualParameter_list)) {
actualParameter_list.setFullNameParent(this);
actualParameter_list.setMyScope(getMyScope());
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Function_Type in project titan.EclipsePlug-ins by eclipse.
the class Start_Referenced_Component_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
Component_Type compType = null;
if (componentReference != null) {
compType = Port_Utility.checkComponentReference(timestamp, this, componentReference, false, false);
}
if (dereferredValue == null) {
return;
}
switch(dereferredValue.getValuetype()) {
case EXPRESSION_VALUE:
if (Operation_type.REFERS_OPERATION.equals(((Expression_Value) dereferredValue).getOperationType())) {
dereferredValue.getLocation().reportSemanticError("A value of a function type was expected in the argument instead of a `refers' operation," + " which does not specify any function type.");
return;
}
break;
case TTCN3_NULL_VALUE:
case FAT_NULL_VALUE:
dereferredValue.getLocation().reportSemanticError("A value of a function type was expected in the argument instead of a `null' value, which does not specify any function type.");
return;
default:
break;
}
dereferredValue.setLoweridToReference(timestamp);
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_type.TYPE_FUNCTION.equals(type.getTypetype())) {
dereferredValue.getLocation().reportSemanticError(MessageFormat.format("A value of type function was expected in the argument of `{0}''", type.getTypename()));
return;
}
final Function_Type functionType = (Function_Type) type;
if (functionType.isRunsOnSelf()) {
dereferredValue.getLocation().reportSemanticError("The argument cannot be a function reference with 'runs on self' clause");
return;
}
if (!functionType.checkStartable(timestamp, getLocation())) {
return;
}
final IType runsOnType = functionType.getRunsOnType(timestamp);
if (compType != null && runsOnType != null && !runsOnType.isCompatible(timestamp, compType, null, null, null)) {
final String message = MessageFormat.format("Component type mismatch: the component reference os of type `{0}'', but functions of type `{1}'' run on `{2}''", compType.getTypename(), functionType.getTypename(), runsOnType.getTypename());
componentReference.getLocation().reportSemanticError(message);
}
final IType returnType = functionType.getReturnType();
if (returnType != null) {
if (functionType.returnsTemplate()) {
dereferredValue.getLocation().reportSemanticWarning(MessageFormat.format("Function of type `{0}'' return a template of type `{1}''," + " which cannot be retrieved when the test component terminates", functionType.getTypename(), returnType.getTypename()));
} 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) {
dereferredValue.getLocation().reportSemanticWarning(MessageFormat.format("Return type of function type `{0}'' is `{1}'', which does not have the `done'' extension attibute." + " When the test component terminates the returnes value cannot be retrived with a `done'' operation", functionType.getTypename(), returnType.getTypename()));
}
}
}
actualParameterList2 = new ActualParameterList();
final FormalParameterList formalParameters = functionType.getFormalParameters();
if (!formalParameters.checkActualParameterList(timestamp, parameters, actualParameterList2)) {
actualParameterList2.setFullNameParent(this);
actualParameterList2.setMyScope(getMyScope());
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Function_Type in project titan.EclipsePlug-ins by eclipse.
the class Scope method checkRunsOnScope.
/**
* Checks that operations that can only be executed in definitions that
* have a runs on scope, are really executed in such a definition. And
* that the required runs on component is compatible with the runs on
* component of the definition.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param type
* the fat type to check (used or referred to by the
* location).
* @param errorLocation
* the location to report the error to.
* @param operation
* the name of the operation.
*/
public void checkRunsOnScope(final CompilationTimeStamp timestamp, final IType type, final ILocateableNode errorLocation, final String operation) {
if (type == null) {
return;
}
Component_Type referencedComponent;
String typename;
switch(type.getTypetype()) {
case TYPE_FUNCTION:
referencedComponent = ((Function_Type) type).getRunsOnType(timestamp);
typename = "function";
break;
case TYPE_ALTSTEP:
referencedComponent = ((Altstep_Type) type).getRunsOnType(timestamp);
typename = "altstep";
break;
default:
return;
}
if (referencedComponent == null) {
return;
}
final RunsOnScope runsOnScope = getScopeRunsOn();
if (runsOnScope == null) {
errorLocation.getLocation().reportSemanticError(MessageFormat.format(RUNSONREQUIRED2, operation, typename, type.getTypename(), referencedComponent.getTypename()));
} else {
final Component_Type localType = runsOnScope.getComponentType();
if (!referencedComponent.isCompatible(timestamp, localType, null, null, null)) {
errorLocation.getLocation().reportSemanticError(MessageFormat.format(RUNSONMISSMATCH2, localType.getTypename(), operation, typename, type.getTypename(), referencedComponent.getTypename()));
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Function_Type in project titan.EclipsePlug-ins by eclipse.
the class SpecificValue_Template method checkSpecificValue.
@Override
public /**
* {@inheritDoc}
*/
void checkSpecificValue(final CompilationTimeStamp timestamp, final boolean allowOmit) {
if (specificValue == null) {
return;
}
switch(specificValue.getValuetype()) {
case EXPRESSION_VALUE:
// checked later
break;
case OMIT_VALUE:
if (!allowOmit) {
getLocation().reportSemanticError(OmitValue_Template.SPECIFICVALUEEXPECTED);
}
return;
default:
return;
}
final Expression_Value expressionValue = (Expression_Value) specificValue;
if (!Operation_type.APPLY_OPERATION.equals(expressionValue.getOperationType())) {
return;
}
expressionValue.setLoweridToReference(timestamp);
IType type = ((ApplyExpression) expressionValue).getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (type == null) {
return;
}
type = type.getTypeRefdLast(timestamp);
if (Type_type.TYPE_FUNCTION.equals(type.getTypetype()) && ((Function_Type) type).returnsTemplate()) {
final ITTCN3Template template = setTemplatetype(timestamp, Template_type.TEMPLATE_INVOKE);
template.checkSpecificValue(timestamp, allowOmit);
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Function_Type 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);
}
}
}
Aggregations