Search in sources :

Example 26 with FormalParameter

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

the class Lazy method process.

@Override
protected void process(final IVisitableNode node, final Problems problems) {
    // This variable indicates occurrence of Return_Statement.
    haveToContinue = true;
    // Collect and store FormalParameters.
    formalParameterCollector = new RelevantFormalParameterCollector();
    node.accept(formalParameterCollector);
    // Build structure.
    final RelevantNodeBuilder relevantNodeBuilder = new RelevantNodeBuilder(node);
    node.accept(relevantNodeBuilder);
    // Evaluate tree and return with FormalParameters which have to be evaluated.
    final Set<FormalParameter> shouldBeEvaluated = relevantNodeBuilder.collectRelevantReferences();
    for (final FormalParameter formalParameter : formalParameterCollector.getItems()) {
        final boolean isLazy = formalParameter.getIsLazy();
        String message = null;
        if (shouldBeEvaluated.contains(formalParameter)) {
            if (isLazy) {
                message = "not ";
            }
        } else {
            if (!isLazy) {
                message = "";
            }
        }
        if (message != null) {
            final String msg = MessageFormat.format(ERROR_MESSAGE, formalParameter.getIdentifier().getDisplayName(), message);
            problems.report(formalParameter.getLocation(), msg);
        }
    }
}
Also used : FormalParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter)

Example 27 with FormalParameter

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

the class ReadOnlyInOutPar method process.

@Override
public void process(final IVisitableNode node, final Problems problems) {
    if (node instanceof FormalParameter) {
        final FormalParameter s = (FormalParameter) node;
        if (s.getMyParameterList().getMyDefinition() instanceof Def_Type) {
            return;
        }
        if (!s.getWritten() && !(s.getMyParameterList().getMyDefinition() instanceof Def_Extfunction)) {
            switch(s.getAssignmentType()) {
                case A_PAR_VAL_INOUT:
                case A_PAR_TEMP_INOUT:
                    final String msg = MessageFormat.format(READONLY, s.getDescription());
                    problems.report(s.getLocation(), msg);
                    break;
                default:
                    break;
            }
        }
    }
}
Also used : FormalParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter) Def_Type(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type) Def_Extfunction(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Extfunction)

Example 28 with FormalParameter

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

the class ReadOnlyOutPar method process.

@Override
public void process(final IVisitableNode node, final Problems problems) {
    if (node instanceof FormalParameter) {
        final FormalParameter s = (FormalParameter) node;
        if (s.getMyParameterList().getMyDefinition() instanceof Def_Type) {
            return;
        }
        if (!s.getWritten() && !(s.getMyParameterList().getMyDefinition() instanceof Def_Extfunction)) {
            switch(s.getAssignmentType()) {
                case A_PAR_VAL_OUT:
                case A_PAR_TEMP_OUT:
                    final String msg = MessageFormat.format(READONLY, s.getDescription());
                    problems.report(s.getLocation(), msg);
                    break;
                default:
                    break;
            }
        }
    }
}
Also used : FormalParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter) Def_Type(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type) Def_Extfunction(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Extfunction)

Example 29 with FormalParameter

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

the class ReadingOutParBeforeWritten method process.

@Override
protected void process(final IVisitableNode node, final Problems problems) {
    this.problems = problems;
    if (!(node instanceof FormalParameter)) {
        return;
    }
    final FormalParameter fp = (FormalParameter) node;
    this.toFind = fp;
    final Assignment_type at = fp.getAssignmentType();
    if (at != Assignment_type.A_PAR_VAL_OUT && at != Assignment_type.A_PAR_TEMP_OUT) {
        return;
    }
    final Definition d = fp.getMyParameterList().getMyDefinition();
    final NewFuncVisitor visitor = new NewFuncVisitor();
    // call visitor on function in which the out parameter was found
    d.accept(visitor);
}
Also used : FormalParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter) Assignment_type(org.eclipse.titan.designer.AST.Assignment.Assignment_type) Definition(org.eclipse.titan.designer.AST.TTCN3.definitions.Definition)

Example 30 with FormalParameter

use of org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter 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)

Aggregations

FormalParameter (org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter)18 IType (org.eclipse.titan.designer.AST.IType)12 Assignment (org.eclipse.titan.designer.AST.Assignment)9 Type (org.eclipse.titan.designer.AST.Type)8 CodeSectionType (org.eclipse.titan.designer.AST.GovernedSimple.CodeSectionType)4 IValue (org.eclipse.titan.designer.AST.IValue)4 Identifier (org.eclipse.titan.designer.AST.Identifier)4 Reference (org.eclipse.titan.designer.AST.Reference)4 Def_Var (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var)4 TemplateInstance (org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance)4 HashMap (java.util.HashMap)3 ISubReference (org.eclipse.titan.designer.AST.ISubReference)3 Def_Var_Template (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var_Template)3 Definition (org.eclipse.titan.designer.AST.TTCN3.definitions.Definition)3 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)3 FunctionReferenceDefinition (org.eclipse.titan.designer.AST.TTCN3.types.FunctionReferenceGenerator.FunctionReferenceDefinition)3 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)2 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)2 Location (org.eclipse.titan.designer.AST.Location)2 Module (org.eclipse.titan.designer.AST.Module)2