Add high level comments.
--- a/stage3/fill_candidate_datatypes.cc Thu May 10 15:40:19 2012 +0100
+++ b/stage3/fill_candidate_datatypes.cc Thu May 10 16:09:50 2012 +0100
@@ -42,8 +42,17 @@
*/
+/* NOTE: The algorithm implemented here assumes that flow control analysis has already been completed!
+ * BEFORE running this visitor, be sure to CALL the flow_control_analysis_c visitor!
+ */
+
+
/*
- * Fill candidate list of data types for all symbols
+ * Fill the candidate datatype list for all symbols that may legally 'have' a data type (e.g. variables, literals, function calls, expressions, etc.)
+ *
+ * The candidate datatype list will be filled with a list of all the data types that expression may legally take.
+ * For example, the very simple literal '0' (as in foo := 0), may represent a:
+ * BOOL, BYTE, WORD, DWORD, LWORD, USINT, SINT, UINT, INT, UDINT, DINT, ULINT, LINT (as well as the SAFE versions of these data tyes too!)
*/
#include "fill_candidate_datatypes.hh"
--- a/stage3/fill_candidate_datatypes.hh Thu May 10 15:40:19 2012 +0100
+++ b/stage3/fill_candidate_datatypes.hh Thu May 10 16:09:50 2012 +0100
@@ -32,6 +32,19 @@
*
*/
+/* NOTE: The algorithm implemented here assumes that flow control analysis has already been completed!
+ * BEFORE running this visitor, be sure to CALL the flow_control_analysis_c visitor!
+ */
+
+
+/*
+ * Fill the candidate datatype list for all symbols that may legally 'have' a data type (e.g. variables, literals, function calls, expressions, etc.)
+ *
+ * The candidate datatype list will be filled with a list of all the data types that expression may legally take.
+ * For example, the very simple literal '0' (as in foo := 0), may represent a:
+ * BOOL, BYTE, WORD, DWORD, LWORD, USINT, SINT, UINT, INT, UDINT, DINT, ULINT, LINT (as well as the SAFE versions of these data tyes too!)
+ */
+
#include "../absyntax_utils/absyntax_utils.hh"
#include "datatype_functions.hh"
--- a/stage3/narrow_candidate_datatypes.cc Thu May 10 15:40:19 2012 +0100
+++ b/stage3/narrow_candidate_datatypes.cc Thu May 10 16:09:50 2012 +0100
@@ -32,10 +32,27 @@
*/
+/* NOTE: The algorithm implemented here assumes that candidate datatype lists have already been filled!
+ * BEFORE running this visitor, be sure to CALL the fill_candidate_datatype_c visitor!
+ */
+
+
/*
- * Narrow class select and store a data type from candidate data types list for all symbols
+ * Choose, from the list of all the possible datatypes each expression may take, the single datatype that it will in fact take.
+ * The resulting (chosen) datatype, will be stored in the symbol_c.datatype variable, leaving the candidate datatype list untouched!
+ *
+ * For rvalue expressions, this decision will be based on the datatype of the lvalue expression.
+ * For lvalue expressions, the candidate datatype list should have a single entry.
+ *
+ * For example, the very simple literal '0' in 'foo := 0', may represent a:
+ * BOOL, BYTE, WORD, DWORD, LWORD, USINT, SINT, UINT, INT, UDINT, DINT, ULINT, LINT (as well as the SAFE versions of these data tyes too!)
+ *
+ * In this class, the datatype of '0' will be set to the same datatype as the 'foo' variable.
+ * If the intersection of the candidate datatype lists of the left and right side expressions is empty,
+ * then a datatype error has been found, and the datatype is either left at NULL, or set to a pointer of an invalid_type_name_c object!
*/
+
#include "narrow_candidate_datatypes.hh"
#include "datatype_functions.hh"
#include <typeinfo>
--- a/stage3/narrow_candidate_datatypes.hh Thu May 10 15:40:19 2012 +0100
+++ b/stage3/narrow_candidate_datatypes.hh Thu May 10 16:09:50 2012 +0100
@@ -33,6 +33,27 @@
*/
+/* NOTE: The algorithm implemented here assumes that candidate datatype lists have already been filled!
+ * BEFORE running this visitor, be sure to CALL the fill_candidate_datatype_c visitor!
+ */
+
+
+/*
+ * Choose, from the list of all the possible datatypes each expression may take, the single datatype that it will in fact take.
+ * The resulting (chosen) datatype, will be stored in the symbol_c.datatype variable, leaving the candidate datatype list untouched!
+ *
+ * For rvalue expressions, this decision will be based on the datatype of the lvalue expression.
+ * For lvalue expressions, the candidate datatype list should have a single entry.
+ *
+ * For example, the very simple literal '0' in 'foo := 0', may represent a:
+ * BOOL, BYTE, WORD, DWORD, LWORD, USINT, SINT, UINT, INT, UDINT, DINT, ULINT, LINT (as well as the SAFE versions of these data tyes too!)
+ *
+ * In this class, the datatype of '0' will be set to the same datatype as the 'foo' variable.
+ * If the intersection of the candidate datatype lists of the left and right side expressions is empty,
+ * then a datatype error has been found, and the datatype is either left at NULL, or set to a pointer of an invalid_type_name_c object!
+ */
+
+
#include "../absyntax_utils/absyntax_utils.hh"
#include "datatype_functions.hh"
--- a/stage3/print_datatypes_error.cc Thu May 10 15:40:19 2012 +0100
+++ b/stage3/print_datatypes_error.cc Thu May 10 16:09:50 2012 +0100
@@ -31,11 +31,18 @@
*
*/
+/* NOTE: The algorithm implemented here assumes that the symbol_c.candidate_datatype, and the symbol_c.datatype
+ * annotations have already been apropriately filled in!
+ * BEFORE running this visitor, be sure to CALL the fill_candidate_datatypes_c, and the narrow_candidate_datatypes_c visitors!
+ */
+
/*
- * Fill candidate list of data types for all symbols
+ * By analysing the candidate datatype lists, as well as the chosen datatype for each expression, determine
+ * if an datatype error has been found, and if so, print out an error message.
*/
+
#include "print_datatypes_error.hh"
#include "datatype_functions.hh"
--- a/stage3/print_datatypes_error.hh Thu May 10 15:40:19 2012 +0100
+++ b/stage3/print_datatypes_error.hh Thu May 10 16:09:50 2012 +0100
@@ -32,6 +32,17 @@
*
*/
+/* NOTE: The algorithm implemented here assumes that the symbol_c.candidate_datatype, and the symbol_c.datatype
+ * annotations have already been apropriately filled in!
+ * BEFORE running this visitor, be sure to CALL the fill_candidate_datatypes_c, and the narrow_candidate_datatypes_c visitors!
+ */
+
+
+/*
+ * By analysing the candidate datatype lists, as well as the chosen datatype for each expression, determine
+ * if an datatype error has been found, and if so, print out an error message.
+ */
+
#include "../absyntax_utils/absyntax_utils.hh"
#include "datatype_functions.hh"