--- a/stage3/narrow_candidate_datatypes.cc Tue Nov 13 18:02:15 2012 +0000
+++ b/stage3/narrow_candidate_datatypes.cc Tue Nov 13 18:03:17 2012 +0000
@@ -414,9 +414,8 @@
return search_base_type_c::get_basetype_decl(symbol);
}
-/*********************/
-/* B 1.2 - Constants */
-/*********************/
+
+
/**********************/
/* B 1.3 - Data types */
@@ -424,6 +423,18 @@
/********************************/
/* B 1.3.3 - Derived data types */
/********************************/
+/* TYPE type_declaration_list END_TYPE */
+// SYM_REF1(data_type_declaration_c, type_declaration_list)
+/* NOTE: Not required. already handled by iterator_visitor_c base class */
+
+/* helper symbol for data_type_declaration */
+// SYM_LIST(type_declaration_list_c)
+/* NOTE: Not required. already handled by iterator_visitor_c base class */
+
+/* simple_type_name ':' simple_spec_init */
+// SYM_REF2(simple_type_declaration_c, simple_type_name, simple_spec_init)
+/* NOTE: Not required. already handled by iterator_visitor_c base class */
+
/* simple_specification ASSIGN constant */
// SYM_REF2(simple_spec_init_c, simple_specification, constant)
void *narrow_candidate_datatypes_c::visit(simple_spec_init_c *symbol) {
@@ -441,9 +452,18 @@
}
+/* subrange_type_name ':' subrange_spec_init */
+// SYM_REF2(subrange_type_declaration_c, subrange_type_name, subrange_spec_init)
+
+/* subrange_specification ASSIGN signed_integer */
+// SYM_REF2(subrange_spec_init_c, subrange_specification, signed_integer)
+
+/* integer_type_name '(' subrange')' */
+// SYM_REF2(subrange_specification_c, integer_type_name, subrange)
/* signed_integer DOTDOT signed_integer */
-// SYM_REF2(subrange_c, lower_limit, upper_limit)
+/* dimension will be filled in during stage 3 (array_range_check_c) with the number of elements in this subrange */
+// SYM_REF2(subrange_c, lower_limit, upper_limit, unsigned long long int dimension;)
void *narrow_candidate_datatypes_c::visit(subrange_c *symbol) {
symbol->lower_limit->datatype = symbol->datatype;
symbol->lower_limit->accept(*this);
@@ -453,6 +473,113 @@
}
+/* enumerated_type_name ':' enumerated_spec_init */
+// SYM_REF2(enumerated_type_declaration_c, enumerated_type_name, enumerated_spec_init)
+void *narrow_candidate_datatypes_c::visit(enumerated_type_declaration_c *symbol) {
+ symbol->datatype = search_base_type_c::get_basetype_decl(symbol);
+ symbol->enumerated_type_name->datatype = symbol->datatype;
+ symbol->enumerated_spec_init->datatype = symbol->datatype;
+
+ symbol->enumerated_spec_init->accept(*this);
+ return NULL;
+}
+
+
+/* enumerated_specification ASSIGN enumerated_value */
+// SYM_REF2(enumerated_spec_init_c, enumerated_specification, enumerated_value)
+void *narrow_candidate_datatypes_c::visit(enumerated_spec_init_c *symbol) {
+ /* If we are handling an anonymous datatype (i.e. a datatype implicitly declared inside a VAR ... END_VAR declaration)
+ * then the symbol->datatype has not yet been set by the previous visit(enumerated_spec_init_c) method!
+ */
+ if (NULL == symbol->datatype)
+ symbol->datatype = search_base_type_c::get_basetype_decl(symbol);
+ symbol->enumerated_specification->datatype = symbol->datatype;
+ if (NULL != symbol->enumerated_value)
+ /* the enumerated_value_c object to which this list points to has both the datatype and the candidate_datatype_list filled in, so we
+ * call set_datatype() instead of setting the datatype directly!
+ * If the desired datatype does not match the datatypes in the candidate list, then the source code has a bug that will be caught by
+ * print_datatypes_error_c
+ */
+ set_datatype(symbol->datatype, symbol->enumerated_value);
+
+ symbol->enumerated_specification->accept(*this); /* calls enumerated_value_list_c (or identifier_c, which we ignore!) visit method */
+ return NULL;
+}
+
+/* helper symbol for enumerated_specification->enumerated_spec_init */
+/* enumerated_value_list ',' enumerated_value */
+// SYM_LIST(enumerated_value_list_c)
+void *narrow_candidate_datatypes_c::visit(enumerated_value_list_c *symbol) {
+ if (NULL == symbol->datatype) ERROR;
+
+ for(int i = 0; i < symbol->n; i++) {
+ /* the enumerated_value_c objects to which this list points to has both the datatype and the candidate_datatype_list filled in, so we
+ * call set_datatype() instead of setting the datatype directly!
+ */
+ set_datatype(symbol->datatype, symbol->elements[i]);
+ if (NULL == symbol->elements[i]->datatype) ERROR;
+ }
+ return NULL;
+}
+
+
+/* enumerated_type_name '#' identifier */
+// SYM_REF2(enumerated_value_c, type, value)
+// void *narrow_candidate_datatypes_c::visit(enumerated_value_c *symbol) {/* do nothing! */ return NULL;}
+
+
+/* identifier ':' array_spec_init */
+// SYM_REF2(array_type_declaration_c, identifier, array_spec_init)
+
+/* array_specification [ASSIGN array_initialization} */
+/* array_initialization may be NULL ! */
+// SYM_REF2(array_spec_init_c, array_specification, array_initialization)
+
+/* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */
+// SYM_REF2(array_specification_c, array_subrange_list, non_generic_type_name)
+
+/* helper symbol for array_specification */
+/* array_subrange_list ',' subrange */
+// SYM_LIST(array_subrange_list_c)
+
+/* array_initialization: '[' array_initial_elements_list ']' */
+/* helper symbol for array_initialization */
+/* array_initial_elements_list ',' array_initial_elements */
+// SYM_LIST(array_initial_elements_list_c)
+
+/* integer '(' [array_initial_element] ')' */
+/* array_initial_element may be NULL ! */
+// SYM_REF2(array_initial_elements_c, integer, array_initial_element)
+
+/* structure_type_name ':' structure_specification */
+// SYM_REF2(structure_type_declaration_c, structure_type_name, structure_specification)
+
+/* structure_type_name ASSIGN structure_initialization */
+/* structure_initialization may be NULL ! */
+// SYM_REF2(initialized_structure_c, structure_type_name, structure_initialization)
+
+/* helper symbol for structure_declaration */
+/* structure_declaration: STRUCT structure_element_declaration_list END_STRUCT */
+/* structure_element_declaration_list structure_element_declaration ';' */
+// SYM_LIST(structure_element_declaration_list_c)
+
+/* structure_element_name ':' *_spec_init */
+// SYM_REF2(structure_element_declaration_c, structure_element_name, spec_init)
+
+/* helper symbol for structure_initialization */
+/* structure_initialization: '(' structure_element_initialization_list ')' */
+/* structure_element_initialization_list ',' structure_element_initialization */
+// SYM_LIST(structure_element_initialization_list_c)
+
+/* structure_element_name ASSIGN value */
+// SYM_REF2(structure_element_initialization_c, structure_element_name, value)
+
+/* string_type_name ':' elementary_string_type_name string_type_declaration_size string_type_declaration_init */
+// SYM_REF4(string_type_declaration_c, string_type_name, elementary_string_type_name, string_type_declaration_size, string_type_declaration_init/* may be == NULL! */)
+
+
+
+
/*********************/
/* B 1.4 - Variables */
/*********************/