Fix calling of functions whose parameters are of an implicitly declared datatype (currently only makes sense for REF_TO datatypes, but may make sense to other datatypes too if the datatype model is changed in the future).
--- a/stage4/generate_c/generate_c_base.cc Sun Aug 10 08:51:33 2014 +0100
+++ b/stage4/generate_c/generate_c_base.cc Mon Aug 11 07:22:37 2014 +0100
@@ -619,7 +619,61 @@
}
-
+/* identifier ':' array_spec_init */
+void *visit(array_type_declaration_c *symbol) {ERROR;/* Should never get called! */ return NULL;}
+
+/* array_specification [ASSIGN array_initialization] */
+/* array_initialization may be NULL ! */
+void *visit(array_spec_init_c *symbol) {
+ int implicit_id_count = symbol->anotations_map.count("generate_c_annotaton__implicit_type_id");
+ if (implicit_id_count != 1) ERROR;
+ /* this is part of an implicitly declared datatype (i.e. inside a variable decaration), for which an equivalent C datatype
+ * has already been defined. So, we simly print out the id of that C datatpe...
+ */
+ return symbol->anotations_map["generate_c_annotaton__implicit_type_id"]->accept(*this);
+}
+
+/* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */
+void *visit(array_specification_c *symbol) {
+ int implicit_id_count = symbol->anotations_map.count("generate_c_annotaton__implicit_type_id");
+ if (implicit_id_count != 1) ERROR;
+ /* this is part of an implicitly declared datatype (i.e. inside a variable decaration), for which an equivalent C datatype
+ * has already been defined. So, we simly print out the id of that C datatpe...
+ */
+ return symbol->anotations_map["generate_c_annotaton__implicit_type_id"]->accept(*this);
+}
+
+
+/* ref_spec: REF_TO (non_generic_type_name | function_block_type_name) */
+void *visit(ref_spec_c *symbol) {
+ int implicit_id_count = symbol->anotations_map.count("generate_c_annotaton__implicit_type_id");
+ if (implicit_id_count != 1) ERROR;
+ /* this is part of an implicitly declared datatype (i.e. inside a variable decaration), for which an equivalent C datatype
+ * has already been defined. So, we simly print out the id of that C datatpe...
+ */
+ return symbol->anotations_map["generate_c_annotaton__implicit_type_id"]->accept(*this);
+}
+
+/* For the moment, we do not support initialising reference data types */
+/* ref_spec_init: ref_spec [ ASSIGN ref_initialization ] */
+/* NOTE: ref_initialization may be NULL!! */
+// SYM_REF2(ref_spec_init_c, ref_spec, ref_initialization)
+void *visit(ref_spec_init_c *symbol) {
+ int implicit_id_count = symbol->anotations_map.count("generate_c_annotaton__implicit_type_id");
+ if (implicit_id_count != 1) ERROR;
+ /* this is part of an implicitly declared datatype (i.e. inside a variable decaration), for which an equivalent C datatype
+ * has already been defined. So, we simly print out the id of that C datatpe...
+ */
+ return symbol->anotations_map["generate_c_annotaton__implicit_type_id"]->accept(*this);
+}
+
+/* ref_type_decl: identifier ':' ref_spec_init */
+void *visit(ref_type_decl_c *symbol) {ERROR;/* Should never get called! */ return NULL;}
+
+
+
+
+
/* NOTE: visit(subrange_spec_init_c *)
* and visit(subrange_specification_c *)
* together simply print out the integer datatype
@@ -643,7 +697,10 @@
return NULL;
}
-
+
+/* NOTE: Why is this here? This visit() method should not be here!!
+ * TODO: Figure out who is dependent on this method, and move it to its correct location!
+ */
/* helper symbol for array_specification */
/* array_subrange_list ',' subrange */
void *visit(array_subrange_list_c *symbol) {