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

Added support for NULL literal.

markus.muehlbrandt@gmail.com 11 лет назад
Родитель
Сommit
fd4a69584c

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

@@ -43,6 +43,7 @@ import org.yakindu.sct.model.stext.stext.EventValueReferenceExpression
 import org.yakindu.sct.model.stext.stext.OperationDefinition
 import org.yakindu.sct.model.stext.stext.VariableDefinition
 import org.yakindu.sct.model.stext.types.ISTextTypeInferrer
+import org.yakindu.base.expressions.expressions.NullLiteral
 
 class ExpressionCode {
 
@@ -73,6 +74,8 @@ class ExpressionCode {
 
 	/* HANDLING LITERALS */
 	def dispatch CharSequence code(Literal it) '''#error unknown literal type «getClass().name» '''
+	
+	def dispatch CharSequence code(NullLiteral it) '''«Naming::NULL_STRING»'''
 
 	def dispatch CharSequence code(StringLiteral it) '''"«value.escaped»"'''
 

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

@@ -40,6 +40,8 @@ class Naming {
 	@Inject GeneratorEntry entry
 	
 	@Inject extension GenmodelEntries
+	
+	public static final String NULL_STRING = "null";
 	
 	def getFullyQualifiedName(State state) {
 		provider.getFullyQualifiedName(state).toString.asEscapedIdentifier
@@ -54,7 +56,7 @@ class Naming {
 	
 //	def module(InterfaceScope it) {
 //		flow.type + (if (name.nullOrEmpty) 'Default' else name).asIdentifier.toFirstUpper	
-//	}
+//	}
 	
 	def client(String it) {
 		it + "Required"	

+ 9 - 1
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Types.xtend

@@ -50,7 +50,7 @@ class Types {
 		
 		#include <stdint.h>
 		#include <stdbool.h>
-		
+		 
 		typedef bool			sc_boolean;
 		typedef int_fast16_t	sc_short;
 		typedef uint_fast16_t	sc_ushort;
@@ -65,6 +65,14 @@ class Types {
 		}
 		#endif
 		
+		#ifndef «Naming::NULL_STRING»
+			#ifdef __cplusplus
+				#define «Naming::NULL_STRING» 0
+			#else
+				#define «Naming::NULL_STRING» ((void *)0)
+			#endif
+		#endif
+		
 		#define bool_true true
 		#define bool_false false
 		

+ 4 - 1
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/ExpressionCode.xtend

@@ -33,6 +33,7 @@ import org.yakindu.sct.model.stext.stext.EventValueReferenceExpression
 import org.yakindu.sct.model.stext.stext.OperationDefinition
 import org.yakindu.sct.model.stext.stext.VariableDefinition
 import org.yakindu.sct.model.stext.types.ISTextTypeInferrer
+import org.yakindu.base.expressions.expressions.NullLiteral
 
 class ExpressionCode {
 
@@ -65,7 +66,9 @@ class ExpressionCode {
 
 	/* HANDLING LITERALS */
 	def dispatch CharSequence code(Literal it) '''#error unknown literal type «getClass().name» '''
-
+	
+	def dispatch CharSequence code(NullLiteral it) '''«Naming::NULL_STRING»'''
+	
 	def dispatch CharSequence code(StringLiteral it) '''"«value.escaped»"'''
 
 	def String escaped(String it) {

+ 2 - 4
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/StatemachineImplementation.xtend

@@ -107,10 +107,8 @@ class StatemachineImplementation {
 			stateConfVectorPosition = 0;
 		
 			clearInEvents();
-			clearOutEvents();
-		
-			// TODO: initialize all events ...
-
+			clearOutEvents();
+			
 			«initSequence.code»
 
 		}

+ 4 - 0
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/Types.xtend

@@ -55,6 +55,10 @@ class Types {
 		
 		typedef void*			sc_eventid;
 		
+		#ifndef «Naming::NULL_STRING»
+			#define «Naming::NULL_STRING» 0
+		#endif
+		
 		#endif /* «typesModule.define»_H_ */
 	'''
 }

BIN
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.CppGenerator.java._trace


BIN
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.Naming.java._trace


BIN
plugins/org.yakindu.sct.generator.cpp/xtend-gen/org/yakindu/sct/generator/cpp/.Types.java._trace