Commit 5f4005ca authored by Daniel Honsel's avatar Daniel Honsel
Browse files

fixed timer references

parent 3b520ffc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -168,7 +168,7 @@ AltstepDef:
	local=AltstepLocalDefList guard=AltGuardList RBRACKET;

AltstepLocalDefList:
	{AltstepLocalDefList} (local+=AltstepLocalDef withstm+=WithStatement? sc+=SEMICOLON?)*;
	{AltstepLocalDefList} (defs+=AltstepLocalDef withstats+=WithStatement? sc+=SEMICOLON?)*;

AltstepLocalDef:
	variable=VarInstance | timer=TimerInstance | const=ConstDef | template=TemplateDef;
+18 −14
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ class TTCN3ScopeHelper {
	}

	def static void scopeAltstepLocalDefList(RefValue variable, AltstepLocalDefList localList, ArrayList<EObject> list) {
		for (AltstepLocalDef a : localList.local.filter[it != null]) {
		for (AltstepLocalDef a : localList.defs.filter[it != null]) {
			if (a.const != null) {
				val constDefList = a.const.defs as ConstList
				for (SingleConstDef d : constDefList.list) {
@@ -209,12 +209,15 @@ class TTCN3ScopeHelper {

	def static void scopeAltstepExtendedDefList(RefValue variable, AltstepDef altstep, ArrayList<EObject> list) {
		if (altstep.spec != null) {
			componentScopeValueRefs(altstep.spec.component, list)
			componentScopeValueRefs(altstep.spec.component, list, false)
		}
		if (list.contains(variable)) {
			list.remove(variable)
		}
	}

	def private static void componentScopeValueRefs(ComponentDef component, ArrayList<EObject> list) {

	def static void componentScopeValueRefs(ComponentDef component, ArrayList<EObject> list, boolean onlyTimer) {
		if (!onlyTimer) {
			// TODO: template parameters l.element.variable.tempList
			for (ComponentDefList l : component.defs.filter[it.element.variable != null]) {
				if (l.element.variable.list != null) {
@@ -223,18 +226,19 @@ class TTCN3ScopeHelper {
					}
				}
			}
		for (ComponentDefList l : component.defs.filter[it.element.timer != null]) {
			for (SingleVarInstance v : l.element.timer.list.variables) {
			for (ComponentDefList l : component.defs.filter[it.element.const != null]) {
				for (SingleConstDef v : l.element.const.defs.list) {
					list.add(v)
				}
			}
		for (ComponentDefList l : component.defs.filter[it.element.const != null]) {
			for (SingleConstDef v : l.element.const.defs.list) {
		}
		for (ComponentDefList l : component.defs.filter[it.element.timer != null]) {
			for (SingleVarInstance v : l.element.timer.list.variables) {
				list.add(v)
			}
		}
		for (ComponentDef e : component.extends) {
			componentScopeValueRefs(e, list)
			componentScopeValueRefs(e, list, onlyTimer)
		}
	}
}
+44 −0
Original line number Diff line number Diff line
package de.ugoe.cs.swe.scoping

import de.ugoe.cs.swe.tTCN3.AltstepDef
import de.ugoe.cs.swe.tTCN3.AltstepLocalDef
import de.ugoe.cs.swe.tTCN3.AltstepLocalDefList
import de.ugoe.cs.swe.tTCN3.ComponentDef
import de.ugoe.cs.swe.tTCN3.ComponentDefList
import de.ugoe.cs.swe.tTCN3.ControlStatementOrDefList
import de.ugoe.cs.swe.tTCN3.EnumDefNamed
import de.ugoe.cs.swe.tTCN3.FieldSpec
import de.ugoe.cs.swe.tTCN3.ForStatement
import de.ugoe.cs.swe.tTCN3.FunctionDef
import de.ugoe.cs.swe.tTCN3.GroupDef
import de.ugoe.cs.swe.tTCN3.Initial
import de.ugoe.cs.swe.tTCN3.ModuleControlBody
import de.ugoe.cs.swe.tTCN3.ModuleControlPart
import de.ugoe.cs.swe.tTCN3.ModuleDefinition
import de.ugoe.cs.swe.tTCN3.ModuleDefinitionsList
@@ -22,11 +25,13 @@ import de.ugoe.cs.swe.tTCN3.ReferencedType
import de.ugoe.cs.swe.tTCN3.SetDefNamed
import de.ugoe.cs.swe.tTCN3.SetOfDefNamed
import de.ugoe.cs.swe.tTCN3.SignatureDef
import de.ugoe.cs.swe.tTCN3.SingleVarInstance
import de.ugoe.cs.swe.tTCN3.StatementBlock
import de.ugoe.cs.swe.tTCN3.StructuredTypeDef
import de.ugoe.cs.swe.tTCN3.TTCN3Module
import de.ugoe.cs.swe.tTCN3.TemplateDef
import de.ugoe.cs.swe.tTCN3.TestcaseDef
import de.ugoe.cs.swe.tTCN3.TimerRefOrAny
import de.ugoe.cs.swe.tTCN3.TypeDef
import de.ugoe.cs.swe.tTCN3.UnionDefNamed
import java.util.ArrayList
@@ -139,6 +144,45 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
		scopeFor(inner)
	}

	def IScope scope_TimerRefOrAny_ref(TimerRefOrAny variable, EReference ref) {
		val list = newArrayList
		var parent = variable.eContainer

		while (parent != null) {
			if (parent instanceof AltstepDef) {
				if (parent.spec != null) {
					componentScopeValueRefs(parent.spec.component, list, true)
				}
				for (AltstepLocalDef d : parent.local.defs) {
					if (d.timer != null) {
						for (SingleVarInstance v : d.timer.list.variables) {
							list.add(v)
						}
					}
				}
			} else if (parent instanceof ComponentDef) {
				for (ComponentDefList l : parent.defs) {
					if (l.element.timer != null) {
						for (SingleVarInstance v : l.element.timer.list.variables) {
							list.add(v)
						}
					}
				}

			} else if (parent instanceof ModuleControlBody) {
				for (ControlStatementOrDefList l : parent.list) {
					if (l.def.localInst != null && l.def.localInst.timer != null) {
						for (SingleVarInstance v : l.def.localInst.timer.list.variables) {
							list.add(v)
						}
					}
				}
			}
			parent = parent.eContainer
		}
		scopeFor(list)
	}

	def IScope scope_PortOrAny_ref(PortOrAny spec, EReference ref) {
		val altstep = spec.findDesiredParent(typeof(AltstepDef)) as AltstepDef
		val inner = newArrayList
+1 −1
Original line number Diff line number Diff line
@@ -494,7 +494,7 @@ class TTCN3Validator extends AbstractTTCN3Validator {
	}

	def private boolean checkNameClashAltstepLocalDefList(AltstepLocalDefList list, RefValue variable) {
		for (AltstepLocalDef a : list.local.filter[it != null]) {
		for (AltstepLocalDef a : list.defs.filter[it != null]) {

			if (a.const != null) {
				val constDefList = a.const.defs as ConstList