stage4/generate_c/generate_c_sfc.cc
changeset 350 2c3c4dc34979
parent 279 c0453b7f99df
child 392 9b88b8b6bccd
equal deleted inserted replaced
341:ba80c3ceb6fb 350:2c3c4dc34979
   517             if (strcmp(qualifier, "P") == 0 || strcmp(qualifier, "SD") == 0 || 
   517             if (strcmp(qualifier, "P") == 0 || strcmp(qualifier, "SD") == 0 || 
   518                 strcmp(qualifier, "DS") == 0 || strcmp(qualifier, "SL") == 0) {
   518                 strcmp(qualifier, "DS") == 0 || strcmp(qualifier, "SL") == 0) {
   519               s4o.print("activated");
   519               s4o.print("activated");
   520             }
   520             }
   521             if (strcmp(qualifier, "D") == 0 || strcmp(qualifier, "L") == 0) {
   521             if (strcmp(qualifier, "D") == 0 || strcmp(qualifier, "L") == 0) {
   522               s4o.print("active && __TIME_CMP(");
   522               s4o.print("active && __time_cmp(");
   523               print_step_argument(current_step, "elapsed_time");
   523               print_step_argument(current_step, "elapsed_time");
   524               s4o.print(", ");
   524               s4o.print(", ");
   525               symbol->action_time->accept(*this);
   525               symbol->action_time->accept(*this);
   526               if (strcmp(qualifier, "D") == 0) {
   526               if (strcmp(qualifier, "D") == 0) {
   527                 s4o.print(") >= 0");
   527                 s4o.print(") >= 0");
   638       s4o.print(s4o.indent_spaces +"TIME elapsed_time, current_time;\n\n");
   638       s4o.print(s4o.indent_spaces +"TIME elapsed_time, current_time;\n\n");
   639       
   639       
   640       /* generate elapsed_time initializations */
   640       /* generate elapsed_time initializations */
   641       s4o.print(s4o.indent_spaces + "// Calculate elapsed_time\n");
   641       s4o.print(s4o.indent_spaces + "// Calculate elapsed_time\n");
   642       s4o.print(s4o.indent_spaces +"current_time = __CURRENT_TIME;\n");
   642       s4o.print(s4o.indent_spaces +"current_time = __CURRENT_TIME;\n");
   643       s4o.print(s4o.indent_spaces +"elapsed_time = __time_sub(__BOOL_LITERAL(TRUE), NULL, current_time, ");
   643 //       s4o.print(s4o.indent_spaces +"elapsed_time = __time_sub(__BOOL_LITERAL(TRUE), NULL, current_time, ");
       
   644 //       s4o.print(s4o.indent_spaces +"elapsed_time = SUB_TIME(__BOOL_LITERAL(TRUE), NULL, current_time, ");
       
   645       s4o.print(s4o.indent_spaces +"elapsed_time = __time_sub(current_time, ");
   644       print_variable_prefix();
   646       print_variable_prefix();
   645       s4o.print("__lasttick_time);\n");
   647       s4o.print("__lasttick_time);\n");
   646       s4o.print(s4o.indent_spaces);
   648       s4o.print(s4o.indent_spaces);
   647       print_variable_prefix();
   649       print_variable_prefix();
   648       s4o.print("__lasttick_time = current_time;\n");
   650       s4o.print("__lasttick_time = current_time;\n");
   684       print_variable_prefix();
   686       print_variable_prefix();
   685       s4o.print("__step_list[i].state)) {\n");
   687       s4o.print("__step_list[i].state)) {\n");
   686       s4o.indent_right();
   688       s4o.indent_right();
   687       s4o.print(s4o.indent_spaces);
   689       s4o.print(s4o.indent_spaces);
   688       print_variable_prefix();
   690       print_variable_prefix();
   689       s4o.print("__step_list[i].elapsed_time = __time_add(__BOOL_LITERAL(TRUE), NULL, ");
   691 //      s4o.print("__step_list[i].elapsed_time = __time_add(__BOOL_LITERAL(TRUE), NULL, ");
       
   692 //      s4o.print("__step_list[i].elapsed_time = ADD_TIME(__BOOL_LITERAL(TRUE), NULL, ");
       
   693       s4o.print("__step_list[i].elapsed_time = __time_add(");
   690       print_variable_prefix();
   694       print_variable_prefix();
   691       s4o.print("__step_list[i].elapsed_time, elapsed_time);\n");
   695       s4o.print("__step_list[i].elapsed_time, elapsed_time);\n");
   692       s4o.indent_left();
   696       s4o.indent_left();
   693       s4o.print(s4o.indent_spaces + "}\n");
   697       s4o.print(s4o.indent_spaces + "}\n");
   694       s4o.indent_left();
   698       s4o.indent_left();
   708       s4o.print("__action_list[i].set = 0;\n");
   712       s4o.print("__action_list[i].set = 0;\n");
   709       s4o.print(s4o.indent_spaces);
   713       s4o.print(s4o.indent_spaces);
   710       print_variable_prefix();
   714       print_variable_prefix();
   711       s4o.print("__action_list[i].reset = 0;\n");
   715       s4o.print("__action_list[i].reset = 0;\n");
   712       s4o.print(s4o.indent_spaces + "if (");
   716       s4o.print(s4o.indent_spaces + "if (");
   713       s4o.print("__TIME_CMP(");
   717       s4o.print("__time_cmp(");
   714       print_variable_prefix();
   718       print_variable_prefix();
   715       s4o.print("__action_list[i].set_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0)) > 0) {\n");
   719       s4o.print("__action_list[i].set_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0)) > 0) {\n");
   716       s4o.indent_right();
   720       s4o.indent_right();
   717       s4o.print(s4o.indent_spaces);
   721       s4o.print(s4o.indent_spaces);
   718       print_variable_prefix();
   722       print_variable_prefix();
   719       s4o.print("__action_list[i].set_remaining_time = __time_sub(__BOOL_LITERAL(TRUE), NULL, ");
   723 //       s4o.print("__action_list[i].set_remaining_time = __time_sub(__BOOL_LITERAL(TRUE), NULL, ");
       
   724 //       s4o.print("__action_list[i].set_remaining_time = SUB_TIME(__BOOL_LITERAL(TRUE), NULL, ");
       
   725       s4o.print("__action_list[i].set_remaining_time = __time_sub(");
   720       print_variable_prefix();
   726       print_variable_prefix();
   721       s4o.print("__action_list[i].set_remaining_time, elapsed_time);\n");
   727       s4o.print("__action_list[i].set_remaining_time, elapsed_time);\n");
   722       s4o.print(s4o.indent_spaces + "if (");
   728       s4o.print(s4o.indent_spaces + "if (");
   723       s4o.print("__TIME_CMP(");
   729       s4o.print("__time_cmp(");
   724       print_variable_prefix();
   730       print_variable_prefix();
   725       s4o.print("__action_list[i].set_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0)) <= 0) {\n");
   731       s4o.print("__action_list[i].set_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0)) <= 0) {\n");
   726       s4o.indent_right();
   732       s4o.indent_right();
   727       s4o.print(s4o.indent_spaces);
   733       s4o.print(s4o.indent_spaces);
   728       print_variable_prefix();
   734       print_variable_prefix();
   733       s4o.indent_left();
   739       s4o.indent_left();
   734       s4o.print(s4o.indent_spaces + "}\n");
   740       s4o.print(s4o.indent_spaces + "}\n");
   735       s4o.indent_left();
   741       s4o.indent_left();
   736       s4o.print(s4o.indent_spaces + "}\n");
   742       s4o.print(s4o.indent_spaces + "}\n");
   737       s4o.print(s4o.indent_spaces + "if (");
   743       s4o.print(s4o.indent_spaces + "if (");
   738       s4o.print("__TIME_CMP(");
   744       s4o.print("__time_cmp(");
   739       print_variable_prefix();
   745       print_variable_prefix();
   740       s4o.print("__action_list[i].reset_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0)) > 0) {\n");
   746       s4o.print("__action_list[i].reset_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0)) > 0) {\n");
   741       s4o.indent_right();
   747       s4o.indent_right();
   742       s4o.print(s4o.indent_spaces);
   748       s4o.print(s4o.indent_spaces);
   743       print_variable_prefix();
   749       print_variable_prefix();
   744       s4o.print("__action_list[i].reset_remaining_time = __time_sub(__BOOL_LITERAL(TRUE), NULL, ");
   750 //       s4o.print("__action_list[i].reset_remaining_time = __time_sub(__BOOL_LITERAL(TRUE), NULL, ");
       
   751 //       s4o.print("__action_list[i].reset_remaining_time = SUB_TIME(__BOOL_LITERAL(TRUE), NULL, ");
       
   752       s4o.print("__action_list[i].reset_remaining_time = __time_sub(");
   745       print_variable_prefix();
   753       print_variable_prefix();
   746       s4o.print("__action_list[i].reset_remaining_time, elapsed_time);\n");
   754       s4o.print("__action_list[i].reset_remaining_time, elapsed_time);\n");
   747       s4o.print(s4o.indent_spaces + "if (");
   755       s4o.print(s4o.indent_spaces + "if (");
   748       s4o.print("__TIME_CMP(");
   756       s4o.print("__time_cmp(");
   749       print_variable_prefix();
   757       print_variable_prefix();
   750       s4o.print("__action_list[i].reset_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0)) <= 0) {\n");
   758       s4o.print("__action_list[i].reset_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0)) <= 0) {\n");
   751       s4o.indent_right();
   759       s4o.indent_right();
   752       s4o.print(s4o.indent_spaces);
   760       s4o.print(s4o.indent_spaces);
   753       print_variable_prefix();
   761       print_variable_prefix();