Просмотр исходного кода

Changed generators to use common SExecExtensions

Andreas Mülder 13 лет назад
Родитель
Сommit
5b4cc82b8c
24 измененных файлов с 327 добавлено и 637 удалено
  1. 0 26
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Base.xtend
  2. 34 3
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CCodeGenerator.java
  3. 13 3
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/INaming.java
  4. 10 7
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CSCTGenerator.xtend
  5. 11 1
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/ActionCode.xtend
  6. 11 1
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/FlowCode.xtend
  7. 0 57
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/GeneratorEntryAccess.java
  8. 38 27
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Naming.xtend
  9. 26 219
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Navigation.xtend
  10. 19 11
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Statemachine.xtend
  11. 26 20
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineC.xtend
  12. 13 4
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineRequired.xtend
  13. 10 0
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Timer.xtend
  14. 10 0
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Types.xtend
  15. 31 0
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/types/CTypeSystemAccess.xtend
  16. 3 4
      plugins/org.yakindu.sct.generator.java/.settings/org.eclipse.core.resources.prefs
  17. 0 13
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/INaming.java
  18. 0 2
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/IStatemachine.xtend
  19. 1 0
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/JavaCodeGenerator.java
  20. 24 0
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/JavaKeywords.java
  21. 22 23
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/Naming.xtend
  22. 17 211
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/Navigation.xtend
  23. 4 4
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/StatemachineInterface.xtend
  24. 4 1
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/JavaTypeSystemAccess.xtend

+ 0 - 26
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Base.xtend

@@ -1,26 +0,0 @@
-package org.yakindu.sct.generator.c
-
-import org.yakindu.sct.model.sgen.GeneratorEntry
-import org.yakindu.base.types.Type
-
-class Base {
-	
-		def licenseHeader(GeneratorEntry it) {
-//		 .getFeatureConfiguration(getLicenseFeature())!=null
-//		&& this.genEntry().getFeatureConfiguration(getLicenseFeature()).getParameterValue(getLicenseText()) != null then
-//		this.genEntry().getFeatureConfiguration(getLicenseFeature()).getParameterValue(getLicenseText()).getStringValue()
-//	else 
-//		null;	
-	}
-	
-	def cPrimitive(Type it) {
-		switch (if (it == null) 'void' else name ) {
-			case 'void' 	: 'void'
-			case 'integer'	: 'sc_integer'
-			case 'real'		: 'sc_real'
-			case 'boolean'	: 'sc_boolean'
-			case 'string'	: 'sc_string'
-		}
-	}
-	
-}

+ 34 - 3
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CCodeGenerator.java

@@ -1,23 +1,54 @@
+/**
+ * Copyright (c) 2012 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
 package org.yakindu.sct.generator.c;
 
 import static org.yakindu.sct.generator.core.util.GeneratorUtils.isDumpSexec;
 
+import org.yakindu.base.types.ITypeSystemAccess;
+import org.yakindu.sct.generator.c.types.CTypeSystemAccess;
 import org.yakindu.sct.generator.core.impl.GenericJavaBasedGenerator;
 import org.yakindu.sct.model.sexec.ExecutionFlow;
 import org.yakindu.sct.model.sgen.GeneratorEntry;
 import org.yakindu.sct.model.sgraph.Statechart;
 
+import com.google.inject.Binder;
+import com.google.inject.Module;
+import com.google.inject.util.Modules;
+
+/**
+ * 
+ * @author andreas muelder
+ * 
+ */
 public class CCodeGenerator extends GenericJavaBasedGenerator {
 
 	@Override
 	public void runGenerator(Statechart statechart, GeneratorEntry entry) {
-		CSCTGenerator delegate = getInjector(entry).getInstance(CSCTGenerator.class);
-		
+		CSCTGenerator delegate = getInjector(entry).getInstance(
+				CSCTGenerator.class);
 		ExecutionFlow flow = createExecutionFlow(statechart, entry);
-		
 		if (isDumpSexec(entry)) {
 			dumpSexec(entry, flow);
 		}
 		delegate.generate(flow, entry, getFileSystemAccess(entry));
 	}
+
+	@Override
+	protected Module createModule(GeneratorEntry entry) {
+		Module module = super.createModule(entry);
+		return Modules.override(module).with(new Module() {
+			public void configure(Binder binder) {
+				binder.bind(ITypeSystemAccess.class)
+						.to(CTypeSystemAccess.class);
+			}
+		});
+	}
 }

+ 13 - 3
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/INaming.java

