Fill symbol->datatype anotation for FB declarations.
authorMario de Sousa <msousa@fe.up.pt>
Wed, 23 Jan 2013 14:30:03 +0000
changeset 807 4d71292f8732
parent 806 f218434eeaf8
child 808 7a6b53d61ea3
Fill symbol->datatype anotation for FB declarations.
stage3/fill_candidate_datatypes.cc
stage3/narrow_candidate_datatypes.cc
--- a/stage3/fill_candidate_datatypes.cc	Wed Jan 23 13:46:11 2013 +0000
+++ b/stage3/fill_candidate_datatypes.cc	Wed Jan 23 14:30:03 2013 +0000
@@ -1293,6 +1293,12 @@
 	search_varfb_instance_type = NULL;
 
 	local_enumerated_value_symtable.reset();
+	
+	/* The FB declaration itself may be used as a dataype! We now do the fill algorithm considering 
+	 * function_block_declaration_c a data type declaration...
+	 */
+	// The next line is essentially equivalent to doing-->  symbol->candidate_datatypes.push_back(symbol);
+	add_datatype_to_candidate_list(symbol, base_type(symbol));
 	return NULL;
 }
 
--- a/stage3/narrow_candidate_datatypes.cc	Wed Jan 23 13:46:11 2013 +0000
+++ b/stage3/narrow_candidate_datatypes.cc	Wed Jan 23 14:30:03 2013 +0000
@@ -748,6 +748,10 @@
 	symbol->fblock_body->accept(*this);
 	delete search_varfb_instance_type;
 	search_varfb_instance_type = NULL;
+	
+	// A FB declaration can also be used as a Datatype! We now do the narrow algorithm considering it as such!
+	if (symbol->candidate_datatypes.size() == 1)
+		symbol->datatype = symbol->candidate_datatypes[0];
 	return NULL;
 }