Search in sources :

Example 1 with EncodingPrototype_type

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function.EncodingPrototype_type in project titan.EclipsePlug-ins by eclipse.

the class FunctionTypeMappingTarget method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp, final Type source) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    lastTimeChecked = timestamp;
    functionReferenced = null;
    extfunctionReferenced = null;
    if (functionReference == null) {
        return;
    }
    final Assignment assignment = functionReference.getRefdAssignment(timestamp, false);
    if (assignment == null) {
        return;
    }
    assignment.check(timestamp);
    EncodingPrototype_type referencedPrototype;
    Type inputType;
    Type outputType;
    switch(assignment.getAssignmentType()) {
        case A_FUNCTION:
        case A_FUNCTION_RVAL:
        case A_FUNCTION_RTEMP:
            functionReferenced = (Def_Function) assignment;
            referencedPrototype = functionReferenced.getPrototype();
            inputType = functionReferenced.getInputType();
            outputType = functionReferenced.getOutputType();
            break;
        case A_EXT_FUNCTION:
        case A_EXT_FUNCTION_RVAL:
        case A_EXT_FUNCTION_RTEMP:
            extfunctionReferenced = (Def_Extfunction) assignment;
            referencedPrototype = extfunctionReferenced.getPrototype();
            inputType = extfunctionReferenced.getInputType();
            outputType = extfunctionReferenced.getOutputType();
            break;
        default:
            functionReference.getLocation().reportSemanticError(MessageFormat.format("Reference to a function or external function was expected instead of {0}", assignment.getDescription()));
            return;
    }
    if (EncodingPrototype_type.NONE.equals(referencedPrototype)) {
        functionReference.getLocation().reportSemanticError(MessageFormat.format("The referenced {0} does not have `prototype'' attribute", assignment.getDescription()));
        return;
    }
    if (inputType != null && source != null && !source.isIdentical(timestamp, inputType)) {
        final String message = MessageFormat.format("The input type of {0} must be the same as the source type of the mapping: `{1}'' was expected instead of `{2}''", assignment.getDescription(), source.getTypename(), inputType.getTypename());
        source.getLocation().reportSemanticError(message);
    }
    if (outputType != null && !targetType.isIdentical(timestamp, outputType)) {
        final String message = MessageFormat.format("The output type of {0} must be the same as the target type of the mapping: `{1}'' was expected instead of `{2}''", assignment.getDescription(), targetType.getTypename(), outputType.getTypename());
        targetType.getLocation().reportSemanticError(message);
    }
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) Type(org.eclipse.titan.designer.AST.Type) EncodingPrototype_type(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function.EncodingPrototype_type)

Aggregations

Assignment (org.eclipse.titan.designer.AST.Assignment)1 EncodingPrototype_type (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function.EncodingPrototype_type)1 Type (org.eclipse.titan.designer.AST.Type)1