stage4/generate_c/generate_c_sfcdecl.cc
changeset 594 c8092e909886
parent 401 7f052bd3508a
child 628 fe0d516fe291
equal deleted inserted replaced
593:412780374bd3 594:c8092e909886
    87           for(int i = 0; i < symbol->n; i++)
    87           for(int i = 0; i < symbol->n; i++)
    88             symbol->elements[i]->accept(*this);
    88             symbol->elements[i]->accept(*this);
    89           
    89           
    90           /* steps table declaration */
    90           /* steps table declaration */
    91           s4o.print(s4o.indent_spaces + "STEP __step_list[");
    91           s4o.print(s4o.indent_spaces + "STEP __step_list[");
    92           s4o.print_integer(step_number);
    92           s4o.print(step_number);
    93           s4o.print("];\n");
    93           s4o.print("];\n");
    94           s4o.print(s4o.indent_spaces + "UINT __nb_steps;\n");
    94           s4o.print(s4o.indent_spaces + "UINT __nb_steps;\n");
    95           
    95           
    96           /* actions table declaration */
    96           /* actions table declaration */
    97           s4o.print(s4o.indent_spaces + "ACTION __action_list[");
    97           s4o.print(s4o.indent_spaces + "ACTION __action_list[");
    98           s4o.print_integer(action_number);
    98           s4o.print(action_number);
    99           s4o.print("];\n");
    99           s4o.print("];\n");
   100           s4o.print(s4o.indent_spaces + "UINT __nb_actions;\n");
   100           s4o.print(s4o.indent_spaces + "UINT __nb_actions;\n");
   101           
   101           
   102           /* transitions table declaration */
   102           /* transitions table declaration */
   103           s4o.print(s4o.indent_spaces + "__IEC_BOOL_t __transition_list[");
   103           s4o.print(s4o.indent_spaces + "__IEC_BOOL_t __transition_list[");
   104           s4o.print_integer(transition_number);
   104           s4o.print(transition_number);
   105           s4o.print("];\n");
   105           s4o.print("];\n");
   106           
   106           
   107           /* transitions debug table declaration */
   107           /* transitions debug table declaration */
   108           s4o.print(s4o.indent_spaces + "__IEC_BOOL_t __debug_transition_list[");
   108           s4o.print(s4o.indent_spaces + "__IEC_BOOL_t __debug_transition_list[");
   109           s4o.print_integer(transition_number);
   109           s4o.print(transition_number);
   110           s4o.print("];\n");
   110           s4o.print("];\n");
   111           s4o.print(s4o.indent_spaces + "UINT __nb_transitions;\n");
   111           s4o.print(s4o.indent_spaces + "UINT __nb_transitions;\n");
   112           
   112           
   113           /* last_ticktime declaration */
   113           /* last_ticktime declaration */
   114           s4o.print(s4o.indent_spaces + "TIME __lasttick_time;\n");
   114           s4o.print(s4o.indent_spaces + "TIME __lasttick_time;\n");
   122           for(int i = 0; i < symbol->n; i++)
   122           for(int i = 0; i < symbol->n; i++)
   123             symbol->elements[i]->accept(*this);
   123             symbol->elements[i]->accept(*this);
   124           s4o.print(s4o.indent_spaces);
   124           s4o.print(s4o.indent_spaces);
   125           print_variable_prefix();
   125           print_variable_prefix();
   126           s4o.print("__nb_steps = ");
   126           s4o.print("__nb_steps = ");
   127           s4o.print_integer(step_number);
   127           s4o.print(step_number);
   128           s4o.print(";\n");
   128           s4o.print(";\n");
   129           step_number = 0;
   129           step_number = 0;
   130           wanted_sfcdeclaration = sfcinit_sd;
   130           wanted_sfcdeclaration = sfcinit_sd;
   131           
   131           
   132           /* steps table initialisation */
   132           /* steps table initialisation */
   148           for(int i = 0; i < symbol->n; i++)
   148           for(int i = 0; i < symbol->n; i++)
   149             symbol->elements[i]->accept(*this);
   149             symbol->elements[i]->accept(*this);
   150           s4o.print(s4o.indent_spaces);
   150           s4o.print(s4o.indent_spaces);
   151           print_variable_prefix();
   151           print_variable_prefix();
   152           s4o.print("__nb_actions = ");
   152           s4o.print("__nb_actions = ");
   153           s4o.print_integer(action_number);
   153           s4o.print(action_number);
   154           s4o.print(";\n");
   154           s4o.print(";\n");
   155           action_number = 0;
   155           action_number = 0;
   156           wanted_sfcdeclaration = sfcinit_sd;
   156           wanted_sfcdeclaration = sfcinit_sd;
   157           
   157           
   158           /* actions table initialisation */
   158           /* actions table initialisation */
   172           for(int i = 0; i < symbol->n; i++)
   172           for(int i = 0; i < symbol->n; i++)
   173             symbol->elements[i]->accept(*this);
   173             symbol->elements[i]->accept(*this);
   174           s4o.print(s4o.indent_spaces);
   174           s4o.print(s4o.indent_spaces);
   175           print_variable_prefix();
   175           print_variable_prefix();
   176           s4o.print("__nb_transitions = ");
   176           s4o.print("__nb_transitions = ");
   177           s4o.print_integer(transition_number);
   177           s4o.print(transition_number);
   178           s4o.print(";\n");
   178           s4o.print(";\n");
   179           transition_number = 0;
   179           transition_number = 0;
   180           wanted_sfcdeclaration = sfcinit_sd;
   180           wanted_sfcdeclaration = sfcinit_sd;
   181 
   181 
   182           /* last_ticktime initialisation */
   182           /* last_ticktime initialisation */
   197             for(pt = variable_list.begin(); pt != variable_list.end(); pt++) {
   197             for(pt = variable_list.begin(); pt != variable_list.end(); pt++) {
   198               s4o.print("#define ");
   198               s4o.print("#define ");
   199               s4o.print(SFC_STEP_ACTION_PREFIX);
   199               s4o.print(SFC_STEP_ACTION_PREFIX);
   200               pt->symbol->accept(*this);
   200               pt->symbol->accept(*this);
   201               s4o.print(" ");
   201               s4o.print(" ");
   202               s4o.print_integer(action_number);
   202               s4o.print(action_number);
   203               s4o.print("\n");
   203               s4o.print("\n");
   204               action_number++;
   204               action_number++;
   205             }
   205             }
   206           }
   206           }
   207           for(int i = 0; i < symbol->n; i++)
   207           for(int i = 0; i < symbol->n; i++)
   249           s4o.print(s4o.indent_spaces);
   249           s4o.print(s4o.indent_spaces);
   250           s4o.print(SET_VAR);
   250           s4o.print(SET_VAR);
   251           s4o.print("(");
   251           s4o.print("(");
   252           print_variable_prefix();
   252           print_variable_prefix();
   253           s4o.print(",__step_list[");
   253           s4o.print(",__step_list[");
   254           s4o.print_integer(step_number);
   254           s4o.print(step_number);
   255           s4o.print("].state,1);\n");
   255           s4o.print("].state,1);\n");
   256           step_number++;
   256           step_number++;
   257           break;
   257           break;
   258         case stepdef_sd:
   258         case stepdef_sd:
   259           s4o.print("#define ");
   259           s4o.print("#define ");
   260           s4o.print(SFC_STEP_ACTION_PREFIX);
   260           s4o.print(SFC_STEP_ACTION_PREFIX);
   261           symbol->step_name->accept(*this);
   261           symbol->step_name->accept(*this);
   262           s4o.print(" ");
   262           s4o.print(" ");
   263           s4o.print_integer(step_number);
   263           s4o.print(step_number);
   264           s4o.print("\n");
   264           s4o.print("\n");
   265           step_number++;
   265           step_number++;
   266           break;
   266           break;
   267         case stepundef_sd:
   267         case stepundef_sd:
   268           s4o.print("#undef ");
   268           s4o.print("#undef ");
   290         case stepdef_sd:
   290         case stepdef_sd:
   291           s4o.print("#define ");
   291           s4o.print("#define ");
   292           s4o.print(SFC_STEP_ACTION_PREFIX);
   292           s4o.print(SFC_STEP_ACTION_PREFIX);
   293           symbol->step_name->accept(*this);
   293           symbol->step_name->accept(*this);
   294           s4o.print(" ");
   294           s4o.print(" ");
   295           s4o.print_integer(step_number);
   295           s4o.print(step_number);
   296           s4o.print("\n");
   296           s4o.print("\n");
   297           step_number++;
   297           step_number++;
   298           break;
   298           break;
   299         case stepundef_sd:
   299         case stepundef_sd:
   300           s4o.print("#undef ");
   300           s4o.print("#undef ");
   344         case actiondef_sd:
   344         case actiondef_sd:
   345           s4o.print("#define ");
   345           s4o.print("#define ");
   346           s4o.print(SFC_STEP_ACTION_PREFIX);
   346           s4o.print(SFC_STEP_ACTION_PREFIX);
   347           symbol->action_name->accept(*this);
   347           symbol->action_name->accept(*this);
   348           s4o.print(" ");
   348           s4o.print(" ");
   349           s4o.print_integer(action_number);
   349           s4o.print(action_number);
   350           s4o.print("\n");
   350           s4o.print("\n");
   351           action_number++;
   351           action_number++;
   352           break;
   352           break;
   353         case actionundef_sd:
   353         case actionundef_sd:
   354           s4o.print("#undef ");
   354           s4o.print("#undef ");