warning elimination reported by clang
[deliverable/titan.core.git] / compiler2 / AST.cc
index da8696b515b231f9316405abc92fe19291a929f2..82686289f829e85b3b30aefd6995e1015ae5ff5d 100644 (file)
@@ -815,8 +815,9 @@ namespace Common {
     // pre_init function
     bool has_pre_init = false;
     bool profiled = MOD_TTCN == get_moduletype() && is_file_profiled(get_filename());
+    bool debugged = debugger_active && MOD_TTCN == get_moduletype();
     // always generate pre_init_module if the file is profiled
-    if (output->functions.pre_init || profiled) {
+    if (output->functions.pre_init || profiled || debugged) {
       output->source.static_function_prototypes =
        mputstr(output->source.static_function_prototypes,
          "static void pre_init_module();\n");
@@ -848,6 +849,10 @@ namespace Common {
             "TTCN3_Stack_Depth stack_depth;\n"
             "ttcn3_prof.execute_line(\"%s\", 0);\n", get_modid().get_name().c_str(), get_filename());
         }
+        if (debugged) {
+          output->source.static_function_bodies = mputprintf(output->source.static_function_bodies,
+            "%s::init_ttcn3_debugger();\n", get_modid().get_name().c_str());
+        }
       }
       output->source.static_function_bodies =
         mputstr(output->source.static_function_bodies, output->functions.pre_init);
@@ -1032,19 +1037,19 @@ namespace Common {
     // All we can do is store NULLs for the unused namespaces.
     size_t num_xml_namespaces = namespaces.size();
     if (moduletype == MOD_TTCN) { //TODO remove this when ASN.1 gets EXER
-      output->source.global_vars = mputprintf(output->source.global_vars,
 #ifndef NDEBUG
+      output->source.global_vars = mputprintf(output->source.global_vars,
         "// written by %s in " __FILE__ " at %d\n"
-#endif
-        "static const size_t num_namespaces = %lu;\n"
-#ifndef NDEBUG
         , __FUNCTION__, __LINE__
-#endif
-        , (unsigned long)num_xml_namespaces
       );
+#endif
+
       if (num_xml_namespaces != 0 || (control_ns && control_ns_prefix)) {
-        output->source.global_vars = mputstr(output->source.global_vars,
-          "static const namespace_t xml_namespaces[num_namespaces+1] = {\n");
+        output->source.global_vars = mputprintf(output->source.global_vars,
+          "static const size_t num_namespaces = %lu;\n"
+          "static const namespace_t xml_namespaces[num_namespaces+1] = {\n"
+          , (unsigned long)num_xml_namespaces
+        );
         for (size_t i=0; i < namespaces.size(); ++i) {
           if (used_namespaces.has_key(i)) {
             output->source.global_vars = mputprintf(output->source.global_vars,
@@ -1564,7 +1569,7 @@ namespace Common {
         "{\n");
       char* function_name = 0;
       int line_no = -1;
-      while(get_profiler_code_line(get_filename(), &function_name, &line_no)) {
+      while (get_profiler_code_line(get_filename(), &function_name, &line_no)) {
         output->source.global_vars = mputprintf(output->source.global_vars,
           "  ttcn3_prof.create_line(ttcn3_prof.get_element(\"%s\"), %d);\n",
           get_filename(), line_no);
@@ -1574,7 +1579,15 @@ namespace Common {
             get_filename(), line_no, function_name);
         }
       }
-      output->source.global_vars = mputstr(output->source.global_vars, "}\n\n");
+      output->source.global_vars = mputstr(output->source.global_vars, "}\n");
+    }
+    /* TTCN-3 debugger:
+       generate the printing function for the types defined in this module
+       and initialize the debugger with this module's global variables,
+       component types and the components' variables */
+    if (debugger_active) {
+      generate_debugger_functions(output);
+      generate_debugger_init(output);
     }
   }
 
This page took 0.025119 seconds and 5 git commands to generate.