Commit 2ccf27ac authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ added specialised handling of in and out parameters in function calls...

+ added specialised handling of in and out parameters in function calls directly within statement blocks
parent 239d1642
Loading
Loading
Loading
Loading
+47 −2
Original line number Diff line number Diff line
@@ -16,8 +16,11 @@ import de.ugoe.cs.swe.tTCN3.ComponentDef
import de.ugoe.cs.swe.tTCN3.ComponentElementDef
import de.ugoe.cs.swe.tTCN3.ConditionalConstruct
import de.ugoe.cs.swe.tTCN3.ControlStatement
import de.ugoe.cs.swe.tTCN3.ExtFunctionDef
import de.ugoe.cs.swe.tTCN3.FunctionDef
import de.ugoe.cs.swe.tTCN3.FunctionDefList
import de.ugoe.cs.swe.tTCN3.FunctionFormalPar
import de.ugoe.cs.swe.tTCN3.FunctionInstance
import de.ugoe.cs.swe.tTCN3.FunctionLocalDef
import de.ugoe.cs.swe.tTCN3.FunctionLocalInst
import de.ugoe.cs.swe.tTCN3.FunctionStatement
@@ -38,6 +41,7 @@ import de.ugoe.cs.swe.tTCN3.VarInstance
import de.ugoe.cs.swe.tTCN3.VariableRef
import de.ugoe.cs.swe.tTCN3.WithStatement
import de.ugoe.cs.swe.validation.DataFlowHelper.STATUS
import org.eclipse.emf.common.util.EList
import org.eclipse.emf.ecore.EObject
import org.eclipse.xtext.nodemodel.INode
import org.eclipse.xtext.nodemodel.impl.CompositeNode
@@ -418,8 +422,11 @@ class DataFlowValidator extends AbstractDeclarativeValidator {
        if (behavior.alt !== null) {
            behavior.alt.processAltStatement(dfh)

        } else if (behavior.interleaved !== null) {
        } else if (behavior.function !== null) {
            //cse.behavior.function -> might be covered twice? -> no
            behavior.function.processFunctionInstance(dfh)
                
        } else if (behavior.interleaved !== null) {
            behavior.interleaved.processInterleavedStatement(dfh)
                
        } else if (behavior.goto !== null) {
@@ -431,7 +438,6 @@ class DataFlowValidator extends AbstractDeclarativeValidator {
            //cse.behavior.altstep
            //cse.behavior.activate
            //cse.behavior.deactivate -> no filtering as it uses VariableRef
            //cse.behavior.function -> might be covered twice? -> no
            //cse.behavior.testcase
            val values = behavior.eAllOfType(ReferencedValue)
            dfh.checkVariableStatus(values)
@@ -439,6 +445,45 @@ class DataFlowValidator extends AbstractDeclarativeValidator {
        }
    }
    
    protected def void processFunctionInstance(FunctionInstance function, DataFlowHelper dfh) {
            val r = function.ref;
            //TODO: also external functions?
            if (r instanceof FunctionDef) {
                function.processParameters(r.parameterList.params, dfh)
            } else if (r instanceof ExtFunctionDef) {
                function.processParameters(r.list.params, dfh)
            } else if (r instanceof AltstepDef) {
                function.processParameters(r.params.params, dfh)
            } else {
                //handle other cases
                val values = function.eAllOfType(ReferencedValue)
                dfh.checkVariableStatus(values)
            }
    }
    
    protected def void processParameters(FunctionInstance function, EList<FunctionFormalPar> formalParameters, DataFlowHelper dfh) {
        var i = 0;
        val actualParameters = function.params.params
        //actual parameters
        for (p : actualParameters) {
            if (p.template!=null) {
                //get corresponding formal parameter
                val fp = formalParameters.get(i);
                if (fp.value != null) {
                    if (fp.value.inOut.equals("out")) {
                        //update
                        dfh.updateVariableStatus(p.eAllOfType(ReferencedValue).get(0))
                    } else if (fp.value.inOut.equals("in")) {
                        //check
                        dfh.checkVariableStatus(p.eAllOfType(ReferencedValue))
                    }
                    //TODO: how to handle inout?
                }
            }
            i++;
        }
    }

    protected def void processInterleavedStatement(InterleavedConstruct interleaved, DataFlowHelper dfh) {
        val igl = interleaved.eContents.get(0)
        if (igl instanceof InterleavedGuardList) {