Insert #line directives in generated C code.
--- a/stage4/generate_c/generate_c_base.cc Sat Mar 15 20:10:20 2014 +0000
+++ b/stage4/generate_c/generate_c_base.cc Sun Mar 16 10:16:25 2014 +0000
@@ -90,6 +90,14 @@
s4o.print(variable_prefix_);
}
+ void print_line_directive(symbol_c *symbol) {
+ s4o.print("#line ");
+ s4o.print(symbol->first_line);
+ s4o.print(" \"");
+ s4o.print(symbol->first_file);
+ s4o.print("\"\n");
+ }
+
void *print_token(token_c *token, int offset = 0) {
return s4o.printupper((token->value)+offset);
}
--- a/stage4/generate_c/generate_c_il.cc Sat Mar 15 20:10:20 2014 +0000
+++ b/stage4/generate_c/generate_c_il.cc Sun Mar 16 10:16:25 2014 +0000
@@ -704,12 +704,13 @@
/* Declare the backup to the IL implicit variable, that will store the result of the IL operations executed inside a parenthesis... */
declare_implicit_variable_back();
- /*
- s4o.print(s4o.indent_spaces);
- this->implicit_variable_result_back.accept(*this);
- s4o.print(".INTvar = 0;\n\n");
- */
- print_list(symbol, s4o.indent_spaces, ";\n" + s4o.indent_spaces, ";\n");
+
+ for(int i = 0; i < symbol->n; i++) {
+ print_line_directive(symbol->elements[i]);
+ s4o.print(s4o.indent_spaces);
+ symbol->elements[i]->accept(*this);
+ s4o.print(";\n");
+ }
return NULL;
}
--- a/stage4/generate_c/generate_c_st.cc Sat Mar 15 20:10:20 2014 +0000
+++ b/stage4/generate_c/generate_c_st.cc Sun Mar 16 10:16:25 2014 +0000
@@ -874,7 +874,13 @@
/* B 3.2 Statements */
/********************/
void *visit(statement_list_c *symbol) {
- return print_list(symbol, s4o.indent_spaces, ";\n" + s4o.indent_spaces, ";\n");
+ for(int i = 0; i < symbol->n; i++) {
+ print_line_directive(symbol->elements[i]);
+ s4o.print(s4o.indent_spaces);
+ symbol->elements[i]->accept(*this);
+ s4o.print(";\n");
+ }
+ return NULL;
}
/*********************************/