Start of support for IL expressions (parenthesis).
--- a/stage3/fill_candidate_datatypes.cc Mon Feb 20 17:52:01 2012 +0000
+++ b/stage3/fill_candidate_datatypes.cc Mon Feb 20 19:44:40 2012 +0000
@@ -923,8 +923,9 @@
il_parenthesis_level--;
if (il_parenthesis_level < 0) ERROR;
+
/* Now check the if the data type semantics of operation are correct, */
- il_operand = prev_il_instruction;
+ il_operand = symbol->simple_instr_list;
prev_il_instruction = prev_il_instruction_backup;
symbol->il_expr_operator->accept(*this);
il_operand = NULL;
@@ -998,9 +999,26 @@
return NULL;
}
+
+// void *visit(il_operand_list_c *symbol);
+
+
+/* | simple_instr_list il_simple_instruction */
+/* This object is referenced by il_expression_c objects */
+void *fill_candidate_datatypes_c::visit(simple_instr_list_c *symbol) {
+ int i;
+ for(i = 0; i < symbol->n; i++)
+ symbol->elements[i]->accept(*this);
+ /* This object has (inherits) the same candidate datatypes as the last il_instruction (if it exists!) */
+ if (i > 0)
+ copy_candidate_datatype_list(symbol->elements[i-1] /*from*/, symbol /*to*/);
+
+ if (debug) std::cout << "simple_instr_list_c [" << symbol->candidate_datatypes.size() << "] result.\n";
+std::cout << "simple_instr_list_c [" << symbol->candidate_datatypes.size() << "] result.\n";
+ return NULL;
+}
+
/*
- void *visit(il_operand_list_c *symbol);
- void *visit(simple_instr_list_c *symbol);
void *visit(il_param_list_c *symbol);
void *visit(il_param_assignment_c *symbol);
void *visit(il_param_out_assignment_c *symbol);
--- a/stage3/fill_candidate_datatypes.hh Mon Feb 20 17:52:01 2012 +0000
+++ b/stage3/fill_candidate_datatypes.hh Mon Feb 20 19:44:40 2012 +0000
@@ -202,13 +202,11 @@
void *visit(il_jump_operation_c *symbol);
void *visit(il_fb_call_c *symbol);
void *visit(il_formal_funct_call_c *symbol);
- /*
- void *visit(il_operand_list_c *symbol);
- void *visit(simple_instr_list_c *symbol);
- void *visit(il_param_list_c *symbol);
- void *visit(il_param_assignment_c *symbol);
- void *visit(il_param_out_assignment_c *symbol);
- */
+// void *visit(il_operand_list_c *symbol);
+ void *visit(simple_instr_list_c *symbol);
+// void *visit(il_param_list_c *symbol);
+// void *visit(il_param_assignment_c *symbol);
+// void *visit(il_param_out_assignment_c *symbol);
/*******************/
/* B 2.2 Operators */
--- a/stage3/flow_control_analysis.cc Mon Feb 20 17:52:01 2012 +0000
+++ b/stage3/flow_control_analysis.cc Mon Feb 20 19:44:40 2012 +0000
@@ -133,7 +133,8 @@
* label4:
* LD I
*/
-
+ if (NULL != symbol->il_instruction)
+ symbol->il_instruction->accept(*this);
return NULL;
}
@@ -171,16 +172,25 @@
void *flow_control_analysis_c::visit(il_formal_funct_call_c *symbol) {
return NULL;
}
+#endif
+// void *visit(il_operand_list_c *symbol);
+
+void *flow_control_analysis_c::visit(simple_instr_list_c *symbol) {
+ for(int i = 0; i < symbol->n; i++) {
+ prev_il_instruction = NULL;
+ if (i > 0) prev_il_instruction = symbol->elements[i-1];
+ symbol->elements[i]->accept(*this);
+ }
+ return NULL;
+}
+
/*
- void *visit(il_operand_list_c *symbol);
- void *visit(simple_instr_list_c *symbol);
void *visit(il_param_list_c *symbol);
void *visit(il_param_assignment_c *symbol);
void *visit(il_param_out_assignment_c *symbol);
*/
-#endif
--- a/stage3/flow_control_analysis.hh Mon Feb 20 17:52:01 2012 +0000
+++ b/stage3/flow_control_analysis.hh Mon Feb 20 19:44:40 2012 +0000
@@ -91,13 +91,11 @@
// void *visit(il_expression_c *symbol);
// void *visit(il_fb_call_c *symbol);
// void *visit(il_formal_funct_call_c *symbol);
- /*
- void *visit(il_operand_list_c *symbol);
- void *visit(simple_instr_list_c *symbol);
- void *visit(il_param_list_c *symbol);
- void *visit(il_param_assignment_c *symbol);
- void *visit(il_param_out_assignment_c *symbol);
- */
+// void *visit(il_operand_list_c *symbol);
+ void *visit(simple_instr_list_c *symbol);
+// void *visit(il_param_list_c *symbol);
+// void *visit(il_param_assignment_c *symbol);
+// void *visit(il_param_out_assignment_c *symbol);
/*******************/
/* B 2.2 Operators */
--- a/stage3/narrow_candidate_datatypes.cc Mon Feb 20 17:52:01 2012 +0000
+++ b/stage3/narrow_candidate_datatypes.cc Mon Feb 20 19:44:40 2012 +0000
@@ -566,16 +566,18 @@
return NULL;
}
-/* MJS: Manuele, could you please not delete the following 2 lines of comments. They help me understand where this class is used
- * and when it is created by bison - syntax parse, and how it can show up in the abstract syntax tree.
- *
- * Actually, it could be helpful if we could have all the similar comments already present in visit_expression_type_c
- * in the 3 new classes fill/narrow/print candidate datatype
- */
+
/* | il_expr_operator '(' [il_operand] eol_list [simple_instr_list] ')' */
// SYM_REF3(il_expression_c, il_expr_operator, il_operand, simple_instr_list);
void *narrow_candidate_datatypes_c::visit(il_expression_c *symbol) {
-/* MJS: TODO... */
+ symbol_c *save_prev_il_instruction = prev_il_instruction;
+
+ symbol->simple_instr_list->datatype = symbol->datatype;
+ symbol->simple_instr_list->accept(*this);
+
+ prev_il_instruction = save_prev_il_instruction;
+
+ /* TODO: finish this */
return NULL;
}
@@ -638,13 +640,21 @@
}
-/*
- void *visit(il_operand_list_c *symbol);
- void *visit(simple_instr_list_c *symbol);
- void *visit(il_param_list_c *symbol);
- void *visit(il_param_assignment_c *symbol);
- void *visit(il_param_out_assignment_c *symbol);
- */
+// void *visit(il_operand_list_c *symbol);
+void *narrow_candidate_datatypes_c::visit(simple_instr_list_c *symbol) {
+ if (symbol->n > 0)
+ symbol->elements[symbol->n - 1]->datatype = symbol->datatype;
+
+ for(int i = symbol->n-1; i >= 0; i--) {
+ symbol->elements[i]->accept(*this);
+ }
+ return NULL;
+}
+
+// void *visit(il_param_list_c *symbol);
+// void *visit(il_param_assignment_c *symbol);
+// void *visit(il_param_out_assignment_c *symbol);
+
/*******************/
/* B 2.2 Operators */
--- a/stage3/narrow_candidate_datatypes.hh Mon Feb 20 17:52:01 2012 +0000
+++ b/stage3/narrow_candidate_datatypes.hh Mon Feb 20 19:44:40 2012 +0000
@@ -114,13 +114,11 @@
void *visit(il_expression_c *symbol);
void *visit(il_fb_call_c *symbol);
void *visit(il_formal_funct_call_c *symbol);
- /*
- void *visit(il_operand_list_c *symbol);
- void *visit(simple_instr_list_c *symbol);
- void *visit(il_param_list_c *symbol);
- void *visit(il_param_assignment_c *symbol);
- void *visit(il_param_out_assignment_c *symbol);
- */
+// void *visit(il_operand_list_c *symbol);
+ void *visit(simple_instr_list_c *symbol);
+// void *visit(il_param_list_c *symbol);
+// void *visit(il_param_assignment_c *symbol);
+// void *visit(il_param_out_assignment_c *symbol);
/*******************/
/* B 2.2 Operators */