Explorar o código

Merge in TYPE_SYSTEM_REFACTORING branch.

Alexander Nyßen %!s(int64=12) %!d(string=hai) anos
pai
achega
8414004bc1
Modificáronse 84 ficheiros con 6971 adicións e 5248 borrados
  1. 5 5
      plugins/org.yakindu.sct.doc.user/help/02_Getting_started/getting_started.html
  2. 905 61
      plugins/org.yakindu.sct.doc.user/help/04_Reference/reference.html
  3. 2 2
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CCodeGenerator.java
  4. 5 5
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/ExpressionCode.xtend
  5. 22 22
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Naming.xtend
  6. 11 11
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Statemachine.xtend
  7. 16 16
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineC.xtend
  8. 4 4
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/StatemachineRequired.xtend
  9. 18 12
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/types/CTypeSystemAccess.xtend
  10. 1 0
      plugins/org.yakindu.sct.generator.core/META-INF/MANIFEST.MF
  11. 20 19
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/extensions/TypeAnalyzerExtensions.java
  12. 8 0
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/types/ICodegenTypeSystemAccess.java
  13. 41 41
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/ExpressionCode.xtend
  14. 2 2
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/JavaCodeGenerator.java
  15. 32 30
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/Statemachine.xtend
  16. 18 14
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/StatemachineInterface.xtend
  17. 18 12
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/types/JavaTypeSystemAccess.xtend
  18. 3 3
      plugins/org.yakindu.sct.model.sexec.interpreter/src/org/yakindu/sct/model/sexec/interpreter/InterpreterModule.java
  19. 54 55
      plugins/org.yakindu.sct.model.sexec.interpreter/src/org/yakindu/sct/model/sexec/interpreter/impl/ExecutionFlowInterpreter.xtend
  20. 1 0
      plugins/org.yakindu.sct.model.sexec.interpreter/src/org/yakindu/sct/model/sexec/interpreter/stext/CoreFunction.java
  21. 754 754
      plugins/org.yakindu.sct.model.sexec.interpreter/xtend-gen/org/yakindu/sct/model/sexec/interpreter/impl/ExecutionFlowInterpreter.java
  22. 580 580
      plugins/org.yakindu.sct.model.sexec.interpreter/xtend-gen/org/yakindu/sct/model/sexec/interpreter/stext/StextStatementInterpreter.java
  23. 10 11
      plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/SequenceBuilder.xtend
  24. 4 4
      plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/SequencerModule.java
  25. BIN=BIN
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.SequenceBuilder.java._trace
  26. BIN=BIN
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.StateVectorBuilder.java._trace
  27. 10 10
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SequenceBuilder.java
  28. 257 257
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StateVectorBuilder.java
  29. BIN=BIN
      plugins/org.yakindu.sct.model.stext.edit/icons/full/ctool16/CreatePrimitiveValueExpression_value_EnumLiteral.gif
  30. BIN=BIN
      plugins/org.yakindu.sct.model.stext.edit/icons/full/obj16/EnumLiteral.gif
  31. 3 0
      plugins/org.yakindu.sct.model.stext.edit/plugin.properties
  32. 1 0
      plugins/org.yakindu.sct.model.stext.ui/META-INF/MANIFEST.MF
  33. 1 1
      plugins/org.yakindu.sct.model.stext.ui/src-gen/org/yakindu/sct/model/stext/ui/contentassist/antlr/internal/InternalSText.tokens
  34. 2 2
      plugins/org.yakindu.sct.model.stext.ui/src-gen/org/yakindu/sct/model/stext/ui/contentassist/antlr/internal/InternalSTextLexer.java
  35. 1 1
      plugins/org.yakindu.sct.model.stext.ui/src-gen/org/yakindu/sct/model/stext/ui/contentassist/antlr/internal/InternalSTextParser.java
  36. 1 0
      plugins/org.yakindu.sct.model.stext/META-INF/MANIFEST.MF
  37. 1 2
      plugins/org.yakindu.sct.model.stext/build.properties
  38. 0 10
      plugins/org.yakindu.sct.model.stext/libraries/Primitives.types
  39. 0 6
      plugins/org.yakindu.sct.model.stext/plugin.xml
  40. 2 2
      plugins/org.yakindu.sct.model.stext/src-gen/org/yakindu/sct/model/stext/parser/antlr/internal/InternalSText.tokens
  41. 2 2
      plugins/org.yakindu.sct.model.stext/src-gen/org/yakindu/sct/model/stext/parser/antlr/internal/InternalSTextLexer.java
  42. 1 1
      plugins/org.yakindu.sct.model.stext/src-gen/org/yakindu/sct/model/stext/parser/antlr/internal/InternalSTextParser.java
  43. 10 9
      plugins/org.yakindu.sct.model.stext/src-gen/org/yakindu/sct/model/stext/stext/impl/EventDefinitionImpl.java
  44. 10 9
      plugins/org.yakindu.sct.model.stext/src-gen/org/yakindu/sct/model/stext/stext/impl/OperationDefinitionImpl.java
  45. 10 9
      plugins/org.yakindu.sct.model.stext/src-gen/org/yakindu/sct/model/stext/stext/impl/VariableDefinitionImpl.java
  46. 1 1
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/SText.xtext
  47. 4 10
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/STextRuntimeModule.java
  48. 9 8
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/ContextPredicateProvider.java
  49. 11 21
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextGlobalScopeProvider.java
  50. 31 8
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextScopeProvider.java
  51. 40 0
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/types/ISTextTypeInferrer.java
  52. 124 0
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/types/ISTextTypeSystem.java
  53. 643 0
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/types/STextDefaulTypeSystem.java
  54. 421 0
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/types/STextDefaultTypeInferrer.xtend
  55. 0 34
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/ITypeInferrer.java
  56. 83 47
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextJavaValidator.java
  57. 0 28
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/TypeCheckException.java
  58. 0 306
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/TypeInferrer.xtend
  59. 0 40
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/TypeInferrerCache.java
  60. BIN=BIN
      plugins/org.yakindu.sct.model.stext/xtend-gen/org/yakindu/sct/model/stext/types/.DefaultSTextTypeInferrer.java._trace
  61. BIN=BIN
      plugins/org.yakindu.sct.model.stext/xtend-gen/org/yakindu/sct/model/stext/types/.STextDefaultTypeInferrer.java._trace
  62. 901 0
      plugins/org.yakindu.sct.model.stext/xtend-gen/org/yakindu/sct/model/stext/types/STextDefaultTypeInferrer.java
  63. 0 581
      plugins/org.yakindu.sct.model.stext/xtend-gen/org/yakindu/sct/model/stext/validation/TypeInferrer.java
  64. 3 3
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/providers/StatechartPaletteProvider.java
  65. 2 2
      test-plugins/org.yakindu.sct.generator.core.test/src/org/yakindu/sct/generator/core/extensions/ExecutionModelCoreExtensionsTest.java
  66. 1 1
      test-plugins/org.yakindu.sct.generator.core.test/src/org/yakindu/sct/generator/core/extensions/TypeAnalyzerExtensionsTest.java
  67. 5 2
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/IStatemachine.java
  68. 8 0
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/ITimerService.java
  69. 4 4
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/RuntimeService.java
  70. 4 3
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/TimerService.java
  71. 5 0
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/assignmentasexpression/AssignmentAsExpressionStatemachine.java
  72. 2 2
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/performancetest/PerformanceTestStatemachine.java
  73. 6 6
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/statewithemptyregion/IStateWithEmptyRegionStatemachine.java
  74. 116 116
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/statewithemptyregion/StateWithEmptyRegionStatemachine.java
  75. 16 16
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/stextkeywordsinstatesandregions/ISTextKeywordsInStatesAndRegionsStatemachine.java
  76. 949 949
      test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/stextkeywordsinstatesandregions/STextKeywordsInStatesAndRegionsStatemachine.java
  77. 6 6
      test-plugins/org.yakindu.sct.model.sexec.test/src/org/yakindu/sct/model/sexec/transformation/test/SCTTestUtil.java
  78. 2 0
      test-plugins/org.yakindu.sct.model.stext.test/.settings/org.eclipse.core.resources.prefs
  79. 3 62
      test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/STextJavaValidatorTest.java
  80. 0 1
      test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/STextScopeProviderTest.java
  81. 20 20
      test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/StextParserRuleTest.java
  82. 675 982
      test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/TypeInferrerTest.java
  83. 3 2
      test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/util/AbstractSTextTest.java
  84. 27 3
      test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/util/StextTestFactory.java

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 5 - 5
plugins/org.yakindu.sct.doc.user/help/02_Getting_started/getting_started.html


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 905 - 61
plugins/org.yakindu.sct.doc.user/help/04_Reference/reference.html


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

@@ -12,9 +12,9 @@ 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.generator.core.types.ICodegenTypeSystemAccess;
 import org.yakindu.sct.model.sexec.ExecutionFlow;
 import org.yakindu.sct.model.sgen.GeneratorEntry;
 import org.yakindu.sct.model.sgraph.Statechart;
