Commit ca148db4 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ added refined support for bounded loops



Change-Id: I6c94528fa8eafe40c1d8263fa69c70b8958422d1
Signed-off-by: default avatarmakedonski <makedonski@informatik.uni-goettingen.de>
parent b9919736
Loading
Loading
Loading
Loading
+102 −5
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ pre {

    var f = new TTCN!TTCN3File();
    var stack = new Map();
    var currentScope;
    
}

post {
@@ -1371,7 +1373,9 @@ operation TDL!Interaction execute() {
    //TODO: simplify
    
    //source behaviour
    if (simulateSUT or self.sourceGate.component.role = TDL!ComponentInstanceRole#Tester) {
    if ((simulateSUT or self.sourceGate.component.role = TDL!ComponentInstanceRole#Tester)
        and (currentScope.isUndefined() or currentScope = self.sourceGate.component)
    ) {
        var sc = self.getMainContext(self.sourceGate.component);
        var sb = stack.get(sc).last();
        var ssl = self.executeSource();
@@ -1380,7 +1384,9 @@ operation TDL!Interaction execute() {

    //TODO: handle multicast?
    //target behaviour
    if (simulateSUT or self.target.first().targetGate.component.role = TDL!ComponentInstanceRole#Tester) {
    if ((simulateSUT or self.target.first().targetGate.component.role = TDL!ComponentInstanceRole#Tester)
        and (currentScope.isUndefined() or currentScope = self.target.first().targetGate.component)
    ) {
        var tc = self.getMainContext(self.target.first().targetGate.component);
        var tb = stack.get(tc).last();
        var t = self.target.first();
@@ -1532,10 +1538,101 @@ operation TDL!Interaction getGuardOp() : TTCN!GuardOp {
}

operation TDL!BoundedLoopBehaviour execute() {
    //TODO
    //TODO: no component?
    for (le in self.numIteration) {
        currentScope = le.scope;
        var sc = self.getMainContext(le.scope);
        var sb = stack.get(sc).last();
    
	    var tsl = new TTCN!FunctionStatementList();
	    sb.stat.add(tsl);
	    
	    var fs = new TTCN!FunctionStatement();
	    fs.basic = new TTCN!BasicStatements();
	    fs.basic.loop = new TTCN!LoopConstruct();
	    fs.basic.loop.forStm = new TTCN!ForStatement();
	
	    tsl.statements.add(fs);
	
	    var init = new TTCN!Initial();
	    fs.basic.loop.forStm.init = init;
	
	    var cv = new TTCN!SingleVarInstance();
	
	    var exp = new TTCN!RelExpression();
	    fs.basic.loop.forStm.expression = exp;
	    
	    //init
	    if (le.expression.isKindOf(TDL!DataInstanceUse)) {
	    
	        cv.name = "cv";
	        cv.ac = ":=";
	        cv.expr = new TTCN!Value();
	        cv.expr.predef = new TTCN!PredefinedValue();
	        cv.expr.predef.integer = "0";
	        
		    init.variable = new TTCN!VarInstance();
	        //TODO: add more comprehensive resolution
		    init.variable.listType = le.expression.dataInstance.dataType.getTTCNType();
		    init.variable.list = new TTCN!VarList();
		    init.variable.list.variables.add(cv);
	    
	        //TODO: the TTCN3 grammar needs to save the operators 
	    
	        //control
	        exp.left = new TTCN!Value();
	        exp.left.ref = new TTCN!ReferencedValue();
	        exp.left.ref.head = new TTCN!Head();
	        exp.left.ref.head.target = cv;
	        
	        exp.right = new TTCN!Value();
	        exp.right.ref = new TTCN!ReferencedValue();
	        exp.right.ref.head = new TTCN!Head();
	        if (le.expression.dataInstance.isValue()) {
	            exp.right.ref.head.target = le.expression.dataInstance.equivalent().defs.list.first();
	        } else {
	            //can it even be template?
		        exp.right.ref.head.target = le.expression.dataInstance.equivalent().base;
	        }
	
	    } else {
	        //TODO:
	    }
	
	    //increment    
	    var assign = new TTCN!Assignment();
	    assign.ref = new TTCN!VariableRef();
	    assign.ref.ref = new TTCN!ReferencedValue();
	    assign.ref.ref.head = new TTCN!Head();
	    assign.ref.ref.head.target = cv;
	    
	    assign.expression = new TTCN!AddExpression();
	    assign.expression.left = new TTCN!Value();
	    assign.expression.left.ref = new TTCN!ReferencedValue();
	    assign.expression.left.ref.head = new TTCN!Head();
	    assign.expression.left.ref.head.target = cv;
	
	    assign.expression.right = new TTCN!Value();
	    assign.expression.right.predef = new TTCN!PredefinedValue();
	    assign.expression.right.predef.integer = "1";
	    
	    fs.basic.loop.forStm.assign = assign;
	    
	    var block = new TTCN!StatementBlock();
	        
	    fs.basic.loop.forStm.statement = block;
	        
	    var cf = self.getMainContext(le.scope);
	    stack.get(cf).add(block);
	    
	    for (b in self.block.behaviour) {
	        b.execute();
	    }
	    
	    stack.get(cf).remove(block);
	    currentScope = null;
    }
    
}

operation TDL!UnboundedLoopBehaviour execute() {