Search in sources :

Example 1 with Altstep_Type

use of org.eclipse.titan.designer.AST.TTCN3.types.Altstep_Type in project titan.EclipsePlug-ins by eclipse.

the class Activate_Referenced_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    isErroneous = false;
    lastTimeChecked = timestamp;
    if (dereferredValue == null) {
        setIsErroneous();
        return;
    }
    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)) {
        setIsErroneous();
        return;
    }
    if (!Type_type.TYPE_ALTSTEP.equals(type.getTypetype())) {
        dereferredValue.getLocation().reportSemanticError(MessageFormat.format(ALTSTEPEXPECTED, type.getTypename()));
        setIsErroneous();
        return;
    }
    if (((Altstep_Type) type).isRunsOnSelf()) {
        dereferredValue.getLocation().reportSemanticError(RUNONSELFERROR);
        setIsErroneous();
        return;
    }
    if (myStatementBlock != null) {
        myStatementBlock.checkRunsOnScope(timestamp, type, this, STATEMENT_NAME);
    }
    actualParameterList2 = new ActualParameterList();
    final FormalParameterList formalParameterList = ((Altstep_Type) type).getFormalParameters();
    if (formalParameterList.checkActualParameterList(timestamp, actualParameterList, actualParameterList2)) {
        setIsErroneous();
        return;
    }
    actualParameterList2.setFullNameParent(this);
    actualParameterList2.setMyScope(getMyScope());
    if (!formalParameterList.checkActivateArgument(timestamp, actualParameterList2, getFullName())) {
        setIsErroneous();
    }
}
Also used : FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) ActualParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList) Altstep_Type(org.eclipse.titan.designer.AST.TTCN3.types.Altstep_Type) IType(org.eclipse.titan.designer.AST.IType)

Example 2 with Altstep_Type

use of org.eclipse.titan.designer.AST.TTCN3.types.Altstep_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()));
        }
    }
}
Also used : Component_Type(org.eclipse.titan.designer.AST.TTCN3.types.Component_Type) RunsOnScope(org.eclipse.titan.designer.AST.TTCN3.definitions.RunsOnScope)

Example 3 with Altstep_Type

use of org.eclipse.titan.designer.AST.TTCN3.types.Altstep_Type in project titan.EclipsePlug-ins by eclipse.

the class Altstep_Reference_Value method generateSingleExpression.

@Override
public /**
 * {@inheritDoc}
 */
StringBuilder generateSingleExpression(final JavaGenData aData) {
    aData.addBuiltinTypeImport("Default_Base");
    aData.addBuiltinTypeImport("TitanAlt_Status");
    final StringBuilder result = new StringBuilder();
    IType governor = myGovernor;
    if (governor == null) {
        governor = getExpressionGovernor(CompilationTimeStamp.getBaseTimestamp(), Expected_Value_type.EXPECTED_TEMPLATE);
    }
    if (governor == null) {
        governor = myLastSetGovernor;
    }
    if (governor == null || referredAltstep == null) {
        ErrorReporter.INTERNAL_ERROR("FATAL ERROR while generating code for value `" + getFullName() + "''");
        return result;
    }
    final IType lastGovernor = governor.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
    result.append(MessageFormat.format("new {0}(new {0}.function_pointer() '{'\n", governor.getGenNameValue(aData, result, myScope)));
    result.append("@Override\n");
    result.append("public String getModuleName() {\n");
    result.append(MessageFormat.format("return \"{0}\";\n", referredAltstep.getMyScope().getModuleScope().getIdentifier().getName()));
    result.append("}\n");
    result.append("@Override\n");
    result.append("public String getDefinitionName() {\n");
    result.append(MessageFormat.format("return \"{0}\";\n", referredAltstep.getIdentifier().getName()));
    result.append("}\n");
    final Altstep_Type altstepType = (Altstep_Type) lastGovernor;
    final String moduleName = referredAltstep.getMyScope().getModuleScope().getName();
    final String altstepName = referredAltstep.getIdentifier().getName();
    final StringBuilder actualParList = altstepType.getFormalParameters().generateCodeActualParlist("");
    result.append("@Override\n");
    result.append("public void invoke_standalone(");
    altstepType.getFormalParameters().generateCode(aData, result);
    result.append(") {\n");
    result.append(MessageFormat.format("{0}.{1}({2});\n", moduleName, altstepName, actualParList));
    result.append("}\n");
    result.append("@Override\n");
    result.append("public Default_Base activate(");
    altstepType.getFormalParameters().generateCode(aData, result);
    result.append(") {\n");
    result.append(MessageFormat.format("return {0}.activate_{1}({2});\n", moduleName, altstepName, actualParList));
    result.append("}\n");
    result.append("@Override\n");
    result.append("public TitanAlt_Status invoke(");
    altstepType.getFormalParameters().generateCode(aData, result);
    result.append(") {\n");
    result.append(MessageFormat.format("return {0}.{1}_instance({2});\n", moduleName, altstepName, actualParList));
    result.append("}\n");
    result.append("})\n");
    return result;
}
Also used : Altstep_Type(org.eclipse.titan.designer.AST.TTCN3.types.Altstep_Type) IType(org.eclipse.titan.designer.AST.IType)

Example 4 with Altstep_Type

use of org.eclipse.titan.designer.AST.TTCN3.types.Altstep_Type in project titan.EclipsePlug-ins by eclipse.