@@ -46,7 +46,7 @@ public class CCodeGenerator extends GenericJavaBasedGenerator {
 		Module module = super.createModule(entry);
 		return Modules.override(module).with(new Module() {
 			public void configure(Binder binder) {
-				binder.bind(ITypeSystemAccess.class)
+				binder.bind(ICodegenTypeSystemAccess.class)
 						.to(CTypeSystemAccess.class);
 			}
 		});

+ 5 - 5
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/ExpressionCode.xtend

@@ -11,7 +11,6 @@
 package org.yakindu.sct.generator.c
 
 import com.google.inject.Inject
-import org.yakindu.base.types.ITypeSystemAccess
 import org.yakindu.sct.model.sgraph.Event
 import org.yakindu.sct.model.sgraph.Statement
 import org.yakindu.sct.model.stext.stext.ActiveStateReferenceExpression
@@ -40,16 +39,17 @@ import org.yakindu.sct.model.stext.stext.PrimitiveValueExpression
 import org.yakindu.sct.model.stext.stext.RealLiteral
 import org.yakindu.sct.model.stext.stext.StringLiteral
 import org.yakindu.sct.model.stext.stext.VariableDefinition
-import org.yakindu.sct.model.stext.validation.ITypeInferrer
 import org.yakindu.sct.model.stext.stext.ShiftExpression
 import org.yakindu.sct.model.stext.stext.ParenthesizedExpression
+import org.yakindu.sct.model.stext.types.ISTextTypeSystem
+import org.yakindu.sct.model.stext.types.ISTextTypeInferrer
 
 class ExpressionCode {
 	
 	@Inject extension Naming
 	@Inject extension Navigation
-	@Inject extension ITypeInferrer
-	@Inject extension ITypeSystemAccess
+	@Inject extension ISTextTypeSystem
+	@Inject extension ISTextTypeInferrer
 	
 	/* Refering to declared elements */
 	
@@ -127,7 +127,7 @@ class ExpressionCode {
 		'''! «operand.code»'''
 		
 	def dispatch code (LogicalRelationExpression it) '''
-		«IF leftOperand.type.isString»
+		«IF leftOperand.inferType.type.stringType»
 			(strcmp(«leftOperand.code», «rightOperand.code») «operator.literal» 0)
 		«ELSE»«leftOperand.code» «operator.literal» «rightOperand.code»«ENDIF»'''
 	

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

@@ -8,37 +8,37 @@
  * 	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
+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.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.sct.model.stext.stext.InterfaceScope
 import org.yakindu.sct.model.stext.stext.InternalScope
+import org.yakindu.sct.model.stext.stext.EventDefinition
 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 org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess
 
 class Naming implements CKeywords{
 
 	@Inject
 	extension Navigation
 	
-	@Inject extension ITypeSystemAccess
+	@Inject extension ICodegenTypeSystemAccess
 	
 	@Inject
 	private StextNameProvider provider
@@ -250,7 +250,7 @@ class Naming implements CKeywords{
 	def scHandle() { 'handle' }
 	
 	def valueParams(EventDefinition it) {
-		if (hasValue) ', ' + type.targetLanguageTypeName + ' value' 
+		if (hasValue) ', ' + type.targetLanguageName + ' value' 
 		else ''
 	}
 	

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

@@ -14,22 +14,22 @@ import com.google.inject.Inject
 import org.eclipse.xtext.generator.IFileSystemAccess
 import org.yakindu.sct.model.sexec.ExecutionFlow
 import org.yakindu.sct.model.sgraph.Statechart
-import org.yakindu.sct.model.stext.stext.InterfaceScope
-import org.yakindu.sct.model.stext.stext.EventDefinition
-import org.yakindu.sct.model.stext.stext.VariableDefinition
 import org.yakindu.sct.model.sgraph.Declaration
 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.EventDefinition
+import org.yakindu.sct.model.stext.stext.VariableDefinition
 import org.yakindu.sct.model.stext.stext.Direction
-import org.yakindu.base.types.ITypeSystemAccess
+import org.yakindu.sct.model.stext.stext.StatechartScope
+import org.yakindu.sct.model.stext.stext.InterfaceScope
+import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess
 import org.yakindu.sct.model.sgen.GeneratorEntry
 
 class Statemachine {
 	
 	@Inject extension Naming cNaming
 	@Inject extension Navigation
-	@Inject extension ITypeSystemAccess
+	@Inject extension ICodegenTypeSystemAccess
 	@Inject extension GenmodelEntries
 	
 	def generateStatemachineH(ExecutionFlow flow, Statechart sc, IFileSystemAccess fsa, GeneratorEntry entry) {
@@ -102,7 +102,7 @@ class Statemachine {
 
 	def dispatch structDeclaration(EventDefinition it) '''
 		sc_boolean «name.asIdentifier»_raised;
-		«IF type != null && type.name != 'void'»«type.targetLanguageTypeName»  «name.asIdentifier»_value;«ENDIF»
+		«IF type != null && type.name != 'void'»«type.targetLanguageName»  «name.asIdentifier»_value;«ENDIF»
 	'''
 
 	def dispatch structDeclaration(TimeEvent it) '''
@@ -110,7 +110,7 @@ class Statemachine {
 	'''
 
 	def dispatch structDeclaration(VariableDefinition it) '''
-		«IF type.name != 'void'»«type.targetLanguageTypeName»  «name.asEscapedIdentifier»;«ENDIF»
+		«IF type.name != 'void'»«type.targetLanguageName»  «name.asEscapedIdentifier»;«ENDIF»
 	'''
 	
 	def dispatch structDeclaration(Declaration it) ''''''
@@ -171,7 +171,7 @@ class Statemachine {
 			
 			«IF hasValue»
 				/*! Gets the value of the out event '«name»' that is defined in the «scope.scopeDescription». */ 
-				extern «type.targetLanguageTypeName» «asGetter»(«it.flow.type»* handle);
+				extern «type.targetLanguageName» «asGetter»(«it.flow.type»* handle);
 				
 			«ENDIF»
 		«ENDIF»
@@ -179,10 +179,10 @@ class Statemachine {
 
 	def dispatch functionPrototypes(VariableDefinition it) '''
 		/*! Gets the value of the variable '«name»' that is defined in the «scope.scopeDescription». */ 
-		extern «type.targetLanguageTypeName» «it.asGetter»(«it.flow.type»* handle);
+		extern «type.targetLanguageName» «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.targetLanguageTypeName» value);
+			extern void «asSetter»(«it.flow.type»* handle, «type.targetLanguageName» value);
 		«ENDIF»
 	'''
 }

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

@@ -8,26 +8,26 @@
  * 	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
+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
 import org.yakindu.sct.model.sgen.GeneratorEntry
-import org.yakindu.sct.generator.c.GenmodelEntries
+import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess
+import org.yakindu.sct.generator.c.GenmodelEntries
 
 class StatemachineC {
 	
 	@Inject extension Naming
 	@Inject extension Navigation
-	@Inject extension FlowCode
-	@Inject extension ITypeSystemAccess
-	@Inject extension GenmodelEntries
+	@Inject extension FlowCode
+	@Inject extension GenmodelEntries
+	@Inject extension ICodegenTypeSystemAccess
 	
 	def generateStatemachineC(ExecutionFlow flow, Statechart sc, IFileSystemAccess fsa, GeneratorEntry entry) {
 		 fsa.generateFile(flow.module.c, flow.statemachineCContent(entry) )
@@ -211,7 +211,7 @@ class StatemachineC {
 					return «event.access»;
 				}
 				«IF event.hasValue» 
-					«event.type.targetLanguageTypeName» «event.asGetter»(«scHandleDecl») {
+					«event.type.targetLanguageName» «event.asGetter»(«scHandleDecl») {
 						//TODO: Check if event is not raised
 						return «event.valueAccess»;
 					}
@@ -219,11 +219,11 @@ class StatemachineC {
 			«ENDFOR»
 			
 			«FOR variable : scope.variableDefinitions»
-				«variable.type.targetLanguageTypeName» «variable.asGetter»(«scHandleDecl») {
+				«variable.type.targetLanguageName» «variable.asGetter»(«scHandleDecl») {
 					return «variable.access»;
 				}
 				«IF !variable.readonly »
-				void «variable.asSetter»(«scHandleDecl», «variable.type.targetLanguageTypeName» value) {
+				void «variable.asSetter»(«scHandleDecl», «variable.type.targetLanguageName» value) {
 					«variable.access» = value;
 				}
 				«ENDIF»

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

@@ -15,16 +15,16 @@ import org.eclipse.xtext.generator.IFileSystemAccess
 import org.yakindu.sct.model.sexec.ExecutionFlow
 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
+import org.yakindu.sct.model.stext.stext.OperationDefinition
+import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess
 import org.yakindu.sct.model.sgen.GeneratorEntry
 
 class StatemachineRequired {
 
 	@Inject extension Naming cNaming
 	@Inject extension Navigation
-	@Inject extension ITypeSystemAccess
+	@Inject extension ICodegenTypeSystemAccess
 	@Inject extension GenmodelEntries
 	
 	def generateStatemachineClientH(ExecutionFlow flow, Statechart sc, IFileSystemAccess fsa, GeneratorEntry entry) {
@@ -116,7 +116,7 @@ class StatemachineRequired {
 	def dispatch functionPrototypes(Declaration it) ''''''
 
 	def dispatch functionPrototypes(OperationDefinition it) '''
-		extern «type.targetLanguageTypeName» «asFunction»(«FOR p : parameters SEPARATOR ', '»const «p.type.targetLanguageTypeName» «p.name.asIdentifier»«ENDFOR»);
+		extern «type.targetLanguageName» «asFunction»(«FOR p : parameters SEPARATOR ', '»const «p.type.targetLanguageName» «p.name.asIdentifier»«ENDFOR»);
 	'''
 
 }

+ 18 - 12
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/types/CTypeSystemAccess.xtend

@@ -8,23 +8,29 @@
  * 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
+package org.yakindu.sct.generator.c.types
+
+import com.google.inject.Inject
+import org.yakindu.base.types.Type
+import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess
+import org.yakindu.sct.model.stext.types.ISTextTypeSystem
 
 /**
  * @author andreas muelder
+ * @author Alexander Nyßen - Adopted to type system changes
  */
-class CTypeSystemAccess extends BaseTypeSystemAccessImpl {
+class CTypeSystemAccess implements ICodegenTypeSystemAccess {
+	
+	@Inject
+	extension ISTextTypeSystem ts
 	
-	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'
+	override getTargetLanguageName(Type type) {
+		switch (type) {
+			case type == null || isVoidType(type): 'void'
+			case isIntegerType(type): 'sc_integer'
+			case isRealType(type)	: 'sc_real'
+			case isBooleanType(type): 'sc_boolean'
+			case isStringType(type)	: 'sc_string'
 		}
 	}
 	

+ 1 - 0
plugins/org.yakindu.sct.generator.core/META-INF/MANIFEST.MF

@@ -29,4 +29,5 @@ Export-Package: org.yakindu.sct.builder.nature,
  org.yakindu.sct.generator.core.extensions,
  org.yakindu.sct.generator.core.features,
  org.yakindu.sct.generator.core.impl,
+ org.yakindu.sct.generator.core.types,
  org.yakindu.sct.generator.core.util

+ 20 - 19
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/extensions/TypeAnalyzerExtensions.java

@@ -14,19 +14,25 @@ import static org.yakindu.sct.generator.core.impl.AbstractXpandBasedCodeGenerato
 
 import org.eclipse.xtend.expression.ExecutionContext;
 import org.eclipse.xtend.expression.IExecutionContextAware;
-import org.yakindu.base.types.ITypeSystemAccess;
+import org.yakindu.base.types.ITypeSystem.InferredType;
 import org.yakindu.base.types.Type;
+import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess;
 import org.yakindu.sct.model.sgraph.Statement;
-import org.yakindu.sct.model.stext.validation.ITypeInferrer;
+import org.yakindu.sct.model.stext.stext.Expression;
+import org.yakindu.sct.model.stext.types.ISTextTypeInferrer;
+import org.yakindu.sct.model.stext.types.ISTextTypeSystem;
 
 import com.google.inject.Inject;
 import com.google.inject.Injector;
 
 public class TypeAnalyzerExtensions implements IExecutionContextAware {
+
+	@Inject
+	private ISTextTypeInferrer typeInferrer;
 	@Inject
-	private ITypeInferrer typeInferrer;
+	private ISTextTypeSystem typeSystem;
 	@Inject
-	private ITypeSystemAccess access;
+	private ICodegenTypeSystemAccess typeSystemAccess;
 
 	public void setExecutionContext(ExecutionContext ctx) {
 		Injector injector = null;
@@ -42,24 +48,19 @@ public class TypeAnalyzerExtensions implements IExecutionContextAware {
 		}
 	}
 
-	public boolean isBoolean(Type type) {
-		return access.isBoolean(type);
-	}
-
-	public boolean isInteger(Type type) {
-		return access.isInteger(type);
-	}
-
-	public boolean isReal(Type type) {
-		return access.isReal(type);
-	}
-
-	public boolean isString(Type type) {
-		return access.isString(type);
+	public boolean isStringType(Type type) {
+		return typeSystem.isStringType(new InferredType(type));
 	}
 
 	public Type getType(Statement stmt) {
-		return typeInferrer.getType(stmt);
+		if (stmt instanceof Expression) {
+			InferredType type = typeInferrer.inferType((Expression) stmt)
+					.getType();
+			if (type != null) {
+				return typeSystem.getTypes(type).iterator().next();
+			}
+		}
+		return null;
 	}
 
 }

+ 8 - 0
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/types/ICodegenTypeSystemAccess.java

@@ -0,0 +1,8 @@
+package org.yakindu.sct.generator.core.types;
+
+import org.yakindu.base.types.Type;
+
+public interface ICodegenTypeSystemAccess {
+
+	public String getTargetLanguageName(Type type);
+}

+ 41 - 41
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/ExpressionCode.xtend

@@ -1,43 +1,43 @@
-package org.yakindu.sct.generator.java
-
-import com.google.inject.Inject
-import org.eclipse.emf.ecore.EObject
-import org.yakindu.sct.generator.core.extensions.TypeAnalyzerExtensions
-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.Variable
-import org.yakindu.sct.model.stext.stext.ActiveStateReferenceExpression
-import org.yakindu.sct.model.stext.stext.AdditiveOperator
-import org.yakindu.sct.model.stext.stext.AssignmentExpression
-import org.yakindu.sct.model.stext.stext.AssignmentOperator
-import org.yakindu.sct.model.stext.stext.BitwiseAndExpression
-import org.yakindu.sct.model.stext.stext.BitwiseOrExpression
-import org.yakindu.sct.model.stext.stext.BitwiseXorExpression
-import org.yakindu.sct.model.stext.stext.BoolLiteral
-import org.yakindu.sct.model.stext.stext.ElementReferenceExpression
-import org.yakindu.sct.model.stext.stext.EventRaisingExpression
-import org.yakindu.sct.model.stext.stext.EventValueReferenceExpression
-import org.yakindu.sct.model.stext.stext.FeatureCall
-import org.yakindu.sct.model.stext.stext.HexLiteral
-import org.yakindu.sct.model.stext.stext.IntLiteral
-import org.yakindu.sct.model.stext.stext.LogicalAndExpression
-import org.yakindu.sct.model.stext.stext.LogicalNotExpression
-import org.yakindu.sct.model.stext.stext.LogicalOrExpression
-import org.yakindu.sct.model.stext.stext.LogicalRelationExpression
-import org.yakindu.sct.model.stext.stext.MultiplicativeOperator
-import org.yakindu.sct.model.stext.stext.NumericalAddSubtractExpression
-import org.yakindu.sct.model.stext.stext.NumericalMultiplyDivideExpression
-import org.yakindu.sct.model.stext.stext.NumericalUnaryExpression
-import org.yakindu.sct.model.stext.stext.OperationDefinition
-import org.yakindu.sct.model.stext.stext.ParenthesizedExpression
-import org.yakindu.sct.model.stext.stext.PrimitiveValueExpression
-import org.yakindu.sct.model.stext.stext.RealLiteral
-import org.yakindu.sct.model.stext.stext.RelationalOperator
-import org.yakindu.sct.model.stext.stext.ShiftExpression
-import org.yakindu.sct.model.stext.stext.ShiftOperator
-import org.yakindu.sct.model.stext.stext.StringLiteral
-import org.yakindu.sct.model.stext.stext.UnaryOperator
+package org.yakindu.sct.generator.java
+
+import com.google.inject.Inject
+import org.eclipse.emf.ecore.EObject
+import org.yakindu.sct.generator.core.extensions.TypeAnalyzerExtensions
+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.Variable
+import org.yakindu.sct.model.stext.stext.ActiveStateReferenceExpression
+import org.yakindu.sct.model.stext.stext.AdditiveOperator
+import org.yakindu.sct.model.stext.stext.AssignmentExpression
+import org.yakindu.sct.model.stext.stext.AssignmentOperator
+import org.yakindu.sct.model.stext.stext.BitwiseAndExpression
+import org.yakindu.sct.model.stext.stext.BitwiseOrExpression
+import org.yakindu.sct.model.stext.stext.BitwiseXorExpression
+import org.yakindu.sct.model.stext.stext.BoolLiteral
+import org.yakindu.sct.model.stext.stext.ElementReferenceExpression
+import org.yakindu.sct.model.stext.stext.EventRaisingExpression
+import org.yakindu.sct.model.stext.stext.EventValueReferenceExpression
+import org.yakindu.sct.model.stext.stext.FeatureCall
+import org.yakindu.sct.model.stext.stext.HexLiteral
+import org.yakindu.sct.model.stext.stext.IntLiteral
+import org.yakindu.sct.model.stext.stext.LogicalAndExpression
+import org.yakindu.sct.model.stext.stext.LogicalNotExpression
+import org.yakindu.sct.model.stext.stext.LogicalOrExpression
+import org.yakindu.sct.model.stext.stext.LogicalRelationExpression
+import org.yakindu.sct.model.stext.stext.MultiplicativeOperator
+import org.yakindu.sct.model.stext.stext.NumericalAddSubtractExpression
+import org.yakindu.sct.model.stext.stext.NumericalMultiplyDivideExpression
+import org.yakindu.sct.model.stext.stext.NumericalUnaryExpression
+import org.yakindu.sct.model.stext.stext.OperationDefinition
+import org.yakindu.sct.model.stext.stext.ParenthesizedExpression
+import org.yakindu.sct.model.stext.stext.PrimitiveValueExpression
+import org.yakindu.sct.model.stext.stext.RealLiteral
+import org.yakindu.sct.model.stext.stext.RelationalOperator
+import org.yakindu.sct.model.stext.stext.ShiftExpression
+import org.yakindu.sct.model.stext.stext.ShiftOperator
+import org.yakindu.sct.model.stext.stext.StringLiteral
+import org.yakindu.sct.model.stext.stext.UnaryOperator
 import org.yakindu.base.types.Operation
 
 class ExpressionCode {
@@ -103,7 +103,7 @@ class ExpressionCode {
 	}
 	
 	def dispatch String code(LogicalRelationExpression expression) {
-		if (expression.leftOperand.type.isString) {
+		if (expression.leftOperand.type.isStringType()) {
 			expression.logicalString
 		}
 		else

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

@@ -11,8 +11,8 @@ package org.yakindu.sct.generator.java;
 
 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.core.types.ICodegenTypeSystemAccess;
 import org.yakindu.sct.generator.java.types.JavaTypeSystemAccess;
 import org.yakindu.sct.model.sexec.ExecutionFlow;
 import org.yakindu.sct.model.sgen.GeneratorEntry;
@@ -43,7 +43,7 @@ public class JavaCodeGenerator extends GenericJavaBasedGenerator {
 		Module module = super.createModule(entry);
 		return Modules.override(module).with(new Module() {
 			public void configure(Binder binder) {
-				binder.bind(ITypeSystemAccess.class).to(
+				binder.bind(ICodegenTypeSystemAccess.class).to(
 						JavaTypeSystemAccess.class);
 			}
 		});

+ 32 - 30
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/Statemachine.xtend

@@ -13,20 +13,22 @@ import com.google.inject.Inject
 import org.eclipse.xtext.generator.IFileSystemAccess
 import org.yakindu.sct.model.sexec.ExecutionFlow
 import org.yakindu.sct.model.sgen.GeneratorEntry
-import org.yakindu.sct.model.stext.stext.InterfaceScope
-import org.yakindu.sct.model.stext.stext.Direction
-import org.yakindu.sct.model.stext.stext.EventDefinition
 import java.util.List
 import org.yakindu.sct.model.sexec.Step
 import org.yakindu.sct.model.sexec.Check
-import org.yakindu.base.types.ITypeSystemAccess
+import org.yakindu.sct.model.stext.types.ISTextTypeSystem
+import org.yakindu.sct.model.stext.stext.InterfaceScope
+import org.yakindu.sct.model.stext.stext.Direction
+import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess
+import org.yakindu.sct.model.stext.stext.EventDefinition
 
 class Statemachine {
 	
 	@Inject extension Naming
 	@Inject extension GenmodelEntries
 	@Inject extension Navigation
-	@Inject extension ITypeSystemAccess
+	@Inject extension ICodegenTypeSystemAccess
+	@Inject extension ISTextTypeSystem
 	@Inject extension FlowCode
 	@Inject Beautifier beautifier
 	
@@ -88,8 +90,8 @@ class Statemachine {
 		«FOR event : flow.internalScopeEvents»
 		private boolean «event.name.asEscapedIdentifier»;
 		
-		«IF !event.type.isVoid()»
-			private «event.type.targetLanguageTypeName» «event.valueIdentifier»;
+		«IF event.type != null && !event.type.voidType»
+			private «event.type.targetLanguageName» «event.valueIdentifier»;
 		«ENDIF»
 		«ENDFOR»
 		«var timeEvents = flow.timeEvents»
@@ -115,7 +117,7 @@ class Statemachine {
 		};
 		
 		«FOR variable : flow.internalScopeVariables»
-		private «variable.type.targetLanguageTypeName» «variable.name.asEscapedIdentifier»;
+		private «variable.type.targetLanguageName» «variable.name.asEscapedIdentifier»;
 		«ENDFOR»
 		
 		«IF flow.hasHistory»
@@ -267,18 +269,18 @@ class Statemachine {
 			
 			private boolean «event.name.asEscapedIdentifier»;
 			
-			«IF !event.type.isVoid()»
-				private «event.type.targetLanguageTypeName» «event.valueIdentifier»;
+			«IF event.type != null && !event.type.voidType»
+				private «event.type.targetLanguageName» «event.valueIdentifier»;
 			«ENDIF»
 			
 			«IF event.direction == Direction::IN»
-				«IF !event.type.void»
-					public void raise«event.name.asName»(«event.type.targetLanguageTypeName» value) {
+				«IF event.type != null && !event.type.voidType»
+					public void raise«event.name.asName»(«event.type.targetLanguageName» value) {
 						«event.name.asEscapedIdentifier» = true;
 						«event.valueIdentifier» = value;
 					}
 					
-					private «event.type.targetLanguageTypeName» get«event.name.asName»Value() {
+					private «event.type.targetLanguageName» get«event.name.asName»Value() {
 						«event.getIllegalAccessValidation()»
 						return «event.valueIdentifier»;
 					}
@@ -297,8 +299,8 @@ class Statemachine {
 					return «event.name.asEscapedIdentifier»;
 				}
 				
-				«IF !event.type.isVoid()»
-					private void raise«event.name.asName»(«event.type.targetLanguageTypeName» value) {
+				«IF event.type != null && !event.type.voidType»
+					private void raise«event.name.asName»(«event.type.targetLanguageName» value) {
 						«event.name.asEscapedIdentifier» = true;
 						«event.valueIdentifier» = value;
 						«IF entry.createInterfaceObserver»
@@ -308,7 +310,7 @@ class Statemachine {
 						«ENDIF»
 					}
 					
-					public «event.type.targetLanguageTypeName» get«event.name.asName»Value() {
+					public «event.type.targetLanguageName» get«event.name.asName»Value() {
 						«event.getIllegalAccessValidation()»
 						return «event.valueIdentifier»;
 					}
@@ -327,14 +329,14 @@ class Statemachine {
 		
 		«FOR variable : scope.variableDefinitions»
 				
-				private «variable.type.targetLanguageTypeName» «variable.name.asEscapedIdentifier»;
+				private «variable.type.targetLanguageName» «variable.name.asEscapedIdentifier»;
 				
-				public «variable.type.targetLanguageTypeName» «variable.getter» {
+				public «variable.type.targetLanguageName» «variable.getter» {
 					return «variable.name.asEscapedIdentifier»;
 				}
 				
 				«IF  !variable.readonly»
-					public void «variable.setter»(«variable.type.targetLanguageTypeName» value) {
+					public void «variable.setter»(«variable.type.targetLanguageName» value) {
 						this.«variable.name.asEscapedIdentifier» = value;
 					}
 				«ENDIF»
@@ -370,13 +372,13 @@ class Statemachine {
 	
 	def private internalScopeFunctions (ExecutionFlow flow) '''
 		«FOR event : flow.internalScopeEvents»
-			«IF !event.type.void»
-				private void raise«event.name.asEscapedName»(«event.type.targetLanguageTypeName» value) {
+			«IF event.type != null && !event.type.voidType»
+				private void raise«event.name.asEscapedName»(«event.type.targetLanguageName» value) {
 					«event.valueIdentifier» = value;
 					«event.name.asEscapedIdentifier» = true;
 				}
 				
-				private «event.type.targetLanguageTypeName» get«event.name.asEscapedName»Value() {
+				private «event.type.targetLanguageName» get«event.name.asEscapedName»Value() {
 					«event.getIllegalAccessValidation()»
 					return «event.valueIdentifier»;
 				}
@@ -389,11 +391,11 @@ class Statemachine {
 			«ENDIF»
 		«ENDFOR»
 «««		«FOR variable : flow.internalScopeVariables»
-«««		private «variable.type.targetLanguageTypeName» «variable.getter» {
+«««		private «variable.type.targetLanguageName» «variable.getter» {
 «««			return «variable.name.asEscapedIdentifier»;
 «««		}
 «««		
-«««		private void «variable.setter»(«variable.type.targetLanguageTypeName» value) {
+«««		private void «variable.setter»(«variable.type.targetLanguageName» value) {
 «««			«variable.name.asEscapedIdentifier» = value;
 «««		}	
 «««		«ENDFOR»
@@ -413,8 +415,8 @@ class Statemachine {
 			«var InterfaceScope scope = flow.defaultScope»
 			«FOR event : scope.eventDefinitions»
 				«IF event.direction == Direction::IN»
-					«IF !event.type.void»
-					public void raise«event.name.asName»(«event.type.targetLanguageTypeName» value) {
+					«IF event.type != null && !event.type.voidType»
+					public void raise«event.name.asName»(«event.type.targetLanguageName» value) {
 						«scope.interfaceName.asEscapedIdentifier».raise«event.name.asName»(value);
 					}
 					«ELSE»
@@ -427,8 +429,8 @@ class Statemachine {
 					public boolean isRaised«event.name.asName»() {
 						return «scope.interfaceName.asEscapedIdentifier».isRaised«event.name.asName»();
 					}
-					«IF !event.type.isVoid()»
-						public «event.type.targetLanguageTypeName» get«event.name.asName»Value() {
+					«IF event.type != null && !event.type.voidType»
+						public «event.type.targetLanguageName» get«event.name.asName»Value() {
 							return «scope.interfaceName.asEscapedIdentifier».get«event.name.asName»Value();
 						}
 					«ENDIF»
@@ -436,11 +438,11 @@ class Statemachine {
 			«ENDFOR»
 			
 			«FOR variable : scope.variableDefinitions»
-			public «variable.type.targetLanguageTypeName» «variable.getter()» {
+			public «variable.type.targetLanguageName» «variable.getter()» {
 				return «scope.interfaceName.asEscapedIdentifier».«variable.getter()»;
 			}
 			
-			public void «variable.setter»(«variable.type.targetLanguageTypeName» value) {
+			public void «variable.setter»(«variable.type.targetLanguageName» value) {
 				«scope.interfaceName.asEscapedIdentifier».«variable.setter»(value);
 			}	
 			«ENDFOR»

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

@@ -13,20 +13,22 @@ import com.google.inject.Inject
 import org.eclipse.xtext.generator.IFileSystemAccess
 import org.yakindu.sct.model.sexec.ExecutionFlow
 import org.yakindu.sct.model.sgen.GeneratorEntry
-import org.yakindu.sct.model.stext.stext.Direction
-import org.yakindu.sct.model.stext.stext.OperationDefinition
 import org.yakindu.base.types.Parameter
+import org.yakindu.sct.model.sgraph.Scope
+import org.yakindu.sct.model.stext.types.ISTextTypeSystem
 import org.yakindu.sct.model.stext.stext.InterfaceScope
 import org.yakindu.sct.model.stext.stext.InternalScope
-import org.yakindu.sct.model.sgraph.Scope
-import org.yakindu.base.types.ITypeSystemAccess
+import org.yakindu.sct.model.stext.stext.Direction
+import org.yakindu.sct.model.stext.stext.OperationDefinition
+import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess
 
 class StatemachineInterface {
 	
 	@Inject extension Naming 
 	@Inject extension GenmodelEntries
 	@Inject extension Navigation
-	@Inject extension ITypeSystemAccess
+	@Inject extension ISTextTypeSystem
+	@Inject extension ICodegenTypeSystemAccess
 	@Inject Beautifier beautifier
 	
 	def generateStatemachineInterface(ExecutionFlow flow, GeneratorEntry entry, IFileSystemAccess fsa) {
@@ -111,8 +113,8 @@ class StatemachineInterface {
 			public interface «scope.getInterfaceListenerName()» {
 				«FOR event : scope.eventDefinitions»
 					«IF event.direction ==  Direction::OUT»
-						«IF !event.type.isVoid()»
-							public void on«event.name.toFirstUpper()»Raised(«event.type.targetLanguageTypeName» value);
+						«IF !event.type.voidType»
+							public void on«event.name.toFirstUpper()»Raised(«event.type.targetLanguageName» value);
 						«ELSE»
 							public void on«event.name.toFirstUpper()»Raised();
 						«ENDIF»	
@@ -140,15 +142,17 @@ class StatemachineInterface {
 		'''
 		«FOR event : scope.eventDefinitions»
 			«IF  event.direction ==  Direction::IN»
-				«IF !event.type.void»
-					public void raise«event.name.asName»(«event.type.targetLanguageTypeName» value);
+				««« IMPORTANT: An event not specifying a type is regarded to have a void type		
+				«IF event.type != null && !event.type.voidType»
+					public void raise«event.name.asName»(«event.type.targetLanguageName» value);
 				«ELSE»
 					public void raise«event.name.asName»();
 				«ENDIF»
 			«ELSEIF event.direction ==  Direction::OUT»
 				public boolean isRaised«event.name.asName»();
-				«IF !event.type.void»
-					public «event.type.targetLanguageTypeName» get«event.name.asName»Value();
+				««« IMPORTANT: An event not specifying a type is regarded to have a void type
+				«IF event.type != null && !event.type.voidType»
+					public «event.type.targetLanguageName» get«event.name.asName»Value();
 				«ENDIF»	
 			«ENDIF»
 		«ENDFOR»
@@ -157,9 +161,9 @@ class StatemachineInterface {
 	
 	def variableAccessors(InterfaceScope scope) '''
 		«FOR variable : scope.variableDefinitions»
-					public «variable.type.targetLanguageTypeName» «variable.getter»;
+					public «variable.type.targetLanguageName» «variable.getter»;
 					«IF  !variable.readonly»
-						public void «variable.setter»(«variable.type.targetLanguageTypeName» value);	
+						public void «variable.setter»(«variable.type.targetLanguageName» value);	
 					«ENDIF»
 		«ENDFOR»
 	'''
@@ -179,7 +183,7 @@ class StatemachineInterface {
 	
 	def private operationSignature(OperationDefinition it) {
 		'''
-		public «type.targetLanguageTypeName» «name.asEscapedIdentifier»(«FOR parameter : parameters SEPARATOR ', '»«parameter.type.targetLanguageTypeName» «parameter.identifier»«ENDFOR»);
+		public «type.targetLanguageName» «name.asEscapedIdentifier»(«FOR parameter : parameters SEPARATOR ', '»«parameter.type.targetLanguageName» «parameter.identifier»«ENDFOR»);
 		'''
 	}
 	

+ 18 - 12
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/types/JavaTypeSystemAccess.xtend

@@ -8,23 +8,29 @@
  * Contributors:
  *     committers of YAKINDU - initial API and implementation
  */
-package org.yakindu.sct.generator.java.types
-
-import org.yakindu.base.types.impl.BaseTypeSystemAccessImpl
-import org.yakindu.base.types.Type
+package org.yakindu.sct.generator.java.types
+
+import com.google.inject.Inject
+import org.yakindu.base.types.Type
+import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess
+import org.yakindu.sct.model.stext.types.ISTextTypeSystem
 
 /**
  * @author andreas muelder
+ * @author Alexander Nyßen - Adopted to type system changes
  */
-class JavaTypeSystemAccess extends BaseTypeSystemAccessImpl {
+class JavaTypeSystemAccess implements ICodegenTypeSystemAccess {
+	
+	@Inject
+	private extension ISTextTypeSystem ts
 	
-	override getTargetLanguageTypeName(Type type) {
-		switch (type.name) {
-			case "real" : "double"
-			case "integer" : "int"
-			case "boolean" : "boolean"
-			case "string" : "String"
-			case "void" : "void"
+	override String getTargetLanguageName(Type type) {
+		switch (type) {
+			case type == null || isVoidType(type): "void"
+			case isRealType(type) : "double"
+			case isIntegerType(type) : "int"
+			case isBooleanType(type) : "boolean"
+			case isStringType(type) : "String"
 			default : "//"+this
 		};
 	}

+ 3 - 3
plugins/org.yakindu.sct.model.sexec.interpreter/src/org/yakindu/sct/model/sexec/interpreter/InterpreterModule.java

@@ -10,12 +10,12 @@
  */
 package org.yakindu.sct.model.sexec.interpreter;
 
-import org.yakindu.base.types.ITypeSystemAccess;
-import org.yakindu.base.types.impl.BaseTypeSystemAccessImpl;
+import org.yakindu.base.types.ITypeSystem;
 import org.yakindu.sct.model.sexec.interpreter.impl.ExecutionFlowInterpreter;
 import org.yakindu.sct.model.sexec.interpreter.impl.TimerTaskTimingService;
 import org.yakindu.sct.model.sexec.interpreter.stext.StextStatementInterpreter;
 import org.yakindu.sct.model.sexec.transformation.SequencerModule;
+import org.yakindu.sct.model.stext.types.STextDefaulTypeSystem;
 import org.yakindu.sct.simulation.core.runtime.IExecutionContext;
 import org.yakindu.sct.simulation.core.runtime.impl.ExecutionContextImpl;
 
@@ -44,6 +44,6 @@ public class InterpreterModule implements Module {
 		binder.bind(ITimingService.class).to(TimerTaskTimingService.class);
 		binder.bind(IExecutionFlowInterpreter.class).to(
 				ExecutionFlowInterpreter.class);
-		binder.bind(ITypeSystemAccess.class).to(BaseTypeSystemAccessImpl.class);
+		binder.bind(ITypeSystem.class).to(STextDefaulTypeSystem.class);
 	}
 }

+ 54 - 55
plugins/org.yakindu.sct.model.sexec.interpreter/src/org/yakindu/sct/model/sexec/interpreter/impl/ExecutionFlowInterpreter.xtend

@@ -8,54 +8,53 @@
  * 	committers of YAKINDU - initial API and implementation
  * 
  */
-package org.yakindu.sct.model.sexec.interpreter.impl
-
-import com.google.inject.Inject
-import com.google.inject.name.Named
-import org.yakindu.base.types.ITypeSystemAccess
-import org.yakindu.base.types.Type
-import org.yakindu.sct.model.sexec.Call
-import org.yakindu.sct.model.sexec.Check
-import org.yakindu.sct.model.sexec.EnterState
-import org.yakindu.sct.model.sexec.Execution
-import org.yakindu.sct.model.sexec.ExecutionFlow
-import org.yakindu.sct.model.sexec.ExitState
-import org.yakindu.sct.model.sexec.HistoryEntry
-import org.yakindu.sct.model.sexec.If
-import org.yakindu.sct.model.sexec.SaveHistory
-import org.yakindu.sct.model.sexec.ScheduleTimeEvent
-import org.yakindu.sct.model.sexec.Sequence
-import org.yakindu.sct.model.sexec.SexecFactory
-import org.yakindu.sct.model.sexec.StateSwitch
-import org.yakindu.sct.model.sexec.Step
-import org.yakindu.sct.model.sexec.TimeEvent
-import org.yakindu.sct.model.sexec.Trace
-import org.yakindu.sct.model.sexec.TraceBeginRunCycle
-import org.yakindu.sct.model.sexec.TraceEndRunCycle
-import org.yakindu.sct.model.sexec.UnscheduleTimeEvent
-import org.yakindu.sct.model.sexec.interpreter.IExecutionFlowInterpreter
-import org.yakindu.sct.model.sexec.interpreter.IStatementInterpreter
-import org.yakindu.sct.model.sexec.interpreter.ITimingService
-import org.yakindu.sct.model.sgraph.Scope
-import org.yakindu.sct.model.stext.naming.StextNameProvider
-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.simulation.core.runtime.AbstractExecutionFacade
-import org.yakindu.sct.simulation.core.runtime.IExecutionContext
-import org.yakindu.sct.simulation.core.runtime.impl.ExecutionEvent
+package org.yakindu.sct.model.sexec.interpreter.impl
+
+import com.google.inject.Inject
+import com.google.inject.name.Named
+import org.yakindu.base.types.Type
+import org.yakindu.sct.model.sexec.Call
+import org.yakindu.sct.model.sexec.Check
+import org.yakindu.sct.model.sexec.EnterState
+import org.yakindu.sct.model.sexec.Execution
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sexec.ExitState
+import org.yakindu.sct.model.sexec.HistoryEntry
+import org.yakindu.sct.model.sexec.If
+import org.yakindu.sct.model.sexec.SaveHistory
+import org.yakindu.sct.model.sexec.ScheduleTimeEvent
+import org.yakindu.sct.model.sexec.Sequence
+import org.yakindu.sct.model.sexec.SexecFactory
+import org.yakindu.sct.model.sexec.StateSwitch
+import org.yakindu.sct.model.sexec.Step
+import org.yakindu.sct.model.sexec.TimeEvent
+import org.yakindu.sct.model.sexec.Trace
+import org.yakindu.sct.model.sexec.TraceBeginRunCycle
+import org.yakindu.sct.model.sexec.TraceEndRunCycle
+import org.yakindu.sct.model.sexec.UnscheduleTimeEvent
+import org.yakindu.sct.model.sexec.interpreter.IExecutionFlowInterpreter
+import org.yakindu.sct.model.sexec.interpreter.IStatementInterpreter
+import org.yakindu.sct.model.sexec.interpreter.ITimingService
+import org.yakindu.sct.model.sgraph.Scope
+import org.yakindu.sct.model.stext.naming.StextNameProvider
+import org.yakindu.sct.simulation.core.runtime.AbstractExecutionFacade
+import org.yakindu.sct.simulation.core.runtime.IExecutionContext
+import org.yakindu.sct.simulation.core.runtime.impl.ExecutionEvent
 import org.yakindu.sct.simulation.core.runtime.impl.ExecutionVariable
-import org.yakindu.sct.model.stext.stext.Direction
 import java.util.List
-import java.util.ArrayList
 import java.util.Map
 import org.yakindu.sct.model.sgraph.Declaration
 import org.yakindu.sct.simulation.core.runtime.ISlot
 import java.util.HashMap
 import org.yakindu.sct.simulation.core.runtime.IEventSlot
 import org.yakindu.sct.model.sgraph.Event
+import org.yakindu.sct.model.stext.stext.EventDefinition
+import org.yakindu.sct.model.stext.types.ISTextTypeSystem
+import org.yakindu.sct.model.stext.stext.InterfaceScope
+import org.yakindu.sct.model.stext.stext.InternalScope
+import org.yakindu.sct.model.stext.stext.VariableDefinition
+import org.yakindu.sct.model.stext.stext.OperationDefinition
+import org.yakindu.sct.model.stext.stext.Direction
 
 /**
  * 
@@ -74,7 +73,7 @@ class ExecutionFlowInterpreter extends AbstractExecutionFacade implements IExecu
 	@Inject 
 	ITimingService timingService
 	@Inject extension
-	ITypeSystemAccess ts
+	ISTextTypeSystem tsa
 	 
 	@Inject
 	@Named("InterpreterName")
@@ -192,16 +191,16 @@ class ExecutionFlowInterpreter extends AbstractExecutionFacade implements IExecu
 		var fqName = provider.qualifiedName(variable).toString
 		var ExecutionVariable varSlot 
 		
-		if(variable.type.^boolean){
+		if(variable.type.booleanType){
 			varSlot = new ExecutionVariable(fqName ,typeof(Boolean),false)
 		} 
-		else if (variable.type.integer){
+		else if (variable.type.integerType){
 			varSlot = new ExecutionVariable(fqName,typeof(Integer),0)
 		}
-		else if(variable.type.real){
+		else if(variable.type.realType){
 			varSlot = new ExecutionVariable(fqName,typeof(Float),0.0f)
 		}
-		else if (variable.type.string){
+		else if (variable.type.stringType){
 			varSlot = new ExecutionVariable(fqName,typeof(String),"")
 		}
 		
@@ -213,19 +212,19 @@ class ExecutionFlowInterpreter extends AbstractExecutionFacade implements IExecu
 		var fqName = provider.qualifiedName(event).toString
 		var ExecutionEvent eventSlot
 		
-		if(event.type.^boolean){
+		if(event.type.booleanType){
 			eventSlot = new ExecutionEvent(fqName,typeof(Boolean),false)
 		}
-		else if(event.type.integer){
+		else if(event.type.integerType){
 			eventSlot = new ExecutionEvent(fqName,typeof(Integer),0)
 		}
-		else if(event.type.real){
+		else if(event.type.realType){
 			eventSlot = new ExecutionEvent(fqName,typeof(Float),0.0f)
 		}
-		else if(event.type.^void){
+		else if(event.type.voidType){
 			eventSlot = new ExecutionEvent(fqName,typeof(Void))
 		}
-		else if (event.type.string){
+		else if (event.type.stringType){
 			eventSlot = new ExecutionEvent(fqName,typeof(String),"")
 		}
 		 
@@ -244,11 +243,11 @@ class ExecutionFlowInterpreter extends AbstractExecutionFacade implements IExecu
 	}
 	
 	def Class<?> mappedType(Type it) {
-		if(it.^boolean)		{ typeof(Boolean) } 
-		else if(it.integer)	{ typeof(Integer) }
-		else if(it.real)	{ typeof(Float) }
-		else if(it.^void)	{ typeof(Void)	}
-		else if(it.string)	{ typeof(String) }
+		if(it.booleanType)		{ typeof(Boolean) } 
+		else if(it.integerType)	{ typeof(Integer) }
+		else if(it.realType)	{ typeof(Float) }
+		else if(it.voidType)	{ typeof(Void)	}
+		else if(it.stringType)	{ typeof(String) }
 		else null 
 	} 
 	

+ 1 - 0
plugins/org.yakindu.sct.model.sexec.interpreter/src/org/yakindu/sct/model/sexec/interpreter/stext/CoreFunction.java

@@ -12,6 +12,7 @@ package org.yakindu.sct.model.sexec.interpreter.stext;
 
 public class CoreFunction extends Function {
 
+	// TODO: Unify with type system
 	public static String EQUALS = "==";
 	public static String NOT_EQUALS = "!=";
 	public static String SMALLER = "<";

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 754 - 754
plugins/org.yakindu.sct.model.sexec.interpreter/xtend-gen/org/yakindu/sct/model/sexec/interpreter/impl/ExecutionFlowInterpreter.java


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 580 - 580
plugins/org.yakindu.sct.model.sexec.interpreter/xtend-gen/org/yakindu/sct/model/sexec/interpreter/stext/StextStatementInterpreter.java


+ 10 - 11
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/SequenceBuilder.xtend

@@ -13,23 +13,22 @@ import org.yakindu.sct.model.sgraph.RegularState
 import org.yakindu.sct.model.sgraph.State
 import org.yakindu.sct.model.sgraph.Statechart
 import org.yakindu.sct.model.sgraph.Vertex
-import org.yakindu.sct.model.stext.stext.AssignmentOperator
-import org.yakindu.sct.model.stext.stext.VariableDefinition
+import org.yakindu.sct.model.sgraph.Statement
 
 import static extension org.eclipse.emf.ecore.util.EcoreUtil.*
+import org.yakindu.sct.model.stext.stext.VariableDefinition
+import org.yakindu.sct.model.stext.stext.AssignmentOperator
 import org.yakindu.sct.model.stext.stext.TimeEventSpec
-import org.yakindu.sct.model.stext.stext.MultiplicativeOperator
-import org.yakindu.sct.model.sgraph.Statement
 import org.yakindu.sct.model.stext.stext.Expression
 import org.yakindu.sct.model.stext.stext.NumericalMultiplyDivideExpression
 import org.yakindu.sct.model.stext.stext.PrimitiveValueExpression
 import org.yakindu.sct.model.stext.stext.IntLiteral
+import org.yakindu.sct.model.stext.stext.MultiplicativeOperator
 import org.yakindu.sct.model.stext.stext.TimeUnit
-import org.yakindu.base.types.ITypeSystemAccess
 import org.yakindu.sct.model.stext.stext.BoolLiteral
 import org.yakindu.sct.model.stext.stext.RealLiteral
 import org.yakindu.sct.model.stext.stext.StringLiteral
-
+import org.yakindu.sct.model.stext.types.ISTextTypeSystem
 
 class SequenceBuilder {
 	
@@ -40,7 +39,7 @@ class SequenceBuilder {
 	@Inject extension SexecElementMapping mapping
 	@Inject extension TraceExtensions trace
 	
-	@Inject extension ITypeSystemAccess tsa
+	@Inject extension ISTextTypeSystem ts
 	
 	
 	@Inject @Named("ADD_TRACES") 
@@ -425,10 +424,10 @@ class SequenceBuilder {
 			return vd.initialValue
 		} else {
 			switch (vd) {
-				case vd.type.isBoolean: false.buildValue
-				case vd.type.isInteger: 0.buildValue
-				case vd.type.isReal: buildValue(0.0 as float)
-				case vd.type.isString: "".buildValue
+				case isBooleanType(vd.type): false.buildValue
+				case isIntegerType(vd.type): 0.buildValue
+				case isRealType(vd.type): buildValue(0.0 as float)
+				case isStringType(vd.type): "".buildValue
 				default : null
 			}
 		}

+ 4 - 4
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/SequencerModule.java

@@ -1,9 +1,9 @@
 package org.yakindu.sct.model.sexec.transformation;
 
 import org.eclipse.xtext.naming.IQualifiedNameProvider;
-import org.yakindu.base.types.ITypeSystemAccess;
-import org.yakindu.base.types.impl.BaseTypeSystemAccessImpl;
 import org.yakindu.sct.model.sgraph.naming.SGraphNameProvider;
+import org.yakindu.sct.model.stext.types.ISTextTypeSystem;
+import org.yakindu.sct.model.stext.types.STextDefaulTypeSystem;
 
 import com.google.inject.Binder;
 import com.google.inject.Module;
@@ -20,10 +20,10 @@ public class SequencerModule implements Module {
 
 	public void configure(Binder binder) {
 		binder.bind(IQualifiedNameProvider.class).to(SGraphNameProvider.class);
-		binder.bind(ITypeSystemAccess.class).to(BaseTypeSystemAccessImpl.class);
+		binder.bind(ISTextTypeSystem.class).to(STextDefaulTypeSystem.class);
 		binder.bind(Boolean.class).annotatedWith(Names.named(ADD_TRACES))
 				.toInstance(Boolean.FALSE);
-		
+
 	}
 
 }

BIN=BIN
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.SequenceBuilder.java._trace


BIN=BIN
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.StateVectorBuilder.java._trace


+ 10 - 10
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SequenceBuilder.java

@@ -21,7 +21,6 @@ import org.eclipse.xtext.xbase.lib.IterableExtensions;
 import org.eclipse.xtext.xbase.lib.IteratorExtensions;
 import org.eclipse.xtext.xbase.lib.ListExtensions;
 import org.yakindu.base.base.NamedElement;
-import org.yakindu.base.types.ITypeSystemAccess;
 import org.yakindu.base.types.Type;
 import org.yakindu.sct.model.sexec.Call;
 import org.yakindu.sct.model.sexec.EnterState;
@@ -74,6 +73,7 @@ import org.yakindu.sct.model.stext.stext.StringLiteral;
 import org.yakindu.sct.model.stext.stext.TimeEventSpec;
 import org.yakindu.sct.model.stext.stext.TimeUnit;
 import org.yakindu.sct.model.stext.stext.VariableDefinition;
+import org.yakindu.sct.model.stext.types.ISTextTypeSystem;
 
 @SuppressWarnings("all")
 public class SequenceBuilder {
@@ -96,7 +96,7 @@ public class SequenceBuilder {
   private TraceExtensions trace;
   
   @Inject
-  private ITypeSystemAccess tsa;
+  private ISTextTypeSystem ts;
   
   @Inject
   @Named(value = "ADD_TRACES")
@@ -767,8 +767,8 @@ public class SequenceBuilder {
       boolean _matched = false;
       if (!_matched) {
         Type _type = vd.getType();
-        boolean _isBoolean = this.tsa.isBoolean(_type);
-        if (_isBoolean) {
+        boolean _isBooleanType = this.ts.isBooleanType(_type);
+        if (_isBooleanType) {
           _matched=true;
           Expression _buildValue = this.buildValue(false);
           _switchResult = _buildValue;
@@ -776,8 +776,8 @@ public class SequenceBuilder {
       }
       if (!_matched) {
         Type _type_1 = vd.getType();
-        boolean _isInteger = this.tsa.isInteger(_type_1);
-        if (_isInteger) {
+        boolean _isIntegerType = this.ts.isIntegerType(_type_1);
+        if (_isIntegerType) {
           _matched=true;
           Expression _buildValue_1 = this.buildValue(0);
           _switchResult = _buildValue_1;
@@ -785,8 +785,8 @@ public class SequenceBuilder {
       }
       if (!_matched) {
         Type _type_2 = vd.getType();
-        boolean _isReal = this.tsa.isReal(_type_2);
-        if (_isReal) {
+        boolean _isRealType = this.ts.isRealType(_type_2);
+        if (_isRealType) {
           _matched=true;
           Expression _buildValue_2 = this.buildValue(((float) 0.0));
           _switchResult = _buildValue_2;
@@ -794,8 +794,8 @@ public class SequenceBuilder {
       }
       if (!_matched) {
         Type _type_3 = vd.getType();
-        boolean _isString = this.tsa.isString(_type_3);
-        if (_isString) {
+        boolean _isStringType = this.ts.isStringType(_type_3);
+        if (_isStringType) {
           _matched=true;
           Expression _buildValue_3 = this.buildValue("");
           _switchResult = _buildValue_3;

+ 257 - 257
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StateVectorBuilder.java

@@ -1,257 +1,257 @@
-package org.yakindu.sct.model.sexec.transformation;
-
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Iterators;
-import com.google.inject.Inject;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.Functions.Function2;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.IteratorExtensions;
-import org.yakindu.sct.model.sexec.ExecutionFlow;
-import org.yakindu.sct.model.sexec.ExecutionRegion;
-import org.yakindu.sct.model.sexec.ExecutionState;
-import org.yakindu.sct.model.sexec.SexecFactory;
-import org.yakindu.sct.model.sexec.StateVector;
-import org.yakindu.sct.model.sexec.transformation.SexecElementMapping;
-import org.yakindu.sct.model.sexec.transformation.SexecExtensions;
-import org.yakindu.sct.model.sexec.transformation.SgraphExtensions;
-import org.yakindu.sct.model.sexec.transformation.StatechartExtensions;
-import org.yakindu.sct.model.sgraph.Choice;
-import org.yakindu.sct.model.sgraph.FinalState;
-import org.yakindu.sct.model.sgraph.Region;
-import org.yakindu.sct.model.sgraph.RegularState;
-import org.yakindu.sct.model.sgraph.State;
-import org.yakindu.sct.model.sgraph.Statechart;
-import org.yakindu.sct.model.sgraph.Vertex;
-
-@SuppressWarnings("all")
-public class StateVectorBuilder {
-  @Inject
-  private SexecExtensions sexec;
-  
-  @Inject
-  private SexecElementMapping mapping;
-  
-  @Inject
-  private StatechartExtensions sc;
-  
-  @Inject
-  private SgraphExtensions sgraph;
-  
-  public void defineHistoryVector(final ExecutionFlow flow, final Statechart sc) {
-    int offset = (-1);
-    TreeIterator<EObject> _eAllContents = sc.eAllContents();
-    Iterator<Region> _filter = Iterators.<Region>filter(_eAllContents, Region.class);
-    Iterable<Region> _iterable = IteratorExtensions.<Region>toIterable(_filter);
-    for (final Region r : _iterable) {
-      boolean _requireHistory = this.sgraph.requireHistory(r);
-      if (_requireHistory) {
-        int _plus = (offset + 1);
-        offset = _plus;
-        final ExecutionRegion er = this.mapping.create(r);
-        SexecFactory _factory = this.sexec.factory();
-        StateVector _createStateVector = _factory.createStateVector();
-        er.setHistoryVector(_createStateVector);
-        StateVector _historyVector = er.getHistoryVector();
-        _historyVector.setOffset(offset);
-        StateVector _historyVector_1 = er.getHistoryVector();
-        _historyVector_1.setSize(1);
-      }
-    }
-    int _minus = (-1);
-    boolean _notEquals = (offset != _minus);
-    if (_notEquals) {
-      SexecFactory _factory_1 = this.sexec.factory();
-      StateVector _createStateVector_1 = _factory_1.createStateVector();
-      flow.setHistoryVector(_createStateVector_1);
-      StateVector _historyVector_2 = flow.getHistoryVector();
-      _historyVector_2.setOffset(0);
-      StateVector _historyVector_3 = flow.getHistoryVector();
-      int _plus_1 = (offset + 1);
-      _historyVector_3.setSize(_plus_1);
-    }
-  }
-  
-  public void defineStateVector(final ExecutionFlow flow, final Statechart sc) {
-    int offset = 0;
-    EList<Region> _regions = sc.getRegions();
-    for (final Region r : _regions) {
-      int _defineStateVectors = this.defineStateVectors(r, offset);
-      int _plus = (offset + _defineStateVectors);
-      offset = _plus;
-    }
-    SexecFactory _factory = this.sexec.factory();
-    StateVector _createStateVector = _factory.createStateVector();
-    flow.setStateVector(_createStateVector);
-    StateVector _stateVector = flow.getStateVector();
-    _stateVector.setOffset(0);
-    StateVector _stateVector_1 = flow.getStateVector();
-    _stateVector_1.setSize(offset);
-  }
-  
-  /**
-   * calculates the maximum orthogonality (maximum number of possible active leaf states) of the statechart
-   */
-  public int defineStateVectors(final Statechart sc, final int offset) {
-    EList<Region> _regions = sc.getRegions();
-    final Function2<Integer,Region,Integer> _function = new Function2<Integer,Region,Integer>() {
-        public Integer apply(final Integer o, final Region r) {
-          int _maxOrthogonality = StateVectorBuilder.this.sc.maxOrthogonality(r);
-          int _plus = (_maxOrthogonality + (o).intValue());
-          return Integer.valueOf(_plus);
-        }
-      };
-    Integer _fold = IterableExtensions.<Region, Integer>fold(_regions, Integer.valueOf(0), _function);
-    return (_fold).intValue();
-  }
-  
-  /**
-   * calculates the maximum orthogonality (maximum number of possible active leaf states) of a region
-   */
-  public int defineStateVectors(final Region r, final int offset) {
-    EList<Vertex> _vertices = r.getVertices();
-    final Function2<Integer,Vertex,Integer> _function = new Function2<Integer,Vertex,Integer>() {
-        public Integer apply(final Integer s, final Vertex v) {
-          int _xblockexpression = (int) 0;
-          {
-            final int mo = StateVectorBuilder.this.defineStateVectors(v, offset);
-            int _xifexpression = (int) 0;
-            boolean _greaterThan = (mo > (s).intValue());
-            if (_greaterThan) {
-              _xifexpression = mo;
-            } else {
-              _xifexpression = s;
-            }
-            _xblockexpression = (_xifexpression);
-          }
-          return Integer.valueOf(_xblockexpression);
-        }
-      };
-    final Integer maxOrthogonality = IterableExtensions.<Vertex, Integer>fold(_vertices, Integer.valueOf(0), _function);
-    final ExecutionRegion er = this.mapping.create(r);
-    SexecFactory _factory = this.sexec.factory();
-    StateVector _createStateVector = _factory.createStateVector();
-    er.setStateVector(_createStateVector);
-    StateVector _stateVector = er.getStateVector();
-    _stateVector.setOffset(offset);
-    StateVector _stateVector_1 = er.getStateVector();
-    _stateVector_1.setSize((maxOrthogonality).intValue());
-    return (maxOrthogonality).intValue();
-  }
-  
-  /**
-   * the maximum orthogonality of all  pseudo states is 0
-   */
-  protected int _defineStateVectors(final Vertex v, final int offset) {
-    return 0;
-  }
-  
-  /**
-   * calculates the maximum orthogonality (maximum number of possible active leaf states) of a state
-   */
-  protected int _defineStateVectors(final State s, final int offset) {
-    int maxOrthogonality = 0;
-    EList<Region> _regions = s.getRegions();
-    boolean _containsStates = this.containsStates(_regions);
-    if (_containsStates) {
-      EList<Region> _regions_1 = s.getRegions();
-      for (final Region r : _regions_1) {
-        int _plus = (offset + maxOrthogonality);
-        int _defineStateVectors = this.defineStateVectors(r, _plus);
-        int _plus_1 = (maxOrthogonality + _defineStateVectors);
-        maxOrthogonality = _plus_1;
-      }
-    } else {
-      maxOrthogonality = 1;
-    }
-    final ExecutionState es = this.mapping.create(s);
-    SexecFactory _factory = this.sexec.factory();
-    StateVector _createStateVector = _factory.createStateVector();
-    es.setStateVector(_createStateVector);
-    StateVector _stateVector = es.getStateVector();
-    _stateVector.setOffset(offset);
-    StateVector _stateVector_1 = es.getStateVector();
-    _stateVector_1.setSize(maxOrthogonality);
-    return maxOrthogonality;
-  }
-  
-  public boolean containsStates(final List<Region> regions) {
-    final Function1<Region,Boolean> _function = new Function1<Region,Boolean>() {
-        public Boolean apply(final Region r) {
-          EList<Vertex> _vertices = r.getVertices();
-          Iterable<RegularState> _filter = Iterables.<RegularState>filter(_vertices, RegularState.class);
-          int _size = IterableExtensions.size(_filter);
-          boolean _greaterThan = (_size > 0);
-          return Boolean.valueOf(_greaterThan);
-        }
-      };
-    Iterable<Region> _filter = IterableExtensions.<Region>filter(regions, _function);
-    int _size = IterableExtensions.size(_filter);
-    boolean _greaterThan = (_size > 0);
-    return _greaterThan;
-  }
-  
-  /**
-   * calculates the maximum orthogonality (maximum number of possible active leaf states) of a state
-   */
-  protected int _defineStateVectors(final FinalState s, final int offset) {
-    final ExecutionState es = this.mapping.create(s);
-    SexecFactory _factory = this.sexec.factory();
-    StateVector _createStateVector = _factory.createStateVector();
-    es.setStateVector(_createStateVector);
-    StateVector _stateVector = es.getStateVector();
-    _stateVector.setOffset(offset);
-    StateVector _stateVector_1 = es.getStateVector();
-    _stateVector_1.setSize(1);
-    return 1;
-  }
-  
-  protected StateVector _stateVector(final Vertex v) {
-    return null;
-  }
-  
-  protected StateVector _stateVector(final RegularState s) {
-    ExecutionState _create = this.mapping.create(s);
-    StateVector _stateVector = _create.getStateVector();
-    return _stateVector;
-  }
-  
-  protected StateVector _stateVector(final Choice choice) {
-    Region _parentRegion = choice.getParentRegion();
-    ExecutionRegion _create = this.mapping.create(_parentRegion);
-    StateVector _stateVector = _create.getStateVector();
-    return _stateVector;
-  }
-  
-  public int defineStateVectors(final Vertex s, final int offset) {
-    if (s instanceof FinalState) {
-      return _defineStateVectors((FinalState)s, offset);
-    } else if (s instanceof State) {
-      return _defineStateVectors((State)s, offset);
-    } else if (s != null) {
-      return _defineStateVectors(s, offset);
-    } else {
-      throw new IllegalArgumentException("Unhandled parameter types: " +
-        Arrays.<Object>asList(s, offset).toString());
-    }
-  }
-  
-  public StateVector stateVector(final Vertex choice) {
-    if (choice instanceof Choice) {
-      return _stateVector((Choice)choice);
-    } else if (choice instanceof RegularState) {
-      return _stateVector((RegularState)choice);
-    } else if (choice != null) {
-      return _stateVector(choice);
-    } else {
-      throw new IllegalArgumentException("Unhandled parameter types: " +
-        Arrays.<Object>asList(choice).toString());
-    }
-  }
-}
+package org.yakindu.sct.model.sexec.transformation;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Iterators;
+import com.google.inject.Inject;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.Functions.Function2;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.IteratorExtensions;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.ExecutionRegion;
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sexec.SexecFactory;
+import org.yakindu.sct.model.sexec.StateVector;
+import org.yakindu.sct.model.sexec.transformation.SexecElementMapping;
+import org.yakindu.sct.model.sexec.transformation.SexecExtensions;
+import org.yakindu.sct.model.sexec.transformation.SgraphExtensions;
+import org.yakindu.sct.model.sexec.transformation.StatechartExtensions;
+import org.yakindu.sct.model.sgraph.Choice;
+import org.yakindu.sct.model.sgraph.FinalState;
+import org.yakindu.sct.model.sgraph.Region;
+import org.yakindu.sct.model.sgraph.RegularState;
+import org.yakindu.sct.model.sgraph.State;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.sgraph.Vertex;
+
+@SuppressWarnings("all")
+public class StateVectorBuilder {
+  @Inject
+  private SexecExtensions sexec;
+  
+  @Inject
+  private SexecElementMapping mapping;
+  
+  @Inject
+  private StatechartExtensions sc;
+  
+  @Inject
+  private SgraphExtensions sgraph;
+  
+  public void defineHistoryVector(final ExecutionFlow flow, final Statechart sc) {
+    int offset = (-1);
+    TreeIterator<EObject> _eAllContents = sc.eAllContents();
+    Iterator<Region> _filter = Iterators.<Region>filter(_eAllContents, Region.class);
+    Iterable<Region> _iterable = IteratorExtensions.<Region>toIterable(_filter);
+    for (final Region r : _iterable) {
+      boolean _requireHistory = this.sgraph.requireHistory(r);
+      if (_requireHistory) {
+        int _plus = (offset + 1);
+        offset = _plus;
+        final ExecutionRegion er = this.mapping.create(r);
+        SexecFactory _factory = this.sexec.factory();
+        StateVector _createStateVector = _factory.createStateVector();
+        er.setHistoryVector(_createStateVector);
+        StateVector _historyVector = er.getHistoryVector();
+        _historyVector.setOffset(offset);
+        StateVector _historyVector_1 = er.getHistoryVector();
+        _historyVector_1.setSize(1);
+      }
+    }
+    int _minus = (-1);
+    boolean _notEquals = (offset != _minus);
+    if (_notEquals) {
+      SexecFactory _factory_1 = this.sexec.factory();
+      StateVector _createStateVector_1 = _factory_1.createStateVector();
+      flow.setHistoryVector(_createStateVector_1);
+      StateVector _historyVector_2 = flow.getHistoryVector();
+      _historyVector_2.setOffset(0);
+      StateVector _historyVector_3 = flow.getHistoryVector();
+      int _plus_1 = (offset + 1);
+      _historyVector_3.setSize(_plus_1);
+    }
+  }
+  
+  public void defineStateVector(final ExecutionFlow flow, final Statechart sc) {
+    int offset = 0;
+    EList<Region> _regions = sc.getRegions();
+    for (final Region r : _regions) {
+      int _defineStateVectors = this.defineStateVectors(r, offset);
+      int _plus = (offset + _defineStateVectors);
+      offset = _plus;
+    }
+    SexecFactory _factory = this.sexec.factory();
+    StateVector _createStateVector = _factory.createStateVector();
+    flow.setStateVector(_createStateVector);
+    StateVector _stateVector = flow.getStateVector();
+    _stateVector.setOffset(0);
+    StateVector _stateVector_1 = flow.getStateVector();
+    _stateVector_1.setSize(offset);
+  }
+  
+  /**
+   * calculates the maximum orthogonality (maximum number of possible active leaf states) of the statechart
+   */
+  public int defineStateVectors(final Statechart sc, final int offset) {
+    EList<Region> _regions = sc.getRegions();
+    final Function2<Integer,Region,Integer> _function = new Function2<Integer,Region,Integer>() {
+        public Integer apply(final Integer o, final Region r) {
+          int _maxOrthogonality = StateVectorBuilder.this.sc.maxOrthogonality(r);
+          int _plus = (_maxOrthogonality + (o).intValue());
+          return Integer.valueOf(_plus);
+        }
+      };
+    Integer _fold = IterableExtensions.<Region, Integer>fold(_regions, Integer.valueOf(0), _function);
+    return (_fold).intValue();
+  }
+  
+  /**
+   * calculates the maximum orthogonality (maximum number of possible active leaf states) of a region
+   */
+  public int defineStateVectors(final Region r, final int offset) {
+    EList<Vertex> _vertices = r.getVertices();
+    final Function2<Integer,Vertex,Integer> _function = new Function2<Integer,Vertex,Integer>() {
+        public Integer apply(final Integer s, final Vertex v) {
+          int _xblockexpression = (int) 0;
+          {
+            final int mo = StateVectorBuilder.this.defineStateVectors(v, offset);
+            int _xifexpression = (int) 0;
+            boolean _greaterThan = (mo > (s).intValue());
+            if (_greaterThan) {
+              _xifexpression = mo;
+            } else {
+              _xifexpression = s;
+            }
+            _xblockexpression = (_xifexpression);
+          }
+          return Integer.valueOf(_xblockexpression);
+        }
+      };
+    final Integer maxOrthogonality = IterableExtensions.<Vertex, Integer>fold(_vertices, Integer.valueOf(0), _function);
+    final ExecutionRegion er = this.mapping.create(r);
+    SexecFactory _factory = this.sexec.factory();
+    StateVector _createStateVector = _factory.createStateVector();
+    er.setStateVector(_createStateVector);
+    StateVector _stateVector = er.getStateVector();
+    _stateVector.setOffset(offset);
+    StateVector _stateVector_1 = er.getStateVector();
+    _stateVector_1.setSize((maxOrthogonality).intValue());
+    return (maxOrthogonality).intValue();
+  }
+  
+  /**
+   * the maximum orthogonality of all  pseudo states is 0
+   */
+  protected int _defineStateVectors(final Vertex v, final int offset) {
+    return 0;
+  }
+  
+  /**
+   * calculates the maximum orthogonality (maximum number of possible active leaf states) of a state
+   */
+  protected int _defineStateVectors(final State s, final int offset) {
+    int maxOrthogonality = 0;
+    EList<Region> _regions = s.getRegions();
+    boolean _containsStates = this.containsStates(_regions);
+    if (_containsStates) {
+      EList<Region> _regions_1 = s.getRegions();
+      for (final Region r : _regions_1) {
+        int _plus = (offset + maxOrthogonality);
+        int _defineStateVectors = this.defineStateVectors(r, _plus);
+        int _plus_1 = (maxOrthogonality + _defineStateVectors);
+        maxOrthogonality = _plus_1;
+      }
+    } else {
+      maxOrthogonality = 1;
+    }
+    final ExecutionState es = this.mapping.create(s);
+    SexecFactory _factory = this.sexec.factory();
+    StateVector _createStateVector = _factory.createStateVector();
+    es.setStateVector(_createStateVector);
+    StateVector _stateVector = es.getStateVector();
+    _stateVector.setOffset(offset);
+    StateVector _stateVector_1 = es.getStateVector();
+    _stateVector_1.setSize(maxOrthogonality);
+    return maxOrthogonality;
+  }
+  
+  public boolean containsStates(final List<Region> regions) {
+    final Function1<Region,Boolean> _function = new Function1<Region,Boolean>() {
+        public Boolean apply(final Region r) {
+          EList<Vertex> _vertices = r.getVertices();
+          Iterable<RegularState> _filter = Iterables.<RegularState>filter(_vertices, RegularState.class);
+          int _size = IterableExtensions.size(_filter);
+          boolean _greaterThan = (_size > 0);
+          return Boolean.valueOf(_greaterThan);
+        }
+      };
+    Iterable<Region> _filter = IterableExtensions.<Region>filter(regions, _function);
+    int _size = IterableExtensions.size(_filter);
+    boolean _greaterThan = (_size > 0);
+    return _greaterThan;
+  }
+  
+  /**
+   * calculates the maximum orthogonality (maximum number of possible active leaf states) of a state
+   */
+  protected int _defineStateVectors(final FinalState s, final int offset) {
+    final ExecutionState es = this.mapping.create(s);
+    SexecFactory _factory = this.sexec.factory();
+    StateVector _createStateVector = _factory.createStateVector();
+    es.setStateVector(_createStateVector);
+    StateVector _stateVector = es.getStateVector();
+    _stateVector.setOffset(offset);
+    StateVector _stateVector_1 = es.getStateVector();
+    _stateVector_1.setSize(1);
+    return 1;
+  }
+  
+  protected StateVector _stateVector(final Vertex v) {
+    return null;
+  }
+  
+  protected StateVector _stateVector(final RegularState s) {
+    ExecutionState _create = this.mapping.create(s);
+    StateVector _stateVector = _create.getStateVector();
+    return _stateVector;
+  }
+  
+  protected StateVector _stateVector(final Choice choice) {
+    Region _parentRegion = choice.getParentRegion();
+    ExecutionRegion _create = this.mapping.create(_parentRegion);
+    StateVector _stateVector = _create.getStateVector();
+    return _stateVector;
+  }
+  
+  public int defineStateVectors(final Vertex s, final int offset) {
+    if (s instanceof FinalState) {
+      return _defineStateVectors((FinalState)s, offset);
+    } else if (s instanceof State) {
+      return _defineStateVectors((State)s, offset);
+    } else if (s != null) {
+      return _defineStateVectors(s, offset);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(s, offset).toString());
+    }
+  }
+  
+  public StateVector stateVector(final Vertex choice) {
+    if (choice instanceof Choice) {
+      return _stateVector((Choice)choice);
+    } else if (choice instanceof RegularState) {
+      return _stateVector((RegularState)choice);
+    } else if (choice != null) {
+      return _stateVector(choice);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(choice).toString());
+    }
+  }
+}

BIN=BIN
plugins/org.yakindu.sct.model.stext.edit/icons/full/ctool16/CreatePrimitiveValueExpression_value_EnumLiteral.gif


BIN=BIN
plugins/org.yakindu.sct.model.stext.edit/icons/full/obj16/EnumLiteral.gif


+ 3 - 0
plugins/org.yakindu.sct.model.stext.edit/plugin.properties

@@ -227,3 +227,6 @@ _UI_ElementReferenceExpression_args_feature = Args
 _UI_ParenthesizedExpression_type = Parenthesized Expression
 _UI_ParenthesizedExpression_expression_feature = Expression
 _UI_DefaultTrigger_type = Default Trigger
+_UI_EnumLiteral_type = Enum Literal
+_UI_EnumLiteral_value_feature = Value
+_UI_EnumLiteral_type_feature = Type

+ 1 - 0
plugins/org.yakindu.sct.model.stext.ui/META-INF/MANIFEST.MF

@@ -46,6 +46,7 @@ Export-Package: org.yakindu.sct.model.stext.ui;
    org.antlr.runtime,
    org.eclipse.xtext.ui.editor.contentassist.antlr.internal,
    org.yakindu.sct.model.stext.services",
+ org.yakindu.sct.model.stext.ui.hyperlink,
  org.yakindu.sct.model.stext.ui.internal;uses:="org.eclipse.ui.plugin,org.osgi.framework,com.google.inject",
  org.yakindu.sct.model.stext.ui.labeling;uses:="org.eclipse.emf.edit.ui.provider,org.eclipse.xtext.ui.label",
  org.yakindu.sct.model.stext.ui.outline;uses:="org.eclipse.xtext.ui.editor.outline.impl",

+ 1 - 1
plugins/org.yakindu.sct.model.stext.ui/src-gen/org/yakindu/sct/model/stext/ui/contentassist/antlr/internal/InternalSText.tokens

@@ -31,8 +31,8 @@ T__16=16
 T__51=51
 T__15=15
 T__52=52
-T__18=18
 T__53=53
+T__18=18
 T__54=54
 T__17=17
 T__14=14

+ 2 - 2
plugins/org.yakindu.sct.model.stext.ui/src-gen/org/yakindu/sct/model/stext/ui/contentassist/antlr/internal/InternalSTextLexer.java

@@ -14,8 +14,8 @@ import java.util.ArrayList;
 public class InternalSTextLexer extends Lexer {
     public static final int T__68=68;
     public static final int T__69=69;
-    public static final int RULE_ID=4;
     public static final int T__66=66;
+    public static final int RULE_ID=4;
     public static final int T__67=67;
     public static final int T__29=29;
     public static final int T__64=64;
@@ -46,8 +46,8 @@ public class InternalSTextLexer extends Lexer {
     public static final int T__51=51;
     public static final int T__15=15;
     public static final int T__52=52;
-    public static final int T__18=18;
     public static final int T__53=53;
+    public static final int T__18=18;
     public static final int T__54=54;
     public static final int T__17=17;
     public static final int T__14=14;

+ 1 - 1
plugins/org.yakindu.sct.model.stext.ui/src-gen/org/yakindu/sct/model/stext/ui/contentassist/antlr/internal/InternalSTextParser.java

@@ -59,8 +59,8 @@ public class InternalSTextParser extends AbstractInternalContentAssistParser {
     public static final int T__51=51;
     public static final int T__15=15;
     public static final int T__52=52;
-    public static final int T__18=18;
     public static final int T__53=53;
+    public static final int T__18=18;
     public static final int T__54=54;
     public static final int T__17=17;
     public static final int T__14=14;

+ 1 - 0
plugins/org.yakindu.sct.model.stext/META-INF/MANIFEST.MF

@@ -39,5 +39,6 @@ Export-Package: org.yakindu.sct.model.stext,
  org.yakindu.sct.model.stext.stext,
  org.yakindu.sct.model.stext.stext.impl,
  org.yakindu.sct.model.stext.stext.util,
+ org.yakindu.sct.model.stext.types,
  org.yakindu.sct.model.stext.validation
 Bundle-ClassPath: .

+ 1 - 2
plugins/org.yakindu.sct.model.stext/build.properties

@@ -8,9 +8,8 @@
 # 
 
 bin.includes = .,\
-			   META-INF/,\
+               META-INF/,\
                plugin.xml,\
-               libraries/,\
                model/,\
                .project
 jre.compilation.profile = J2SE-1.5

+ 0 - 10
plugins/org.yakindu.sct.model.stext/libraries/Primitives.types

@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<types:Library xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:types="http://www.yakindu.org/base/types/2.0.0" id="Primitives">
-  <types name="void"/>
-  <types name="integer"/>
-  <types name="real"/>
-  <types name="boolean"/>
-  <types name="string">
-    <features xsi:type="types:Property" type="//@types.0" name="length"/>
-  </types>
-</types:Library>

+ 0 - 6
plugins/org.yakindu.sct.model.stext/plugin.xml

@@ -9,12 +9,6 @@
        genModel = "model/SText.genmodel" /> 
 	
   </extension>
-   <extension
-         point="org.yakindu.base.types.libraries">
-      <TypeLibrary
-            location="libraries/Primitives.types">
-      </TypeLibrary>
-   </extension>
    <extension
          point="org.eclipse.emf.ecore.uri_mapping">
       <mapping

+ 2 - 2
plugins/org.yakindu.sct.model.stext/src-gen/org/yakindu/sct/model/stext/parser/antlr/internal/InternalSText.tokens

@@ -31,8 +31,8 @@ T__16=16
 T__51=51
 T__15=15
 T__52=52
-T__18=18
 T__53=53
+T__18=18
 T__54=54
 T__17=17
 T__14=14
@@ -125,8 +125,8 @@ T__77=77
 '@@state@@'=15
 '='=25
 'always'=37
-'oncycle'=38
 ')'=29
+'oncycle'=38
 '*='=56
 'entry'=35
 '%'=71

+ 2 - 2
plugins/org.yakindu.sct.model.stext/src-gen/org/yakindu/sct/model/stext/parser/antlr/internal/InternalSTextLexer.java

@@ -14,8 +14,8 @@ import java.util.ArrayList;
 public class InternalSTextLexer extends Lexer {
     public static final int T__68=68;
     public static final int T__69=69;
-    public static final int RULE_ID=4;
     public static final int T__66=66;
+    public static final int RULE_ID=4;
     public static final int T__67=67;
     public static final int T__29=29;
     public static final int T__64=64;
@@ -46,8 +46,8 @@ public class InternalSTextLexer extends Lexer {
     public static final int T__51=51;
     public static final int T__15=15;
     public static final int T__52=52;
-    public static final int T__18=18;
     public static final int T__53=53;
+    public static final int T__18=18;
     public static final int T__54=54;
     public static final int T__17=17;
     public static final int T__14=14;

+ 1 - 1
plugins/org.yakindu.sct.model.stext/src-gen/org/yakindu/sct/model/stext/parser/antlr/internal/InternalSTextParser.java

@@ -59,8 +59,8 @@ public class InternalSTextParser extends AbstractInternalAntlrParser {
     public static final int T__51=51;
     public static final int T__15=15;
     public static final int T__52=52;
-    public static final int T__18=18;
     public static final int T__53=53;
+    public static final int T__18=18;
     public static final int T__54=54;
     public static final int T__17=17;
     public static final int T__14=14;

+ 10 - 9
plugins/org.yakindu.sct.model.stext/src-gen/org/yakindu/sct/model/stext/stext/impl/EventDefinitionImpl.java

@@ -12,6 +12,7 @@ import org.eclipse.emf.ecore.impl.ENotificationImpl;
 
 import org.eclipse.emf.ecore.util.EcoreUtil;
 
+import org.yakindu.base.types.ComplexType;
 import org.yakindu.base.types.Event;
 import org.yakindu.base.types.Feature;
 import org.yakindu.base.types.Type;
@@ -140,10 +141,10 @@ public class EventDefinitionImpl extends EventImpl implements EventDefinition
    * <!-- end-user-doc -->
    * @generated
    */
-  public Type getOwningType()
+  public ComplexType getOwningType()
   {
     if (eContainerFeatureID() != StextPackage.EVENT_DEFINITION__OWNING_TYPE) return null;
-    return (Type)eContainer();
+    return (ComplexType)eContainer();
   }
 
   /**
@@ -151,7 +152,7 @@ public class EventDefinitionImpl extends EventImpl implements EventDefinition
    * <!-- end-user-doc -->
    * @generated
    */
-  public NotificationChain basicSetOwningType(Type newOwningType, NotificationChain msgs)
+  public NotificationChain basicSetOwningType(ComplexType newOwningType, NotificationChain msgs)
   {
     msgs = eBasicSetContainer((InternalEObject)newOwningType, StextPackage.EVENT_DEFINITION__OWNING_TYPE, msgs);
     return msgs;
@@ -162,7 +163,7 @@ public class EventDefinitionImpl extends EventImpl implements EventDefinition
    * <!-- end-user-doc -->
    * @generated
    */
-  public void setOwningType(Type newOwningType)
+  public void setOwningType(ComplexType newOwningType)
   {
     if (newOwningType != eInternalContainer() || (eContainerFeatureID() != StextPackage.EVENT_DEFINITION__OWNING_TYPE && newOwningType != null))
     {
@@ -172,7 +173,7 @@ public class EventDefinitionImpl extends EventImpl implements EventDefinition
       if (eInternalContainer() != null)
         msgs = eBasicRemoveFromContainer(msgs);
       if (newOwningType != null)
-        msgs = ((InternalEObject)newOwningType).eInverseAdd(this, TypesPackage.TYPE__FEATURES, Type.class, msgs);
+        msgs = ((InternalEObject)newOwningType).eInverseAdd(this, TypesPackage.COMPLEX_TYPE__FEATURES, ComplexType.class, msgs);
       msgs = basicSetOwningType(newOwningType, msgs);
       if (msgs != null) msgs.dispatch();
     }
@@ -216,7 +217,7 @@ public class EventDefinitionImpl extends EventImpl implements EventDefinition
       case StextPackage.EVENT_DEFINITION__OWNING_TYPE:
         if (eInternalContainer() != null)
           msgs = eBasicRemoveFromContainer(msgs);
-        return basicSetOwningType((Type)otherEnd, msgs);
+        return basicSetOwningType((ComplexType)otherEnd, msgs);
     }
     return super.eInverseAdd(otherEnd, featureID, msgs);
   }
@@ -248,7 +249,7 @@ public class EventDefinitionImpl extends EventImpl implements EventDefinition
     switch (eContainerFeatureID())
     {
       case StextPackage.EVENT_DEFINITION__OWNING_TYPE:
-        return eInternalContainer().eInverseRemove(this, TypesPackage.TYPE__FEATURES, Type.class, msgs);
+        return eInternalContainer().eInverseRemove(this, TypesPackage.COMPLEX_TYPE__FEATURES, ComplexType.class, msgs);
     }
     return super.eBasicRemoveFromContainerFeature(msgs);
   }
@@ -288,7 +289,7 @@ public class EventDefinitionImpl extends EventImpl implements EventDefinition
         setType((Type)newValue);
         return;
       case StextPackage.EVENT_DEFINITION__OWNING_TYPE:
-        setOwningType((Type)newValue);
+        setOwningType((ComplexType)newValue);
         return;
       case StextPackage.EVENT_DEFINITION__DIRECTION:
         setDirection((Direction)newValue);
@@ -311,7 +312,7 @@ public class EventDefinitionImpl extends EventImpl implements EventDefinition
         setType((Type)null);
         return;
       case StextPackage.EVENT_DEFINITION__OWNING_TYPE:
-        setOwningType((Type)null);
+        setOwningType((ComplexType)null);
         return;
       case StextPackage.EVENT_DEFINITION__DIRECTION:
         setDirection(DIRECTION_EDEFAULT);

+ 10 - 9
plugins/org.yakindu.sct.model.stext/src-gen/org/yakindu/sct/model/stext/stext/impl/OperationDefinitionImpl.java

@@ -18,6 +18,7 @@ import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
 import org.eclipse.emf.ecore.util.EcoreUtil;
 import org.eclipse.emf.ecore.util.InternalEList;
 
+import org.yakindu.base.types.ComplexType;
 import org.yakindu.base.types.Feature;
 import org.yakindu.base.types.Operation;
 import org.yakindu.base.types.Parameter;
@@ -136,10 +137,10 @@ public class OperationDefinitionImpl extends DeclarationImpl implements Operatio
    * <!-- end-user-doc -->
    * @generated
    */
-  public Type getOwningType()
+  public ComplexType getOwningType()
   {
     if (eContainerFeatureID() != StextPackage.OPERATION_DEFINITION__OWNING_TYPE) return null;
-    return (Type)eContainer();
+    return (ComplexType)eContainer();
   }
 
   /**
@@ -147,7 +148,7 @@ public class OperationDefinitionImpl extends DeclarationImpl implements Operatio
    * <!-- end-user-doc -->
    * @generated
    */
-  public NotificationChain basicSetOwningType(Type newOwningType, NotificationChain msgs)
+  public NotificationChain basicSetOwningType(ComplexType newOwningType, NotificationChain msgs)
   {
     msgs = eBasicSetContainer((InternalEObject)newOwningType, StextPackage.OPERATION_DEFINITION__OWNING_TYPE, msgs);
     return msgs;
@@ -158,7 +159,7 @@ public class OperationDefinitionImpl extends DeclarationImpl implements Operatio
    * <!-- end-user-doc -->
    * @generated
    */
-  public void setOwningType(Type newOwningType)
+  public void setOwningType(ComplexType newOwningType)
   {
     if (newOwningType != eInternalContainer() || (eContainerFeatureID() != StextPackage.OPERATION_DEFINITION__OWNING_TYPE && newOwningType != null))
     {
@@ -168,7 +169,7 @@ public class OperationDefinitionImpl extends DeclarationImpl implements Operatio
       if (eInternalContainer() != null)
         msgs = eBasicRemoveFromContainer(msgs);
       if (newOwningType != null)
-        msgs = ((InternalEObject)newOwningType).eInverseAdd(this, TypesPackage.TYPE__FEATURES, Type.class, msgs);
+        msgs = ((InternalEObject)newOwningType).eInverseAdd(this, TypesPackage.COMPLEX_TYPE__FEATURES, ComplexType.class, msgs);
       msgs = basicSetOwningType(newOwningType, msgs);
       if (msgs != null) msgs.dispatch();
     }
@@ -204,7 +205,7 @@ public class OperationDefinitionImpl extends DeclarationImpl implements Operatio
       case StextPackage.OPERATION_DEFINITION__OWNING_TYPE:
         if (eInternalContainer() != null)
           msgs = eBasicRemoveFromContainer(msgs);
-        return basicSetOwningType((Type)otherEnd, msgs);
+        return basicSetOwningType((ComplexType)otherEnd, msgs);
       case StextPackage.OPERATION_DEFINITION__PARAMETERS:
         return ((InternalEList<InternalEObject>)(InternalEList<?>)getParameters()).basicAdd(otherEnd, msgs);
     }
@@ -240,7 +241,7 @@ public class OperationDefinitionImpl extends DeclarationImpl implements Operatio
     switch (eContainerFeatureID())
     {
       case StextPackage.OPERATION_DEFINITION__OWNING_TYPE:
-        return eInternalContainer().eInverseRemove(this, TypesPackage.TYPE__FEATURES, Type.class, msgs);
+        return eInternalContainer().eInverseRemove(this, TypesPackage.COMPLEX_TYPE__FEATURES, ComplexType.class, msgs);
     }
     return super.eBasicRemoveFromContainerFeature(msgs);
   }
@@ -281,7 +282,7 @@ public class OperationDefinitionImpl extends DeclarationImpl implements Operatio
         setType((Type)newValue);
         return;
       case StextPackage.OPERATION_DEFINITION__OWNING_TYPE:
-        setOwningType((Type)newValue);
+        setOwningType((ComplexType)newValue);
         return;
       case StextPackage.OPERATION_DEFINITION__PARAMETERS:
         getParameters().clear();
@@ -305,7 +306,7 @@ public class OperationDefinitionImpl extends DeclarationImpl implements Operatio
         setType((Type)null);
         return;
       case StextPackage.OPERATION_DEFINITION__OWNING_TYPE:
-        setOwningType((Type)null);
+        setOwningType((ComplexType)null);
         return;
       case StextPackage.OPERATION_DEFINITION__PARAMETERS:
         getParameters().clear();

+ 10 - 9
plugins/org.yakindu.sct.model.stext/src-gen/org/yakindu/sct/model/stext/stext/impl/VariableDefinitionImpl.java

@@ -12,6 +12,7 @@ import org.eclipse.emf.ecore.impl.ENotificationImpl;
 
 import org.eclipse.emf.ecore.util.EcoreUtil;
 
+import org.yakindu.base.types.ComplexType;
 import org.yakindu.base.types.Feature;
 import org.yakindu.base.types.Property;
 import org.yakindu.base.types.Type;
@@ -172,10 +173,10 @@ public class VariableDefinitionImpl extends VariableImpl implements VariableDefi
    * <!-- end-user-doc -->
    * @generated
    */
-  public Type getOwningType()
+  public ComplexType getOwningType()
   {
     if (eContainerFeatureID() != StextPackage.VARIABLE_DEFINITION__OWNING_TYPE) return null;
-    return (Type)eContainer();
+    return (ComplexType)eContainer();
   }
 
   /**
@@ -183,7 +184,7 @@ public class VariableDefinitionImpl extends VariableImpl implements VariableDefi
    * <!-- end-user-doc -->
    * @generated
    */
-  public NotificationChain basicSetOwningType(Type newOwningType, NotificationChain msgs)
+  public NotificationChain basicSetOwningType(ComplexType newOwningType, NotificationChain msgs)
   {
     msgs = eBasicSetContainer((InternalEObject)newOwningType, StextPackage.VARIABLE_DEFINITION__OWNING_TYPE, msgs);
     return msgs;
@@ -194,7 +195,7 @@ public class VariableDefinitionImpl extends VariableImpl implements VariableDefi
    * <!-- end-user-doc -->
    * @generated
    */
-  public void setOwningType(Type newOwningType)
+  public void setOwningType(ComplexType newOwningType)
   {
     if (newOwningType != eInternalContainer() || (eContainerFeatureID() != StextPackage.VARIABLE_DEFINITION__OWNING_TYPE && newOwningType != null))
     {
@@ -204,7 +205,7 @@ public class VariableDefinitionImpl extends VariableImpl implements VariableDefi
       if (eInternalContainer() != null)
         msgs = eBasicRemoveFromContainer(msgs);
       if (newOwningType != null)
-        msgs = ((InternalEObject)newOwningType).eInverseAdd(this, TypesPackage.TYPE__FEATURES, Type.class, msgs);
+        msgs = ((InternalEObject)newOwningType).eInverseAdd(this, TypesPackage.COMPLEX_TYPE__FEATURES, ComplexType.class, msgs);
       msgs = basicSetOwningType(newOwningType, msgs);
       if (msgs != null) msgs.dispatch();
     }
@@ -319,7 +320,7 @@ public class VariableDefinitionImpl extends VariableImpl implements VariableDefi
       case StextPackage.VARIABLE_DEFINITION__OWNING_TYPE:
         if (eInternalContainer() != null)
           msgs = eBasicRemoveFromContainer(msgs);
-        return basicSetOwningType((Type)otherEnd, msgs);
+        return basicSetOwningType((ComplexType)otherEnd, msgs);
     }
     return super.eInverseAdd(otherEnd, featureID, msgs);
   }
@@ -353,7 +354,7 @@ public class VariableDefinitionImpl extends VariableImpl implements VariableDefi
     switch (eContainerFeatureID())
     {
       case StextPackage.VARIABLE_DEFINITION__OWNING_TYPE:
-        return eInternalContainer().eInverseRemove(this, TypesPackage.TYPE__FEATURES, Type.class, msgs);
+        return eInternalContainer().eInverseRemove(this, TypesPackage.COMPLEX_TYPE__FEATURES, ComplexType.class, msgs);
     }
     return super.eBasicRemoveFromContainerFeature(msgs);
   }
@@ -397,7 +398,7 @@ public class VariableDefinitionImpl extends VariableImpl implements VariableDefi
         setType((Type)newValue);
         return;
       case StextPackage.VARIABLE_DEFINITION__OWNING_TYPE:
-        setOwningType((Type)newValue);
+        setOwningType((ComplexType)newValue);
         return;
       case StextPackage.VARIABLE_DEFINITION__READONLY:
         setReadonly((Boolean)newValue);
@@ -426,7 +427,7 @@ public class VariableDefinitionImpl extends VariableImpl implements VariableDefi
         setType((Type)null);
         return;
       case StextPackage.VARIABLE_DEFINITION__OWNING_TYPE:
-        setOwningType((Type)null);
+        setOwningType((ComplexType)null);
         return;
       case StextPackage.VARIABLE_DEFINITION__READONLY:
         setReadonly(READONLY_EDEFAULT);

+ 1 - 1
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/SText.xtext

@@ -233,7 +233,7 @@ AlwaysEvent:
 //****************
 
 EventRaisingExpression returns Expression:
-	{EventRaisingExpression}'raise' event=FeatureCall  (':' value=Expression)?
+	{EventRaisingExpression} 'raise' event=FeatureCall  (':' value=Expression)?
 ;	
 
 StatementExpression returns sgraph::Statement:

+ 4 - 10
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/STextRuntimeModule.java

@@ -14,15 +14,13 @@ import org.eclipse.xtext.Constants;
 import org.eclipse.xtext.linking.ILinker;
 import org.eclipse.xtext.naming.IQualifiedNameProvider;
 import org.eclipse.xtext.resource.IDefaultResourceDescriptionStrategy;
-import org.yakindu.base.types.ITypeSystemAccess;
-import org.yakindu.base.types.impl.BaseTypeSystemAccessImpl;
+import org.yakindu.base.types.ITypeSystem;
 import org.yakindu.sct.model.sgraph.resource.SCTLinker;
 import org.yakindu.sct.model.sgraph.resource.provider.SCTResourceDescriptionStrategy;
 import org.yakindu.sct.model.stext.conversion.StextValueConverterService;
 import org.yakindu.sct.model.stext.naming.StextNameProvider;
 import org.yakindu.sct.model.stext.scoping.STextGlobalScopeProvider;
-import org.yakindu.sct.model.stext.validation.ITypeInferrer;
-import org.yakindu.sct.model.stext.validation.TypeInferrer;
+import org.yakindu.sct.model.stext.types.STextDefaulTypeSystem;
 
 import com.google.inject.Binder;
 import com.google.inject.name.Names;
@@ -56,12 +54,8 @@ public class STextRuntimeModule extends
 		return StextValueConverterService.class;
 	}
 
-	public Class<? extends ITypeSystemAccess> bindITypeSystemAccess() {
-		return BaseTypeSystemAccessImpl.class;
-	}
-
-	public Class<? extends ITypeInferrer> bindITypeInferrer() {
-		return TypeInferrer.class;
+	public Class<? extends ITypeSystem> bindITypeSystem() {
+		return STextDefaulTypeSystem.class;
 	}
 
 	public Class<? extends IDefaultResourceDescriptionStrategy> bindIDefaultResourceDescriptionStrategy() {

+ 9 - 8
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/ContextPredicateProvider.java

@@ -93,7 +93,7 @@ public class ContextPredicateProvider {
 		}
 	}
 
-	static class VariableOperationEventPredicate extends FeaturedTypePredicate {
+	static class VariableOperationEventEnumeratorPredicate extends FeaturedTypePredicate {
 		@Override
 		public boolean apply(IEObjectDescription input) {
 			if (super.apply(input))
@@ -102,7 +102,8 @@ public class ContextPredicateProvider {
 					.getEClass())
 					|| TypesPackage.Literals.OPERATION.isSuperTypeOf(input
 							.getEClass()) || TypesPackage.Literals.EVENT
-						.isSuperTypeOf(input.getEClass()));
+						.isSuperTypeOf(input.getEClass())
+						|| TypesPackage.Literals.ENUMERATOR.isSuperTypeOf(input.getEClass()));
 		}
 	}
 
@@ -118,7 +119,7 @@ public class ContextPredicateProvider {
 	private static final VariablePredicate VARIABLES = new VariablePredicate();
 	private static final EventPredicate EVENTS = new EventPredicate();
 	private static final VariableOperationPredicate VARIABLES_AND_OPERATIONS = new VariableOperationPredicate();
-	public static final VariableOperationEventPredicate VARIABLES_OPERATIONS_EVENTS = new VariableOperationEventPredicate();
+	public static final VariableOperationEventEnumeratorPredicate VARIABLES_OPERATIONS_EVENTS_ENUMERATORS = new VariableOperationEventEnumeratorPredicate();
 	private static final Predicate<IEObjectDescription> ALL = Predicates
 			.<IEObjectDescription> alwaysTrue();
 
@@ -138,21 +139,21 @@ public class ContextPredicateProvider {
 	}
 
 	protected void initMap() {
-		filter.put(key(ASSIGNMENT_EXPRESSION), VARIABLES);
+		filter.put(key(ASSIGNMENT_EXPRESSION), VARIABLES_OPERATIONS_EVENTS_ENUMERATORS);
 		filter.put(
 				key(ASSIGNMENT_EXPRESSION, ASSIGNMENT_EXPRESSION__EXPRESSION),
 				ALL);
 
 		filter.put(key(CONDITIONAL_EXPRESSION), VARIABLES_AND_OPERATIONS);
-		filter.put(key(LOGICAL_OR_EXPRESSION), VARIABLES_OPERATIONS_EVENTS);
-		filter.put(key(LOGICAL_AND_EXPRESSION), VARIABLES_OPERATIONS_EVENTS);
-		filter.put(key(LOGICAL_NOT_EXPRESSION), VARIABLES_OPERATIONS_EVENTS);
+		filter.put(key(LOGICAL_OR_EXPRESSION), VARIABLES_OPERATIONS_EVENTS_ENUMERATORS);
+		filter.put(key(LOGICAL_AND_EXPRESSION), VARIABLES_OPERATIONS_EVENTS_ENUMERATORS);
+		filter.put(key(LOGICAL_NOT_EXPRESSION), VARIABLES_OPERATIONS_EVENTS_ENUMERATORS);
 		filter.put(key(BITWISE_XOR_EXPRESSION), VARIABLES);
 		filter.put(key(BITWISE_OR_EXPRESSION), VARIABLES);
 		filter.put(key(BITWISE_AND_EXPRESSION), VARIABLES);
 		filter.put(key(SHIFT_EXPRESSION), VARIABLES);
 		filter.put(key(LOGICAL_RELATION_EXPRESSION),
-				VARIABLES_OPERATIONS_EVENTS);
+				VARIABLES_OPERATIONS_EVENTS_ENUMERATORS);
 		filter.put(key(NUMERICAL_ADD_SUBTRACT_EXPRESSION),
 				VARIABLES_AND_OPERATIONS);
 		filter.put(key(NUMERICAL_MULTIPLY_DIVIDE_EXPRESSION),

+ 11 - 21
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextGlobalScopeProvider.java

@@ -14,12 +14,13 @@ import org.eclipse.emf.common.util.URI;
 import org.eclipse.emf.ecore.EReference;
 import org.eclipse.emf.ecore.resource.Resource;
 import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.xtext.naming.IQualifiedNameProvider;
 import org.eclipse.xtext.resource.IEObjectDescription;
 import org.eclipse.xtext.scoping.IScope;
 import org.eclipse.xtext.scoping.impl.DefaultGlobalScopeProvider;
 import org.eclipse.xtext.scoping.impl.FilteringScope;
-import org.yakindu.base.types.TypesPackage;
-import org.yakindu.base.types.scope.TypeLibrariesExtensionPointScopeHelper;
+import org.yakindu.base.types.ITypeSystem;
+import org.yakindu.base.types.scope.TypeSystemAwareScope;
 import org.yakindu.sct.model.sgraph.SGraphPackage;
 import org.yakindu.sct.model.stext.stext.StextPackage;
 
@@ -30,18 +31,24 @@ import de.itemis.xtext.utils.jface.viewers.ContextElementAdapter;
 
 /**
  * @author andreas muelder - Initial contribution and API
+ * @author Alexander Nyßen - Ensured type system information is only inferred via {@link ITypeSystem} facade.
  * 
  */
 public class STextGlobalScopeProvider extends DefaultGlobalScopeProvider {
 
 	@Inject
-	private TypeLibrariesExtensionPointScopeHelper typeScopeHelper;
+	private ITypeSystem typeSystemAccess;
+
+	@Inject
+	private IQualifiedNameProvider qualifiedNameProvider;
 
 	public IScope getScope(Resource context, EReference reference,
 			Predicate<IEObjectDescription> filter) {
 		IScope parentScope = super.getScope(context, reference, filter);
 		parentScope = filterExternalDeclarations(context, parentScope);
-		parentScope = addTypeLibraries(reference, parentScope);
+
+		parentScope = new TypeSystemAwareScope(parentScope, typeSystemAccess,
+				qualifiedNameProvider, reference.getEReferenceType());
 		return parentScope;
 	}
 
@@ -76,21 +83,4 @@ public class STextGlobalScopeProvider extends DefaultGlobalScopeProvider {
 		}
 		return parentScope;
 	}
-
-	/**
-	 * add types from type libraries, in case the type of the reference refers
-	 * to Type
-	 * 
-	 * @param reference
-	 * @param parentScope
-	 * @return
-	 */
-	protected IScope addTypeLibraries(EReference reference, IScope parentScope) {
-		if (reference.getEReferenceType().isSuperTypeOf(
-				TypesPackage.eINSTANCE.getType())) {
-			return typeScopeHelper.createExtensionScope(parentScope);
-		}
-		return parentScope;
-	}
-
 }

+ 31 - 8
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextScopeProvider.java

@@ -12,6 +12,7 @@
 package org.yakindu.sct.model.stext.scoping;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -30,8 +31,13 @@ import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider;
 import org.eclipse.xtext.scoping.impl.FilteringScope;
 import org.eclipse.xtext.scoping.impl.SimpleScope;
 import org.eclipse.xtext.util.PolymorphicDispatcher.ErrorHandler;
+import org.yakindu.base.types.DataType;
+import org.yakindu.base.types.EnumerationType;
+import org.yakindu.base.types.Enumerator;
 import org.yakindu.base.types.Feature;
+import org.yakindu.base.types.ITypeSystem;
 import org.yakindu.base.types.Type;
+import org.yakindu.base.types.TypeSystemUtils;
 import org.yakindu.sct.model.sgraph.SGraphPackage;
 import org.yakindu.sct.model.sgraph.Scope;
 import org.yakindu.sct.model.sgraph.Statechart;
@@ -53,10 +59,17 @@ import de.itemis.xtext.utils.jface.viewers.ContextElementAdapter;
  * 
  * @author andreas muelder
  * @author axel terfloth
+ * @author alexander nyssen Added support for scoping of enumeration literals
  * 
  */
 public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 
+	@Inject
+	ITypeSystem typeSystem;
+	
+	@Inject
+	TypeSystemUtils typeSystemUtils;
+	
 	private static class ErrorHandlerDelegate<T> implements ErrorHandler<T> {
 
 		private ErrorHandler<T> delegate;
@@ -101,17 +114,19 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 			final EObject context, EReference reference) {
 		IScope namdScope = getNamedTopLevelScope(context, reference);
 		IScope unnamedScope = getUnnamedTopLevelScope(context, reference);
-		Predicate<IEObjectDescription> predicate = calcuateFilterPredicate(
+		Predicate<IEObjectDescription> predicate = calculateFilterPredicate(
 				context, reference);
 		unnamedScope = new FilteringScope(unnamedScope, predicate);
+		// add enum types
 		return new SimpleScope(Iterables.concat(namdScope.getAllElements(),
-				unnamedScope.getAllElements()));
+				unnamedScope.getAllElements(),
+				Scopes.scopeFor(typeSystemUtils.getEnumerationTypes(typeSystem)).getAllElements()));
 	}
 
 	public IScope scope_FeatureCall_feature(final FeatureCall context,
 			EReference reference) {
 
-		Predicate<IEObjectDescription> predicate = calcuateFilterPredicate(
+		Predicate<IEObjectDescription> predicate = calculateFilterPredicate(
 				context, reference);
 
 		Expression owner = context.getOwner();
@@ -131,10 +146,15 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 			scope = new FilteringScope(scope, predicate);
 		}
 
-		if (element instanceof Type) {
+		if (element instanceof DataType) {
 			scope = Scopes.scopeFor(allFeatures((Type) element), scope);
 			scope = new FilteringScope(scope, predicate);
 		}
+		
+		if( element instanceof EnumerationType){
+			scope = Scopes.scopeFor(((EnumerationType) element).getEnumerator(), scope);
+			scope = new FilteringScope(scope, predicate);
+		}
 
 		if (element instanceof Feature) {
 			scope = Scopes.scopeFor(allFeatures(((Feature) element).getType()),
@@ -145,7 +165,7 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 		return scope;
 	}
 
-	private Predicate<IEObjectDescription> calcuateFilterPredicate(
+	private Predicate<IEObjectDescription> calculateFilterPredicate(
 			final EObject context, final EReference reference) {
 		Predicate<IEObjectDescription> predicate = null;
 		EObject container = context;
@@ -204,6 +224,7 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 		}
 		return Scopes.scopeFor(scopeCandidates);
 	}
+	
 
 	/**
 	 * Returns the {@link Statechart} for a context element
@@ -241,10 +262,12 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 			Set<Type> visited) {
 		if (type == null || visited.contains(type))
 			return;
-		for (Type superType : type.getSuperTypes()) {
-			collectFeatures(superType, features, visited);
+		if (type instanceof DataType) {
+			for (Type superType : ((DataType) type).getSuperTypes()) {
+				collectFeatures(superType, features, visited);
+			}
+			features.addAll(((DataType) type).getFeatures());
 		}
-		features.addAll(type.getFeatures());
 		visited.add(type);
 	}
 

+ 40 - 0
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/types/ISTextTypeInferrer.java

@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2012 itemis AG 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:
+ * 	itemis AG - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.model.stext.types;
+
+import org.yakindu.base.types.ITypeSystem.InferenceResult;
+import org.yakindu.sct.model.stext.stext.EventDefinition;
+import org.yakindu.sct.model.stext.stext.Expression;
+import org.yakindu.sct.model.stext.stext.VariableDefinition;
+
+import com.google.inject.ImplementedBy;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * @author Alexander Nyßen - Adopted to changes in type system
+ * 
+ */
+@ImplementedBy(STextDefaultTypeInferrer.class)
+public interface ISTextTypeInferrer {
+	
+	/**
+	 * Infers the type for a given {@link Expression}
+	 * 
+	 */
+	InferenceResult inferType(Expression e);
+	
+	InferenceResult inferType(VariableDefinition d);
+	
+	InferenceResult inferType(EventDefinition d);
+	
+}

+ 124 - 0
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/types/ISTextTypeSystem.java

@@ -0,0 +1,124 @@
+/**
+ * 
+ */
+package org.yakindu.sct.model.stext.types;
+
+import org.yakindu.base.types.ITypeSystem;
+import org.yakindu.base.types.Type;
+import org.yakindu.sct.model.stext.stext.AdditiveOperator;
+import org.yakindu.sct.model.stext.stext.AssignmentOperator;
+import org.yakindu.sct.model.stext.stext.Literal;
+import org.yakindu.sct.model.stext.stext.MultiplicativeOperator;
+import org.yakindu.sct.model.stext.stext.RelationalOperator;
+import org.yakindu.sct.model.stext.stext.ShiftOperator;
+
+import com.google.inject.ImplementedBy;
+
+/**
+ * @author Alexander Nyßen (alexander.nyssen@itemis.de) - Inital contribution
+ *         and API
+ * 
+ */
+@ImplementedBy(STextDefaulTypeSystem.class)
+public interface ISTextTypeSystem extends ITypeSystem {
+
+	public enum UnaryOperators implements ITypeSystemOperator {
+		LOGICAL_NOT("!"), POSITIVE("+"), NEGATIVE("-"), COMPLEMENT("~");
+
+		private String symbol;
+
+		UnaryOperators(String symbol) {
+			this.symbol = symbol;
+		}
+
+		public String getSymbol() {
+			return symbol;
+		}
+	};
+
+	public enum BinaryOperators implements ITypeSystemOperator {
+		LOGICAL_OR("||"), LOGICAL_AND("&&"), BITWISE_OR("|"), BITWISE_AND("&"), BITWISE_XOR(
+				"^"), SMALLER(RelationalOperator.SMALLER.getLiteral()), SMALLER_EQUAL(
+				RelationalOperator.SMALLER_EQUAL.getLiteral()), GREATER(
+				RelationalOperator.GREATER.getLiteral()), GREATER_EQUAL(
+				RelationalOperator.GREATER_EQUAL.getLiteral()), EQUAL(
+				RelationalOperator.EQUALS.getLiteral()), NOT_EQUAL(
+				RelationalOperator.NOT_EQUALS.getLiteral()), MULTIPLY(
+				MultiplicativeOperator.MUL.getLiteral()), DIV(
+				MultiplicativeOperator.DIV.getLiteral()), MOD(
+				MultiplicativeOperator.MOD.getLiteral()), ADD(
+				AdditiveOperator.PLUS.getLiteral()), SUBTRACT(
+				AdditiveOperator.MINUS.getLiteral()), LEFT_SHIFT(
+				ShiftOperator.LEFT.getLiteral()), RIGHT_SHIFT(
+				ShiftOperator.RIGHT.getLiteral()), ASSIGN(
+				AssignmentOperator.ASSIGN.getLiteral()), ASSIGN_MULTIPLY(
+				AssignmentOperator.MULT_ASSIGN.getLiteral()), ASSIGN_DIV(
+				AssignmentOperator.DIV_ASSIGN.getLiteral()), ASSIGN_MOD(
+				AssignmentOperator.MOD_ASSIGN.getLiteral()), ASSIGN_ADD(
+				AssignmentOperator.ADD_ASSIGN.getLiteral()), ASSIGN_SUBTRACT(
+				AssignmentOperator.SUB_ASSIGN.getLiteral()), ASSIGN_LEFTSHIFT(
+				AssignmentOperator.LEFT_SHIFT_ASSIGN.getLiteral()), ASSIGN_RIGHTSHIFT(
+				AssignmentOperator.RIGHT_SHIFT_ASSIGN.getLiteral()), ASSIGN_AND(
+				AssignmentOperator.AND_ASSIGN.getLiteral()), ASSIGN_XOR(
+				AssignmentOperator.XOR_ASSIGN.getLiteral()), ASSIGN_OR(
+				AssignmentOperator.OR_ASSIGN.getLiteral());
+
+		private String symbol;
+
+		BinaryOperators(String symbol) {
+			this.symbol = symbol;
+		}
+
+		public String getSymbol() {
+			return symbol;
+		}
+	};
+
+	public enum TernaryOperators implements ITypeSystemOperator {
+		CONDITIONAL("?");
+
+		private String symbol;
+
+		TernaryOperators(String symbol) {
+			this.symbol = symbol;
+		}
+
+		public String getSymbol() {
+			return symbol;
+		}
+	};
+
+	public Type getVoidType();
+
+	public Type getBooleanType();
+
+	public Type getIntegerType();
+
+	public Type getRealType();
+
+	public Type getStringType();
+
+	public boolean isVoidType(InferredType inferredType);
+
+	public boolean isBooleanType(InferredType inferredType);
+
+	public boolean isIntegerType(InferredType inferredType);
+
+	public boolean isRealType(InferredType inferredType);
+
+	public boolean isStringType(InferredType inferredType);
+	
+	public boolean isVoidType(Type type);
+
+	public boolean isBooleanType(Type type);
+
+	public boolean isIntegerType(Type type);
+
+	public boolean isRealType(Type type);
+
+	public boolean isStringType(Type type);
+	
+	// TODO: This can be moved to ITypeSystem if we have a common abstraction over literals within the meta model
+	public InferenceResult inferType(Literal literal);
+
+}

+ 643 - 0
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/types/STextDefaulTypeSystem.java

@@ -0,0 +1,643 @@
+package org.yakindu.sct.model.stext.types;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.yakindu.base.types.AbstractTypeSystem;
+import org.yakindu.base.types.ComplexType;
+import org.yakindu.base.types.ITypeSystem;
+import org.yakindu.base.types.PrimitiveType;
+import org.yakindu.base.types.Type;
+import org.yakindu.base.types.TypesFactory;
+import org.yakindu.sct.model.stext.stext.BoolLiteral;
+import org.yakindu.sct.model.stext.stext.HexLiteral;
+import org.yakindu.sct.model.stext.stext.IntLiteral;
+import org.yakindu.sct.model.stext.stext.Literal;
+import org.yakindu.sct.model.stext.stext.RealLiteral;
+import org.yakindu.sct.model.stext.stext.StringLiteral;
+
+import com.google.inject.Singleton;
+
+@Singleton
+public class STextDefaulTypeSystem extends AbstractTypeSystem implements
+		ISTextTypeSystem {
+
+	/**
+	 * Dummy resource. Xtext linker expects types to be contained in a resource.
+	 */
+	private static Resource resource;
+	private static PrimitiveType voidType;
+	private static PrimitiveType stringType;
+	private static PrimitiveType realType;
+	private static PrimitiveType integerType;
+	private static PrimitiveType booleanType;
+
+	protected static synchronized Resource getResource() {
+		if (resource == null) {
+			resource = new ResourceImpl();
+			// use old uri for backwards compatibility
+			resource.setURI(URI
+					.createURI("platform:/plugin/org.yakindu.sct.model.stext/libraries/Primitives.types"));
+		}
+		return resource;
+	}
+
+	public Type getBooleanType() {
+		synchronized (STextDefaulTypeSystem.class) {
+			if (booleanType == null) {
+				booleanType = TypesFactory.eINSTANCE.createPrimitiveType();
+				booleanType.setName("boolean");
+				getResource().getContents().add(booleanType);
+			}
+			return booleanType;
+		}
+	}
+
+	public Type getIntegerType() {
+		synchronized (STextDefaulTypeSystem.class) {
+			if (integerType == null) {
+				integerType = TypesFactory.eINSTANCE.createPrimitiveType();
+				integerType.setName("integer");
+				getResource().getContents().add(integerType);
+			}
+			return integerType;
+		}
+	}
+
+	public Type getRealType() {
+		synchronized (STextDefaulTypeSystem.class) {
+			if (realType == null) {
+				realType = TypesFactory.eINSTANCE.createPrimitiveType();
+				realType.setName("real");
+				getResource().getContents().add(realType);
+			}
+			return realType;
+		}
+	}
+
+	public Type getStringType() {
+		synchronized (STextDefaulTypeSystem.class) {
+			if (stringType == null) {
+				stringType = TypesFactory.eINSTANCE.createPrimitiveType();
+				stringType.setName("string");
+				getResource().getContents().add(stringType);
+			}
+			return stringType;
+		}
+	}
+
+	public Type getVoidType() {
+		synchronized (STextDefaulTypeSystem.class) {
+			if (voidType == null) {
+				voidType = TypesFactory.eINSTANCE.createPrimitiveType();
+				voidType.setName("void");
+				getResource().getContents().add(voidType);
+			}
+			return voidType;
+		}
+	}
+
+	public InferenceResult inferType(Literal literal) {
+		if (literal instanceof StringLiteral) {
+			return new InferenceResult(getStringType());
+		} else if (literal instanceof BoolLiteral) {
+			return new InferenceResult(getBooleanType());
+		} else if (literal instanceof IntLiteral
+				|| literal instanceof HexLiteral) {
+			return new InferenceResult(getIntegerType());
+		} else if (literal instanceof RealLiteral) {
+			return new InferenceResult(getRealType());
+		}
+		return new InferenceResult(null, new InferenceIssue(
+				"Literal of unknown kind " + literal, IStatus.ERROR));
+	}
+
+	public InferenceResult inferType(InferredType operandType,
+			ITypeSystemOperator unaryOperator) {
+		// some defense programming
+		if (operandType == null) {
+			throw new NullPointerException("operandType may not be null.");
+		}
+
+		// if the operand type could not be inferred, there is not much we can
+		// do here
+		if (operandType.getType() == null) {
+			return new InferenceResult(
+					null,
+					new InferenceIssue(
+							"Could not infer a type for the operation "
+									+ unaryOperator.getSymbol()
+									+ ", because no type was inferred for its operand.",
+							IStatus.ERROR));
+		}
+
+		// check we have a primitive type
+		if (!(operandType.getType() instanceof PrimitiveType)) {
+			return new InferenceResult(null, new InferenceIssue("Operator "
+					+ unaryOperator.getSymbol()
+					+ " may only be applied on a primitive type.",
+					IStatus.ERROR));
+		}
+
+		// infer type based on given operator
+		UnaryOperators o = (UnaryOperators) unaryOperator;
+		switch (o) {
+		case COMPLEMENT:
+			if (!isIntegerType(operandType.getType())) {
+				return new InferenceResult(
+						null,
+						new InferenceIssue(
+								"Bitwise operator '"
+										+ o.getSymbol()
+										+ "' may only be applied on integer types, not on "
+										+ operandType.getType().getName() + ".",
+								IStatus.ERROR));
+
+			}
+			return new InferenceResult(operandType);
+		case NEGATIVE:
+		case POSITIVE:
+			if (!isIntegerType(operandType.getType())
+					&& !isRealType(operandType.getType())) {
+				return new InferenceResult(
+						null,
+						new InferenceIssue(
+								"Arithmetic operator '"
+										+ o.getSymbol()
+										+ "' may only be applied on numeric types, not on "
+										+ operandType.getType().getName() + ".",
+								IStatus.ERROR));
+			}
+			return new InferenceResult(operandType);
+		case LOGICAL_NOT:
+			if (!isBooleanType(operandType.getType())) {
+				return new InferenceResult(
+						null,
+						new InferenceIssue(
+								"Logical operator '"
+										+ o.getSymbol()
+										+ "' may only be applied on boolean types, not on "
+										+ operandType.getType().getName() + ".",
+								IStatus.ERROR));
+
+			}
+			return new InferenceResult(operandType);
+		default:
+			throw new IllegalArgumentException("Unsupported unary operator: "
+					+ unaryOperator);
+		}
+	}
+
+	public InferenceResult inferType(InferredType firstOperandType,
+			InferredType secondOperandType, ITypeSystemOperator binaryOperator) {
+		// some defense programming
+		if (firstOperandType == null || secondOperandType == null) {
+			throw new NullPointerException("Operand types may not be null.");
+		}
+
+		// if the operand type could not be inferred, there is not much we can
+		// do here
+		if (firstOperandType.getType() == null
+				|| secondOperandType.getType() == null) {
+			return new InferenceResult(
+					null,
+					new InferenceIssue(
+							"Could not infer a type for the operation "
+									+ binaryOperator.getSymbol()
+									+ ", because types were not inferred for all of its operands.",
+							IStatus.ERROR));
+		}
+
+		// infer type base on operator (fist pass: check types are valid, second
+		// pass: compute result type)
+		BinaryOperators o = (BinaryOperators) binaryOperator;
+		switch (o) {
+		case BITWISE_OR:
+		case BITWISE_XOR:
+		case BITWISE_AND:
+		case RIGHT_SHIFT:
+		case LEFT_SHIFT:
+		case ASSIGN_LEFTSHIFT:
+		case ASSIGN_RIGHTSHIFT:
+			// check only integer types are used
+			if (!isIntegerType(firstOperandType.getType())
+					|| !isIntegerType(secondOperandType.getType())) {
+				return new InferenceResult(
+						null,
+						new InferenceIssue(
+								"Bitwise operator '"
+										+ o.getSymbol()
+										+ "' may only be applied on integer types, not on "
+										+ firstOperandType.getType().getName()
+										+ " and "
+										+ secondOperandType.getType().getName()
+										+ ".", IStatus.ERROR));
+			}
+			// second pass: compute common type
+			switch (o) {
+			case BITWISE_OR:
+			case BITWISE_XOR:
+			case BITWISE_AND:
+				// compute union type
+				return union(firstOperandType, secondOperandType);
+			case RIGHT_SHIFT:
+			case LEFT_SHIFT:
+			case ASSIGN_LEFTSHIFT:
+			case ASSIGN_RIGHTSHIFT:
+				// return type of assignment target
+				return new InferenceResult(firstOperandType);
+			default:
+				throw new IllegalStateException("Unsupported operator kind.");
+			}
+		case ADD:
+		case SUBTRACT:
+		case MULTIPLY:
+		case DIV:
+		case MOD:
+		case ASSIGN_ADD:
+		case ASSIGN_SUBTRACT:
+		case ASSIGN_MULTIPLY:
+		case ASSIGN_DIV:
+		case ASSIGN_MOD:
+			// only numeric types
+			if (!isNumericType(firstOperandType.getType())
+					|| !isNumericType(secondOperandType.getType())) {
+				return new InferenceResult(
+						null,
+						new InferenceIssue(
+								"Arithmetic operator '"
+										+ o.getSymbol()
+										+ "' may only be applied on numeric types, not on "
+										+ firstOperandType.getType().getName()
+										+ " and "
+										+ secondOperandType.getType().getName()
+										+ ".", IStatus.ERROR));
+			}
+
+			// second pass: compute type
+			switch (o) {
+			case ADD:
+			case SUBTRACT:
+			case MULTIPLY:
+			case DIV:
+			case MOD:
+				return union(firstOperandType, secondOperandType);
+			case ASSIGN_ADD:
+			case ASSIGN_SUBTRACT:
+			case ASSIGN_MULTIPLY:
+			case ASSIGN_DIV:
+			case ASSIGN_MOD:
+				// return type of assignment target
+				return new InferenceResult(firstOperandType);
+			default:
+				throw new IllegalStateException("Unsupported operator kind.");
+			}
+		case LOGICAL_OR:
+		case LOGICAL_AND:
+		case ASSIGN_AND:
+		case ASSIGN_OR:
+		case ASSIGN_XOR:
+			// only boolean types allowed
+			if (!isBooleanType(firstOperandType.getType())
+					|| !isBooleanType(secondOperandType.getType())) {
+				return new InferenceResult(
+						null,
+						new InferenceIssue(
+								"Logical operator '"
+										+ o.getSymbol()
+										+ "' may only be applied on boolean types, not on "
+										+ firstOperandType.getType().getName()
+										+ " and "
+										+ secondOperandType.getType().getName()
+										+ ".", IStatus.ERROR));
+			}
+
+			// second pass: compute type
+			switch (o) {
+			case LOGICAL_OR:
+			case LOGICAL_AND:
+				return union(firstOperandType, secondOperandType);
+			case ASSIGN_AND:
+			case ASSIGN_OR:
+			case ASSIGN_XOR:
+				// use type of assignment target
+				return new InferenceResult(firstOperandType);
+			default:
+				throw new IllegalStateException("Unsupported operator kind.");
+			}
+		case GREATER:
+		case GREATER_EQUAL:
+		case SMALLER:
+		case SMALLER_EQUAL:
+			// check we have primitive types
+			if (!(firstOperandType.getType() instanceof PrimitiveType)
+					|| !(secondOperandType.getType() instanceof PrimitiveType)) {
+				return new InferenceResult(
+						null,
+						new InferenceIssue(
+								"Comparison operator '"
+										+ o.getSymbol()
+										+ "' may only be applied on primitive types, not on "
+										+ firstOperandType.getType().getName()
+										+ " and "
+										+ secondOperandType.getType().getName()
+										+ ".", IStatus.ERROR));
+			}
+			// check types have the same base type
+			if (!EcoreUtil.equals(
+					getBaseType((PrimitiveType) firstOperandType.getType()),
+					getBaseType((PrimitiveType) secondOperandType.getType()))) {
+				// exclude coercion case (integer -> real)
+				if (!(isNumericType(firstOperandType.getType()) && isNumericType(secondOperandType
+						.getType()))) {
+					return new InferenceResult(
+							null,
+							new InferenceIssue(
+									"Comparison operator '"
+											+ o.getSymbol()
+											+ "' may only be applied on compatible types, not on "
+											+ firstOperandType.getType()
+													.getName()
+											+ " and "
+											+ secondOperandType.getType()
+													.getName() + ".",
+									IStatus.ERROR));
+				}
+
+			}
+			// expression has boolean type
+			return new InferenceResult(new InferredType(getBooleanType()));
+		case EQUAL:
+		case NOT_EQUAL:
+		case ASSIGN:
+			// complex types are allowed here
+			if (firstOperandType.getType() instanceof PrimitiveType
+					&& secondOperandType.getType() instanceof PrimitiveType) {
+				// check primitive types have the same base type
+				if (!EcoreUtil
+						.equals(getBaseType((PrimitiveType) firstOperandType
+								.getType()),
+								getBaseType((PrimitiveType) secondOperandType
+										.getType()))) {
+					// handle coercion
+					if (!(isNumericType(firstOperandType.getType()) && isNumericType(secondOperandType
+							.getType()))) {
+						return new InferenceResult(
+								null,
+								o.equals(BinaryOperators.ASSIGN) ? new InferenceIssue(
+										"Assignment operator '"
+												+ o.getSymbol()
+												+ "' may only be applied on compatible types, not on "
+												+ firstOperandType.getType()
+														.getName()
+												+ " and "
+												+ secondOperandType.getType()
+														.getName() + ".",
+										IStatus.ERROR)
+										: new InferenceIssue(
+												"Comparison operator '"
+														+ o.getSymbol()
+														+ "' may only be applied on compatible types, not on "
+														+ firstOperandType
+																.getType()
+																.getName()
+														+ " and "
+														+ secondOperandType
+																.getType()
+																.getName()
+														+ ".", IStatus.ERROR));
+					} else {
+						if (o.equals(BinaryOperators.ASSIGN)
+								&& !isRealType(firstOperandType.getType())
+								&& isRealType(secondOperandType.getType())) {
+							// may only assign integer to real, not vice versa
+							return new InferenceResult(
+									null,
+									new InferenceIssue(
+											"Assignment operator '"
+													+ o.getSymbol()
+													+ "' may only be applied on compatible types, not on "
+													+ firstOperandType
+															.getType()
+															.getName()
+													+ " and "
+													+ secondOperandType
+															.getType()
+															.getName() + ".",
+											IStatus.ERROR));
+						}
+					}
+				}
+			} else if (firstOperandType instanceof ComplexType
+					&& secondOperandType.getType() instanceof ComplexType) {
+				// no further checks for complex types required here
+				// (computation of type in second pass will result in null, if
+				// they are not compatible)
+			} else {
+				return new InferenceResult(
+						null,
+						new InferenceIssue(
+								"Assignment and equality operations may only be applied on types of the same kind, not on "
+										+ firstOperandType.getType().getName()
+										+ " and "
+										+ secondOperandType.getType().getName()
+										+ ".", IStatus.ERROR));
+			}
+
+			// second pass, compute types
+			switch (o) {
+			case ASSIGN:
+				// type of assignment target
+				return new InferenceResult(firstOperandType);
+			case EQUAL:
+			case NOT_EQUAL:
+				// boolean type
+				return new InferenceResult(new InferredType(getBooleanType()));
+			default:
+				throw new IllegalStateException("Unsupported operator kind.");
+			}
+		default:
+			throw new IllegalArgumentException("Unsupported binary operator: "
+					+ binaryOperator);
+		}
+	}
+
+	public InferenceResult inferType(InferredType firstOperandType,
+			InferredType secondOperandType, InferredType thirdOperandType,
+			ITypeSystemOperator ternaryOperator) {
+		// some defense programming
+		if (firstOperandType == null || secondOperandType == null
+				|| thirdOperandType == null) {
+			throw new NullPointerException("Operand types may not be null");
+		}
+
+		// if the operand type could not be inferred, there is not much we can
+		// do here
+		if (firstOperandType.getType() == null
+				|| secondOperandType.getType() == null
+				|| thirdOperandType.getType() == null) {
+			return new InferenceResult(
+					null,
+					new InferenceIssue(
+							"Could not infer a type for the operation "
+									+ ternaryOperator.getSymbol()
+									+ ", because types were not inferred for all of its operands.",
+							IStatus.ERROR));
+		}
+
+		// infer type based on operator
+		TernaryOperators o = (TernaryOperators) ternaryOperator;
+		switch (o) {
+		case CONDITIONAL:
+			// first operand has to be boolean, second and third determine the
+			// inferred type of the expression
+			List<InferenceIssue> issues = new ArrayList<ITypeSystem.InferenceIssue>();
+			if (!isBooleanType(firstOperandType.getType())) {
+				issues.add(new InferenceIssue(
+						"No valid type can be inferred for conditional expression, because type of first operand is not boolean.",
+						IStatus.ERROR));
+			}
+			// compute a union of the second and third operand types
+			InferenceResult unionResult = union(firstOperandType,
+					secondOperandType);
+			unionResult.getIssues().addAll(issues);
+			return unionResult;
+		default:
+			throw new IllegalArgumentException("Unsupported ternary operator: "
+					+ ternaryOperator);
+		}
+	}
+
+	public InferenceResult union(InferredType firstType, InferredType secondType) {
+		// defense programming
+		if (firstType == null || secondType == null) {
+			throw new NullPointerException(
+					"firstType and secondType may not be null.");
+		}
+
+		// if the operand type could not be inferred, there is not much we can
+		// do here
+		if (firstType.getType() == null || secondType.getType() == null) {
+			return new InferenceResult(
+					null,
+					new InferenceIssue(
+							"Could not infer a type union, because not all given types were properly inferred in advance.",
+							IStatus.ERROR));
+		}
+
+		// infer the union of both given types
+		if (firstType.getType() instanceof PrimitiveType
+				&& secondType.getType() instanceof PrimitiveType) {
+			Type commonType = computeCommonType(
+					(PrimitiveType) firstType.getType(),
+					(PrimitiveType) secondType.getType());
+			if (commonType != null) {
+				return new InferenceResult(new InferredType(commonType));
+			} else {
+				// handle coercion of types
+				if (isNumericType(firstType) && isNumericType(secondType)) {
+					// integer to real coercion
+					if (isRealType(firstType)) {
+						return new InferenceResult(firstType);
+					} else {
+						return new InferenceResult(secondType);
+					}
+				}
+			}
+		}
+		return new InferenceResult(null, new InferenceIssue(
+				"Cannot compute a type union for the given types: " + firstType
+						+ ", " + secondType, IStatus.ERROR));
+	}
+
+	public List<Type> getTypes(InferenceResult inferenceResult) {
+		if (inferenceResult == null) {
+			throw new NullPointerException(
+					"InferenceResult result may not be null.");
+		}
+		// we do not evaluate constraints and we only have one type of a kind
+		if (inferenceResult.getType() == null) {
+			return Collections.<Type> emptyList();
+		} else {
+			return Collections.singletonList(inferenceResult.getType()
+					.getType());
+		}
+	}
+
+	public List<Type> getTypes() {
+		List<Type> types = new ArrayList<Type>();
+		types.add(getVoidType());
+		types.add(getBooleanType());
+		types.add(getIntegerType());
+		types.add(getRealType());
+		types.add(getStringType());
+		return types;
+	}
+
+	public boolean isVoidType(Type type) {
+		return EcoreUtil.equals(getVoidType(), type);
+	}
+
+	public boolean isVoidType(InferredType type) {
+		return isVoidType(type.getType());
+	}
+
+	public boolean isBooleanType(InferredType type) {
+		return isBooleanType(type.getType());
+	}
+
+	public boolean isBooleanType(Type type) {
+		return EcoreUtil.equals(getBooleanType(), type);
+	}
+
+	public boolean isRealType(Type type) {
+		return EcoreUtil.equals(getRealType(), type);
+	}
+
+	public boolean isRealType(InferredType type) {
+		return isRealType(type.getType());
+	}
+
+	public boolean isIntegerType(Type type) {
+		return EcoreUtil.equals(getIntegerType(), type);
+	}
+
+	public boolean isIntegerType(InferredType type) {
+		return isIntegerType(type.getType());
+	}
+
+	public boolean isStringType(Type type) {
+		return EcoreUtil.equals(getStringType(), type);
+	}
+
+	public boolean isStringType(InferredType type) {
+		return isStringType(type.getType());
+	}
+
+	public boolean isNumericType(Type type) {
+		return EcoreUtil.equals(getIntegerType(), type)
+				|| EcoreUtil.equals(getRealType(), type);
+	}
+
+	public boolean isNumericType(InferredType type) {
+		return isNumericType(type.getType());
+	}
+
+	public InferenceResult inferType(Type type) {
+		return new InferenceResult(new InferredType(type));
+	}
+
+	public List<Type> getTypes(InferredType inferredType) {
+		if (inferredType == null) {
+			throw new NullPointerException("inferredType may not be null.");
+		}
+		return Collections.singletonList(inferredType.getType());
+	}
+
+}

+ 421 - 0
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/types/STextDefaultTypeInferrer.xtend

@@ -0,0 +1,421 @@
+/**
+ * Copyright (c) 2011 itemis AG 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:
+ * 	itemis AG - initial API and implementation
+ *  
+ */
+package org.yakindu.sct.model.stext.types
+
+import com.google.inject.Inject
+import org.eclipse.emf.ecore.EObject
+import org.yakindu.base.types.Event
+import org.yakindu.base.types.Feature
+import org.yakindu.base.types.ITypeSystem$InferenceResult
+import org.yakindu.base.types.ITypeSystem$InferredType
+import org.yakindu.base.types.ITypeSystem$ITypeSystemOperator
+import org.yakindu.sct.model.stext.stext.ActiveStateReferenceExpression
+import org.yakindu.sct.model.stext.stext.AssignmentExpression
+import org.yakindu.sct.model.stext.stext.BitwiseAndExpression
+import org.yakindu.sct.model.stext.stext.BitwiseOrExpression
+import org.yakindu.sct.model.stext.stext.BitwiseXorExpression
+import org.yakindu.sct.model.stext.stext.ConditionalExpression
+import org.yakindu.sct.model.stext.stext.ElementReferenceExpression
+import org.yakindu.sct.model.stext.stext.EventRaisingExpression
+import org.yakindu.sct.model.stext.stext.EventValueReferenceExpression
+import org.yakindu.sct.model.stext.stext.Expression
+import org.yakindu.sct.model.stext.stext.FeatureCall
+import org.yakindu.sct.model.stext.stext.Literal
+import org.yakindu.sct.model.stext.stext.LogicalAndExpression
+import org.yakindu.sct.model.stext.stext.LogicalNotExpression
+import org.yakindu.sct.model.stext.stext.LogicalOrExpression
+import org.yakindu.sct.model.stext.stext.LogicalRelationExpression
+import org.yakindu.sct.model.stext.stext.NumericalAddSubtractExpression
+import org.yakindu.sct.model.stext.stext.NumericalMultiplyDivideExpression
+import org.yakindu.sct.model.stext.stext.NumericalUnaryExpression
+import org.yakindu.sct.model.stext.stext.OperationDefinition
+import org.yakindu.sct.model.stext.stext.ParenthesizedExpression
+import org.yakindu.sct.model.stext.stext.PrimitiveValueExpression
+import org.yakindu.sct.model.stext.stext.ShiftExpression
+import org.yakindu.sct.model.stext.types.ISTextTypeSystem$UnaryOperators
+import org.yakindu.sct.model.stext.types.ISTextTypeSystem$BinaryOperators
+import org.yakindu.sct.model.stext.types.ISTextTypeSystem$TernaryOperators
+import org.yakindu.sct.model.stext.stext.AssignmentOperator
+import org.yakindu.sct.model.stext.stext.ShiftOperator
+import org.yakindu.sct.model.stext.stext.AdditiveOperator
+import org.yakindu.sct.model.stext.stext.MultiplicativeOperator
+import org.yakindu.sct.model.stext.stext.RelationalOperator
+import com.google.inject.Singleton
+import org.yakindu.sct.model.stext.stext.UnaryOperator
+import com.google.common.collect.Iterables
+import org.yakindu.base.types.ITypeSystem$InferenceIssue
+import org.eclipse.core.runtime.IStatus
+import org.yakindu.sct.model.stext.stext.VariableDefinition
+import org.yakindu.sct.model.stext.stext.EventDefinition
+import org.yakindu.base.types.Type
+import org.yakindu.base.types.Enumerator
+import org.yakindu.base.types.TypedElement
+
+/**
+ * 
+ * The TypeInferrer checks an expression AST for type conformance
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * @author Alexander Nyßen - Complete revision of API
+ *  
+ */
+ @Singleton
+class STextDefaultTypeInferrer implements ISTextTypeInferrer {
+	
+	@Inject protected extension
+	ISTextTypeSystem ts
+	
+	override inferType(Expression e) {
+		if(e == null){
+			throw new IllegalArgumentException("Expression may not be null")
+		}
+		else{
+			return doInferType(e)
+		}
+	}
+	
+	override inferType(VariableDefinition definition) {
+		if(definition == null){
+			throw new IllegalArgumentException("Definition may not be null")
+		}
+		else{
+			definition.doInferType
+		}
+	}
+	
+	override inferType(EventDefinition definition) {
+		if(definition == null){
+			throw new IllegalArgumentException("Definition may not be null")
+		}
+		else{
+			definition.doInferType
+		}
+	}
+	
+	def dispatch InferenceResult doInferType(VariableDefinition definition) {
+		if(definition.type == null) {
+ 				return new InferenceResult(null, new InferenceIssue("Could not infer type of variable: " + definition.name, IStatus::ERROR))
+ 		}
+ 		else{
+ 			var varType = new InferenceResult(new InferredType(definition.type))
+ 			if(definition.initialValue != null){
+ 				val valueType = definition.initialValue.doInferType
+ 				if(valueType.type == null){
+ 					return new InferenceResult(null, new InferenceIssue("Could not infer type of initial value expression: " + definition.initialValue, IStatus::ERROR))
+ 				}
+ 			
+ 				// reuse the assignment logic of the type system
+ 				val result = inferResult(varType, valueType, BinaryOperators::ASSIGN)
+ 				if(result.type == null){
+ 					return new InferenceResult(null, new InferenceIssue("Cannot assign a value of type " + valueType.type.type.name + " to a variable of type " + varType.type.type.name + ".", IStatus::ERROR))
+ 				}	
+ 			}
+ 			return varType
+ 		}
+	}
+
+	def dispatch InferenceResult doInferType(EventDefinition definition) {
+		if(definition == null){
+			throw new IllegalArgumentException("EventDefinition may not be null")
+		}
+		if(definition.type == null){
+			return new InferenceResult(new InferredType(voidType))
+		}
+		return new InferenceResult(new InferredType(definition.type))
+	}
+
+	def dispatch InferenceResult doInferType(OperationDefinition definition) {
+		if(definition == null){
+			throw new IllegalArgumentException("EventDefinition may not be null")
+		}
+		if(definition.type == null){
+			return new InferenceResult(new InferredType(voidType))
+		}
+		return new InferenceResult(new InferredType(definition.type))
+	}
+	
+	def dispatch InferenceResult doInferType(Type type) {
+		return new InferenceResult(new InferredType(type))
+	}
+	
+	def dispatch InferenceResult doInferType(TypedElement typedElement) {
+		return new InferenceResult(new InferredType(typedElement.type))
+	}
+	
+	def dispatch InferenceResult doInferType(Enumerator enumerator) {
+		return new InferenceResult(new InferredType(enumerator.owningEnumeration));
+	}
+	
+	def dispatch InferenceResult doInferType(EObject e) {
+		// TODO: delegate to type system
+		return new InferenceResult(new InferredType(voidType))
+	}
+
+	def dispatch InferenceResult doInferType(Expression e) {
+		throw new UnsupportedOperationException("Unsupported expression type " + e)
+	}
+	
+	def InferenceResult inferResult(InferenceResult operand, ITypeSystemOperator unaryOperator){
+		if(operand.getType() != null){
+			return ts.inferType(operand.type, unaryOperator);
+//			result.issues.addAll(operand.issues);
+		}
+		return new InferenceResult(null, operand.issues)
+	}
+	
+	def InferenceResult inferResult(InferenceResult firstOperand, InferenceResult secondOperand, ITypeSystemOperator binaryOperator){
+		if(firstOperand.getType() != null && secondOperand.getType() != null){
+			val result = ts.inferType(firstOperand.type, secondOperand.type, binaryOperator);
+			result.issues.addAll(firstOperand.issues);
+			result.issues.addAll(secondOperand.issues);
+			return result;
+		}
+		return new InferenceResult(null, Iterables::concat(firstOperand.issues, secondOperand.issues).toList);
+	}
+	
+	def InferenceResult inferResult(InferenceResult firstOperand, InferenceResult secondOperand, InferenceResult thirdOperand, ITypeSystemOperator ternaryOperator){
+		if(firstOperand.getType() != null && secondOperand.getType() != null && thirdOperand.getType() != null){
+			val result = ts.inferType(firstOperand.type, secondOperand.type, thirdOperand.type, ternaryOperator);
+			result.issues.addAll(firstOperand.issues);
+			result.issues.addAll(secondOperand.issues);
+			result.issues.addAll(thirdOperand.issues);
+			return result;
+		}
+		return new InferenceResult(null, Iterables::concat(firstOperand.issues, secondOperand.issues).toList);
+	}
+	
+	def dispatch InferenceResult doInferType(AssignmentExpression expression){
+		return inferResult(expression.varRef.doInferType, expression.expression.doInferType, getTypeSystemOperator(expression.operator))
+	}
+	
+	def dispatch InferenceResult doInferType(LogicalAndExpression expression){
+		return inferResult(expression.leftOperand.doInferType, expression.rightOperand.doInferType, BinaryOperators::LOGICAL_AND)
+	}
+	def dispatch InferenceResult doInferType(LogicalOrExpression expression){
+		return inferResult(expression.leftOperand.doInferType, expression.rightOperand.doInferType, BinaryOperators::LOGICAL_OR)
+	}
+	
+	def dispatch InferenceResult doInferType(LogicalNotExpression expression){
+		return inferResult(expression.operand.doInferType, UnaryOperators::LOGICAL_NOT)
+	}
+	
+	def dispatch InferenceResult doInferType(BitwiseAndExpression expression){
+		return inferResult(expression.leftOperand.doInferType, expression.rightOperand.doInferType, BinaryOperators::BITWISE_AND)
+	}
+	
+	def dispatch InferenceResult doInferType(BitwiseOrExpression expression){
+		return inferResult(expression.leftOperand.doInferType, expression.rightOperand.doInferType, BinaryOperators::BITWISE_OR)
+	}
+	
+	def dispatch InferenceResult doInferType(BitwiseXorExpression expression){
+		return inferResult(expression.leftOperand.doInferType, expression.rightOperand.doInferType, BinaryOperators::BITWISE_XOR)
+	}
+	
+	def dispatch InferenceResult doInferType(LogicalRelationExpression expression){ 
+		return inferResult(expression.leftOperand.doInferType, expression.rightOperand.doInferType, getTypeSystemOperator(expression.operator))
+	}
+	
+	def dispatch InferenceResult doInferType(NumericalAddSubtractExpression expression){
+		return inferResult(expression.leftOperand.doInferType, expression.rightOperand.doInferType, getTypeSystemOperator(expression.operator))
+	}
+	def dispatch InferenceResult doInferType(NumericalMultiplyDivideExpression expression){
+		return inferResult(expression.leftOperand.doInferType, expression.rightOperand.doInferType, getTypeSystemOperator(expression.operator))
+	}
+	def dispatch InferenceResult doInferType(NumericalUnaryExpression expression){
+		return inferResult(expression.operand.doInferType, getTypeSystemOperator(expression.operator))
+	}	
+	
+	def dispatch InferenceResult doInferType(PrimitiveValueExpression expression){
+		return expression.value.doInferType
+	}
+	
+	def dispatch InferenceResult doInferType(ShiftExpression expression){
+		return inferResult(expression.leftOperand.doInferType, expression.rightOperand.doInferType, getTypeSystemOperator(expression.operator))
+	}
+	
+	def dispatch InferenceResult doInferType(ConditionalExpression expression){
+		return inferResult(expression.condition.doInferType, expression.trueCase.doInferType, expression.falseCase.doInferType, TernaryOperators::CONDITIONAL);
+	} 
+	
+	def dispatch InferenceResult doInferType(EventRaisingExpression eventRaising){
+ 		val eventType = eventRaising.event.doInferType
+ 		if(eventType.type == null) {
+ 			return new InferenceResult(null, new InferenceIssue("Could not infer type of event expression: " + eventRaising.event, IStatus::ERROR))
+ 		}
+ 		else{
+ 			if(eventRaising.value == null){
+ 				if(!eventType.type.voidType){
+ 					return new InferenceResult(null, new InferenceIssue("Need to assign a value to an event of type " + eventType.type.type.name + ".", IStatus::ERROR))
+ 				}	
+ 				return eventType
+ 			}
+ 			else{
+ 				val valueType = eventRaising.value.doInferType
+ 				if(valueType.type == null){
+ 					return new InferenceResult(null, new InferenceIssue("Could not infer type of value expression: " + eventRaising.value, IStatus::ERROR))
+ 				}
+ 			
+ 				// reuse the assignment logic of the type system
+ 				val result = inferResult(eventType, valueType, BinaryOperators::ASSIGN)
+ 				if(result.type == null){
+ 					return new InferenceResult(null, new InferenceIssue("Cannot assign a value of type " + valueType.type.type.name + " to an event of type " + eventType.type.type.name + ".", IStatus::ERROR))
+ 				}
+ 				else {
+ 					return result
+ 				}
+ 			}
+ 		}
+	}
+	
+	def dispatch InferenceResult doInferType(FeatureCall featureCall){
+		if(featureCall.feature instanceof Event /*Definition*/ 
+			&& !(featureCall.eContainer instanceof EventRaisingExpression) 
+			&& !(featureCall.eContainer instanceof EventValueReferenceExpression)
+		){
+			// e1 is a shortcut for isRaised(e1) and thus we have to return boolean here
+			return new InferenceResult(getBooleanType)
+		}
+		if (featureCall.feature instanceof Feature) {
+			val type = (featureCall.feature as Feature).type
+			if(type != null){
+				return new InferenceResult(new InferredType(type))
+			}
+			return new InferenceResult(getVoidType)
+		}
+		return featureCall.feature.doInferType
+	}
+	 
+	def dispatch InferenceResult doInferType(ActiveStateReferenceExpression expression){
+		return new InferenceResult(getBooleanType)
+	}
+
+	def dispatch InferenceResult doInferType(ElementReferenceExpression expression){
+		if(expression.reference instanceof EventDefinition && !(expression.eContainer instanceof EventRaisingExpression
+				|| expression.eContainer instanceof EventValueReferenceExpression)){
+			// in case we are not inside an raise or valueOf expression, the event is a shortcut for isRaised(event) and thus, we may return boolean here
+			return new InferenceResult(getBooleanType)
+		}
+		else {
+			// inference of the reference type is not context dependent
+			return expression.reference.doInferType
+		}
+	}
+	
+	def dispatch InferenceResult doInferType(EventValueReferenceExpression expression){
+		return doInferType(expression.value)
+	}
+	
+	def dispatch InferenceResult doInferType(ParenthesizedExpression expression){
+		return doInferType(expression.expression)
+	}
+	
+	def dispatch InferenceResult doInferType(Literal literal){
+		return ts.inferType(literal)
+	}
+	
+	def protected dispatch ITypeSystemOperator getTypeSystemOperator(UnaryOperator operator){
+		switch(operator){
+			case UnaryOperator::COMPLEMENT:
+				UnaryOperators::COMPLEMENT
+			case UnaryOperator::NEGATIVE:
+				UnaryOperators::NEGATIVE
+			case UnaryOperator::POSITIVE:
+				UnaryOperators::POSITIVE
+			default:
+				throw new IllegalArgumentException("Unsupported operator" + operator)
+		}
+	}
+	
+	def protected dispatch ITypeSystemOperator getTypeSystemOperator(AssignmentOperator operator) {
+		switch(operator){
+			case AssignmentOperator::ADD_ASSIGN:
+				BinaryOperators::ASSIGN_ADD
+			case AssignmentOperator::AND_ASSIGN:
+				BinaryOperators::ASSIGN_AND
+			case AssignmentOperator::ASSIGN:
+				BinaryOperators::ASSIGN
+			case AssignmentOperator::DIV_ASSIGN:
+				BinaryOperators::ASSIGN_DIV
+			case AssignmentOperator::LEFT_SHIFT_ASSIGN:
+				BinaryOperators::ASSIGN_LEFTSHIFT
+			case AssignmentOperator::MOD_ASSIGN:
+				BinaryOperators::ASSIGN_MOD
+			case AssignmentOperator::MULT_ASSIGN:
+				BinaryOperators::ASSIGN_MULTIPLY
+			case AssignmentOperator::OR_ASSIGN:
+				BinaryOperators::ASSIGN_OR
+			case AssignmentOperator::RIGHT_SHIFT_ASSIGN:
+				BinaryOperators::ASSIGN_RIGHTSHIFT
+			case AssignmentOperator::SUB_ASSIGN:
+				BinaryOperators::ASSIGN_SUBTRACT
+			case AssignmentOperator::XOR_ASSIGN:
+				BinaryOperators::ASSIGN_XOR
+			default: 
+				throw new IllegalArgumentException("Unsupported operator" + operator)
+		}
+	}
+	
+	def dispatch ITypeSystemOperator getTypeSystemOperator(ShiftOperator operator) {
+		switch(operator){
+			case ShiftOperator::LEFT:
+				BinaryOperators::LEFT_SHIFT
+			case ShiftOperator::RIGHT:
+				BinaryOperators::RIGHT_SHIFT
+			default: 
+				throw new IllegalArgumentException("Unsupported operator" + operator)
+		}
+	}
+	
+	def protected dispatch ITypeSystemOperator getTypeSystemOperator(AdditiveOperator operator) {
+		switch(operator){
+			case AdditiveOperator::PLUS:
+				BinaryOperators::ADD
+			case AdditiveOperator::MINUS:
+				BinaryOperators::SUBTRACT
+			default: 
+				throw new IllegalArgumentException("Unsupported operator" + operator)
+		}
+	}
+	
+	def protected dispatch ITypeSystemOperator getTypeSystemOperator(MultiplicativeOperator operator) {
+		switch(operator){
+			case MultiplicativeOperator::DIV:
+				BinaryOperators::DIV
+			case MultiplicativeOperator::MOD:
+				BinaryOperators::MOD
+			case MultiplicativeOperator::MUL:
+				BinaryOperators::MULTIPLY
+			default: 
+				throw new IllegalArgumentException("Unsupported operator" + operator)
+		}
+	}
+
+	def protected dispatch ITypeSystemOperator getTypeSystemOperator(RelationalOperator operator) {
+		switch(operator){
+			case RelationalOperator::EQUALS:
+				BinaryOperators::EQUAL
+			case RelationalOperator::NOT_EQUALS:
+				BinaryOperators::NOT_EQUAL
+			case RelationalOperator::GREATER:
+				BinaryOperators::GREATER
+			case RelationalOperator::GREATER_EQUAL:
+				BinaryOperators::GREATER_EQUAL
+			case RelationalOperator::SMALLER:
+				BinaryOperators::SMALLER
+			case RelationalOperator::SMALLER_EQUAL:
+				BinaryOperators::SMALLER_EQUAL
+			default: 
+				throw new IllegalArgumentException("Unsupported operator" + operator)
+		}
+	}
+
+}

+ 0 - 34
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/ITypeInferrer.java

@@ -1,34 +0,0 @@
-/**
- * Copyright (c) 2012 itemis AG 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:
- * 	itemis AG - initial API and implementation
- * 
- */
-package org.yakindu.sct.model.stext.validation;
-
-import org.yakindu.base.types.Type;
-import org.yakindu.sct.model.sgraph.Statement;
-
-import com.google.inject.ImplementedBy;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-@ImplementedBy(TypeInferrer.class)
-public interface ITypeInferrer {
-	/**
-	 * infers the type for a given {@link Statement}
-	 * 
-	 * @throws TypeCheckException
-	 *             if the Statement is invalid
-	 */
-	Type getType(Statement expr) throws TypeCheckException;
-
-}

+ 83 - 47
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextJavaValidator.java

@@ -32,11 +32,12 @@ import org.eclipse.xtext.validation.CheckType;
 import org.eclipse.xtext.validation.ComposedChecks;
 import org.eclipse.xtext.validation.ValidationMessageAcceptor;
 import org.yakindu.base.types.Event;
-import org.yakindu.base.types.ITypeSystemAccess;
+import org.yakindu.base.types.Feature;
+import org.yakindu.base.types.ITypeSystem.InferenceResult;
+import org.yakindu.base.types.ITypeSystem.InferredType;
 import org.yakindu.base.types.Operation;
 import org.yakindu.base.types.Parameter;
 import org.yakindu.base.types.Property;
-import org.yakindu.base.types.Type;
 import org.yakindu.sct.model.sgraph.Choice;
 import org.yakindu.sct.model.sgraph.SGraphPackage;
 import org.yakindu.sct.model.sgraph.Scope;
@@ -66,6 +67,9 @@ import org.yakindu.sct.model.stext.stext.ReactionEffect;
 import org.yakindu.sct.model.stext.stext.ReactionTrigger;
 import org.yakindu.sct.model.stext.stext.StextPackage;
 import org.yakindu.sct.model.stext.stext.VariableDefinition;
+import org.yakindu.sct.model.stext.types.ISTextTypeInferrer;
+import org.yakindu.sct.model.stext.types.ISTextTypeSystem;
+import org.yakindu.sct.model.stext.types.ISTextTypeSystem.BinaryOperators;
 
 import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
@@ -96,9 +100,10 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
 	public static final String VARIABLE_VOID_TYPE = "'void' is an invalid type for variables";
 
 	@Inject
-	private ITypeInferrer inferrer;
+	private ISTextTypeInferrer typeInferrer;
 	@Inject
-	private ITypeSystemAccess tsAccess;
+	private ISTextTypeSystem typeSystem;
+
 	@Inject
 	private IQualifiedNameProvider nameProvider;
 	@Inject
@@ -107,7 +112,7 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
 
 	@Check(CheckType.FAST)
 	public void checkVariableType(final VariableDefinition definition) {
-		if (tsAccess.isVoid(definition.getType())) {
+		if (typeSystem.isVoidType(new InferredType(definition.getType()))) {
 			error(VARIABLE_VOID_TYPE, null);
 		}
 	}
@@ -165,7 +170,8 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
 			Property reference = (Property) ((ElementReferenceExpression) varRef)
 					.getReference();
 			return reference.getName();
-		} else if (varRef instanceof FeatureCall) {
+		} else if (varRef instanceof FeatureCall
+				&& ((FeatureCall) varRef).getFeature() instanceof Property) {
 			Property reference = (Property) ((FeatureCall) varRef).getFeature();
 			return reference.getName();
 		}
@@ -198,18 +204,16 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
 
 	@Check(CheckType.FAST)
 	public void checkGuardHasBooleanExpression(ReactionTrigger trigger) {
-		if (trigger.getGuardExpression() == null)
+		if (trigger.getGuardExpression() == null) {
 			return;
-		try {
-			Type type = inferrer.getType(trigger.getGuardExpression());
-			if (!tsAccess.isBoolean(type)) {
-				error(GUARD_EXPRESSION,
-						StextPackage.Literals.REACTION_TRIGGER__GUARD_EXPRESSION);
-			}
-		} catch (TypeCheckException ex) {
-			// This is handled by checkExpression
 		}
-
+		InferenceResult t = typeInferrer
+				.inferType(trigger.getGuardExpression());
+		if (t == null || t.getType() == null
+				|| !typeSystem.isBooleanType(t.getType())) {
+			error(GUARD_EXPRESSION,
+					StextPackage.Literals.REACTION_TRIGGER__GUARD_EXPRESSION);
+		}
 	}
 
 	@Check(CheckType.FAST)
@@ -251,8 +255,44 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
 		}
 	}
 
+	protected void checkEventRaisingExpression(EventRaisingExpression e) {
+		if (e.getEvent() != null) {
+			InferenceResult eventType = typeInferrer.inferType(e.getEvent());
+			if (e.getValue() != null) {
+				// if there is a value, check the event has void type
+				if (eventType == null || eventType.getType() == null) {
+					throw new IllegalArgumentException(
+							"Could not infer a type for event part of EventRaisingExpression"
+									+ e);
+				}
+				if (!typeSystem.isVoidType(eventType.getType())) {
+					error("Need to assign a value to an event of type "
+							+ eventType, null);
+				}
+			} else {
+				// check an assignment is possible.
+				InferenceResult valueType = typeInferrer
+						.inferType(e.getValue());
+				if (valueType == null || valueType.getType() == null) {
+					throw new IllegalArgumentException(
+							"Could not infer a type for value part of EventRaisingExpression"
+									+ e);
+				}
+				InferenceResult assignmentResult = typeSystem.inferType(
+						eventType.getType(), valueType.getType(),
+						BinaryOperators.ASSIGN);
+				if (assignmentResult == null
+						|| assignmentResult.getType() == null) {
+					// TODO: could user the issues within result
+					error("Can not assign a value of type " + valueType
+							+ " to an event of type " + eventType, null);
+				}
+			}
+		}
+	}
+
 	protected void checkFeatureCallEffect(FeatureCall call) {
-		if (call.getFeature() != null
+		if (call.getFeature() != null && call.getFeature() instanceof Feature
 				&& !(call.getFeature() instanceof Operation)) {
 			if (call.getFeature() instanceof Property) {
 				error("Access to property '"
@@ -274,7 +314,6 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
 						INSIGNIFICANT_INDEX, FEATURE_CALL_HAS_NO_EFFECT);
 			}
 		}
-
 	}
 
 	protected void checkElementReferenceEffect(ElementReferenceExpression refExp) {
@@ -356,41 +395,38 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
 				return;
 			}
 		}
-
 		error(message, source, (EStructuralFeature) null,
 				ValidationMessageAcceptor.INSIGNIFICANT_INDEX, code);
-
-	}
-
-	@Check(CheckType.FAST)
-	public void checkVariableDefinitionInitialValue(
-			VariableDefinition definition) {
-		Type varType = definition.getType();
-		if (definition.getInitialValue() == null)
-			return;
-		try {
-			Type valType = inferrer.getType(definition.getInitialValue());
-			Type combine = tsAccess.combine(valType, varType);
-			if (combine == null || !tsAccess.isAssignable(varType, valType)) {
-				error("Can not assign a value of type '" + valType.getName()
-						+ "' to a variable of type '" + varType + "'",
-						StextPackage.Literals.VARIABLE_DEFINITION__INITIAL_VALUE);
-			}
-		} catch (Exception e) {
-			error(e.getMessage(), null);
-		}
 	}
 
+	// private void reportIssues(Collection<InferenceIssue> issues) {
+	// int severity = IStatus.OK;
+	// String message = "";
+	// for (InferenceIssue issue : issues) {
+	// if (issue.getSeverity() > severity) {
+	// severity = issue.getSeverity();
+	// }
+	// if (message.length() > 0) {
+	// message += "; ";
+	// }
+	// message += issue.getMessage();
+	// }
+	// if (severity == IStatus.ERROR) {
+	// error(message, null);
+	// } else if (severity == IStatus.WARNING) {
+	// warning(message, null);
+	// }
+	// }
 	@Check(CheckType.FAST)
 	public void checkExpression(final Statement statement) {
-		try {
-			inferrer.getType(statement);
-		} catch (TypeCheckException e) {
-			error(e.getMessage(), null);
-		} catch (IllegalArgumentException e) {
-			// This happens, when the expression is not completed for Unhandled
-			// parameter types: [null]
-			// We can safely ignore this exception
+		if (statement instanceof Expression) {
+			InferenceResult inferType = typeInferrer
+					.inferType((Expression) statement);
+			if (!inferType.getIssues().isEmpty()) {
+				// TODO: handle severity and multiple issues here
+				error(inferType.getIssues().iterator().next().getMessage(),
+						null);
+			}
 		}
 	}
 

+ 0 - 28
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/TypeCheckException.java

@@ -1,28 +0,0 @@
-/**
- * Copyright (c) 2011 itemis AG 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:
- * 	itemis AG - initial API and implementation
- * 
- */
-package org.yakindu.sct.model.stext.validation;
-
-/**
- * runtime Exception thrown by the {@link StaticTypeAnalyzer} if a type
- * conformance check fails.
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public class TypeCheckException extends RuntimeException {
-
-	private static final long serialVersionUID = 1L;
-
-	public TypeCheckException(String cause) {
-		super(cause);
-	}
-}

+ 0 - 306
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/TypeInferrer.xtend

@@ -1,306 +0,0 @@
-/**
- * Copyright (c) 2011 itemis AG 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:
- * 	itemis AG - initial API and implementation
- *  
- */
-package org.yakindu.sct.model.stext.validation
-
-import com.google.inject.Inject
-import org.eclipse.emf.ecore.EObject
-import org.yakindu.base.types.Event
-import org.yakindu.base.types.Feature
-import org.yakindu.base.types.ITypeSystemAccess
-import org.yakindu.base.types.Property
-import org.yakindu.base.types.Type
-import org.yakindu.sct.model.sgraph.Statement
-import org.yakindu.sct.model.stext.stext.ActiveStateReferenceExpression
-import org.yakindu.sct.model.stext.stext.AssignmentExpression
-import org.yakindu.sct.model.stext.stext.BitwiseAndExpression
-import org.yakindu.sct.model.stext.stext.BitwiseOrExpression
-import org.yakindu.sct.model.stext.stext.BitwiseXorExpression
-import org.yakindu.sct.model.stext.stext.BoolLiteral
-import org.yakindu.sct.model.stext.stext.ConditionalExpression
-import org.yakindu.sct.model.stext.stext.ElementReferenceExpression
-import org.yakindu.sct.model.stext.stext.EventRaisingExpression
-import org.yakindu.sct.model.stext.stext.EventValueReferenceExpression
-import org.yakindu.sct.model.stext.stext.Expression
-import org.yakindu.sct.model.stext.stext.FeatureCall
-import org.yakindu.sct.model.stext.stext.HexLiteral
-import org.yakindu.sct.model.stext.stext.IntLiteral
-import org.yakindu.sct.model.stext.stext.LogicalAndExpression
-import org.yakindu.sct.model.stext.stext.LogicalNotExpression
-import org.yakindu.sct.model.stext.stext.LogicalOrExpression
-import org.yakindu.sct.model.stext.stext.LogicalRelationExpression
-import org.yakindu.sct.model.stext.stext.NumericalAddSubtractExpression
-import org.yakindu.sct.model.stext.stext.NumericalMultiplyDivideExpression
-import org.yakindu.sct.model.stext.stext.NumericalUnaryExpression
-import org.yakindu.sct.model.stext.stext.OperationDefinition
-import org.yakindu.sct.model.stext.stext.ParenthesizedExpression
-import org.yakindu.sct.model.stext.stext.PrimitiveValueExpression
-import org.yakindu.sct.model.stext.stext.RealLiteral
-import org.yakindu.sct.model.stext.stext.RelationalOperator
-import org.yakindu.sct.model.stext.stext.ShiftExpression
-import org.yakindu.sct.model.stext.stext.StringLiteral
-import org.yakindu.sct.model.stext.stext.UnaryOperator
- 
-/**
- * 
- * The TypeInferrer checks an expression AST for type conformance
- * 
- * @author andreas muelder - Initial contribution and API
- *  
- */
-class TypeInferrer implements org.yakindu.sct.model.stext.validation.ITypeInferrer, org.yakindu.sct.model.stext.validation.TypeInferrerCache$ICacheableTypeAnalyzer {
-	
-	@Inject protected extension
-	ITypeSystemAccess ts
-	 
-	@Inject 
-	org.yakindu.sct.model.stext.validation.TypeInferrerCache cache
-	
-	override getType(Statement stmt) {
-		if (stmt == null) {
-			return null;
-		}
-		cache.get(stmt, this)
-	}
-	
-	def dispatch inferType(Statement statement){
-		null
-	}
-	
-	def check(Statement stmt) {
-		stmt.getType
-	}
-	
-	/**
-	 * Check Variable assignments
-	 */
-	def dispatch inferType(AssignmentExpression assignment){
-		var valueType = assignment.expression.getType
-		var type = assignment.varRef.getType
-		
-		if(!type.isAssignable(valueType)){
-			error("Can not assign a value of type " + valueType?.name + " to a variable of type " + type?.name)
-			return null 
-		}
-		return type
-	}
-	/**
-	 * Check Event value assignments
-	 */
-	def dispatch inferType(EventRaisingExpression eventRaising){
-		var valueType = eventRaising.value.getType
-		var type = eventRaising.event.getType
-		if(!type.isAssignable(valueType)){
-			error("Can not assign a value of type " + valueType?.name + " to a variable of type " + type?.name)
-			return null 
-		}
-		return type
-	}
-	
-	def dispatch inferType(LogicalAndExpression expression){
-		return assertBooleanTypes(expression.leftOperand.getType,
-			expression.rightOperand.getType,'&&')
-	}
-	def dispatch inferType(LogicalOrExpression expression){
-		return assertBooleanTypes(expression.leftOperand.getType,
-			expression.rightOperand.getType,'||')
-	}
-	def assertBooleanTypes(Type left, Type right, String literal) {
-		if (assertIsBoolean(left,literal) != null
-			&& assertIsBoolean(right, literal) != null) {
-				return left.combine(right)
-			}
-		return null;
-	}
-	def dispatch inferType(LogicalNotExpression expression){
-		val type = expression.operand.getType
-		return assertIsBoolean(type,'!')
-	}
-	def dispatch inferType(BitwiseAndExpression expression){
-		assertIsInteger(expression.leftOperand.getType, '&');
-		assertIsInteger(expression.rightOperand.getType, '&');
-		return integer
-	}
-	def dispatch inferType(BitwiseOrExpression expression){
-		assertIsInteger(expression.leftOperand.getType, '|');
-		assertIsInteger(expression.rightOperand.getType, '|');
-		return integer
-	}
-	def dispatch inferType(BitwiseXorExpression expression){
-		assertIsInteger(expression.leftOperand.getType, '^');
-		assertIsInteger(expression.rightOperand.getType, '^');
-		return integer
-	}
-	
-	def dispatch inferType(LogicalRelationExpression expression){ 
-		val leftType = expression.leftOperand.getType
-		val rightType = expression.rightOperand.getType
-		//If both types are boolean, only relational operators Equals and not_Equals are allowed
-		if(leftType.^boolean && rightType.^boolean){
-			if(expression.operator != RelationalOperator::EQUALS && expression.operator != RelationalOperator::NOT_EQUALS){
-				error("operator '" + expression.operator?.literal + "' can not be applied to boolean values!")
-				return null
-			}
-		} else {
-			val combined = leftType.combine(rightType)
-			if(combined == null){
-				error("Incompatible operands " +leftType?.name + " and " + rightType?.name + " for operator '" + expression.operator.literal+"'")
-		}
-		
-		}
-		return ts.^boolean
-		
-	}
-	
-	def assertNumericalTypes(Type left, Type right, String operator) {
-		if (assertIsNumber(left, operator) != null
-			&& assertIsNumber(right, operator) != null) {
-				return left.combine(right)
-		}
-		return null;
-	}
-	
-	def dispatch inferType(NumericalAddSubtractExpression expression){
-		return assertNumericalTypes(expression.leftOperand.getType, 
-			expression.rightOperand.getType, expression.operator.literal
-		)
-	}
-	def dispatch inferType(NumericalMultiplyDivideExpression expression){
-		return assertNumericalTypes(expression.leftOperand.getType, 
-			expression.rightOperand.getType, expression.operator.literal
-		)
-	}
-	def dispatch Type inferType(NumericalUnaryExpression expression){
-		val type = expression.operand.getType
-		if(expression.operator == UnaryOperator::COMPLEMENT){
-			return assertIsInteger(type, expression.operator.literal)
-		}
-		return assertIsNumber(type, expression.operator.literal)
-	}	
-	def dispatch inferType(PrimitiveValueExpression expression){
-		val Type t = expression.value.literalType
-		return t
-	}
-	
-	def dispatch inferType(ActiveStateReferenceExpression expression){
-		return ts.boolean	
-	}
-	
-	def dispatch inferType(ShiftExpression expression){
-		assertIsInteger(expression.leftOperand.type, expression.operator.literal)
-		assertIsInteger(expression.rightOperand.type, expression.operator.literal)
-	}
-	def dispatch inferType(ConditionalExpression expression){
-		val condType = expression.condition.getType
-		if (!condType.^boolean) {
-			error("Condition type have to be boolean")
-			return null;
-		}
-		val trueType = expression.trueCase.getType
-		val falseType = expression.falseCase.getType
-		return trueType.combine(falseType)
-	} 
-	def dispatch inferType(FeatureCall featureCall){
-		if(featureCall.feature instanceof Event /*ntDefinition*/ 
-			&& !(featureCall.eContainer instanceof EventRaisingExpression) 
-			&&!(featureCall.eContainer instanceof EventValueReferenceExpression)
-		){
-			return ts.boolean
-		}
-		if (featureCall.feature instanceof Feature) {
-			return (featureCall.feature as Feature)?.type
-		} else if (featureCall.feature !=null) {
-			error("Type of FeatureCall is unknown: "+featureCall)			
-			return null;
-		} else {
-			return null;
-		}
-	}
-	 
-	def dispatch inferType(ElementReferenceExpression expression){
-		return expression.reference.inferType(expression)
-	}
-	def dispatch inferType(EObject object, ElementReferenceExpression expression) {
-		//	
-	}
-	def dispatch inferType(Property /*VariableDefinition*/ definition,ElementReferenceExpression expression) {
-		return definition.type
-	}
-
-	def dispatch inferType(Event /*Definition*/ definition,ElementReferenceExpression expression) {
-		if(expression.eContainer instanceof EventRaisingExpression
-				|| expression.eContainer instanceof EventValueReferenceExpression)
-			return definition.type
-		return ts.^boolean
-	}
-
-	def dispatch inferType(OperationDefinition definition,ElementReferenceExpression expression) {
-		return definition.type
-	}
-	
-	def dispatch inferType(EventValueReferenceExpression expression){
-		return getType(expression.value)
-	}
-	
-	def dispatch inferType(ParenthesizedExpression e){
-		return getType(e.expression)
-	}
-	
-	def dispatch getLiteralType(HexLiteral literal){
-		return ts.integer
-	}
-	
-	def dispatch getLiteralType(IntLiteral literal){
-		return ts.integer
-	}
-	
-	def dispatch getLiteralType(BoolLiteral bool){
-		return ts.^boolean
-	}
-	
-	def dispatch getLiteralType(RealLiteral literal){
-		return ts.real
-	}
-	def dispatch getLiteralType(StringLiteral literal){
-		return ts.string
-	}
-	
-	def Type assertIsInteger(Type object, String operator){
-		if(!object.integer){
-			error("operator '" +operator+"' can only be applied to integers!")
-			return null
-		}
-		return object
-	}
-	
-	def Type assertIsNumber(Type object, String operator){
-		if(!object.real && !object.integer) {
-			error("operator '" +operator+"' can only be applied to numbers!")
-			return null
-		}
-		return object
-	}
-	def Type assertIsBoolean(Type object, String operator){
-		if(!object.^boolean) {
-			error("operator '" +operator+"' can only be applied to boolean values!")
-		}
-		return object
-	}
-	 
-	def error(String msg){
-		throw new TypeCheckException(msg)
-	}
-	
-	def dispatch inferType(Expression expr) {
-		return null;
-	}
-
-}

+ 0 - 40
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/TypeInferrerCache.java

@@ -1,40 +0,0 @@
-/**
- * Copyright (c) 2012 itemis AG 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:
- * 	itemis AG - initial API and implementation
- * 
- */
-package org.yakindu.sct.model.stext.validation;
-
-import org.eclipse.xtext.util.OnChangeEvictingCache;
-import org.yakindu.base.types.Type;
-import org.yakindu.sct.model.sgraph.Statement;
-
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-public class TypeInferrerCache {
-	public static interface ICacheableTypeAnalyzer {
-		/**
-		 * calculate the type of the statement. This method is not directly
-		 * cached, but could delegate caches for subsequent elements
-		 */
-		public Type inferType(Statement stmt);
-	}
-
-	@Inject
-	OnChangeEvictingCache cache;
-
-	public Type get(final Statement stmt, final ICacheableTypeAnalyzer analyzer) {
-		return cache.get(stmt, stmt.eResource(), new Provider<Type>() {
-			public Type get() {
-				return analyzer.inferType(stmt);
-			}
-		});
-	}
-}

BIN=BIN
plugins/org.yakindu.sct.model.stext/xtend-gen/org/yakindu/sct/model/stext/types/.DefaultSTextTypeInferrer.java._trace


BIN=BIN
plugins/org.yakindu.sct.model.stext/xtend-gen/org/yakindu/sct/model/stext/types/.STextDefaultTypeInferrer.java._trace


+ 901 - 0
plugins/org.yakindu.sct.model.stext/xtend-gen/org/yakindu/sct/model/stext/types/STextDefaultTypeInferrer.java

@@ -0,0 +1,901 @@
+package org.yakindu.sct.model.stext.types;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.yakindu.base.types.EnumerationType;
+import org.yakindu.base.types.Enumerator;
+import org.yakindu.base.types.Event;
+import org.yakindu.base.types.Feature;
+import org.yakindu.base.types.ITypeSystem.ITypeSystemOperator;
+import org.yakindu.base.types.ITypeSystem.InferenceIssue;
+import org.yakindu.base.types.ITypeSystem.InferenceResult;
+import org.yakindu.base.types.ITypeSystem.InferredType;
+import org.yakindu.base.types.Type;
+import org.yakindu.base.types.TypedElement;
+import org.yakindu.sct.model.stext.stext.ActiveStateReferenceExpression;
+import org.yakindu.sct.model.stext.stext.AdditiveOperator;
+import org.yakindu.sct.model.stext.stext.AssignmentExpression;
+import org.yakindu.sct.model.stext.stext.AssignmentOperator;
+import org.yakindu.sct.model.stext.stext.BitwiseAndExpression;
+import org.yakindu.sct.model.stext.stext.BitwiseOrExpression;
+import org.yakindu.sct.model.stext.stext.BitwiseXorExpression;
+import org.yakindu.sct.model.stext.stext.ConditionalExpression;
+import org.yakindu.sct.model.stext.stext.ElementReferenceExpression;
+import org.yakindu.sct.model.stext.stext.EventDefinition;
+import org.yakindu.sct.model.stext.stext.EventRaisingExpression;
+import org.yakindu.sct.model.stext.stext.EventValueReferenceExpression;
+import org.yakindu.sct.model.stext.stext.Expression;
+import org.yakindu.sct.model.stext.stext.FeatureCall;
+import org.yakindu.sct.model.stext.stext.Literal;
+import org.yakindu.sct.model.stext.stext.LogicalAndExpression;
+import org.yakindu.sct.model.stext.stext.LogicalNotExpression;
+import org.yakindu.sct.model.stext.stext.LogicalOrExpression;
+import org.yakindu.sct.model.stext.stext.LogicalRelationExpression;
+import org.yakindu.sct.model.stext.stext.MultiplicativeOperator;
+import org.yakindu.sct.model.stext.stext.NumericalAddSubtractExpression;
+import org.yakindu.sct.model.stext.stext.NumericalMultiplyDivideExpression;
+import org.yakindu.sct.model.stext.stext.NumericalUnaryExpression;
+import org.yakindu.sct.model.stext.stext.OperationDefinition;
+import org.yakindu.sct.model.stext.stext.ParenthesizedExpression;
+import org.yakindu.sct.model.stext.stext.PrimitiveValueExpression;
+import org.yakindu.sct.model.stext.stext.RelationalOperator;
+import org.yakindu.sct.model.stext.stext.ShiftExpression;
+import org.yakindu.sct.model.stext.stext.ShiftOperator;
+import org.yakindu.sct.model.stext.stext.UnaryOperator;
+import org.yakindu.sct.model.stext.stext.VariableDefinition;
+import org.yakindu.sct.model.stext.types.ISTextTypeInferrer;
+import org.yakindu.sct.model.stext.types.ISTextTypeSystem;
+import org.yakindu.sct.model.stext.types.ISTextTypeSystem.BinaryOperators;
+import org.yakindu.sct.model.stext.types.ISTextTypeSystem.TernaryOperators;
+import org.yakindu.sct.model.stext.types.ISTextTypeSystem.UnaryOperators;
+
+/**
+ * The TypeInferrer checks an expression AST for type conformance
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * @author Alexander Nyßen - Complete revision of API
+ */
+@Singleton
+@SuppressWarnings("all")
+public class STextDefaultTypeInferrer implements ISTextTypeInferrer {
+  @Inject
+  protected ISTextTypeSystem ts;
+  
+  public InferenceResult inferType(final Expression e) {
+    boolean _equals = Objects.equal(e, null);
+    if (_equals) {
+      IllegalArgumentException _illegalArgumentException = new IllegalArgumentException("Expression may not be null");
+      throw _illegalArgumentException;
+    } else {
+      return this.doInferType(e);
+    }
+  }
+  
+  public InferenceResult inferType(final VariableDefinition definition) {
+    InferenceResult _xifexpression = null;
+    boolean _equals = Objects.equal(definition, null);
+    if (_equals) {
+      IllegalArgumentException _illegalArgumentException = new IllegalArgumentException("Definition may not be null");
+      throw _illegalArgumentException;
+    } else {
+      InferenceResult _doInferType = this.doInferType(definition);
+      _xifexpression = _doInferType;
+    }
+    return _xifexpression;
+  }
+  
+  public InferenceResult inferType(final EventDefinition definition) {
+    InferenceResult _xifexpression = null;
+    boolean _equals = Objects.equal(definition, null);
+    if (_equals) {
+      IllegalArgumentException _illegalArgumentException = new IllegalArgumentException("Definition may not be null");
+      throw _illegalArgumentException;
+    } else {
+      InferenceResult _doInferType = this.doInferType(definition);
+      _xifexpression = _doInferType;
+    }
+    return _xifexpression;
+  }
+  
+  protected InferenceResult _doInferType(final VariableDefinition definition) {
+    Type _type = definition.getType();
+    boolean _equals = Objects.equal(_type, null);
+    if (_equals) {
+      String _name = definition.getName();
+      String _plus = ("Could not infer type of variable: " + _name);
+      InferenceIssue _inferenceIssue = new InferenceIssue(_plus, IStatus.ERROR);
+      InferenceResult _inferenceResult = new InferenceResult(null, _inferenceIssue);
+      return _inferenceResult;
+    } else {
+      Type _type_1 = definition.getType();
+      InferredType _inferredType = new InferredType(_type_1);
+      InferenceResult _inferenceResult_1 = new InferenceResult(_inferredType);
+      InferenceResult varType = _inferenceResult_1;
+      Expression _initialValue = definition.getInitialValue();
+      boolean _notEquals = (!Objects.equal(_initialValue, null));
+      if (_notEquals) {
+        Expression _initialValue_1 = definition.getInitialValue();
+        final InferenceResult valueType = this.doInferType(_initialValue_1);
+        InferredType _type_2 = valueType.getType();
+        boolean _equals_1 = Objects.equal(_type_2, null);
+        if (_equals_1) {
+          Expression _initialValue_2 = definition.getInitialValue();
+          String _plus_1 = ("Could not infer type of initial value expression: " + _initialValue_2);
+          InferenceIssue _inferenceIssue_1 = new InferenceIssue(_plus_1, IStatus.ERROR);
+          InferenceResult _inferenceResult_2 = new InferenceResult(null, _inferenceIssue_1);
+          return _inferenceResult_2;
+        }
+        final InferenceResult result = this.inferResult(varType, valueType, BinaryOperators.ASSIGN);
+        InferredType _type_3 = result.getType();
+        boolean _equals_2 = Objects.equal(_type_3, null);
+        if (_equals_2) {
+          InferredType _type_4 = valueType.getType();
+          Type _type_5 = _type_4.getType();
+          String _name_1 = _type_5.getName();
+          String _plus_2 = ("Cannot assign a value of type " + _name_1);
+          String _plus_3 = (_plus_2 + " to a variable of type ");
+          InferredType _type_6 = varType.getType();
+          Type _type_7 = _type_6.getType();
+          String _name_2 = _type_7.getName();
+          String _plus_4 = (_plus_3 + _name_2);
+          String _plus_5 = (_plus_4 + ".");
+          InferenceIssue _inferenceIssue_2 = new InferenceIssue(_plus_5, IStatus.ERROR);
+          InferenceResult _inferenceResult_3 = new InferenceResult(null, _inferenceIssue_2);
+          return _inferenceResult_3;
+        }
+      }
+      return varType;
+    }
+  }
+  
+  protected InferenceResult _doInferType(final EventDefinition definition) {
+    boolean _equals = Objects.equal(definition, null);
+    if (_equals) {
+      IllegalArgumentException _illegalArgumentException = new IllegalArgumentException("EventDefinition may not be null");
+      throw _illegalArgumentException;
+    }
+    Type _type = definition.getType();
+    boolean _equals_1 = Objects.equal(_type, null);
+    if (_equals_1) {
+      Type _voidType = this.ts.getVoidType();
+      InferredType _inferredType = new InferredType(_voidType);
+      InferenceResult _inferenceResult = new InferenceResult(_inferredType);
+      return _inferenceResult;
+    }
+    Type _type_1 = definition.getType();
+    InferredType _inferredType_1 = new InferredType(_type_1);
+    InferenceResult _inferenceResult_1 = new InferenceResult(_inferredType_1);
+    return _inferenceResult_1;
+  }
+  
+  protected InferenceResult _doInferType(final OperationDefinition definition) {
+    boolean _equals = Objects.equal(definition, null);
+    if (_equals) {
+      IllegalArgumentException _illegalArgumentException = new IllegalArgumentException("EventDefinition may not be null");
+      throw _illegalArgumentException;
+    }
+    Type _type = definition.getType();
+    boolean _equals_1 = Objects.equal(_type, null);
+    if (_equals_1) {
+      Type _voidType = this.ts.getVoidType();
+      InferredType _inferredType = new InferredType(_voidType);
+      InferenceResult _inferenceResult = new InferenceResult(_inferredType);
+      return _inferenceResult;
+    }
+    Type _type_1 = definition.getType();
+    InferredType _inferredType_1 = new InferredType(_type_1);
+    InferenceResult _inferenceResult_1 = new InferenceResult(_inferredType_1);
+    return _inferenceResult_1;
+  }
+  
+  protected InferenceResult _doInferType(final Type type) {
+    InferredType _inferredType = new InferredType(type);
+    InferenceResult _inferenceResult = new InferenceResult(_inferredType);
+    return _inferenceResult;
+  }
+  
+  protected InferenceResult _doInferType(final TypedElement typedElement) {
+    Type _type = typedElement.getType();
+    InferredType _inferredType = new InferredType(_type);
+    InferenceResult _inferenceResult = new InferenceResult(_inferredType);
+    return _inferenceResult;
+  }
+  
+  protected InferenceResult _doInferType(final Enumerator enumerator) {
+    EnumerationType _owningEnumeration = enumerator.getOwningEnumeration();
+    InferredType _inferredType = new InferredType(_owningEnumeration);
+    InferenceResult _inferenceResult = new InferenceResult(_inferredType);
+    return _inferenceResult;
+  }
+  
+  protected InferenceResult _doInferType(final EObject e) {
+    Type _voidType = this.ts.getVoidType();
+    InferredType _inferredType = new InferredType(_voidType);
+    InferenceResult _inferenceResult = new InferenceResult(_inferredType);
+    return _inferenceResult;
+  }
+  
+  protected InferenceResult _doInferType(final Expression e) {
+    String _plus = ("Unsupported expression type " + e);
+    UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException(_plus);
+    throw _unsupportedOperationException;
+  }
+  
+  public InferenceResult inferResult(final InferenceResult operand, final ITypeSystemOperator unaryOperator) {
+    InferredType _type = operand.getType();
+    boolean _notEquals = (!Objects.equal(_type, null));
+    if (_notEquals) {
+      InferredType _type_1 = operand.getType();
+      return this.ts.inferType(_type_1, unaryOperator);
+    }
+    Collection<InferenceIssue> _issues = operand.getIssues();
+    InferenceResult _inferenceResult = new InferenceResult(null, _issues);
+    return _inferenceResult;
+  }
+  
+  public InferenceResult inferResult(final InferenceResult firstOperand, final InferenceResult secondOperand, final ITypeSystemOperator binaryOperator) {
+    boolean _and = false;
+    InferredType _type = firstOperand.getType();
+    boolean _notEquals = (!Objects.equal(_type, null));
+    if (!_notEquals) {
+      _and = false;
+    } else {
+      InferredType _type_1 = secondOperand.getType();
+      boolean _notEquals_1 = (!Objects.equal(_type_1, null));
+      _and = (_notEquals && _notEquals_1);
+    }
+    if (_and) {
+      InferredType _type_2 = firstOperand.getType();
+      InferredType _type_3 = secondOperand.getType();
+      final InferenceResult result = this.ts.inferType(_type_2, _type_3, binaryOperator);
+      Collection<InferenceIssue> _issues = result.getIssues();
+      Collection<InferenceIssue> _issues_1 = firstOperand.getIssues();
+      _issues.addAll(_issues_1);
+      Collection<InferenceIssue> _issues_2 = result.getIssues();
+      Collection<InferenceIssue> _issues_3 = secondOperand.getIssues();
+      _issues_2.addAll(_issues_3);
+      return result;
+    }
+    Collection<InferenceIssue> _issues_4 = firstOperand.getIssues();
+    Collection<InferenceIssue> _issues_5 = secondOperand.getIssues();
+    Iterable<InferenceIssue> _concat = Iterables.<InferenceIssue>concat(_issues_4, _issues_5);
+    List<InferenceIssue> _list = IterableExtensions.<InferenceIssue>toList(_concat);
+    InferenceResult _inferenceResult = new InferenceResult(null, _list);
+    return _inferenceResult;
+  }
+  
+  public InferenceResult inferResult(final InferenceResult firstOperand, final InferenceResult secondOperand, final InferenceResult thirdOperand, final ITypeSystemOperator ternaryOperator) {
+    boolean _and = false;
+    boolean _and_1 = false;
+    InferredType _type = firstOperand.getType();
+    boolean _notEquals = (!Objects.equal(_type, null));
+    if (!_notEquals) {
+      _and_1 = false;
+    } else {
+      InferredType _type_1 = secondOperand.getType();
+      boolean _notEquals_1 = (!Objects.equal(_type_1, null));
+      _and_1 = (_notEquals && _notEquals_1);
+    }
+    if (!_and_1) {
+      _and = false;
+    } else {
+      InferredType _type_2 = thirdOperand.getType();
+      boolean _notEquals_2 = (!Objects.equal(_type_2, null));
+      _and = (_and_1 && _notEquals_2);
+    }
+    if (_and) {
+      InferredType _type_3 = firstOperand.getType();
+      InferredType _type_4 = secondOperand.getType();
+      InferredType _type_5 = thirdOperand.getType();
+      final InferenceResult result = this.ts.inferType(_type_3, _type_4, _type_5, ternaryOperator);
+      Collection<InferenceIssue> _issues = result.getIssues();
+      Collection<InferenceIssue> _issues_1 = firstOperand.getIssues();
+      _issues.addAll(_issues_1);
+      Collection<InferenceIssue> _issues_2 = result.getIssues();
+      Collection<InferenceIssue> _issues_3 = secondOperand.getIssues();
+      _issues_2.addAll(_issues_3);
+      Collection<InferenceIssue> _issues_4 = result.getIssues();
+      Collection<InferenceIssue> _issues_5 = thirdOperand.getIssues();
+      _issues_4.addAll(_issues_5);
+      return result;
+    }
+    Collection<InferenceIssue> _issues_6 = firstOperand.getIssues();
+    Collection<InferenceIssue> _issues_7 = secondOperand.getIssues();
+    Iterable<InferenceIssue> _concat = Iterables.<InferenceIssue>concat(_issues_6, _issues_7);
+    List<InferenceIssue> _list = IterableExtensions.<InferenceIssue>toList(_concat);
+    InferenceResult _inferenceResult = new InferenceResult(null, _list);
+    return _inferenceResult;
+  }
+  
+  protected InferenceResult _doInferType(final AssignmentExpression expression) {
+    Expression _varRef = expression.getVarRef();
+    InferenceResult _doInferType = this.doInferType(_varRef);
+    Expression _expression = expression.getExpression();
+    InferenceResult _doInferType_1 = this.doInferType(_expression);
+    AssignmentOperator _operator = expression.getOperator();
+    ITypeSystemOperator _typeSystemOperator = this.getTypeSystemOperator(_operator);
+    return this.inferResult(_doInferType, _doInferType_1, _typeSystemOperator);
+  }
+  
+  protected InferenceResult _doInferType(final LogicalAndExpression expression) {
+    Expression _leftOperand = expression.getLeftOperand();
+    InferenceResult _doInferType = this.doInferType(_leftOperand);
+    Expression _rightOperand = expression.getRightOperand();
+    InferenceResult _doInferType_1 = this.doInferType(_rightOperand);
+    return this.inferResult(_doInferType, _doInferType_1, BinaryOperators.LOGICAL_AND);
+  }
+  
+  protected InferenceResult _doInferType(final LogicalOrExpression expression) {
+    Expression _leftOperand = expression.getLeftOperand();
+    InferenceResult _doInferType = this.doInferType(_leftOperand);
+    Expression _rightOperand = expression.getRightOperand();
+    InferenceResult _doInferType_1 = this.doInferType(_rightOperand);
+    return this.inferResult(_doInferType, _doInferType_1, BinaryOperators.LOGICAL_OR);
+  }
+  
+  protected InferenceResult _doInferType(final LogicalNotExpression expression) {
+    Expression _operand = expression.getOperand();
+    InferenceResult _doInferType = this.doInferType(_operand);
+    return this.inferResult(_doInferType, UnaryOperators.LOGICAL_NOT);
+  }
+  
+  protected InferenceResult _doInferType(final BitwiseAndExpression expression) {
+    Expression _leftOperand = expression.getLeftOperand();
+    InferenceResult _doInferType = this.doInferType(_leftOperand);
+    Expression _rightOperand = expression.getRightOperand();
+    InferenceResult _doInferType_1 = this.doInferType(_rightOperand);
+    return this.inferResult(_doInferType, _doInferType_1, BinaryOperators.BITWISE_AND);
+  }
+  
+  protected InferenceResult _doInferType(final BitwiseOrExpression expression) {
+    Expression _leftOperand = expression.getLeftOperand();
+    InferenceResult _doInferType = this.doInferType(_leftOperand);
+    Expression _rightOperand = expression.getRightOperand();
+    InferenceResult _doInferType_1 = this.doInferType(_rightOperand);
+    return this.inferResult(_doInferType, _doInferType_1, BinaryOperators.BITWISE_OR);
+  }
+  
+  protected InferenceResult _doInferType(final BitwiseXorExpression expression) {
+    Expression _leftOperand = expression.getLeftOperand();
+    InferenceResult _doInferType = this.doInferType(_leftOperand);
+    Expression _rightOperand = expression.getRightOperand();
+    InferenceResult _doInferType_1 = this.doInferType(_rightOperand);
+    return this.inferResult(_doInferType, _doInferType_1, BinaryOperators.BITWISE_XOR);
+  }
+  
+  protected InferenceResult _doInferType(final LogicalRelationExpression expression) {
+    Expression _leftOperand = expression.getLeftOperand();
+    InferenceResult _doInferType = this.doInferType(_leftOperand);
+    Expression _rightOperand = expression.getRightOperand();
+    InferenceResult _doInferType_1 = this.doInferType(_rightOperand);
+    RelationalOperator _operator = expression.getOperator();
+    ITypeSystemOperator _typeSystemOperator = this.getTypeSystemOperator(_operator);
+    return this.inferResult(_doInferType, _doInferType_1, _typeSystemOperator);
+  }
+  
+  protected InferenceResult _doInferType(final NumericalAddSubtractExpression expression) {
+    Expression _leftOperand = expression.getLeftOperand();
+    InferenceResult _doInferType = this.doInferType(_leftOperand);
+    Expression _rightOperand = expression.getRightOperand();
+    InferenceResult _doInferType_1 = this.doInferType(_rightOperand);
+    AdditiveOperator _operator = expression.getOperator();
+    ITypeSystemOperator _typeSystemOperator = this.getTypeSystemOperator(_operator);
+    return this.inferResult(_doInferType, _doInferType_1, _typeSystemOperator);
+  }
+  
+  protected InferenceResult _doInferType(final NumericalMultiplyDivideExpression expression) {
+    Expression _leftOperand = expression.getLeftOperand();
+    InferenceResult _doInferType = this.doInferType(_leftOperand);
+    Expression _rightOperand = expression.getRightOperand();
+    InferenceResult _doInferType_1 = this.doInferType(_rightOperand);
+    MultiplicativeOperator _operator = expression.getOperator();
+    ITypeSystemOperator _typeSystemOperator = this.getTypeSystemOperator(_operator);
+    return this.inferResult(_doInferType, _doInferType_1, _typeSystemOperator);
+  }
+  
+  protected InferenceResult _doInferType(final NumericalUnaryExpression expression) {
+    Expression _operand = expression.getOperand();
+    InferenceResult _doInferType = this.doInferType(_operand);
+    UnaryOperator _operator = expression.getOperator();
+    ITypeSystemOperator _typeSystemOperator = this.getTypeSystemOperator(_operator);
+    return this.inferResult(_doInferType, _typeSystemOperator);
+  }
+  
+  protected InferenceResult _doInferType(final PrimitiveValueExpression expression) {
+    Literal _value = expression.getValue();
+    return this.doInferType(_value);
+  }
+  
+  protected InferenceResult _doInferType(final ShiftExpression expression) {
+    Expression _leftOperand = expression.getLeftOperand();
+    InferenceResult _doInferType = this.doInferType(_leftOperand);
+    Expression _rightOperand = expression.getRightOperand();
+    InferenceResult _doInferType_1 = this.doInferType(_rightOperand);
+    ShiftOperator _operator = expression.getOperator();
+    ITypeSystemOperator _typeSystemOperator = this.getTypeSystemOperator(_operator);
+    return this.inferResult(_doInferType, _doInferType_1, _typeSystemOperator);
+  }
+  
+  protected InferenceResult _doInferType(final ConditionalExpression expression) {
+    Expression _condition = expression.getCondition();
+    InferenceResult _doInferType = this.doInferType(_condition);
+    Expression _trueCase = expression.getTrueCase();
+    InferenceResult _doInferType_1 = this.doInferType(_trueCase);
+    Expression _falseCase = expression.getFalseCase();
+    InferenceResult _doInferType_2 = this.doInferType(_falseCase);
+    return this.inferResult(_doInferType, _doInferType_1, _doInferType_2, TernaryOperators.CONDITIONAL);
+  }
+  
+  protected InferenceResult _doInferType(final EventRaisingExpression eventRaising) {
+    Expression _event = eventRaising.getEvent();
+    final InferenceResult eventType = this.doInferType(_event);
+    InferredType _type = eventType.getType();
+    boolean _equals = Objects.equal(_type, null);
+    if (_equals) {
+      Expression _event_1 = eventRaising.getEvent();
+      String _plus = ("Could not infer type of event expression: " + _event_1);
+      InferenceIssue _inferenceIssue = new InferenceIssue(_plus, IStatus.ERROR);
+      InferenceResult _inferenceResult = new InferenceResult(null, _inferenceIssue);
+      return _inferenceResult;
+    } else {
+      Expression _value = eventRaising.getValue();
+      boolean _equals_1 = Objects.equal(_value, null);
+      if (_equals_1) {
+        InferredType _type_1 = eventType.getType();
+        boolean _isVoidType = this.ts.isVoidType(_type_1);
+        boolean _not = (!_isVoidType);
+        if (_not) {
+          InferredType _type_2 = eventType.getType();
+          Type _type_3 = _type_2.getType();
+          String _name = _type_3.getName();
+          String _plus_1 = ("Need to assign a value to an event of type " + _name);
+          String _plus_2 = (_plus_1 + ".");
+          InferenceIssue _inferenceIssue_1 = new InferenceIssue(_plus_2, IStatus.ERROR);
+          InferenceResult _inferenceResult_1 = new InferenceResult(null, _inferenceIssue_1);
+          return _inferenceResult_1;
+        }
+        return eventType;
+      } else {
+        Expression _value_1 = eventRaising.getValue();
+        final InferenceResult valueType = this.doInferType(_value_1);
+        InferredType _type_4 = valueType.getType();
+        boolean _equals_2 = Objects.equal(_type_4, null);
+        if (_equals_2) {
+          Expression _value_2 = eventRaising.getValue();
+          String _plus_3 = ("Could not infer type of value expression: " + _value_2);
+          InferenceIssue _inferenceIssue_2 = new InferenceIssue(_plus_3, IStatus.ERROR);
+          InferenceResult _inferenceResult_2 = new InferenceResult(null, _inferenceIssue_2);
+          return _inferenceResult_2;
+        }
+        final InferenceResult result = this.inferResult(eventType, valueType, BinaryOperators.ASSIGN);
+        InferredType _type_5 = result.getType();
+        boolean _equals_3 = Objects.equal(_type_5, null);
+        if (_equals_3) {
+          InferredType _type_6 = valueType.getType();
+          Type _type_7 = _type_6.getType();
+          String _name_1 = _type_7.getName();
+          String _plus_4 = ("Cannot assign a value of type " + _name_1);
+          String _plus_5 = (_plus_4 + " to an event of type ");
+          InferredType _type_8 = eventType.getType();
+          Type _type_9 = _type_8.getType();
+          String _name_2 = _type_9.getName();
+          String _plus_6 = (_plus_5 + _name_2);
+          String _plus_7 = (_plus_6 + ".");
+          InferenceIssue _inferenceIssue_3 = new InferenceIssue(_plus_7, IStatus.ERROR);
+          InferenceResult _inferenceResult_3 = new InferenceResult(null, _inferenceIssue_3);
+          return _inferenceResult_3;
+        } else {
+          return result;
+        }
+      }
+    }
+  }
+  
+  protected InferenceResult _doInferType(final FeatureCall featureCall) {
+    boolean _and = false;
+    boolean _and_1 = false;
+    EObject _feature = featureCall.getFeature();
+    if (!(_feature instanceof Event)) {
+      _and_1 = false;
+    } else {
+      EObject _eContainer = featureCall.eContainer();
+      boolean _not = (!(_eContainer instanceof EventRaisingExpression));
+      _and_1 = ((_feature instanceof Event) && _not);
+    }
+    if (!_and_1) {
+      _and = false;
+    } else {
+      EObject _eContainer_1 = featureCall.eContainer();
+      boolean _not_1 = (!(_eContainer_1 instanceof EventValueReferenceExpression));
+      _and = (_and_1 && _not_1);
+    }
+    if (_and) {
+      Type _booleanType = this.ts.getBooleanType();
+      InferenceResult _inferenceResult = new InferenceResult(_booleanType);
+      return _inferenceResult;
+    }
+    EObject _feature_1 = featureCall.getFeature();
+    if ((_feature_1 instanceof Feature)) {
+      EObject _feature_2 = featureCall.getFeature();
+      final Type type = ((Feature) _feature_2).getType();
+      boolean _notEquals = (!Objects.equal(type, null));
+      if (_notEquals) {
+        InferredType _inferredType = new InferredType(type);
+        InferenceResult _inferenceResult_1 = new InferenceResult(_inferredType);
+        return _inferenceResult_1;
+      }
+      Type _voidType = this.ts.getVoidType();
+      InferenceResult _inferenceResult_2 = new InferenceResult(_voidType);
+      return _inferenceResult_2;
+    }
+    EObject _feature_3 = featureCall.getFeature();
+    return this.doInferType(_feature_3);
+  }
+  
+  protected InferenceResult _doInferType(final ActiveStateReferenceExpression expression) {
+    Type _booleanType = this.ts.getBooleanType();
+    InferenceResult _inferenceResult = new InferenceResult(_booleanType);
+    return _inferenceResult;
+  }
+  
+  protected InferenceResult _doInferType(final ElementReferenceExpression expression) {
+    boolean _and = false;
+    EObject _reference = expression.getReference();
+    if (!(_reference instanceof EventDefinition)) {
+      _and = false;
+    } else {
+      boolean _or = false;
+      EObject _eContainer = expression.eContainer();
+      if ((_eContainer instanceof EventRaisingExpression)) {
+        _or = true;
+      } else {
+        EObject _eContainer_1 = expression.eContainer();
+        _or = ((_eContainer instanceof EventRaisingExpression) || (_eContainer_1 instanceof EventValueReferenceExpression));
+      }
+      boolean _not = (!_or);
+      _and = ((_reference instanceof EventDefinition) && _not);
+    }
+    if (_and) {
+      Type _booleanType = this.ts.getBooleanType();
+      InferenceResult _inferenceResult = new InferenceResult(_booleanType);
+      return _inferenceResult;
+    } else {
+      EObject _reference_1 = expression.getReference();
+      return this.doInferType(_reference_1);
+    }
+  }
+  
+  protected InferenceResult _doInferType(final EventValueReferenceExpression expression) {
+    Expression _value = expression.getValue();
+    return this.doInferType(_value);
+  }
+  
+  protected InferenceResult _doInferType(final ParenthesizedExpression expression) {
+    Expression _expression = expression.getExpression();
+    return this.doInferType(_expression);
+  }
+  
+  protected InferenceResult _doInferType(final Literal literal) {
+    return this.ts.inferType(literal);
+  }
+  
+  protected ITypeSystemOperator _getTypeSystemOperator(final UnaryOperator operator) {
+    UnaryOperators _switchResult = null;
+    boolean _matched = false;
+    if (!_matched) {
+      if (Objects.equal(operator,UnaryOperator.COMPLEMENT)) {
+        _matched=true;
+        _switchResult = UnaryOperators.COMPLEMENT;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,UnaryOperator.NEGATIVE)) {
+        _matched=true;
+        _switchResult = UnaryOperators.NEGATIVE;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,UnaryOperator.POSITIVE)) {
+        _matched=true;
+        _switchResult = UnaryOperators.POSITIVE;
+      }
+    }
+    if (!_matched) {
+      String _plus = ("Unsupported operator" + operator);
+      IllegalArgumentException _illegalArgumentException = new IllegalArgumentException(_plus);
+      throw _illegalArgumentException;
+    }
+    return _switchResult;
+  }
+  
+  protected ITypeSystemOperator _getTypeSystemOperator(final AssignmentOperator operator) {
+    BinaryOperators _switchResult = null;
+    boolean _matched = false;
+    if (!_matched) {
+      if (Objects.equal(operator,AssignmentOperator.ADD_ASSIGN)) {
+        _matched=true;
+        _switchResult = BinaryOperators.ASSIGN_ADD;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,AssignmentOperator.AND_ASSIGN)) {
+        _matched=true;
+        _switchResult = BinaryOperators.ASSIGN_AND;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,AssignmentOperator.ASSIGN)) {
+        _matched=true;
+        _switchResult = BinaryOperators.ASSIGN;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,AssignmentOperator.DIV_ASSIGN)) {
+        _matched=true;
+        _switchResult = BinaryOperators.ASSIGN_DIV;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,AssignmentOperator.LEFT_SHIFT_ASSIGN)) {
+        _matched=true;
+        _switchResult = BinaryOperators.ASSIGN_LEFTSHIFT;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,AssignmentOperator.MOD_ASSIGN)) {
+        _matched=true;
+        _switchResult = BinaryOperators.ASSIGN_MOD;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,AssignmentOperator.MULT_ASSIGN)) {
+        _matched=true;
+        _switchResult = BinaryOperators.ASSIGN_MULTIPLY;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,AssignmentOperator.OR_ASSIGN)) {
+        _matched=true;
+        _switchResult = BinaryOperators.ASSIGN_OR;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,AssignmentOperator.RIGHT_SHIFT_ASSIGN)) {
+        _matched=true;
+        _switchResult = BinaryOperators.ASSIGN_RIGHTSHIFT;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,AssignmentOperator.SUB_ASSIGN)) {
+        _matched=true;
+        _switchResult = BinaryOperators.ASSIGN_SUBTRACT;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,AssignmentOperator.XOR_ASSIGN)) {
+        _matched=true;
+        _switchResult = BinaryOperators.ASSIGN_XOR;
+      }
+    }
+    if (!_matched) {
+      String _plus = ("Unsupported operator" + operator);
+      IllegalArgumentException _illegalArgumentException = new IllegalArgumentException(_plus);
+      throw _illegalArgumentException;
+    }
+    return _switchResult;
+  }
+  
+  protected ITypeSystemOperator _getTypeSystemOperator(final ShiftOperator operator) {
+    BinaryOperators _switchResult = null;
+    boolean _matched = false;
+    if (!_matched) {
+      if (Objects.equal(operator,ShiftOperator.LEFT)) {
+        _matched=true;
+        _switchResult = BinaryOperators.LEFT_SHIFT;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,ShiftOperator.RIGHT)) {
+        _matched=true;
+        _switchResult = BinaryOperators.RIGHT_SHIFT;
+      }
+    }
+    if (!_matched) {
+      String _plus = ("Unsupported operator" + operator);
+      IllegalArgumentException _illegalArgumentException = new IllegalArgumentException(_plus);
+      throw _illegalArgumentException;
+    }
+    return _switchResult;
+  }
+  
+  protected ITypeSystemOperator _getTypeSystemOperator(final AdditiveOperator operator) {
+    BinaryOperators _switchResult = null;
+    boolean _matched = false;
+    if (!_matched) {
+      if (Objects.equal(operator,AdditiveOperator.PLUS)) {
+        _matched=true;
+        _switchResult = BinaryOperators.ADD;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,AdditiveOperator.MINUS)) {
+        _matched=true;
+        _switchResult = BinaryOperators.SUBTRACT;
+      }
+    }
+    if (!_matched) {
+      String _plus = ("Unsupported operator" + operator);
+      IllegalArgumentException _illegalArgumentException = new IllegalArgumentException(_plus);
+      throw _illegalArgumentException;
+    }
+    return _switchResult;
+  }
+  
+  protected ITypeSystemOperator _getTypeSystemOperator(final MultiplicativeOperator operator) {
+    BinaryOperators _switchResult = null;
+    boolean _matched = false;
+    if (!_matched) {
+      if (Objects.equal(operator,MultiplicativeOperator.DIV)) {
+        _matched=true;
+        _switchResult = BinaryOperators.DIV;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,MultiplicativeOperator.MOD)) {
+        _matched=true;
+        _switchResult = BinaryOperators.MOD;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,MultiplicativeOperator.MUL)) {
+        _matched=true;
+        _switchResult = BinaryOperators.MULTIPLY;
+      }
+    }
+    if (!_matched) {
+      String _plus = ("Unsupported operator" + operator);
+      IllegalArgumentException _illegalArgumentException = new IllegalArgumentException(_plus);
+      throw _illegalArgumentException;
+    }
+    return _switchResult;
+  }
+  
+  protected ITypeSystemOperator _getTypeSystemOperator(final RelationalOperator operator) {
+    BinaryOperators _switchResult = null;
+    boolean _matched = false;
+    if (!_matched) {
+      if (Objects.equal(operator,RelationalOperator.EQUALS)) {
+        _matched=true;
+        _switchResult = BinaryOperators.EQUAL;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,RelationalOperator.NOT_EQUALS)) {
+        _matched=true;
+        _switchResult = BinaryOperators.NOT_EQUAL;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,RelationalOperator.GREATER)) {
+        _matched=true;
+        _switchResult = BinaryOperators.GREATER;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,RelationalOperator.GREATER_EQUAL)) {
+        _matched=true;
+        _switchResult = BinaryOperators.GREATER_EQUAL;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,RelationalOperator.SMALLER)) {
+        _matched=true;
+        _switchResult = BinaryOperators.SMALLER;
+      }
+    }
+    if (!_matched) {
+      if (Objects.equal(operator,RelationalOperator.SMALLER_EQUAL)) {
+        _matched=true;
+        _switchResult = BinaryOperators.SMALLER_EQUAL;
+      }
+    }
+    if (!_matched) {
+      String _plus = ("Unsupported operator" + operator);
+      IllegalArgumentException _illegalArgumentException = new IllegalArgumentException(_plus);
+      throw _illegalArgumentException;
+    }
+    return _switchResult;
+  }
+  
+  public InferenceResult doInferType(final EObject definition) {
+    if (definition instanceof EventDefinition) {
+      return _doInferType((EventDefinition)definition);
+    } else if (definition instanceof OperationDefinition) {
+      return _doInferType((OperationDefinition)definition);
+    } else if (definition instanceof VariableDefinition) {
+      return _doInferType((VariableDefinition)definition);
+    } else if (definition instanceof ActiveStateReferenceExpression) {
+      return _doInferType((ActiveStateReferenceExpression)definition);
+    } else if (definition instanceof AssignmentExpression) {
+      return _doInferType((AssignmentExpression)definition);
+    } else if (definition instanceof BitwiseAndExpression) {
+      return _doInferType((BitwiseAndExpression)definition);
+    } else if (definition instanceof BitwiseOrExpression) {
+      return _doInferType((BitwiseOrExpression)definition);
+    } else if (definition instanceof BitwiseXorExpression) {
+      return _doInferType((BitwiseXorExpression)definition);
+    } else if (definition instanceof ConditionalExpression) {
+      return _doInferType((ConditionalExpression)definition);
+    } else if (definition instanceof ElementReferenceExpression) {
+      return _doInferType((ElementReferenceExpression)definition);
+    } else if (definition instanceof EventRaisingExpression) {
+      return _doInferType((EventRaisingExpression)definition);
+    } else if (definition instanceof EventValueReferenceExpression) {
+      return _doInferType((EventValueReferenceExpression)definition);
+    } else if (definition instanceof FeatureCall) {
+      return _doInferType((FeatureCall)definition);
+    } else if (definition instanceof LogicalAndExpression) {
+      return _doInferType((LogicalAndExpression)definition);
+    } else if (definition instanceof LogicalNotExpression) {
+      return _doInferType((LogicalNotExpression)definition);
+    } else if (definition instanceof LogicalOrExpression) {
+      return _doInferType((LogicalOrExpression)definition);
+    } else if (definition instanceof LogicalRelationExpression) {
+      return _doInferType((LogicalRelationExpression)definition);
+    } else if (definition instanceof NumericalAddSubtractExpression) {
+      return _doInferType((NumericalAddSubtractExpression)definition);
+    } else if (definition instanceof NumericalMultiplyDivideExpression) {
+      return _doInferType((NumericalMultiplyDivideExpression)definition);
+    } else if (definition instanceof NumericalUnaryExpression) {
+      return _doInferType((NumericalUnaryExpression)definition);
+    } else if (definition instanceof ParenthesizedExpression) {
+      return _doInferType((ParenthesizedExpression)definition);
+    } else if (definition instanceof PrimitiveValueExpression) {
+      return _doInferType((PrimitiveValueExpression)definition);
+    } else if (definition instanceof ShiftExpression) {
+      return _doInferType((ShiftExpression)definition);
+    } else if (definition instanceof Enumerator) {
+      return _doInferType((Enumerator)definition);
+    } else if (definition instanceof Type) {
+      return _doInferType((Type)definition);
+    } else if (definition instanceof Expression) {
+      return _doInferType((Expression)definition);
+    } else if (definition instanceof TypedElement) {
+      return _doInferType((TypedElement)definition);
+    } else if (definition instanceof Literal) {
+      return _doInferType((Literal)definition);
+    } else if (definition != null) {
+      return _doInferType(definition);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(definition).toString());
+    }
+  }
+  
+  public ITypeSystemOperator getTypeSystemOperator(final Object operator) {
+    if (operator instanceof AdditiveOperator) {
+      return _getTypeSystemOperator((AdditiveOperator)operator);
+    } else if (operator instanceof AssignmentOperator) {
+      return _getTypeSystemOperator((AssignmentOperator)operator);
+    } else if (operator instanceof MultiplicativeOperator) {
+      return _getTypeSystemOperator((MultiplicativeOperator)operator);
+    } else if (operator instanceof RelationalOperator) {
+      return _getTypeSystemOperator((RelationalOperator)operator);
+    } else if (operator instanceof ShiftOperator) {
+      return _getTypeSystemOperator((ShiftOperator)operator);
+    } else if (operator instanceof UnaryOperator) {
+      return _getTypeSystemOperator((UnaryOperator)operator);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(operator).toString());
+    }
+  }
+}

+ 0 - 581
plugins/org.yakindu.sct.model.stext/xtend-gen/org/yakindu/sct/model/stext/validation/TypeInferrer.java

@@ -1,581 +0,0 @@
-package org.yakindu.sct.model.stext.validation;
-
-import com.google.common.base.Objects;
-import com.google.inject.Inject;
-import java.util.Arrays;
-import org.eclipse.emf.ecore.EObject;
-import org.yakindu.base.types.Event;
-import org.yakindu.base.types.Feature;
-import org.yakindu.base.types.ITypeSystemAccess;
-import org.yakindu.base.types.Property;
-import org.yakindu.base.types.Type;
-import org.yakindu.sct.model.sgraph.Statement;
-import org.yakindu.sct.model.stext.stext.ActiveStateReferenceExpression;
-import org.yakindu.sct.model.stext.stext.AdditiveOperator;
-import org.yakindu.sct.model.stext.stext.AssignmentExpression;
-import org.yakindu.sct.model.stext.stext.BitwiseAndExpression;
-import org.yakindu.sct.model.stext.stext.BitwiseOrExpression;
-import org.yakindu.sct.model.stext.stext.BitwiseXorExpression;
-import org.yakindu.sct.model.stext.stext.BoolLiteral;
-import org.yakindu.sct.model.stext.stext.ConditionalExpression;
-import org.yakindu.sct.model.stext.stext.ElementReferenceExpression;
-import org.yakindu.sct.model.stext.stext.EventRaisingExpression;
-import org.yakindu.sct.model.stext.stext.EventValueReferenceExpression;
-import org.yakindu.sct.model.stext.stext.Expression;
-import org.yakindu.sct.model.stext.stext.FeatureCall;
-import org.yakindu.sct.model.stext.stext.HexLiteral;
-import org.yakindu.sct.model.stext.stext.IntLiteral;
-import org.yakindu.sct.model.stext.stext.Literal;
-import org.yakindu.sct.model.stext.stext.LogicalAndExpression;
-import org.yakindu.sct.model.stext.stext.LogicalNotExpression;
-import org.yakindu.sct.model.stext.stext.LogicalOrExpression;
-import org.yakindu.sct.model.stext.stext.LogicalRelationExpression;
-import org.yakindu.sct.model.stext.stext.MultiplicativeOperator;
-import org.yakindu.sct.model.stext.stext.NumericalAddSubtractExpression;
-import org.yakindu.sct.model.stext.stext.NumericalMultiplyDivideExpression;
-import org.yakindu.sct.model.stext.stext.NumericalUnaryExpression;
-import org.yakindu.sct.model.stext.stext.OperationDefinition;
-import org.yakindu.sct.model.stext.stext.ParenthesizedExpression;
-import org.yakindu.sct.model.stext.stext.PrimitiveValueExpression;
-import org.yakindu.sct.model.stext.stext.RealLiteral;
-import org.yakindu.sct.model.stext.stext.RelationalOperator;
-import org.yakindu.sct.model.stext.stext.ShiftExpression;
-import org.yakindu.sct.model.stext.stext.ShiftOperator;
-import org.yakindu.sct.model.stext.stext.StringLiteral;
-import org.yakindu.sct.model.stext.stext.UnaryOperator;
-import org.yakindu.sct.model.stext.validation.ITypeInferrer;
-import org.yakindu.sct.model.stext.validation.TypeCheckException;
-import org.yakindu.sct.model.stext.validation.TypeInferrerCache;
-import org.yakindu.sct.model.stext.validation.TypeInferrerCache.ICacheableTypeAnalyzer;
-
-/**
- * The TypeInferrer checks an expression AST for type conformance
- * 
- * @author andreas muelder - Initial contribution and API
- */
-@SuppressWarnings("all")
-public class TypeInferrer implements ITypeInferrer, ICacheableTypeAnalyzer {
-  @Inject
-  protected ITypeSystemAccess ts;
-  
-  @Inject
-  private TypeInferrerCache cache;
-  
-  public Type getType(final Statement stmt) {
-    Type _xblockexpression = null;
-    {
-      boolean _equals = Objects.equal(stmt, null);
-      if (_equals) {
-        return null;
-      }
-      Type _get = this.cache.get(stmt, this);
-      _xblockexpression = (_get);
-    }
-    return _xblockexpression;
-  }
-  
-  protected Type _inferType(final Statement statement) {
-    return null;
-  }
-  
-  public Type check(final Statement stmt) {
-    Type _type = this.getType(stmt);
-    return _type;
-  }
-  
-  /**
-   * Check Variable assignments
-   */
-  protected Type _inferType(final AssignmentExpression assignment) {
-    Expression _expression = assignment.getExpression();
-    Type valueType = this.getType(_expression);
-    Expression _varRef = assignment.getVarRef();
-    Type type = this.getType(_varRef);
-    boolean _isAssignable = this.ts.isAssignable(type, valueType);
-    boolean _not = (!_isAssignable);
-    if (_not) {
-      String _name = valueType==null?(String)null:valueType.getName();
-      String _plus = ("Can not assign a value of type " + _name);
-      String _plus_1 = (_plus + " to a variable of type ");
-      String _name_1 = type==null?(String)null:type.getName();
-      String _plus_2 = (_plus_1 + _name_1);
-      this.error(_plus_2);
-      return null;
-    }
-    return type;
-  }
-  
-  /**
-   * Check Event value assignments
-   */
-  protected Type _inferType(final EventRaisingExpression eventRaising) {
-    Expression _value = eventRaising.getValue();
-    Type valueType = this.getType(_value);
-    Expression _event = eventRaising.getEvent();
-    Type type = this.getType(_event);
-    boolean _isAssignable = this.ts.isAssignable(type, valueType);
-    boolean _not = (!_isAssignable);
-    if (_not) {
-      String _name = valueType==null?(String)null:valueType.getName();
-      String _plus = ("Can not assign a value of type " + _name);
-      String _plus_1 = (_plus + " to a variable of type ");
-      String _name_1 = type==null?(String)null:type.getName();
-      String _plus_2 = (_plus_1 + _name_1);
-      this.error(_plus_2);
-      return null;
-    }
-    return type;
-  }
-  
-  protected Type _inferType(final LogicalAndExpression expression) {
-    Expression _leftOperand = expression.getLeftOperand();
-    Type _type = this.getType(_leftOperand);
-    Expression _rightOperand = expression.getRightOperand();
-    Type _type_1 = this.getType(_rightOperand);
-    return this.assertBooleanTypes(_type, _type_1, "&&");
-  }
-  
-  protected Type _inferType(final LogicalOrExpression expression) {
-    Expression _leftOperand = expression.getLeftOperand();
-    Type _type = this.getType(_leftOperand);
-    Expression _rightOperand = expression.getRightOperand();
-    Type _type_1 = this.getType(_rightOperand);
-    return this.assertBooleanTypes(_type, _type_1, "||");
-  }
-  
-  public Type assertBooleanTypes(final Type left, final Type right, final String literal) {
-    boolean _and = false;
-    Type _assertIsBoolean = this.assertIsBoolean(left, literal);
-    boolean _notEquals = (!Objects.equal(_assertIsBoolean, null));
-    if (!_notEquals) {
-      _and = false;
-    } else {
-      Type _assertIsBoolean_1 = this.assertIsBoolean(right, literal);
-      boolean _notEquals_1 = (!Objects.equal(_assertIsBoolean_1, null));
-      _and = (_notEquals && _notEquals_1);
-    }
-    if (_and) {
-      return this.ts.combine(left, right);
-    }
-    return null;
-  }
-  
-  protected Type _inferType(final LogicalNotExpression expression) {
-    Expression _operand = expression.getOperand();
-    final Type type = this.getType(_operand);
-    return this.assertIsBoolean(type, "!");
-  }
-  
-  protected Type _inferType(final BitwiseAndExpression expression) {
-    Expression _leftOperand = expression.getLeftOperand();
-    Type _type = this.getType(_leftOperand);
-    this.assertIsInteger(_type, "&");
-    Expression _rightOperand = expression.getRightOperand();
-    Type _type_1 = this.getType(_rightOperand);
-    this.assertIsInteger(_type_1, "&");
-    return this.ts.getInteger();
-  }
-  
-  protected Type _inferType(final BitwiseOrExpression expression) {
-    Expression _leftOperand = expression.getLeftOperand();
-    Type _type = this.getType(_leftOperand);
-    this.assertIsInteger(_type, "|");
-    Expression _rightOperand = expression.getRightOperand();
-    Type _type_1 = this.getType(_rightOperand);
-    this.assertIsInteger(_type_1, "|");
-    return this.ts.getInteger();
-  }
-  
-  protected Type _inferType(final BitwiseXorExpression expression) {
-    Expression _leftOperand = expression.getLeftOperand();
-    Type _type = this.getType(_leftOperand);
-    this.assertIsInteger(_type, "^");
-    Expression _rightOperand = expression.getRightOperand();
-    Type _type_1 = this.getType(_rightOperand);
-    this.assertIsInteger(_type_1, "^");
-    return this.ts.getInteger();
-  }
-  
-  protected Type _inferType(final LogicalRelationExpression expression) {
-    Expression _leftOperand = expression.getLeftOperand();
-    final Type leftType = this.getType(_leftOperand);
-    Expression _rightOperand = expression.getRightOperand();
-    final Type rightType = this.getType(_rightOperand);
-    boolean _and = false;
-    boolean _isBoolean = this.ts.isBoolean(leftType);
-    if (!_isBoolean) {
-      _and = false;
-    } else {
-      boolean _isBoolean_1 = this.ts.isBoolean(rightType);
-      _and = (_isBoolean && _isBoolean_1);
-    }
-    if (_and) {
-      boolean _and_1 = false;
-      RelationalOperator _operator = expression.getOperator();
-      boolean _notEquals = (!Objects.equal(_operator, RelationalOperator.EQUALS));
-      if (!_notEquals) {
-        _and_1 = false;
-      } else {
-        RelationalOperator _operator_1 = expression.getOperator();
-        boolean _notEquals_1 = (!Objects.equal(_operator_1, RelationalOperator.NOT_EQUALS));
-        _and_1 = (_notEquals && _notEquals_1);
-      }
-      if (_and_1) {
-        RelationalOperator _operator_2 = expression.getOperator();
-        String _literal = _operator_2==null?(String)null:_operator_2.getLiteral();
-        String _plus = ("operator \'" + _literal);
-        String _plus_1 = (_plus + "\' can not be applied to boolean values!");
-        this.error(_plus_1);
-        return null;
-      }
-    } else {
-      final Type combined = this.ts.combine(leftType, rightType);
-      boolean _equals = Objects.equal(combined, null);
-      if (_equals) {
-        String _name = leftType==null?(String)null:leftType.getName();
-        String _plus_2 = ("Incompatible operands " + _name);
-        String _plus_3 = (_plus_2 + " and ");
-        String _name_1 = rightType==null?(String)null:rightType.getName();
-        String _plus_4 = (_plus_3 + _name_1);
-        String _plus_5 = (_plus_4 + " for operator \'");
-        RelationalOperator _operator_3 = expression.getOperator();
-        String _literal_1 = _operator_3.getLiteral();
-        String _plus_6 = (_plus_5 + _literal_1);
-        String _plus_7 = (_plus_6 + "\'");
-        this.error(_plus_7);
-      }
-    }
-    return this.ts.getBoolean();
-  }
-  
-  public Type assertNumericalTypes(final Type left, final Type right, final String operator) {
-    boolean _and = false;
-    Type _assertIsNumber = this.assertIsNumber(left, operator);
-    boolean _notEquals = (!Objects.equal(_assertIsNumber, null));
-    if (!_notEquals) {
-      _and = false;
-    } else {
-      Type _assertIsNumber_1 = this.assertIsNumber(right, operator);
-      boolean _notEquals_1 = (!Objects.equal(_assertIsNumber_1, null));
-      _and = (_notEquals && _notEquals_1);
-    }
-    if (_and) {
-      return this.ts.combine(left, right);
-    }
-    return null;
-  }
-  
-  protected Type _inferType(final NumericalAddSubtractExpression expression) {
-    Expression _leftOperand = expression.getLeftOperand();
-    Type _type = this.getType(_leftOperand);
-    Expression _rightOperand = expression.getRightOperand();
-    Type _type_1 = this.getType(_rightOperand);
-    AdditiveOperator _operator = expression.getOperator();
-    String _literal = _operator.getLiteral();
-    return this.assertNumericalTypes(_type, _type_1, _literal);
-  }
-  
-  protected Type _inferType(final NumericalMultiplyDivideExpression expression) {
-    Expression _leftOperand = expression.getLeftOperand();
-    Type _type = this.getType(_leftOperand);
-    Expression _rightOperand = expression.getRightOperand();
-    Type _type_1 = this.getType(_rightOperand);
-    MultiplicativeOperator _operator = expression.getOperator();
-    String _literal = _operator.getLiteral();
-    return this.assertNumericalTypes(_type, _type_1, _literal);
-  }
-  
-  protected Type _inferType(final NumericalUnaryExpression expression) {
-    Expression _operand = expression.getOperand();
-    final Type type = this.getType(_operand);
-    UnaryOperator _operator = expression.getOperator();
-    boolean _equals = Objects.equal(_operator, UnaryOperator.COMPLEMENT);
-    if (_equals) {
-      UnaryOperator _operator_1 = expression.getOperator();
-      String _literal = _operator_1.getLiteral();
-      return this.assertIsInteger(type, _literal);
-    }
-    UnaryOperator _operator_2 = expression.getOperator();
-    String _literal_1 = _operator_2.getLiteral();
-    return this.assertIsNumber(type, _literal_1);
-  }
-  
-  protected Type _inferType(final PrimitiveValueExpression expression) {
-    Literal _value = expression.getValue();
-    final Type t = this.getLiteralType(_value);
-    return t;
-  }
-  
-  protected Type _inferType(final ActiveStateReferenceExpression expression) {
-    return this.ts.getBoolean();
-  }
-  
-  protected Type _inferType(final ShiftExpression expression) {
-    Type _xblockexpression = null;
-    {
-      Expression _leftOperand = expression.getLeftOperand();
-      Type _type = this.getType(_leftOperand);
-      ShiftOperator _operator = expression.getOperator();
-      String _literal = _operator.getLiteral();
-      this.assertIsInteger(_type, _literal);
-      Expression _rightOperand = expression.getRightOperand();
-      Type _type_1 = this.getType(_rightOperand);
-      ShiftOperator _operator_1 = expression.getOperator();
-      String _literal_1 = _operator_1.getLiteral();
-      Type _assertIsInteger = this.assertIsInteger(_type_1, _literal_1);
-      _xblockexpression = (_assertIsInteger);
-    }
-    return _xblockexpression;
-  }
-  
-  protected Type _inferType(final ConditionalExpression expression) {
-    Expression _condition = expression.getCondition();
-    final Type condType = this.getType(_condition);
-    boolean _isBoolean = this.ts.isBoolean(condType);
-    boolean _not = (!_isBoolean);
-    if (_not) {
-      this.error("Condition type have to be boolean");
-      return null;
-    }
-    Expression _trueCase = expression.getTrueCase();
-    final Type trueType = this.getType(_trueCase);
-    Expression _falseCase = expression.getFalseCase();
-    final Type falseType = this.getType(_falseCase);
-    return this.ts.combine(trueType, falseType);
-  }
-  
-  protected Type _inferType(final FeatureCall featureCall) {
-    boolean _and = false;
-    boolean _and_1 = false;
-    EObject _feature = featureCall.getFeature();
-    if (!(_feature instanceof Event)) {
-      _and_1 = false;
-    } else {
-      EObject _eContainer = featureCall.eContainer();
-      boolean _not = (!(_eContainer instanceof EventRaisingExpression));
-      _and_1 = ((_feature instanceof Event) && _not);
-    }
-    if (!_and_1) {
-      _and = false;
-    } else {
-      EObject _eContainer_1 = featureCall.eContainer();
-      boolean _not_1 = (!(_eContainer_1 instanceof EventValueReferenceExpression));
-      _and = (_and_1 && _not_1);
-    }
-    if (_and) {
-      return this.ts.getBoolean();
-    }
-    EObject _feature_1 = featureCall.getFeature();
-    if ((_feature_1 instanceof Feature)) {
-      EObject _feature_2 = featureCall.getFeature();
-      return ((Feature) _feature_2)==null?(Type)null:((Feature) _feature_2).getType();
-    } else {
-      EObject _feature_3 = featureCall.getFeature();
-      boolean _notEquals = (!Objects.equal(_feature_3, null));
-      if (_notEquals) {
-        String _plus = ("Type of FeatureCall is unknown: " + featureCall);
-        this.error(_plus);
-        return null;
-      } else {
-        return null;
-      }
-    }
-  }
-  
-  protected Type _inferType(final ElementReferenceExpression expression) {
-    EObject _reference = expression.getReference();
-    return this.inferType(_reference, expression);
-  }
-  
-  protected Type _inferType(final EObject object, final ElementReferenceExpression expression) {
-    return null;
-  }
-  
-  protected Type _inferType(final Property definition, final ElementReferenceExpression expression) {
-    return definition.getType();
-  }
-  
-  protected Type _inferType(final Event definition, final ElementReferenceExpression expression) {
-    boolean _or = false;
-    EObject _eContainer = expression.eContainer();
-    if ((_eContainer instanceof EventRaisingExpression)) {
-      _or = true;
-    } else {
-      EObject _eContainer_1 = expression.eContainer();
-      _or = ((_eContainer instanceof EventRaisingExpression) || (_eContainer_1 instanceof EventValueReferenceExpression));
-    }
-    if (_or) {
-      return definition.getType();
-    }
-    return this.ts.getBoolean();
-  }
-  
-  protected Type _inferType(final OperationDefinition definition, final ElementReferenceExpression expression) {
-    return definition.getType();
-  }
-  
-  protected Type _inferType(final EventValueReferenceExpression expression) {
-    Expression _value = expression.getValue();
-    return this.getType(_value);
-  }
-  
-  protected Type _inferType(final ParenthesizedExpression e) {
-    Expression _expression = e.getExpression();
-    return this.getType(_expression);
-  }
-  
-  protected Type _getLiteralType(final HexLiteral literal) {
-    return this.ts.getInteger();
-  }
-  
-  protected Type _getLiteralType(final IntLiteral literal) {
-    return this.ts.getInteger();
-  }
-  
-  protected Type _getLiteralType(final BoolLiteral bool) {
-    return this.ts.getBoolean();
-  }
-  
-  protected Type _getLiteralType(final RealLiteral literal) {
-    return this.ts.getReal();
-  }
-  
-  protected Type _getLiteralType(final StringLiteral literal) {
-    return this.ts.getString();
-  }
-  
-  public Type assertIsInteger(final Type object, final String operator) {
-    boolean _isInteger = this.ts.isInteger(object);
-    boolean _not = (!_isInteger);
-    if (_not) {
-      String _plus = ("operator \'" + operator);
-      String _plus_1 = (_plus + "\' can only be applied to integers!");
-      this.error(_plus_1);
-      return null;
-    }
-    return object;
-  }
-  
-  public Type assertIsNumber(final Type object, final String operator) {
-    boolean _and = false;
-    boolean _isReal = this.ts.isReal(object);
-    boolean _not = (!_isReal);
-    if (!_not) {
-      _and = false;
-    } else {
-      boolean _isInteger = this.ts.isInteger(object);
-      boolean _not_1 = (!_isInteger);
-      _and = (_not && _not_1);
-    }
-    if (_and) {
-      String _plus = ("operator \'" + operator);
-      String _plus_1 = (_plus + "\' can only be applied to numbers!");
-      this.error(_plus_1);
-      return null;
-    }
-    return object;
-  }
-  
-  public Type assertIsBoolean(final Type object, final String operator) {
-    boolean _isBoolean = this.ts.isBoolean(object);
-    boolean _not = (!_isBoolean);
-    if (_not) {
-      String _plus = ("operator \'" + operator);
-      String _plus_1 = (_plus + "\' can only be applied to boolean values!");
-      this.error(_plus_1);
-    }
-    return object;
-  }
-  
-  public void error(final String msg) {
-    TypeCheckException _typeCheckException = new TypeCheckException(msg);
-    throw _typeCheckException;
-  }
-  
-  protected Type _inferType(final Expression expr) {
-    return null;
-  }
-  
-  public Type inferType(final Statement expression) {
-    if (expression instanceof ActiveStateReferenceExpression) {
-      return _inferType((ActiveStateReferenceExpression)expression);
-    } else if (expression instanceof AssignmentExpression) {
-      return _inferType((AssignmentExpression)expression);
-    } else if (expression instanceof BitwiseAndExpression) {
-      return _inferType((BitwiseAndExpression)expression);
-    } else if (expression instanceof BitwiseOrExpression) {
-      return _inferType((BitwiseOrExpression)expression);
-    } else if (expression instanceof BitwiseXorExpression) {
-      return _inferType((BitwiseXorExpression)expression);
-    } else if (expression instanceof ConditionalExpression) {
-      return _inferType((ConditionalExpression)expression);
-    } else if (expression instanceof ElementReferenceExpression) {
-      return _inferType((ElementReferenceExpression)expression);
-    } else if (expression instanceof EventRaisingExpression) {
-      return _inferType((EventRaisingExpression)expression);
-    } else if (expression instanceof EventValueReferenceExpression) {
-      return _inferType((EventValueReferenceExpression)expression);
-    } else if (expression instanceof FeatureCall) {
-      return _inferType((FeatureCall)expression);
-    } else if (expression instanceof LogicalAndExpression) {
-      return _inferType((LogicalAndExpression)expression);
-    } else if (expression instanceof LogicalNotExpression) {
-      return _inferType((LogicalNotExpression)expression);
-    } else if (expression instanceof LogicalOrExpression) {
-      return _inferType((LogicalOrExpression)expression);
-    } else if (expression instanceof LogicalRelationExpression) {
-      return _inferType((LogicalRelationExpression)expression);
-    } else if (expression instanceof NumericalAddSubtractExpression) {
-      return _inferType((NumericalAddSubtractExpression)expression);
-    } else if (expression instanceof NumericalMultiplyDivideExpression) {
-      return _inferType((NumericalMultiplyDivideExpression)expression);
-    } else if (expression instanceof NumericalUnaryExpression) {
-      return _inferType((NumericalUnaryExpression)expression);
-    } else if (expression instanceof ParenthesizedExpression) {
-      return _inferType((ParenthesizedExpression)expression);
-    } else if (expression instanceof PrimitiveValueExpression) {
-      return _inferType((PrimitiveValueExpression)expression);
-    } else if (expression instanceof ShiftExpression) {
-      return _inferType((ShiftExpression)expression);
-    } else if (expression instanceof Expression) {
-      return _inferType((Expression)expression);
-    } else if (expression != null) {
-      return _inferType(expression);
-    } else {
-      throw new IllegalArgumentException("Unhandled parameter types: " +
-        Arrays.<Object>asList(expression).toString());
-    }
-  }
-  
-  public Type inferType(final EObject definition, final ElementReferenceExpression expression) {
-    if (definition instanceof OperationDefinition) {
-      return _inferType((OperationDefinition)definition, expression);
-    } else if (definition instanceof Event) {
-      return _inferType((Event)definition, expression);
-    } else if (definition instanceof Property) {
-      return _inferType((Property)definition, expression);
-    } else if (definition != null) {
-      return _inferType(definition, expression);
-    } else {
-      throw new IllegalArgumentException("Unhandled parameter types: " +
-        Arrays.<Object>asList(definition, expression).toString());
-    }
-  }
-  
-  public Type getLiteralType(final Literal bool) {
-    if (bool instanceof BoolLiteral) {
-      return _getLiteralType((BoolLiteral)bool);
-    } else if (bool instanceof HexLiteral) {
-      return _getLiteralType((HexLiteral)bool);
-    } else if (bool instanceof IntLiteral) {
-      return _getLiteralType((IntLiteral)bool);
-    } else if (bool instanceof RealLiteral) {
-      return _getLiteralType((RealLiteral)bool);
-    } else if (bool instanceof StringLiteral) {
-      return _getLiteralType((StringLiteral)bool);
-    } else {
-      throw new IllegalArgumentException("Unhandled parameter types: " +
-        Arrays.<Object>asList(bool).toString());
-    }
-  }
-}

+ 3 - 3
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/providers/StatechartPaletteProvider.java

@@ -23,11 +23,11 @@ public class StatechartPaletteProvider extends DefaultPaletteProvider {
 	public void contributeToPalette(IEditorPart editor, Object content,
 			PaletteRoot root, @SuppressWarnings("rawtypes") Map predefinedEntries) {
 		if (editor instanceof StatechartDiagramEditor) {
-			StatechartDiagramEditor scEditor = (StatechartDiagramEditor) editor;
-			if (StatechartDiagramEditor.ID.equals(scEditor.getContributorId())) {
+//			StatechartDiagramEditor scEditor = (StatechartDiagramEditor) editor;
+//			if (StatechartDiagramEditor.ID.equals(scEditor.getContributorId())) {
 				super.contributeToPalette(editor, content, root,
 						predefinedEntries);
-			}
+//			}
 		}
 		return;
 	}

+ 2 - 2
test-plugins/org.yakindu.sct.generator.core.test/src/org/yakindu/sct/generator/core/extensions/ExecutionModelCoreExtensionsTest.java

@@ -47,7 +47,7 @@ public class ExecutionModelCoreExtensionsTest {
 		result = call("hasOutgoingVoidEvents", scope);
 		assertEquals(Boolean.TRUE, result);
 
-		eventDefinition.setType(_createType("string"));
+		eventDefinition.setType(_createStringType("string"));
 		result = call("hasOutgoingVoidEvents", scope);
 		assertEquals(Boolean.FALSE, result);
 	}
@@ -64,7 +64,7 @@ public class ExecutionModelCoreExtensionsTest {
 		result = call("hasOutgoingValuedEvents", scope);
 		assertEquals(Boolean.FALSE, result);
 
-		eventDefinition.setType(_createType("string"));
+		eventDefinition.setType(_createStringType("string"));
 		result = call("hasOutgoingValuedEvents", scope);
 		assertEquals(Boolean.TRUE, result);
 	}

+ 1 - 1
test-plugins/org.yakindu.sct.generator.core.test/src/org/yakindu/sct/generator/core/extensions/TypeAnalyzerExtensionsTest.java

@@ -38,7 +38,7 @@ public class TypeAnalyzerExtensionsTest {
 		Object result = call("isVoid", new Object[] { null });
 		assertEquals(Boolean.TRUE, result);
 
-		Type type = _createType(null);
+		Type type = _createVoidType("void");
 		result = call("isVoid", type);
 		assertEquals(Boolean.TRUE, result);
 

+ 5 - 2
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/IStatemachine.java

@@ -2,8 +2,6 @@ package org.yakindu.scr;
 
 /**
  * Basic interface for statemachines.
- * 
- * 
  */
 public interface IStatemachine {
 
@@ -17,6 +15,11 @@ public interface IStatemachine {
 	*/
 	public void enter();
 
+	/**
+	* Exits the statemachine. Leaves the statemachine with a defined state.
+	*/
+	public void exit();
+
 	/**
 	* Start a run-to-completion cycle.
 	*/

+ 8 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/ITimerService.java

@@ -35,4 +35,12 @@ public interface ITimerService {
 	 * memory resources.
 	 */
 	public void cancel();
+
+	/**
+	 * Returns the system time in milliseconds.
+	 * 
+	 * @return the difference, measured in milliseconds, between the current
+	 *         time and a defined point of time in the past.
+	 */
+	public long getSystemTimeMillis();
 }

+ 4 - 4
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/RuntimeService.java

@@ -160,11 +160,11 @@ public class RuntimeService {
 	}
 
 	/**
-	 * Pauses the execution of all statemachine which are registered for the
+	 * Pauses the execution of all statemachines which are registered for the
 	 * given cyclePeriod.
 	 * 
 	 * @param cyclePeriod
-	 * @return {@code true} if poperly paused
+	 * @return {@code true} if properly paused
 	 * 
 	 */
 	public boolean pauseAll(long cyclePeriod) {
@@ -176,11 +176,11 @@ public class RuntimeService {
 	}
 
 	/**
-	 * Resumes the execution of all statemachine which are registered for the
+	 * Resumes the execution of all statemachines which are registered for the
 	 * given cyclePeriod.
 	 * 
 	 * @param cyclePeriod
-	 * @return {@code true} if poperly resumed
+	 * @return {@code true} if properly resumed
 	 * 
 	 */
 	public boolean resumeAll(long cyclePeriod) {

+ 4 - 3
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/TimerService.java

@@ -49,11 +49,12 @@ public class TimerService implements ITimerService {
 		timerTaskMap.remove(event);
 	}
 
-	/**
-	 * Cancels all running TimersTasks
-	 */
 	public void cancel() {
 		timer.cancel();
 		timer.purge();
 	}
+
+	public long getSystemTimeMillis() {
+		return System.currentTimeMillis();
+	}
 }

+ 5 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/assignmentasexpression/AssignmentAsExpressionStatemachine.java

@@ -325,6 +325,11 @@ public class AssignmentAsExpressionStatemachine
 				stateVector[0] = State.$NullState$;
 				break;
 
+			case main_region_Subtract :
+				nextStateIndex = 0;
+				stateVector[0] = State.$NullState$;
+				break;
+
 			case main_region_Multiply :
 				nextStateIndex = 0;
 				stateVector[0] = State.$NullState$;

+ 2 - 2
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/performancetest/PerformanceTestStatemachine.java

@@ -119,7 +119,7 @@ public class PerformanceTestStatemachine
 		if (timerService == null) {
 			throw new IllegalStateException("TimerService not set.");
 		}
-		cycleStartTime = System.currentTimeMillis();
+		cycleStartTime = timerService.getSystemTimeMillis();
 		getTimerService().setTimer(performanceTest_time_event_0, 2000,
 				cycleStartTime);
 
@@ -1202,7 +1202,7 @@ public class PerformanceTestStatemachine
 
 	public void runCycle() {
 
-		cycleStartTime = System.currentTimeMillis();
+		cycleStartTime = timerService.getSystemTimeMillis();
 
 		clearOutEvents();
 

+ 6 - 6
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/statewithemptyregion/IStateWithEmptyRegionStatemachine.java

@@ -1,6 +1,6 @@
-package org.yakindu.scr.statewithemptyregion;
-import org.yakindu.scr.IStatemachine;
-
-public interface IStateWithEmptyRegionStatemachine extends IStatemachine {
-
-}
+package org.yakindu.scr.statewithemptyregion;
+import org.yakindu.scr.IStatemachine;
+
+public interface IStateWithEmptyRegionStatemachine extends IStatemachine {
+
+}

+ 116 - 116
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/statewithemptyregion/StateWithEmptyRegionStatemachine.java

@@ -1,116 +1,116 @@
-package org.yakindu.scr.statewithemptyregion;
-
-public class StateWithEmptyRegionStatemachine
-		implements
-			IStateWithEmptyRegionStatemachine {
-
-	public enum State {
-		main_region_A, main_region_B, $NullState$
-	};
-
-	private final State[] stateVector = new State[1];
-
-	private int nextStateIndex;
-
-	public StateWithEmptyRegionStatemachine() {
-
-	}
-
-	public void init() {
-		for (int i = 0; i < 1; i++) {
-			stateVector[i] = State.$NullState$;
-		}
-
-		clearEvents();
-		clearOutEvents();
-
-	}
-
-	public void enter() {
-		entryAction();
-
-		nextStateIndex = 0;
-		stateVector[0] = State.main_region_A;
-	}
-
-	public void exit() {
-		switch (stateVector[0]) {
-			case main_region_A :
-				nextStateIndex = 0;
-				stateVector[0] = State.$NullState$;
-				break;
-
-			case main_region_B :
-				nextStateIndex = 0;
-				stateVector[0] = State.$NullState$;
-				break;
-
-			default :
-				break;
-		}
-
-		exitAction();
-	}
-
-	protected void clearEvents() {
-
-	}
-
-	protected void clearOutEvents() {
-	}
-
-	public boolean isStateActive(State state) {
-		switch (state) {
-			case main_region_A :
-				return stateVector[0] == State.main_region_A;
-			case main_region_B :
-				return stateVector[0] == State.main_region_B;
-			default :
-				return false;
-		}
-	}
-
-	/* Entry action for statechart 'StateWithEmptyRegion'. */
-	private void entryAction() {
-	}
-
-	/* Exit action for state 'StateWithEmptyRegion'. */
-	private void exitAction() {
-	}
-
-	/* The reactions of state A. */
-	private void reactMain_region_A() {
-		if (true) {
-			nextStateIndex = 0;
-			stateVector[0] = State.$NullState$;
-
-			nextStateIndex = 0;
-			stateVector[0] = State.main_region_B;
-		}
-	}
-
-	/* The reactions of state B. */
-	private void reactMain_region_B() {
-	}
-
-	public void runCycle() {
-
-		clearOutEvents();
-
-		for (nextStateIndex = 0; nextStateIndex < stateVector.length; nextStateIndex++) {
-
-			switch (stateVector[nextStateIndex]) {
-				case main_region_A :
-					reactMain_region_A();
-					break;
-				case main_region_B :
-					reactMain_region_B();
-					break;
-				default :
-					// $NullState$
-			}
-		}
-
-		clearEvents();
-	}
-}
+package org.yakindu.scr.statewithemptyregion;
+
+public class StateWithEmptyRegionStatemachine
+		implements
+			IStateWithEmptyRegionStatemachine {
+
+	public enum State {
+		main_region_A, main_region_B, $NullState$
+	};
+
+	private final State[] stateVector = new State[1];
+
+	private int nextStateIndex;
+
+	public StateWithEmptyRegionStatemachine() {
+
+	}
+
+	public void init() {
+		for (int i = 0; i < 1; i++) {
+			stateVector[i] = State.$NullState$;
+		}
+
+		clearEvents();
+		clearOutEvents();
+
+	}
+
+	public void enter() {
+		entryAction();
+
+		nextStateIndex = 0;
+		stateVector[0] = State.main_region_A;
+	}
+
+	public void exit() {
+		switch (stateVector[0]) {
+			case main_region_A :
+				nextStateIndex = 0;
+				stateVector[0] = State.$NullState$;
+				break;
+
+			case main_region_B :
+				nextStateIndex = 0;
+				stateVector[0] = State.$NullState$;
+				break;
+
+			default :
+				break;
+		}
+
+		exitAction();
+	}
+
+	protected void clearEvents() {
+
+	}
+
+	protected void clearOutEvents() {
+	}
+
+	public boolean isStateActive(State state) {
+		switch (state) {
+			case main_region_A :
+				return stateVector[0] == State.main_region_A;
+			case main_region_B :
+				return stateVector[0] == State.main_region_B;
+			default :
+				return false;
+		}
+	}
+
+	/* Entry action for statechart 'StateWithEmptyRegion'. */
+	private void entryAction() {
+	}
+
+	/* Exit action for state 'StateWithEmptyRegion'. */
+	private void exitAction() {
+	}
+
+	/* The reactions of state A. */
+	private void reactMain_region_A() {
+		if (true) {
+			nextStateIndex = 0;
+			stateVector[0] = State.$NullState$;
+
+			nextStateIndex = 0;
+			stateVector[0] = State.main_region_B;
+		}
+	}
+
+	/* The reactions of state B. */
+	private void reactMain_region_B() {
+	}
+
+	public void runCycle() {
+
+		clearOutEvents();
+
+		for (nextStateIndex = 0; nextStateIndex < stateVector.length; nextStateIndex++) {
+
+			switch (stateVector[nextStateIndex]) {
+				case main_region_A :
+					reactMain_region_A();
+					break;
+				case main_region_B :
+					reactMain_region_B();
+					break;
+				default :
+					// $NullState$
+			}
+		}
+
+		clearEvents();
+	}
+}

+ 16 - 16
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/stextkeywordsinstatesandregions/ISTextKeywordsInStatesAndRegionsStatemachine.java

@@ -1,16 +1,16 @@
-package org.yakindu.scr.stextkeywordsinstatesandregions;
-import org.yakindu.scr.IStatemachine;
-
-public interface ISTextKeywordsInStatesAndRegionsStatemachine
-		extends
-			IStatemachine {
-
-	public interface SCIDefault {
-		public void raiseE1();
-		public void raiseE2();
-
-	}
-
-	public SCIDefault getSCIDefault();
-
-}
+package org.yakindu.scr.stextkeywordsinstatesandregions;
+import org.yakindu.scr.IStatemachine;
+
+public interface ISTextKeywordsInStatesAndRegionsStatemachine
+		extends
+			IStatemachine {
+
+	public interface SCIDefault {
+		public void raiseE1();
+		public void raiseE2();
+
+	}
+
+	public SCIDefault getSCIDefault();
+
+}

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 949 - 949
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/stextkeywordsinstatesandregions/STextKeywordsInStatesAndRegionsStatemachine.java


+ 6 - 6
test-plugins/org.yakindu.sct.model.sexec.test/src/org/yakindu/sct/model/sexec/transformation/test/SCTTestUtil.java

@@ -28,7 +28,7 @@ import com.google.common.collect.Collections2;
 
 public class SCTTestUtil {
 
-	public static Type TYPE_INTEGER = _createType("integer");
+	public static Type TYPE_INTEGER = _createIntegerType("integer");
 
 	public static List<Step> flattenSequenceStepsAsList(Step step) {
 		return flattenSequenceStepsAsList(step, new LinkedList<Step>());
@@ -108,7 +108,7 @@ public class SCTTestUtil {
 		public Statechart sc = _createStatechart("test");
 		public InterfaceScope s_scope = _createInterfaceScope("Interface", sc);
 		public VariableDefinition e1 = _createVariableDefinition("e1",
-				_createType("boolean"), s_scope, _createValue(true));
+				_createBooleanType("boolean"), s_scope, _createValue(true));
 
 		public InitializingTSC() {
 		}
@@ -119,16 +119,16 @@ public class SCTTestUtil {
 		public Statechart sc = _createStatechart("test");
 		public InterfaceScope s_scope = _createInterfaceScope("Interface", sc);
 		public VariableDefinition b = _createVariableDefinition("b",
-				_createType("boolean"), s_scope, null);
+				_createBooleanType("boolean"), s_scope, null);
 		
 		public VariableDefinition i = _createVariableDefinition("i",
-				_createType("integer"), s_scope, null);
+				_createIntegerType("integer"), s_scope, null);
 		
 		public VariableDefinition r = _createVariableDefinition("r",
-				_createType("real"), s_scope, null);
+				_createRealType("real"), s_scope, null);
 
 		public VariableDefinition s = _createVariableDefinition("s",
-				_createType("string"), s_scope, null);
+				_createStringType("string"), s_scope, null);
 
 		public InitializingWithoutDefaultTSC() {
 		}

+ 2 - 0
test-plugins/org.yakindu.sct.model.stext.test/.settings/org.eclipse.core.resources.prefs

@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding//src/org/yakindu/sct/model/stext/test/TypeInferrerTest.java=UTF-8

+ 3 - 62
test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/STextJavaValidatorTest.java

@@ -75,7 +75,7 @@ public class STextJavaValidatorTest extends AbstractSTextTest {
 	public void teardown() {
 		tester = null;
 	}
-	
+
 	/**
 	 * @see STextJavaValidator#checkVariableType(org.yakindu.sct.model.stext.stext.VariableDefinition)
 	 */
@@ -115,11 +115,11 @@ public class STextJavaValidatorTest extends AbstractSTextTest {
 	 */
 	@Test
 	public void checkOperationArguments_FeatureCall() {
-		Scope context = (Scope) parseExpression(
+		Scope scope = (Scope) parseExpression(
 				"interface if : operation myOperation(param1 : integer, param2: boolean)",
 				null, InterfaceScope.class.getSimpleName());
 		EObject model = super.parseExpression("if.myOperation(5,true)",
-				context, Expression.class.getSimpleName());
+				Expression.class.getSimpleName(), scope);
 		AssertableDiagnostics validationResult = tester.validate(model);
 		validationResult.assertOK();
 	}
@@ -313,65 +313,6 @@ public class STextJavaValidatorTest extends AbstractSTextTest {
 		// Nothing to do, checked by Typeanalyzer tests
 	}
 
-	/**
-	 * @see STextJavaValidator#checkVariableDefinitionInitialValue(org.yakindu.sct.model.stext.stext.VariableDefinition)
-	 */
-	@Test
-	public void checkVariableDefinitionInitialValue() {
-
-		// Success boolean
-		checkExpressionSuccess("interface: var myBool : boolean = !true");
-		// Success integer
-		checkExpressionSuccess("interface: var myInt : integer = 5");
-		// Success real
-		checkExpressionSuccess("interface: var myReal : real = 0.5");
-		// Success string
-		checkExpressionSuccess("interface: var myString : string = \"text\"");
-
-		String errorMsg = "Can not assign a value of type "
-				+ "'%s' to a variable of type '%s'";
-
-		// Fail boolean 1
-		checkErrorMessageForExpression("interface: var myBool : boolean = 5",
-				String.format(errorMsg, "integer", "boolean"));
-		// Fail boolean 2
-		checkErrorMessageForExpression("interface: var myBool : boolean = 0.5",
-				String.format(errorMsg, "real", "boolean"));
-		// Fail boolean 3
-		checkErrorMessageForExpression(
-				"interface: var myBool : boolean = \"text\"",
-				String.format(errorMsg, "string", "boolean"));
-		// Fail integer 1
-		checkErrorMessageForExpression("interface: var myInt : integer = true",
-				String.format(errorMsg, "boolean", "integer"));
-		// Fail integer 2
-		checkErrorMessageForExpression("interface: var myInt : integer = 0.5",
-				String.format(errorMsg, "real", "integer"));
-		// Fail integer 3
-		checkErrorMessageForExpression(
-				"interface: var myInt : integer = \"text\"",
-				String.format(errorMsg, "string", "integer"));
-		// Fail real 1
-		checkErrorMessageForExpression("interface: var myReal : real = true",
-				String.format(errorMsg, "boolean", "real"));
-		// Fail real 2
-		checkErrorMessageForExpression(
-				"interface: var myReal : real = \"text\"",
-				String.format(errorMsg, "string", "real"));
-		// Fail String 1
-		checkErrorMessageForExpression("interface: var myString : string = 5",
-				String.format(errorMsg, "integer", "string"));
-		// Fail String 2
-		checkErrorMessageForExpression(
-				"interface: var myString : string = 0.5",
-				String.format(errorMsg, "real", "string"));
-		// Fail String 3
-		checkErrorMessageForExpression(
-				"interface: var myString : string = true",
-				String.format(errorMsg, "boolean", "string"));
-
-	}
-
 	private void checkErrorMessageForExpression(String expression,
 			String errorMessage) {
 		AssertableDiagnostics result = tester.validate(getModel(expression));

+ 0 - 1
test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/STextScopeProviderTest.java

@@ -35,7 +35,6 @@ public class STextScopeProviderTest extends AbstractSTextTest {
 	public void setup() {
 		internalScope = createInternalScope(INTERNAL_SCOPE);
 		interfaceScope = createInterfaceScope(INTERFACE_SCOPE);
-
 	}
 
 	@Test

+ 20 - 20
test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/StextParserRuleTest.java

@@ -159,7 +159,7 @@ public class StextParserRuleTest extends AbstractSTextTest {
 	public void testReactionTrigger() {
 		String rule = ReactionTrigger.class.getSimpleName();
 		// Internal Scope
-		parseExpression("event1", internalScope(), rule);
+		parseExpression("intEvent", internalScope(), rule);
 		parseExpression("after 10 s", rule);
 		parseExpression("after 10 ms", rule);
 		parseExpression("after 10 us", rule);
@@ -169,12 +169,12 @@ public class StextParserRuleTest extends AbstractSTextTest {
 		parseExpression("exit", rule);
 		parseExpression("oncycle", rule);
 		parseExpression("always", rule);
-		parseExpression("event1, after 10s", internalScope(), rule);
-		parseExpression("event1, after 10s, every 10 ms", internalScope(), rule);
-		parseExpression("event1, after 10s [false == true]", internalScope(),
+		parseExpression("intEvent, after 10s", internalScope(), rule);
+		parseExpression("intEvent, after 10s, every 10 ms", internalScope(), rule);
+		parseExpression("intEvent, after 10s [false == true]", internalScope(),
 				rule);
-		parseExpression("event1, after 10s [5  > 10]", internalScope(), rule);
-		parseExpression("ABC.event2", interfaceScope(), rule);
+		parseExpression("intEvent, after 10s [5  > 10]", internalScope(), rule);
+		parseExpression("ABC.intEvent", interfaceScope(), rule);
 	}
 
 	/**
@@ -197,15 +197,15 @@ public class StextParserRuleTest extends AbstractSTextTest {
 	@Test
 	public void testReactionEffect() {
 		String rule = ReactionEffect.class.getSimpleName();
-		parseExpression("raise event1", internalScope(), rule);
-		parseExpression("myInt = 5", internalScope(), rule);
-		parseExpression("myOpp1()", internalScope(), rule);
-		parseExpression("myInt = myOpp1()", internalScope(), rule);
+		parseExpression("raise intEvent", internalScope(), rule);
+		parseExpression("intVar = 5", internalScope(), rule);
+		parseExpression("voidOp()", internalScope(), rule);
+		parseExpression("intVar = intOp()", internalScope(), rule);
 
-		parseExpression("raise ABC.event2", interfaceScope(), rule);
-		parseExpression("ABC.myOpp2()", interfaceScope(), rule);
-		parseExpression("ABC.myOpp2(5,false)", interfaceScope(), rule);
-		parseExpression("ABC.myOpp2(); raise ABC.event2 ", interfaceScope(),
+		parseExpression("raise ABC.intEvent : 5", interfaceScope(), rule);
+		parseExpression("ABC.paramOp()", interfaceScope(), rule);
+		parseExpression("ABC.paramOp(5,false)", interfaceScope(), rule);
+		parseExpression("ABC.paramOp(); raise ABC.voidEvent ", interfaceScope(),
 				rule);
 
 	}
@@ -228,7 +228,7 @@ public class StextParserRuleTest extends AbstractSTextTest {
 	@Test
 	public void tesLocalReaction() {
 		String rule = LocalReaction.class.getSimpleName();
-		parseExpression("entry [ABC.myInt > 10] / raise ABC.event2",
+		parseExpression("entry [ABC.intVar > 10] / raise ABC.intEvent",
 				interfaceScope(), rule);
 	}
 
@@ -239,7 +239,7 @@ public class StextParserRuleTest extends AbstractSTextTest {
 	@Test
 	public void testTransitionReaction() {
 		String rule = TransitionReaction.class.getSimpleName();
-		parseExpression("after 10 s / raise ABC.event2", interfaceScope(), rule);
+		parseExpression("after 10 s / raise ABC.intEvent", interfaceScope(), rule);
 	}
 
 	/**
@@ -266,10 +266,10 @@ public class StextParserRuleTest extends AbstractSTextTest {
 	public void testInternalScope() {
 		String rule = InternalScope.class.getSimpleName();
 		parseExpression("internal :", rule);
-		parseExpression("internal : event Event1", rule);
-		parseExpression("internal : var myVar : integer", rule);
-		parseExpression("internal : operation myOpp()", rule);
-		parseExpression("internal : every 10 ms / raise abc", internalScope(),
+		parseExpression("internal : event voidEvent", rule);
+		parseExpression("internal : var intVar : integer", rule);
+		parseExpression("internal : operation voidOp()", rule);
+		parseExpression("internal : every 10 ms / raise intEvent", internalScope(),
 				rule);
 	}
 

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 675 - 982
test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/TypeInferrerTest.java


+ 3 - 2
test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/util/AbstractSTextTest.java

@@ -78,6 +78,7 @@ public abstract class AbstractSTextTest {
 		return parseExpression(expression, null, ruleName);
 	}
 
+	// TODO: REMOVE
 	protected EObject parseExpression(String expression, Scope scope,
 			String ruleName) {
 		return parseExpression(expression, ruleName, scope);
@@ -161,7 +162,7 @@ public abstract class AbstractSTextTest {
 	 * </pre>
 	 */
 	protected Scope internalScope() {
-		return createInternalScope("internal: in event abc : integer in event event1 operation foo() operation myOpp1() :integer var myInt : integer var myBool : boolean var myReal : real var myString : string");
+		return createInternalScope("internal: operation voidOp() operation intOp():integer var intVar : integer var boolVar : boolean var realVar : real var stringVar : string event intEvent : integer  event boolEvent : boolean event realEvent : real event stringEvent : string event voidEvent : void");
 	}
 
 	/**
@@ -175,6 +176,6 @@ public abstract class AbstractSTextTest {
 	 * </pre>
 	 */
 	protected Scope interfaceScope() {
-		return createInterfaceScope("interface ABC : operation myParamOpp(param1 : integer, param2 : boolean ) : string operation myOpp2() in event event2  in event myIntEvent : integer in event event3 var myInt : integer var myBool : boolean");
+		return createInterfaceScope("interface ABC : operation paramOp(param1 : integer, param2 : boolean ) : string operation stringOp() in event voidEvent  in event intEvent : integer var intVar : integer var boolVar : boolean");
 	}
 }

+ 27 - 3
test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/util/StextTestFactory.java

@@ -84,14 +84,38 @@ public class StextTestFactory extends StextFactoryImpl {
 			scope.getDeclarations().add(v);
 		return v;
 	}
-
-	public static Type _createType(String name) {
-		Type t = TypesFactory.eINSTANCE.createType();
+	
+	public static Type _createIntegerType(String name) {
+		Type t = TypesFactory.eINSTANCE.createPrimitiveType();
 		t.setName(name);
 
 		return t;
 	}
 
+	public static Type _createRealType(String name) {
+		Type t = TypesFactory.eINSTANCE.createPrimitiveType();
+		t.setName(name);
+		return t;
+	}
+	
+	public static Type _createBooleanType(String name) {
+		Type t = TypesFactory.eINSTANCE.createPrimitiveType();
+		t.setName(name);
+		return t;
+	}
+	
+	public static Type _createStringType(String name) {
+		Type t = TypesFactory.eINSTANCE.createPrimitiveType();
+		t.setName(name);
+		return t;
+	}
+	
+	public static Type _createVoidType(String name) {
+		Type t = TypesFactory.eINSTANCE.createPrimitiveType();
+		t.setName(name);
+		return t;
+	}
+
 	public static RegularEventSpec _createRegularEventSpec(EventDefinition e1,
 			ReactionTrigger rt) {
 		RegularEventSpec e1Spec = StextFactory.eINSTANCE