stage4/generate_c/generate_c_vardecl.cc
changeset 235 ed66dc50f31a
parent 230 816846a8d66b
child 236 c55b02ca2342
equal deleted inserted replaced
234:e4d31cd0e6d8 235:ed66dc50f31a
   953       if (list == NULL) ERROR;
   953       if (list == NULL) ERROR;
   954 
   954 
   955       /* now to produce the c equivalent... */
   955       /* now to produce the c equivalent... */
   956       if ((wanted_varformat == local_vf) ||
   956       if ((wanted_varformat == local_vf) ||
   957           (wanted_varformat == init_vf) ||
   957           (wanted_varformat == init_vf) ||
   958           (wanted_varformat == localinit_vf)) {
   958           (wanted_varformat == localinit_vf && (current_vartype & inoutput_vt) == 0)) {
   959         for(int i = 0; i < list->n; i++) {
   959         for(int i = 0; i < list->n; i++) {
   960           s4o.print(s4o.indent_spaces);
   960           s4o.print(s4o.indent_spaces);
   961           if (wanted_varformat == local_vf) {
   961           if (wanted_varformat == local_vf) {
   962         	if (!is_fb) {
   962         	if (!is_fb) {
   963         	  s4o.print(DECLARE_VAR);
   963         	  s4o.print(DECLARE_VAR);
   993         for(int i = 0; i < list->n; i++) {
   993         for(int i = 0; i < list->n; i++) {
   994           finterface_var_count++;
   994           finterface_var_count++;
   995           s4o.print(nv->get());
   995           s4o.print(nv->get());
   996           s4o.print("\n" + s4o.indent_spaces);
   996           s4o.print("\n" + s4o.indent_spaces);
   997           this->current_var_type_symbol->accept(*this);
   997           this->current_var_type_symbol->accept(*this);
   998           if ((current_vartype & (output_vt | inoutput_vt)) != 0)
   998           if ((current_vartype & output_vt) != 0)
   999             s4o.print(" *__");
   999             s4o.print(" *__");
       
  1000           else if ((current_vartype & inoutput_vt) != 0)
       
  1001             s4o.print(" *");
  1000           else
  1002           else
  1001             s4o.print(" ");
  1003             s4o.print(" ");
  1002           list->elements[i]->accept(*this);
  1004           list->elements[i]->accept(*this);
  1003           /* We do not print the initial value at function declaration!
  1005           /* We do not print the initial value at function declaration!
  1004            * It is up to the caller to pass the correct default value
  1006            * It is up to the caller to pass the correct default value
  1010         }
  1012         }
  1011       }
  1013       }
  1012 
  1014 
  1013       if (wanted_varformat == foutputassign_vf) {
  1015       if (wanted_varformat == foutputassign_vf) {
  1014         for(int i = 0; i < list->n; i++) {
  1016         for(int i = 0; i < list->n; i++) {
  1015           if ((current_vartype & (output_vt | inoutput_vt)) != 0) {
  1017           if ((current_vartype & output_vt) != 0) {
  1016             s4o.print(s4o.indent_spaces + "if (__");
  1018             s4o.print(s4o.indent_spaces + "if (__");
  1017             list->elements[i]->accept(*this);
  1019             list->elements[i]->accept(*this);
  1018             s4o.print(" != NULL) {\n");
  1020             s4o.print(" != NULL) {\n");
  1019             s4o.indent_right();
  1021             s4o.indent_right();
  1020             s4o.print(s4o.indent_spaces + "*__");
  1022             s4o.print(s4o.indent_spaces + "*__");