Search in sources :

Example 1 with FunctionReferenceDefinition

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

the class Testcase_Type method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    aData.addBuiltinTypeImport("TitanFloat");
    final String genName = getGenNameOwn();
    final String displayName = getFullName();
    generateCodeTypedescriptor(aData, source);
    final FunctionReferenceDefinition def = new FunctionReferenceDefinition(genName, displayName);
    def.returnType = null;
    def.type = fatType.TESTCASE;
    def.runsOnSelf = false;
    def.isStartable = false;
    def.formalParList = formalParList.generateCode(aData).toString();
    def.actualParList = formalParList.generateCodeActualParlist("").toString();
    def.parameterTypeNames = new ArrayList<String>(formalParList.getNofParameters());
    def.parameterNames = new ArrayList<String>(formalParList.getNofParameters());
    if (formalParList.getNofParameters() > 0) {
        def.formalParList = def.formalParList + ", ";
        def.actualParList = def.actualParList + ", ";
    }
    def.formalParList = def.formalParList + "boolean has_timer, TitanFloat timer_value";
    def.actualParList = def.actualParList + "has_timer, timer_value";
    for (int i = 0; i < formalParList.getNofParameters(); i++) {
        final FormalParameter formalParameter = formalParList.getParameterByIndex(i);
        switch(formalParameter.getAssignmentType()) {
            case A_PAR_VAL:
            case A_PAR_VAL_IN:
            case A_PAR_VAL_INOUT:
            case A_PAR_VAL_OUT:
                def.parameterTypeNames.add(formalParameter.getType(CompilationTimeStamp.getBaseTimestamp()).getGenNameValue(aData, source, getMyScope()));
                break;
            case A_PAR_TEMP_IN:
            case A_PAR_TEMP_INOUT:
            case A_PAR_TEMP_OUT:
                def.parameterTypeNames.add(formalParameter.getType(CompilationTimeStamp.getBaseTimestamp()).getGenNameTemplate(aData, source, getMyScope()));
                break;
            default:
                break;
        }
        def.parameterNames.add(formalParameter.getIdentifier().getName());
    }
    FunctionReferenceGenerator.generateValueClass(aData, source, def);
    FunctionReferenceGenerator.generateTemplateClass(aData, source, def);
    if (hasDoneAttribute()) {
        generateCodeDone(aData, source);
    }
    if (subType != null) {
        subType.generateCode(aData, source);
    }
    generateCodeForCodingHandlers(aData, source);
}
Also used : FormalParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter) FunctionReferenceDefinition(org.eclipse.titan.designer.AST.TTCN3.types.FunctionReferenceGenerator.FunctionReferenceDefinition)

Example 2 with FunctionReferenceDefinition

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

the class Altstep_Type method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    final String genName = getGenNameOwn();
    final String displayName = getFullName();
    generateCodeTypedescriptor(aData, source);
    final FunctionReferenceDefinition def = new FunctionReferenceDefinition(genName, displayName);
    def.returnType = null;
    def.type = fatType.ALTSTEP;
    def.runsOnSelf = runsOnSelf;
    def.isStartable = false;
    def.formalParList = formalParList.generateCode(aData).toString();
    def.actualParList = formalParList.generateCodeActualParlist("").toString();
    def.parameterTypeNames = new ArrayList<String>(formalParList.getNofParameters());
    def.parameterNames = new ArrayList<String>(formalParList.getNofParameters());
    for (int i = 0; i < formalParList.getNofParameters(); i++) {
        final FormalParameter formalParameter = formalParList.getParameterByIndex(i);
        switch(formalParameter.getAssignmentType()) {
            case A_PAR_VAL:
            case A_PAR_VAL_IN:
            case A_PAR_VAL_INOUT:
            case A_PAR_VAL_OUT:
                def.parameterTypeNames.add(formalParameter.getType(CompilationTimeStamp.getBaseTimestamp()).getGenNameValue(aData, source, getMyScope()));
                break;
            case A_PAR_TEMP_IN:
            case A_PAR_TEMP_INOUT:
            case A_PAR_TEMP_OUT:
                def.parameterTypeNames.add(formalParameter.getType(CompilationTimeStamp.getBaseTimestamp()).getGenNameTemplate(aData, source, getMyScope()));
                break;
            default:
                break;
        }
        def.parameterNames.add(formalParameter.getIdentifier().getName());
    }
    FunctionReferenceGenerator.generateValueClass(aData, source, def);
    FunctionReferenceGenerator.generateTemplateClass(aData, source, def);
    if (hasDoneAttribute()) {
        generateCodeDone(aData, source);
    }
    if (subType != null) {
        subType.generateCode(aData, source);
    }
    generateCodeForCodingHandlers(aData, source);
}
Also used : FormalParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter) FunctionReferenceDefinition(org.eclipse.titan.designer.AST.TTCN3.types.FunctionReferenceGenerator.FunctionReferenceDefinition)

Example 3 with FunctionReferenceDefinition

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

the class Function_Type method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    final String genName = getGenNameOwn();
    final String displayName = getFullName();
    generateCodeTypedescriptor(aData, source);
    final FunctionReferenceDefinition def = new FunctionReferenceDefinition(genName, displayName);
    if (returnType == null) {
        def.returnType = null;
    } else {
        if (returnsTemplate) {
            def.returnType = returnType.getGenNameTemplate(aData, source, myScope);
        } else {
            def.returnType = returnType.getGenNameValue(aData, source, myScope);
        }
    }
    def.type = fatType.FUNCTION;
    def.runsOnSelf = runsOnSelf;
    def.isStartable = isStartable;
    def.formalParList = formalParList.generateCode(aData).toString();
    def.actualParList = formalParList.generateCodeActualParlist("").toString();
    def.parameterTypeNames = new ArrayList<String>(formalParList.getNofParameters());
    def.parameterNames = new ArrayList<String>(formalParList.getNofParameters());
    for (int i = 0; i < formalParList.getNofParameters(); i++) {
        final FormalParameter formalParameter = formalParList.getParameterByIndex(i);
        switch(formalParameter.getAssignmentType()) {
            case A_PAR_VAL:
            case A_PAR_VAL_IN:
            case A_PAR_VAL_INOUT:
            case A_PAR_VAL_OUT:
                def.parameterTypeNames.add(formalParameter.getType(CompilationTimeStamp.getBaseTimestamp()).getGenNameValue(aData, source, getMyScope()));
                break;
            case A_PAR_TEMP_IN:
            case A_PAR_TEMP_INOUT:
            case A_PAR_TEMP_OUT:
                def.parameterTypeNames.add(formalParameter.getType(CompilationTimeStamp.getBaseTimestamp()).getGenNameTemplate(aData, source, getMyScope()));
                break;
            default:
                break;
        }
        def.parameterNames.add(formalParameter.getIdentifier().getName());
    }
    FunctionReferenceGenerator.generateValueClass(aData, source, def);
    FunctionReferenceGenerator.generateTemplateClass(aData, source, def);
    if (hasDoneAttribute()) {
        generateCodeDone(aData, source);
    }
    if (subType != null) {
        subType.generateCode(aData, source);
    }
    generateCodeForCodingHandlers(aData, source);
}
Also used : FormalParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter) FunctionReferenceDefinition(org.eclipse.titan.designer.AST.TTCN3.types.FunctionReferenceGenerator.FunctionReferenceDefinition)

Aggregations

FormalParameter (org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter)3 FunctionReferenceDefinition (org.eclipse.titan.designer.AST.TTCN3.types.FunctionReferenceGenerator.FunctionReferenceDefinition)3