the class ActivateDereferedExpression method checkExpressionOperands.

/**
 * Checks the parameters of the expression and if they are valid in
 * their position in the expression or not.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 * @param expectedValue
 *                the kind of value expected.
 * @param referenceChain
 *                a reference chain to detect cyclic references.
 */
private void checkExpressionOperands(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    value.setLoweridToReference(timestamp);
    IType type = value.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
    if (type != null) {
        type = type.getTypeRefdLast(timestamp);
    }
    if (type == null || type.getIsErroneous(timestamp)) {
        setIsErroneous(true);
        return;
    }
    if (!Type_type.TYPE_ALTSTEP.equals(type.getTypetype())) {
        value.getLocation().reportSemanticError(MessageFormat.format(ALTSTEPEXPECTED, type.getTypename()));
        setIsErroneous(true);
        return;
    }
    actualParameters = new ActualParameterList();
    final FormalParameterList formalParameterList = ((Altstep_Type) type).getFormalParameters();
    if (formalParameterList.checkActualParameterList(timestamp, actualParameterList, actualParameters)) {
        setIsErroneous(true);
        return;
    }
    actualParameters.setFullNameParent(this);
    actualParameters.setMyScope(getMyScope());
    if (!formalParameterList.checkActivateArgument(timestamp, actualParameters, createStringRepresentation())) {
        setIsErroneous(true);
    }
    checkExpressionDynamicPart(expectedValue, OPERATIONNAME, true, true, false);
}
Also used : FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) ActualParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList) Altstep_Type(org.eclipse.titan.designer.AST.TTCN3.types.Altstep_Type) IType(org.eclipse.titan.designer.AST.IType)

Example 5 with Altstep_Type

use of org.eclipse.titan.designer.AST.TTCN3.types.Altstep_Type in project titan.EclipsePlug-ins by eclipse.

the class Unknown_Applied_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    lastTimeChecked = timestamp;
    if (dereferredValue == null) {
        return;
    }
    dereferredValue.setLoweridToReference(timestamp);
    IType type = dereferredValue.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
    if (type != null) {
        type = type.getTypeRefdLast(timestamp);
    }
    if (type == null) {
        return;
    }
    final ActualParameterList tempActualParameters = new ActualParameterList();
    FormalParameterList formalParameterList;
    switch(type.getTypetype()) {
        case TYPE_FUNCTION:
            if (realStatement == null || !Statement_type.S_FUNCTION_APPLIED.equals(realStatement.getType())) {
                realStatement = new Function_Applied_Statement(dereferredValue, actualParameterList, tempActualParameters);
                realStatement.setFullNameParent(this);
                realStatement.setLocation(location);
                realStatement.setMyStatementBlock(getMyStatementBlock(), statementIndex);
            }
            realStatement.check(timestamp);
            if (((Function_Type) type).getReturnType() != null) {
                location.reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNUSEDFUNCTIONRETURNVALUES, GeneralConstants.WARNING, null), MessageFormat.format(UNUSEDRETURNVALUE, type.getTypename()));
            }
            formalParameterList = ((Function_Type) type).getFormalParameters();
            formalParameterList.checkActualParameterList(timestamp, actualParameterList, tempActualParameters);
            break;
        case TYPE_ALTSTEP:
            if (realStatement == null || !Statement_type.S_ALTSTEP_APPLIED.equals(realStatement.getType())) {
                realStatement = new Altstep_Applied_Statement(dereferredValue, actualParameterList, tempActualParameters);
                realStatement.setFullNameParent(this);
                realStatement.setLocation(location);
                realStatement.setMyStatementBlock(getMyStatementBlock(), statementIndex);
            }
            realStatement.check(timestamp);
            formalParameterList = ((Altstep_Type) type).getFormalParameters();
            formalParameterList.checkActualParameterList(timestamp, actualParameterList, tempActualParameters);
            break;
        default:
            dereferredValue.getLocation().reportSemanticError(MessageFormat.format(FUNCTIONORALTSTEPVALUEXPECTED, type.getTypename()));
            break;
    }
    if (myStatementBlock != null) {
        myStatementBlock.checkRunsOnScope(timestamp, type, this, "call");
    }
    tempActualParameters.setFullNameParent(this);
    tempActualParameters.setMyScope(myScope);
}
Also used : FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) ActualParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList) IType(org.eclipse.titan.designer.AST.IType)

Aggregations

IType (org.eclipse.titan.designer.AST.IType)6 Altstep_Type (org.eclipse.titan.designer.AST.TTCN3.types.Altstep_Type)5 ActualParameterList (org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList)4 FormalParameterList (org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList)4 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)1 IValue (org.eclipse.titan.designer.AST.IValue)1 RunsOnScope (org.eclipse.titan.designer.AST.TTCN3.definitions.RunsOnScope)1 Boolean_Type (org.eclipse.titan.designer.AST.TTCN3.types.Boolean_Type)1 Component_Type (org.eclipse.titan.designer.AST.TTCN3.types.Component_Type)1 Function_Type (org.eclipse.titan.designer.AST.TTCN3.types.Function_Type)1 Testcase_Type (org.eclipse.titan.designer.AST.TTCN3.types.Testcase_Type)1 Type (org.eclipse.titan.designer.AST.Type)1