@@ -1,7 +1,17 @@
+/**
+ * Copyright (c) 2012 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
 package org.yakindu.sct.generator.c;
 
-public interface INaming {
-	public static final String[] C_KEYWORDS = { "alignas", "alignof", "and",
+public interface CKeywords {
+	public static final String[] KEYWORDS = { "alignas", "alignof", "and",
 			"and_eq", "asm", "auto", "bitand", "bitor", "bool", "break",
 			"case", "catch", "char", "char16_t", "char32_t", "class", "compl",
 			"const", "constexpr", "const_cast", "continue", "decltype",
@@ -15,5 +25,5 @@ public interface INaming {
 			"switch", "template", "this", "thread_local", "throw", "true",
 			"try", "typedef", "typeid", "typename", "union", "unsigned",
 			"using", "virtual", "void", "volatile", "wchar_t", "while", "xor",
-			"xor_eq"};
+			"xor_eq" };
 }

+ 10 - 7
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CSCTGenerator.xtend

@@ -1,3 +1,13 @@
+/**
+ * Copyright (c) 2012 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
 package org.yakindu.sct.generator.c
 
 import com.google.inject.Inject
@@ -19,17 +29,10 @@ class CSCTGenerator implements IExecutionFlowGenerator {
 	@Inject extension StatemachineC
 	@Inject extension StatemachineRequired
 	
-//	@Inject protected GeneratorEntry entry
- 	
-
-	
 	override generate(ExecutionFlow flow, GeneratorEntry entry, IFileSystemAccess fsa) {
 
 		flow.generateTypesH(flow.sourceElement as Statechart, fsa)
 		
-//		flow.generateTimerH(flow.sourceElement as Statechart, fsa)
-//		flow.generateTimerC(flow.sourceElement as Statechart, fsa)
-
 		flow.generateStatemachineH(flow.sourceElement as Statechart, fsa)
 		flow.generateStatemachineClientH(flow.sourceElement as Statechart, fsa)
 

+ 11 - 1
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/ActionCode.xtend

@@ -1,3 +1,13 @@
+/**
+ * Copyright (c) 2012 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
 package org.yakindu.sct.generator.c
 
 import com.google.inject.Inject
@@ -34,7 +44,7 @@ import org.yakindu.sct.model.stext.validation.ITypeInferrer
 import org.yakindu.sct.model.stext.stext.ShiftExpression
 import org.yakindu.sct.model.stext.stext.ParenthesizedExpression
 
-class ActionCode {
+class ExpressionCode {
 	
 	@Inject extension Naming
 	@Inject extension Navigation

+ 11 - 1
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/FlowCode.xtend

@@ -1,3 +1,13 @@
+/**
+ * Copyright (c) 2012 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
 package org.yakindu.sct.generator.c
 
 import com.google.inject.Inject
@@ -20,7 +30,7 @@ class FlowCode {
 	
 	@Inject extension Naming
 	@Inject extension Navigation
-	@Inject extension ActionCode
+	@Inject extension ExpressionCode
 	
 	
  

+ 0 - 57
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/GeneratorEntryAccess.java

@@ -1,57 +0,0 @@
-package org.yakindu.sct.generator.c;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.yakindu.sct.model.sgen.GeneratorEntry;
-
-public class GeneratorEntryAccess {
-	public static void setGeneratorEntry(EObject obj, GeneratorEntry entry) {
-		ProxyAdapter<?> adapter = (ProxyAdapter<?>) EcoreUtil.getAdapter(
-				obj.eAdapters(), ProxyAdapter.class);
-		if (adapter != null) {
-			throw new IllegalStateException("One Adapter was already added");
-		}
-		obj.eAdapters().add(new ProxyAdapter<GeneratorEntry>(entry));
-	}
-
-	public static GeneratorEntry getGeneratorEntry(EObject obj) {
-		ProxyAdapter<?> adapter = (ProxyAdapter<?>) EcoreUtil.getAdapter(
-				obj.eAdapters(), ProxyAdapter.class);
-		if (adapter != null) {
-			Object entry = adapter.getEntry();
-			if (entry instanceof GeneratorEntry) {
-				return (GeneratorEntry) entry;
-			}
-		}
-		return null;
-	}
-
-	public static class ProxyAdapter<T> implements Adapter {
-		private final T entry;
-
-		public ProxyAdapter(T entry) {
-			this.entry = entry;
-		}
-
-		public T getEntry() {
-			return entry;
-		}
-
-		public void notifyChanged(Notification notification) {
-		}
-
-		public Notifier getTarget() {
-			return null;
-		}
-
-		public void setTarget(Notifier newTarget) {
-		}
-
-		public boolean isAdapterForType(Object type) {
-			return type == ProxyAdapter.class;
-		}
-	}
-}

+ 38 - 27
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Naming.xtend

@@ -1,33 +1,44 @@
-package org.yakindu.sct.generator.c
+/**
+ * Copyright (c) 2012 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.generator.c
+
+import com.google.inject.Inject
+import java.util.Arrays
+import java.util.List
+import org.eclipse.emf.ecore.EObject
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sexec.ExecutionNode
+import org.yakindu.sct.model.sexec.ExecutionScope
+import org.yakindu.sct.model.sexec.ExecutionState
+import org.yakindu.sct.model.sexec.Step
+import org.yakindu.sct.model.sgraph.Scope
+import org.yakindu.sct.model.stext.stext.EventDefinition
+import org.yakindu.sct.model.stext.stext.InterfaceScope
+import org.yakindu.sct.model.stext.stext.InternalScope
+import org.yakindu.sct.model.stext.stext.OperationDefinition
+import org.yakindu.sct.model.stext.stext.VariableDefinition
+import org.yakindu.sct.model.sgraph.Event
+import org.yakindu.sct.model.stext.naming.StextNameProvider
+import org.yakindu.sct.model.sgraph.State
+import java.util.regex.Pattern
+import java.util.regex.Matcher
+import org.yakindu.sct.generator.c.CKeywords
+import org.yakindu.base.types.ITypeSystemAccess
 
-import com.google.inject.Inject
-import java.util.Arrays
-import java.util.List
-import org.eclipse.emf.ecore.EObject
-import org.yakindu.sct.model.sexec.ExecutionFlow
-import org.yakindu.sct.model.sexec.ExecutionNode
-import org.yakindu.sct.model.sexec.ExecutionScope
-import org.yakindu.sct.model.sexec.ExecutionState
-import org.yakindu.sct.model.sexec.Step
-import org.yakindu.sct.model.sgraph.Scope
-import org.yakindu.sct.model.stext.stext.EventDefinition
-import org.yakindu.sct.model.stext.stext.InterfaceScope
-import org.yakindu.sct.model.stext.stext.InternalScope
-import org.yakindu.sct.model.stext.stext.OperationDefinition
-import org.yakindu.sct.model.stext.stext.VariableDefinition
-import org.yakindu.sct.model.sgraph.Event
-import org.yakindu.sct.model.stext.naming.StextNameProvider
-import org.yakindu.sct.model.sgraph.State
-import java.util.regex.Pattern
-import java.util.regex.Matcher
-
-class Naming implements INaming{
+class Naming implements CKeywords{
 
 	@Inject
 	extension Navigation
 	
-	@Inject
-	extension Base
+	@Inject extension ITypeSystemAccess
 	
 	@Inject
 	private StextNameProvider provider
@@ -239,7 +250,7 @@ class Naming implements INaming{
 	def scHandle() { 'handle' }
 	
 	def valueParams(EventDefinition it) {
-		if (hasValue) ', ' + type.cPrimitive + ' value' 
+		if (hasValue) ', ' + type.targetLanguageTypeName + ' value' 
 		else ''
 	}
 	
@@ -264,7 +275,7 @@ class Naming implements INaming{
 		
 	def boolean isCKeyword(String name) {
 		var String lowName = name.toLowerCase();
-		for (String keyword : Arrays::asList(C_KEYWORDS)) {
+		for (String keyword : Arrays::asList(KEYWORDS)) {
 			var Pattern pattern = Pattern::compile("^" + keyword + "$");
 			var Matcher matcher = pattern.matcher(lowName);
 			if (matcher.find()) {

+ 26 - 219
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Navigation.xtend

@@ -1,32 +1,28 @@
-package org.yakindu.sct.generator.c
+/**
+ * Copyright (c) 2012 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.generator.c
+
+import java.util.ArrayList
+import org.eclipse.emf.ecore.EObject
+import org.yakindu.sct.model.extensions.SExecExtensions
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sexec.TimeEvent
+import org.yakindu.sct.model.sgraph.Declaration
+import org.yakindu.sct.model.sgraph.Scope
+import org.yakindu.sct.model.stext.stext.EventDefinition
+import org.yakindu.sct.model.stext.stext.OperationDefinition
 
-import java.util.ArrayList
-import java.util.List
-import org.eclipse.emf.ecore.EObject
-import org.yakindu.sct.model.sexec.Check
-import org.yakindu.sct.model.sexec.ExecutionFlow
-import org.yakindu.sct.model.sexec.ExecutionNode
-import org.yakindu.sct.model.sexec.ExecutionRegion
-import org.yakindu.sct.model.sexec.ExecutionScope
-import org.yakindu.sct.model.sexec.ExecutionState
-import org.yakindu.sct.model.sexec.Reaction
-import org.yakindu.sct.model.sexec.StateVector
-import org.yakindu.sct.model.sexec.Step
-import org.yakindu.sct.model.sexec.TimeEvent
-import org.yakindu.sct.model.sgraph.Declaration
-import org.yakindu.sct.model.sgraph.Event
-import org.yakindu.sct.model.sgraph.Scope
-import org.yakindu.sct.model.stext.stext.ElementReferenceExpression
-import org.yakindu.sct.model.stext.stext.EventDefinition
-import org.yakindu.sct.model.stext.stext.Expression
-import org.yakindu.sct.model.stext.stext.FeatureCall
-import org.yakindu.sct.model.stext.stext.OperationDefinition
-import org.yakindu.sct.model.stext.stext.Direction
-import org.yakindu.sct.model.stext.stext.InternalScope
-import org.yakindu.sct.model.stext.stext.InterfaceScope
-import org.yakindu.sct.model.stext.stext.VariableDefinition
-
-class Navigation {
+class Navigation extends SExecExtensions {
+	
+	
 	
 	def dispatch ExecutionFlow flow(Scope scope) {
 		if (scope.eContainer instanceof ExecutionFlow) scope.eContainer as ExecutionFlow
@@ -37,7 +33,7 @@ class Navigation {
 		scope?.flow
 	}
 	
-	def dispatch ExecutionFlow flow(EObject it) {
+	def dispatch ExecutionFlow flow(EObject it) {
 		eContainer.flow
 	}
 	
@@ -46,24 +42,12 @@ class Navigation {
 	}
 	
 	
-	def Event event(Declaration it) {
-		if ( it instanceof Event ) it as Event else null 	
-	} 
-	
 	def Scope scope(Declaration it) {
 		if (eContainer instanceof Scope) eContainer as Scope
 		else null
 	}
 	
 	
-	def empty (StateVector sv) {
-		sv == null || sv.size == 0
-	}
-	
-	def isTimed (ExecutionFlow it) {
-		scopes.filter[declarations.filter( typeof(TimeEvent) ).size > 0].size > 0
-	}
-	
 	def hasValue (EventDefinition it) {
 		type != null && type.name != 'void'
 	}
@@ -72,190 +56,13 @@ class Navigation {
 		scopes.fold(new ArrayList<OperationDefinition>(), [ l, s | l.addAll(s.declarations.filter( typeof(OperationDefinition))) return l ])
 	}
 	
-	def List<EventDefinition> getIncomingEvents(Scope it) {
-		val events = new ArrayList<EventDefinition>()
-		declarations.filter(typeof(EventDefinition)).forEach(ev | if (ev.direction == Direction::IN) events += ev)
-		return events
-	}
-	
-	def boolean hasIncomingEvents(Scope it) {
-		return !incomingEvents.empty
-	}
-	
-	def List<EventDefinition> getOutgoingEvents(Scope scope) {
-		val events = new ArrayList<EventDefinition>()
-		scope.declarations.filter(typeof(EventDefinition)).forEach(ev | if (ev.direction == Direction::OUT) events += ev)
-		return events
-	}
-	
-	def boolean hasOutgoingEvents(Scope it) {
-		return !outgoingEvents.empty
-	}
-	
-	def InternalScope getLocalScope(ExecutionFlow it) {
-		return it.scopes.filter(typeof(InternalScope)).head
-	}
-	
 	def Scope getTimeEventScope(ExecutionFlow it) {
 		return 	scopes.filter[declarations.filter( typeof(TimeEvent) ).size > 0].head
 	}
 	
 	def boolean hasLocalScope(ExecutionFlow it) {
-		return localScope != null;
-	}
-	
-	def Iterable<VariableDefinition> getVariableDefinitions(Scope it) {
-		return declarations.filter(typeof(VariableDefinition))
-	} 
-	
-	def Iterable<InterfaceScope> getInterfaceScopes(ExecutionFlow it) {
-		return scopes.filter(typeof(InterfaceScope))
-	}
-	
-	def dispatch Reaction reaction(Check it) { eContainer as Reaction }
-	def dispatch Reaction reaction(EObject it) { eContainer?.reaction }
-	def dispatch Reaction reaction(Reaction it) { it }
-
-	def referencedChecks(ExecutionNode it) {
-		reactions.filter( r | r.check != null && r.check.refs.size > 0).map[it.check]
-	}
-
-	def referencedEffects(ExecutionNode it) {
-		reactions.filter( r | r.effect != null && r.effect.caller.size > 0).map( r | r.effect )
-	}
-
-
-	def dispatch List<ExecutionState> subStates(ExecutionState it) {
-		subScopes.fold(new ArrayList<ExecutionState>, 
-			[a, s | 
-				a.addAll(s.subStates)
-				a
-			]
-		)
-	} 
-	
-	def dispatch List<ExecutionState> subStates(ExecutionRegion it) {
-		subScopes.fold(new ArrayList<ExecutionState>, 
-			[a, s | 
-				a.add(s as ExecutionState)
-				a.addAll(s.subStates)
-				a
-			]
-		)
-	} 
-	
-	def dispatch List<ExecutionState> subStates(ExecutionScope it) {
-		return new ArrayList<ExecutionState>()
-	}
-	
-	
-	def isCalled(Step it) { it != null && caller.size > 0 }
-	
-	
-	def List<Step> checkFunctions(ExecutionFlow it) {
-		val funcs = new ArrayList<Step>()
-		funcs += referencedChecks
-		states.forEach( s | funcs += s.referencedChecks )
-		nodes.forEach( n | funcs += n.referencedChecks )
-		return funcs
-	}
-	 
-	def List<Step> effectFunctions(ExecutionFlow it) {
-		val funcs = new ArrayList<Step>()
-		funcs += referencedEffects
-		states.forEach( s | funcs += s.referencedEffects )
-		nodes.forEach( n | funcs += n.referencedEffects )
-		return funcs
-	}
-	 
-	def List<Step> entryActionFunctions(ExecutionFlow it) {
-		val funcs = new ArrayList<Step>()
-		if (entryAction.called) funcs.add(entryAction) 
-		states.forEach( s | if (s.entryAction.called) funcs += s.entryAction )
-		return funcs
-	}
-	
-	def List<Step> exitActionFunctions(ExecutionFlow it) {
-		val funcs = new ArrayList<Step>()
-		if (exitAction.called) funcs.add(exitAction) 
-		states.forEach( s | if (s.exitAction.called) funcs += s.exitAction )
-		return funcs
-	}
-	 
-	def List<Step> enterSequenceFunctions(ExecutionFlow it) {
-		val funcs = new ArrayList<Step>()
-		if (enterSequence.called) funcs.add(enterSequence) 
-		states.forEach( s | if (s.enterSequence.called) funcs += s.enterSequence )
-		regions.forEach( s | {
-			if (s.enterSequence.called) funcs += s.enterSequence
-			if (s.deepEnterSequence.called) funcs += s.deepEnterSequence
-			if (s.shallowEnterSequence.called) funcs += s.shallowEnterSequence
-		})
-		return funcs
-	}
-	 
-	def List<Step> exitSequenceFunctions(ExecutionFlow it) {
-		val funcs = new ArrayList<Step>()
-		if (exitSequence.called) funcs.add(exitSequence) 
-		states.forEach( s | if (s.exitSequence.called) funcs += s.exitSequence )
-		regions.forEach( s | if (s.exitSequence.called) funcs += s.exitSequence )
-		return funcs
-	}
-	 
-	def List<Step> reactFunctions(ExecutionFlow it) {
-		val funcs = new ArrayList<Step>()
-		if (reactSequence.called) funcs.add(reactSequence) 
-		states.forEach( s | if (s.reactSequence.called) funcs += s.reactSequence )
-		nodes.forEach( s | if (s.reactSequence.called) funcs += s.reactSequence )
-		return funcs
-	}
-	
-	
-	def isEntryAction(Step it) { eContainer.isEntryAction(it) }
-	def dispatch isEntryAction(ExecutionFlow it, Step s) { entryAction == s }
-	def dispatch isEntryAction(ExecutionState it, Step s) { entryAction == s }
-	def dispatch isEntryAction(EObject it, Step s) { false }
-	
-	def isExitAction(Step it) { eContainer.isExitAction(it) }
-	def dispatch isExitAction(ExecutionFlow it, Step s) { exitAction == s }
-	def dispatch isExitAction(ExecutionState it, Step s) { exitAction == s }
-	def dispatch isExitAction(EObject it, Step s) { false }
-	
-	def isEffect(Step it) { eContainer.isEffect(it) }
-	def dispatch isEffect(Reaction it, Step s) { effect == s }
-	def dispatch isEffect(EObject it, Step s) { false }
-	
-	def isEnterSequence(Step it) { eContainer.isEnterSequence(it) }
-	def dispatch isEnterSequence(ExecutionScope it, Step s) { enterSequence == s }
-	def dispatch isEnterSequence(EObject it, Step s) { false }
-	
-	def isDeepEnterSequence(Step it) { eContainer.isDeepEnterSequence(it) }
-	def dispatch isDeepEnterSequence(ExecutionRegion it, Step s) { deepEnterSequence == s }
-	def dispatch isDeepEnterSequence(EObject it, Step s) { false }
-	
-	def isShallowEnterSequence(Step it) { eContainer.isShallowEnterSequence(it) }
-	def dispatch isShallowEnterSequence(ExecutionRegion it, Step s) { shallowEnterSequence == s }
-	def dispatch isShallowEnterSequence(EObject it, Step s) { false }
-
-	def isExitSequence(Step it) { eContainer.isExitSequence(it) }
-	def dispatch isExitSequence(ExecutionScope it, Step s) { exitSequence == s }
-	def dispatch isExitSequence(EObject it, Step s) { false }
-	
-	def isReactSequence(Step it) { eContainer.isReactSequence(it) }
-	def dispatch isReactSequence(ExecutionNode it, Step s) { reactSequence == s }
-	def dispatch isReactSequence(EObject it, Step s) { false }
-	
-	
-	def isCheckFunction(Step it) { it instanceof Check }
-	
-	
-	def dispatch Declaration definition(ElementReferenceExpression it) {
-		if (reference instanceof Declaration) reference as Declaration
-	}
-	def dispatch Declaration definition(FeatureCall it) {
-		if (feature instanceof Declaration) feature as Declaration
+		return internalScope != null;
 	}
-	def dispatch Declaration definition(Expression it) { null }
 	
 		
 }

+ 19 - 11
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Statemachine.xtend

@@ -1,3 +1,13 @@
+/**
+ * Copyright (c) 2012 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
 package org.yakindu.sct.generator.c
 
 import com.google.inject.Inject
@@ -12,20 +22,18 @@ import org.yakindu.sct.model.sgraph.Scope
 import org.yakindu.sct.model.stext.stext.StatechartScope
 import org.yakindu.sct.model.sexec.TimeEvent
 import org.yakindu.sct.model.stext.stext.Direction
+import org.yakindu.base.types.ITypeSystemAccess
 
 class Statemachine {
 	
 	@Inject extension Naming cNaming
 	@Inject extension Navigation
-	@Inject extension Base
-	
+	@Inject extension ITypeSystemAccess
 	
 	def generateStatemachineH(ExecutionFlow flow, Statechart sc, IFileSystemAccess fsa) {
 		 fsa.generateFile(flow.module.h, flow.statemachineHContent )
 	}
 	
-	
-	
 	def statemachineHContent(ExecutionFlow it) '''
 			#ifndef «module.define»_H_
 			#define «module.define»_H_
@@ -90,7 +98,7 @@ class Statemachine {
 
 	def dispatch structDeclaration(EventDefinition it) '''
 		sc_boolean «name.asIdentifier»_raised;
-		«IF type != null && type.name != 'void'»«type.cPrimitive»  «name.asIdentifier»_value;«ENDIF»
+		«IF type != null && type.name != 'void'»«type.targetLanguageTypeName»  «name.asIdentifier»_value;«ENDIF»
 	'''
 
 	def dispatch structDeclaration(TimeEvent it) '''
@@ -98,7 +106,7 @@ class Statemachine {
 	'''
 
 	def dispatch structDeclaration(VariableDefinition it) '''
-		«IF type.name != 'void'»«type.cPrimitive»  «name.asEscapedIdentifier»;«ENDIF»
+		«IF type.name != 'void'»«type.targetLanguageTypeName»  «name.asEscapedIdentifier»;«ENDIF»
 	'''
 	
 	def dispatch structDeclaration(Declaration it) ''''''
@@ -119,7 +127,7 @@ class Statemachine {
 	def statemachineTypeDecl(ExecutionFlow it) '''
 		//! the maximum number of orthogonal states defines the dimension of the state configuration vector.
 		#define «type.toUpperCase»_MAX_ORTHOGONAL_STATES «stateVector.size»
-		«IF ! historyVector.empt
+		«IF hasHistory»
 		//! dimension of the state configuration vector for history states
 		#define «type.toUpperCase»_MAX_HISTORY_STATES «historyVector.size»«ENDIF»
 		
@@ -127,7 +135,7 @@ class Statemachine {
 		This data structure has to be allocated by the client code. */
 		typedef struct {
 			«statesEnumType» stateConfVector[«type.toUpperCase»_MAX_ORTHOGONAL_STATES];
-			«IF ! historyVector.empty»«statesEnumType» historyVector[«type.toUpperCase»_MAX_HISTORY_STATES];«ENDIF»
+			«IF hasHistory»«statesEnumType» historyVector[«type.toUpperCase»_MAX_HISTORY_STATES];«ENDIF»
 			sc_ushort stateConfVectorPosition; 
 			
 			«FOR iScope : scopes »
@@ -159,7 +167,7 @@ class Statemachine {
 			
 			«IF hasValue»
 				/*! Gets the value of the out event '«name»' that is defined in the «scope.scopeDescription». */ 
-				extern «type.cPrimitive» «asGetter»(«it.flow.type»* handle);
+				extern «type.targetLanguageTypeName» «asGetter»(«it.flow.type»* handle);
 				
 			«ENDIF»
 		«ENDIF»
@@ -167,10 +175,10 @@ class Statemachine {
 
 	def dispatch functionPrototypes(VariableDefinition it) '''
 		/*! Gets the value of the variable '«name»' that is defined in the «scope.scopeDescription». */ 
-		extern «type.cPrimitive» «it.asGetter»(«it.flow.type»* handle);
+		extern «type.targetLanguageTypeName» «it.asGetter»(«it.flow.type»* handle);
 		«IF ! readonly »
 			/*! Sets the value of the variable '«name»' that is defined in the «scope.scopeDescription». */ 
-			extern void «asSetter»(«it.flow.type»* handle, «type.cPrimitive» value);
+			extern void «asSetter»(«it.flow.type»* handle, «type.targetLanguageTypeName» value);
 		«ENDIF»
 	'''
 }

+ 26 - 20
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineC.xtend

@@ -1,30 +1,36 @@
-package org.yakindu.sct.generator.c
-
-import com.google.inject.Inject
-import java.util.List
-import org.eclipse.xtext.generator.IFileSystemAccess
-import org.yakindu.sct.model.sexec.Check
-import org.yakindu.sct.model.sexec.Execution
-import org.yakindu.sct.model.sexec.ExecutionFlow
-import org.yakindu.sct.model.sexec.Step
-import org.yakindu.sct.model.sgraph.Statechart
+/**
+ * Copyright (c) 2012 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.generator.c
+
+import com.google.inject.Inject
+import java.util.List
+import org.eclipse.xtext.generator.IFileSystemAccess
+import org.yakindu.sct.model.sexec.Check
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sexec.Step
+import org.yakindu.sct.model.sgraph.Statechart
+import org.yakindu.base.types.ITypeSystemAccess
 
 class StatemachineC {
 	
 	@Inject extension Naming
 	@Inject extension Navigation
 	@Inject extension FlowCode
-	@Inject extension Base
+	@Inject extension ITypeSystemAccess
 	
 	
 	def generateStatemachineC(ExecutionFlow flow, Statechart sc, IFileSystemAccess fsa) {
 		 fsa.generateFile(flow.module.c, flow.statemachineCContent )
 	}
 	
-	def test(ExecutionFlow it) {
-	 	eAllContents.filter( typeof(Execution) ).last
-	}
-	
 	def statemachineCContent(ExecutionFlow it) '''
 		#include <stdlib.h>
 		#include <string.h>
@@ -67,7 +73,7 @@ class StatemachineC {
 			for (i = 0; i < «type.toUpperCase»_MAX_ORTHOGONAL_STATES; ++i)
 				«scHandle»->stateConfVector[i] = «last_state»;
 			
-			«IF ! historyVector.empt
+			«IF hasHistory»
 			for (i = 0; i < «type.toUpperCase»_MAX_HISTORY_STATES; ++i)
 				«scHandle»->historyVector[i] = «last_state»;
 			«ENDIF»
@@ -106,7 +112,7 @@ class StatemachineC {
 				«ENDFOR»
 			«ENDFOR»
 			«IF hasLocalScope»
-				«FOR event : localScope.events»
+				«FOR event : internalScope.events»
 				«event.access» = bool_false; 
 				«ENDFOR»
 			«ENDIF»
@@ -200,7 +206,7 @@ class StatemachineC {
 					return «event.access»;
 				}
 				«IF event.hasValue» 
-					«event.type.cPrimitive» «event.asGetter»(«scHandleDecl») {
+					«event.type.targetLanguageTypeName» «event.asGetter»(«scHandleDecl») {
 						//TODO: Check if event is not raised
 						return «event.valueAccess»;
 					}
@@ -208,11 +214,11 @@ class StatemachineC {
 			«ENDFOR»
 			
 			«FOR variable : scope.variableDefinitions»
-				«variable.type.cPrimitive» «variable.asGetter»(«scHandleDecl») {
+				«variable.type.targetLanguageTypeName» «variable.asGetter»(«scHandleDecl») {
 					return «variable.access»;
 				}
 				«IF !variable.readonly »
-				void «variable.asSetter»(«scHandleDecl», «variable.type.cPrimitive» value) {
+				void «variable.asSetter»(«scHandleDecl», «variable.type.targetLanguageTypeName» value) {
 					«variable.access» = value;
 				}
 				«ENDIF»

+ 13 - 4
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineRequired.xtend

@@ -1,3 +1,13 @@
+/**
+ * Copyright (c) 2012 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
 package org.yakindu.sct.generator.c
 
 import com.google.inject.Inject
@@ -7,19 +17,18 @@ import org.yakindu.sct.model.sgraph.Declaration
 import org.yakindu.sct.model.sgraph.Statechart
 import org.yakindu.sct.model.stext.stext.OperationDefinition
 import org.yakindu.sct.model.stext.stext.StatechartScope
+import org.yakindu.base.types.ITypeSystemAccess
 
 class StatemachineRequired {
 
 	@Inject extension Naming cNaming
 	@Inject extension Navigation
-	@Inject extension Base
+	@Inject extension ITypeSystemAccess
 	
 	def generateStatemachineClientH(ExecutionFlow flow, Statechart sc, IFileSystemAccess fsa) {
 		 fsa.generateFile(flow.module.client.h, flow.statemachineClientHContent )
 	}
 	
-	
-	
 	def statemachineClientHContent(ExecutionFlow it) '''
 			#ifndef «module.client.define»_H_
 			#define «module.client.define»_H_
@@ -103,7 +112,7 @@ class StatemachineRequired {
 	def dispatch functionPrototypes(Declaration it) ''''''
 
 	def dispatch functionPrototypes(OperationDefinition it) '''
-		extern «type.cPrimitive» «asFunction»(«FOR p : parameters SEPARATOR ', '»const «p.type.cPrimitive» «p.name.asIdentifier»«ENDFOR»);
+		extern «type.targetLanguageTypeName» «asFunction»(«FOR p : parameters SEPARATOR ', '»const «p.type.targetLanguageTypeName» «p.name.asIdentifier»«ENDFOR»);
 	'''
 
 }

+ 10 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Timer.xtend

@@ -1,3 +1,13 @@
+/**
+ * Copyright (c) 2012 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
 package org.yakindu.sct.generator.c
 
 import com.google.inject.Inject

+ 10 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Types.xtend

@@ -1,3 +1,13 @@
+/**
+ * Copyright (c) 2012 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
 package org.yakindu.sct.generator.c
 
 import org.yakindu.sct.model.sexec.ExecutionFlow

+ 31 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/types/CTypeSystemAccess.xtend

@@ -0,0 +1,31 @@
+/**
+ * Copyright (c) 2012 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.generator.c.types
+
+import org.yakindu.base.types.impl.BaseTypeSystemAccessImpl
+import org.yakindu.base.types.Type
+
+/**
+ * @author andreas muelder
+ */
+class CTypeSystemAccess extends BaseTypeSystemAccessImpl {
+	
+	override getTargetLanguageTypeName(Type it) {
+		switch (if (it == null) 'void' else name ) {
+			case 'void' 	: 'void'
+			case 'integer'	: 'sc_integer'
+			case 'real'		: 'sc_real'
+			case 'boolean'	: 'sc_boolean'
+			case 'string'	: 'sc_string'
+		}
+	}
+	
+}

+ 3 - 4
plugins/org.yakindu.sct.generator.java/.settings/org.eclipse.core.resources.prefs

@@ -1,4 +1,3 @@
-eclipse.preferences.version=1
-encoding//.settings/org.eclipse.xtend.shared.ui.prefs=Cp1252
-encoding//src/org/yakindu/sct/generator/java/templates=Cp1252
-encoding/<project>=UTF-8
+eclipse.preferences.version=1
+encoding//.settings/org.eclipse.xtend.shared.ui.prefs=Cp1252
+encoding/<project>=UTF-8

+ 0 - 13
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/INaming.java

@@ -1,13 +0,0 @@
-package org.yakindu.sct.generator.java;
-
-public interface INaming {
-	public static final String[] JAVA_KEYWORDS = { "abstract", "assert",
-		"boolean", "break", "byte", "case", "catch", "char", "class",
-		"const", "continue", "default", "do", "double", "else", "enum",
-		"extends", "false", "final", "finally", "float", "for", "goto", "if",
-		"implements", "import", "instanceof", "int", "interface", "long",
-		"native", "new", "null", "package", "private", "protected", "public",
-		"return", "short", "static", "strictfp", "super", "switch",
-		"synchronized", "this", "throw", "throws", "transient", "true" , "try",
-		"void", "volatile", "while" };
-}

+ 0 - 2
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/IStatemachine.xtend

@@ -33,8 +33,6 @@ class IStatemachine {
 
 		/**
 		 * Basic interface for statemachines.
-		 * 
-		 * 
 		 */
 		public interface IStatemachine {
 		

+ 1 - 0
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/JavaCodeGenerator.java

@@ -13,6 +13,7 @@ import static org.yakindu.sct.generator.core.util.GeneratorUtils.isDumpSexec;
 
 import org.yakindu.base.types.ITypeSystemAccess;
 import org.yakindu.sct.generator.core.impl.GenericJavaBasedGenerator;
+import org.yakindu.sct.generator.java.types.JavaTypeSystemAccess;
 import org.yakindu.sct.model.sexec.ExecutionFlow;
 import org.yakindu.sct.model.sgen.GeneratorEntry;
 import org.yakindu.sct.model.sgraph.Statechart;

+ 24 - 0
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/JavaKeywords.java

@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) 2012 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.generator.java;
+
+public interface JavaKeywords {
+	
+	public static final String[] KEYWORDS = { "abstract", "assert",
+			"boolean", "break", "byte", "case", "catch", "char", "class",
+			"const", "continue", "default", "do", "double", "else", "enum",
+			"extends", "false", "final", "finally", "float", "for", "goto",
+			"if", "implements", "import", "instanceof", "int", "interface",
+			"long", "native", "new", "null", "package", "private", "protected",
+			"public", "return", "short", "static", "strictfp", "super",
+			"switch", "synchronized", "this", "throw", "throws", "transient",
+			"true", "try", "void", "volatile", "while" };
+}

+ 22 - 23
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/Naming.xtend

@@ -1,26 +1,25 @@
-package org.yakindu.sct.generator.java
+package org.yakindu.sct.generator.java
+
+import com.google.inject.Inject
+import java.util.Arrays
+import java.util.List
+import java.util.regex.Matcher
+import java.util.regex.Pattern
+import org.eclipse.emf.ecore.EObject
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sexec.ExecutionNode
+import org.yakindu.sct.model.sexec.ExecutionScope
+import org.yakindu.sct.model.sexec.ExecutionState
+import org.yakindu.sct.model.sexec.Step
+import org.yakindu.sct.model.sgraph.Event
+import org.yakindu.sct.model.sgraph.State
+import org.yakindu.sct.model.sgraph.Variable
+import org.yakindu.sct.model.stext.stext.InterfaceScope
+import org.yakindu.sct.model.stext.stext.InternalScope
+import org.yakindu.sct.model.stext.naming.StextNameProvider
+import org.yakindu.sct.generator.java.JavaKeywords
 
-import com.google.inject.Inject
-import java.util.Arrays
-import java.util.List
-import java.util.regex.Matcher
-import java.util.regex.Pattern
-import org.eclipse.emf.ecore.EObject
-import org.yakindu.sct.model.sexec.ExecutionFlow
-import org.yakindu.sct.model.sexec.ExecutionNode
-import org.yakindu.sct.model.sexec.ExecutionScope
-import org.yakindu.sct.model.sexec.ExecutionState
-import org.yakindu.sct.model.sexec.Step
-import org.yakindu.sct.model.sgraph.Event
-import org.yakindu.sct.model.sgraph.State
-import org.yakindu.sct.model.sgraph.Variable
-import org.yakindu.sct.model.stext.stext.InterfaceScope
-import org.yakindu.sct.model.stext.stext.InternalScope
-
-import static org.yakindu.sct.generator.java.INaming.*
-import org.yakindu.sct.model.stext.naming.StextNameProvider
-
-class Naming implements INaming {
+class Naming implements JavaKeywords {
 	
 	@Inject extension Navigation
 	
@@ -68,7 +67,7 @@ class Naming implements INaming {
 	
 	def boolean isJavaKeyword(String name) {
 		var String lowName = name.toLowerCase();
-		for (String keyword : Arrays::asList(JAVA_KEYWORDS)) {
+		for (String keyword : Arrays::asList(KEYWORDS)) {
 			var Pattern pattern = Pattern::compile("^" + keyword + "$");
 			var Matcher matcher = pattern.matcher(lowName);
 			if (matcher.find()) {

+ 17 - 211
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/Navigation.xtend

@@ -7,41 +7,26 @@
   Contributors:
   	Commiters of Yakindu - Initial contribution and API
  */
-package org.yakindu.sct.generator.java
-
-import org.yakindu.sct.model.sexec.ExecutionFlow
-import org.yakindu.sct.model.sgraph.Scope
-import org.yakindu.sct.model.stext.stext.EventDefinition
-import java.util.List
-import java.util.ArrayList
-import org.yakindu.sct.model.stext.stext.InternalScope
-import org.yakindu.sct.model.stext.stext.Direction
-import org.yakindu.sct.model.stext.stext.InterfaceScope
+package org.yakindu.sct.generator.java
+
+import java.util.ArrayList
+import java.util.List
+import org.yakindu.sct.model.extensions.SExecExtensions
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sexec.TimeEvent
+import org.yakindu.sct.model.sgraph.Event
+import org.yakindu.sct.model.sgraph.Scope
+import org.yakindu.sct.model.sgraph.Variable
+import org.yakindu.sct.model.stext.stext.EventDefinition
+import org.yakindu.sct.model.stext.stext.InterfaceScope
+import org.yakindu.sct.model.stext.stext.InternalScope
+import org.yakindu.sct.model.stext.stext.OperationDefinition
 import org.yakindu.sct.model.stext.stext.VariableDefinition
-import org.yakindu.sct.model.stext.stext.OperationDefinition
-import org.yakindu.sct.model.sexec.TimeEvent
-import org.yakindu.sct.model.sexec.ExecutionState
-import org.yakindu.sct.model.sexec.ExecutionRegion
-import org.yakindu.sct.model.sexec.ExecutionScope
-import org.yakindu.sct.model.sgraph.Variable
-import org.yakindu.sct.model.sgraph.Event
-import org.yakindu.sct.model.sexec.Step
-import org.yakindu.sct.model.sexec.ExecutionNode
-import org.yakindu.sct.model.sexec.Reaction
-import org.yakindu.sct.model.sexec.Check
-import org.eclipse.emf.ecore.EObject
-import org.yakindu.sct.model.stext.stext.ElementReferenceExpression
-import org.yakindu.sct.model.sgraph.Declaration
-import org.yakindu.sct.model.stext.stext.FeatureCall
-import org.yakindu.sct.model.stext.stext.Expression
 
-class Navigation {
+class Navigation extends SExecExtensions {
 	
-	def isTimed (ExecutionFlow it) {
-		scopes.filter[declarations.filter( typeof(TimeEvent) ).size > 0].size > 0
-	}
 	
-	def dispatch List<EventDefinition> getOutgoingEvents(ExecutionFlow flow) {
+	def List<EventDefinition> getOutgoingEvents(ExecutionFlow flow) {
 		val events = new ArrayList<EventDefinition>()
 		for (scope: flow.scopes) {
 			events.addAll(scope.outgoingEvents)
@@ -49,11 +34,7 @@ class Navigation {
 		return events
 	}
 	
-	def boolean hasHistory(ExecutionFlow it) {
-		historyVector != null && historyVector.size > 0;		
-	}
-	
-	def dispatch boolean hasOutgoingEvents(ExecutionFlow it) {
+	def boolean hasOutgoingEvents(ExecutionFlow it) {
 		return !outgoingEvents.empty
 	}
 	
@@ -75,9 +56,6 @@ class Navigation {
 		return variables
 	}
 	
-	def InternalScope getInternalScope(ExecutionFlow it) {
-		return it.scopes.filter(typeof(InternalScope)).head
-	}
 	
 	def getDefaultScope(ExecutionFlow it) {
 		interfaceScopes.filter[name == null || name.empty].head
@@ -87,38 +65,10 @@ class Navigation {
 		return scopes.filter(typeof(InternalScope))
 	}
 	
-	def Iterable<InterfaceScope> getInterfaceScopes(ExecutionFlow it) {
-		return scopes.filter(typeof(InterfaceScope))
-	}
-	
-	def List<EventDefinition> getIncomingEvents(Scope it) {
-		val events = new ArrayList<EventDefinition>()
-		declarations.filter(typeof(EventDefinition)).forEach(ev | if (ev.direction == Direction::IN) events += ev)
-		return events
-	}
-	
-	def boolean hasIncomingEvents(Scope it) {
-		return !incomingEvents.empty
-	}
-	
 	def boolean hasEvents(Scope it) {
 		return !eventDefinitions.empty
 	}
 	
-	def dispatch List<EventDefinition> getOutgoingEvents(Scope scope) {
-		val events = new ArrayList<EventDefinition>()
-		scope.declarations.filter(typeof(EventDefinition)).forEach(ev | if (ev.direction == Direction::OUT) events += ev)
-		return events
-	}
-	
-	def dispatch boolean hasOutgoingEvents(Scope it) {
-		return !outgoingEvents.empty
-	}
-	
-	def getVariableDefinitions(Scope it) {
-		return declarations.filter(typeof(VariableDefinition))
-	} 
-	
 	def getEventDefinitions(Scope scope) {
 		scope.declarations.filter(typeof(EventDefinition))
 	}
@@ -131,136 +81,6 @@ class Navigation {
 		!operations.isEmpty;
 	}
 	
-	def dispatch List<ExecutionState> subStates(ExecutionState it) {
-		subScopes.fold(new ArrayList<ExecutionState>, 
-			[a, s | 
-				a.addAll(s.subStates)
-				a
-			]
-		)
-	} 
-	
-	def dispatch List<ExecutionState> subStates(ExecutionRegion it) {
-		subScopes.fold(new ArrayList<ExecutionState>, 
-			[a, s | 
-				a.add(s as ExecutionState)
-				a.addAll(s.subStates)
-				a
-			]
-		)
-	} 
-	
-	def dispatch List<ExecutionState> subStates(ExecutionScope it) {
-		return new ArrayList<ExecutionState>()
-	}
-	
-	def referencedChecks(ExecutionNode it) {
-		reactions.filter( r | r.check != null && r.check.refs.size > 0).map[it.check]
-	}
-
-	def referencedEffects(ExecutionNode it) {
-		reactions.filter( r | r.effect != null && r.effect.caller.size > 0).map( r | r.effect )
-	}
-	
-	def List<Step> checkFunctions(ExecutionFlow it) {
-		val funcs = new ArrayList<Step>()
-		funcs += referencedChecks
-		states.forEach( s | funcs += s.referencedChecks )
-		nodes.forEach( n | funcs += n.referencedChecks )
-		return funcs
-	}
-	 
-	def List<Step> effectFunctions(ExecutionFlow it) {
-		val funcs = new ArrayList<Step>()
-		funcs += referencedEffects
-		states.forEach( s | funcs += s.referencedEffects )
-		nodes.forEach( n | funcs += n.referencedEffects )
-		return funcs
-	}
-	 
-	def List<Step> entryActionFunctions(ExecutionFlow it) {
-		val funcs = new ArrayList<Step>()
-		if (entryAction.called) funcs.add(entryAction) 
-		states.forEach( s | if (s.entryAction.called) funcs += s.entryAction )
-		return funcs
-	}
-	
-	def List<Step> exitActionFunctions(ExecutionFlow it) {
-		val funcs = new ArrayList<Step>()
-		if (exitAction.called) funcs.add(exitAction) 
-		states.forEach( s | if (s.exitAction.called) funcs += s.exitAction )
-		return funcs
-	}
-	 
-	def List<Step> enterSequenceFunctions(ExecutionFlow it) {
-		val funcs = new ArrayList<Step>()
-		if (enterSequence.called) funcs.add(enterSequence) 
-		states.forEach( s | if (s.enterSequence.called) funcs += s.enterSequence )
-		regions.forEach( s | {
-			if (s.enterSequence.called) funcs += s.enterSequence
-			if (s.deepEnterSequence.called) funcs += s.deepEnterSequence
-			if (s.shallowEnterSequence.called) funcs += s.shallowEnterSequence
-		})
-		return funcs
-	}
-	 
-	def List<Step> exitSequenceFunctions(ExecutionFlow it) {
-		val funcs = new ArrayList<Step>()
-		if (exitSequence.called) funcs.add(exitSequence) 
-		states.forEach( s | if (s.exitSequence.called) funcs += s.exitSequence )
-		regions.forEach( s | if (s.exitSequence.called) funcs += s.exitSequence )
-		return funcs
-	}
-	 
-	def List<Step> reactFunctions(ExecutionFlow it) {
-		val funcs = new ArrayList<Step>()
-		if (reactSequence.called) funcs.add(reactSequence) 
-		states.forEach( s | if (s.reactSequence.called) funcs += s.reactSequence )
-		nodes.forEach( s | if (s.reactSequence.called) funcs += s.reactSequence )
-		return funcs
-	}
-	
-	def isCalled(Step it) { it != null && caller.size > 0 }
-	
-	def dispatch Reaction reaction(Check it) { eContainer as Reaction }
-	def dispatch Reaction reaction(EObject it) { eContainer?.reaction }
-	def dispatch Reaction reaction(Reaction it) { it }
-	
-	def isEntryAction(Step it) { eContainer.isEntryAction(it) }
-	def dispatch isEntryAction(ExecutionFlow it, Step s) { entryAction == s }
-	def dispatch isEntryAction(ExecutionState it, Step s) { entryAction == s }
-	def dispatch isEntryAction(EObject it, Step s) { false }
-	
-	def isExitAction(Step it) { eContainer.isExitAction(it) }
-	def dispatch isExitAction(ExecutionFlow it, Step s) { exitAction == s }
-	def dispatch isExitAction(ExecutionState it, Step s) { exitAction == s }
-	def dispatch isExitAction(EObject it, Step s) { false }
-	
-	def isEffect(Step it) { eContainer.isEffect(it) }
-	def dispatch isEffect(Reaction it, Step s) { effect == s }
-	def dispatch isEffect(EObject it, Step s) { false }
-	
-	def isEnterSequence(Step it) { eContainer.isEnterSequence(it) }
-	def dispatch isEnterSequence(ExecutionScope it, Step s) { enterSequence == s }
-	def dispatch isEnterSequence(EObject it, Step s) { false }
-	
-	def isDeepEnterSequence(Step it) { eContainer.isDeepEnterSequence(it) }
-	def dispatch isDeepEnterSequence(ExecutionRegion it, Step s) { deepEnterSequence == s }
-	def dispatch isDeepEnterSequence(EObject it, Step s) { false }
-	
-	def isShallowEnterSequence(Step it) { eContainer.isShallowEnterSequence(it) }
-	def dispatch isShallowEnterSequence(ExecutionRegion it, Step s) { shallowEnterSequence == s }
-	def dispatch isShallowEnterSequence(EObject it, Step s) { false }
-
-	def isExitSequence(Step it) { eContainer.isExitSequence(it) }
-	def dispatch isExitSequence(ExecutionScope it, Step s) { exitSequence == s }
-	def dispatch isExitSequence(EObject it, Step s) { false }
-	
-	def isReactSequence(Step it) { eContainer.isReactSequence(it) }
-	def dispatch isReactSequence(ExecutionNode it, Step s) { reactSequence == s }
-	def dispatch isReactSequence(EObject it, Step s) { false }
-	
-	def isCheckFunction(Step it) { it instanceof Check }
 	
 	def dispatch scope(Variable it) {
 		if (eContainer instanceof InterfaceScope)
@@ -283,19 +103,5 @@ class Navigation {
 			null
 	}
 	
-	def dispatch Declaration definition(ElementReferenceExpression it) {
-		if (reference instanceof Declaration) reference as Declaration
-	}
-	
-	def dispatch Declaration definition(FeatureCall it) {
-		if (feature instanceof Declaration) feature as Declaration
-	}
 	
-	def dispatch Declaration definition(Expression it) {
-		null
-	}
-	
-	def Event event(Declaration it) {
-		if ( it instanceof Event ) it as Event else null 	
-	} 
 }

+ 4 - 4
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/StatemachineInterface.xtend

@@ -123,7 +123,7 @@ class StatemachineInterface {
 		'''
 	}
 	
-	def private createOperationCallbackInterface(InterfaceScope scope) {
+	def createOperationCallbackInterface(InterfaceScope scope) {
 		'''
 		«IF scope.hasOperations»
 			
@@ -136,7 +136,7 @@ class StatemachineInterface {
 		'''
 	}
 	
-	def private eventAccessors(InterfaceScope scope) {
+	def eventAccessors(InterfaceScope scope) {
 		'''
 		«FOR event : scope.eventDefinitions»
 			«IF  event.direction ==  Direction::IN»
@@ -155,7 +155,7 @@ class StatemachineInterface {
 		'''
 	}
 	
-	def private variableAccessors(InterfaceScope scope) '''
+	def variableAccessors(InterfaceScope scope) '''
 		«FOR variable : scope.variableDefinitions»
 					public «variable.type.targetLanguageTypeName» «variable.getter»;
 					«IF  !variable.readonly»
@@ -164,7 +164,7 @@ class StatemachineInterface {
 		«ENDFOR»
 	'''
 	
-	def private String getStatemachineInterfaceExtensions(ExecutionFlow flow) {
+	def getStatemachineInterfaceExtensions(ExecutionFlow flow) {
 
 		var String interfaces = "";
 

+ 4 - 1
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/JavaTypeSystemAccess.xtend

@@ -8,11 +8,14 @@
  * Contributors:
  *     committers of YAKINDU - initial API and implementation
  */
-package org.yakindu.sct.generator.java
+package org.yakindu.sct.generator.java.types
 
 import org.yakindu.base.types.impl.BaseTypeSystemAccessImpl
 import org.yakindu.base.types.Type
 
+/**
+ * @author andreas muelder
+ */
 class JavaTypeSystemAccess extends BaseTypeSystemAccessImpl {
 	
 	override getTargetLanguageTypeName(Type type) {