]> sourceware.org Git - systemtap.git/commitdiff
c code generation: assert C indentation/nesting cancels out at appropriate points
authorFrank Ch. Eigler <fche@elastic.org>
Sat, 2 Aug 2008 17:50:28 +0000 (13:50 -0400)
committerFrank Ch. Eigler <fche@elastic.org>
Sat, 2 Aug 2008 17:50:28 +0000 (13:50 -0400)
ChangeLog
translate.cxx
translate.h

index 6a8101bb4ed97d2a6809cfbbcbca4053a127608b..1be62021354c0a4231e8aee8bbd06e613d53eeb1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-08-02  Frank Ch. Eigler  <fche@elastic.org>
+
+       * translate.h (translator_output::assert_0_indent): New function.
+       * translate.cxx (emit_*): Add a couple of calls to confirm
+       newline(1)/(-1) nest matching.
+
 2008-07-30  Dave Brolley  <brolley@redhat.com>
 
        * stap-client (create_request): No need for random suffix for
index c62ba9fdd5331a0716b148ca5ed5413c35fe9f4d..c4370cc841026f003558b9f0cf0e0203a2e36f83 100644 (file)
@@ -4713,6 +4713,7 @@ translate_pass (systemtap_session& s)
           s.up->emit_global_init (s.globals[i]);
         }
       s.op->newline(-1) << "};";
+      s.op->assert_0_indent();
 
       for (unsigned i=0; i<s.functions.size(); i++)
        {
@@ -4720,6 +4721,7 @@ translate_pass (systemtap_session& s)
          s.op->newline();
          s.up->emit_functionsig (s.functions[i]);
        }
+      s.op->assert_0_indent();
 
       for (unsigned i=0; i<s.functions.size(); i++)
        {
@@ -4727,6 +4729,7 @@ translate_pass (systemtap_session& s)
          s.op->newline();
          s.up->emit_function (s.functions[i]);
        }
+      s.op->assert_0_indent();
 
       // Run a varuse_collecting_visitor over probes that need global
       // variable locks.  We'll use this information later in
@@ -4737,18 +4740,21 @@ translate_pass (systemtap_session& s)
         if (s.probes[i]->needs_global_locks())
            s.probes[i]->body->visit (&cup.vcv_needs_global_locks);
        }
+      s.op->assert_0_indent();
 
       for (unsigned i=0; i<s.probes.size(); i++)
         {
           if (pending_interrupts) return 1;
           s.up->emit_probe (s.probes[i]);
         }
+      s.op->assert_0_indent();
 
       s.op->newline();
       s.up->emit_module_init ();
+      s.op->assert_0_indent();
       s.op->newline();
       s.up->emit_module_exit ();
-
+      s.op->assert_0_indent();
       s.op->newline();
 
       // XXX impedance mismatch
@@ -4759,17 +4765,20 @@ translate_pass (systemtap_session& s)
       s.op->newline() << "void probe_exit () {";
       s.op->newline(1) << "systemtap_module_exit ();";
       s.op->newline(-1) << "}";
+      s.op->assert_0_indent();
 
       for (unsigned i=0; i<s.globals.size(); i++)
         {
           s.op->newline();
           s.up->emit_global_param (s.globals[i]);
         }
+      s.op->assert_0_indent();
 
       emit_symbol_data (s);
 
       s.op->newline() << "MODULE_DESCRIPTION(\"systemtap-generated probe\");";
       s.op->newline() << "MODULE_LICENSE(\"GPL\");";
+      s.op->assert_0_indent();
     }
   catch (const semantic_error& e)
     {
index 6c8b4785eacd56a08b899db7d13bf338fd9caf16..9921acd577381a560ea53426268b91969fe5f34f 100644 (file)
@@ -33,6 +33,7 @@ public:
 
   std::ostream& newline (int indent = 0);
   void indent (int indent = 0);
+  void assert_0_indent () { assert (tablevel == 0); }
   std::ostream& line();
 
   std::ostream::pos_type tellp() { return o.tellp(); }
This page took 0.049147 seconds and 5 git commands to generate.