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 && (current_vartype & inoutput_vt) == 0)) { |
958 (wanted_varformat == localinit_vf)) { |
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); |
974 s4o.print(" "); |
974 s4o.print(" "); |
975 } |
975 } |
976 print_variable_prefix(); |
976 print_variable_prefix(); |
977 list->elements[i]->accept(*this); |
977 list->elements[i]->accept(*this); |
978 if (wanted_varformat != local_vf) { |
978 if (wanted_varformat != local_vf) { |
979 if (this->current_var_init_symbol != NULL) { |
979 if (wanted_varformat == localinit_vf && |
980 s4o.print(" = "); |
980 (current_vartype & inoutput_vt) != 0) { |
|
981 s4o.print(";\n"); |
|
982 s4o.print(s4o.indent_spaces); |
|
983 s4o.print("if (__"); |
|
984 list->elements[i]->accept(*this); |
|
985 s4o.print(" != NULL) {\n"); |
|
986 s4o.indent_right(); |
|
987 s4o.print(s4o.indent_spaces); |
|
988 list->elements[i]->accept(*this); |
|
989 s4o.print(" = *__"); |
|
990 list->elements[i]->accept(*this); |
|
991 s4o.print(";\n"); |
|
992 s4o.indent_left(); |
|
993 s4o.print(s4o.indent_spaces); |
|
994 s4o.print("}\n"); |
|
995 s4o.print(s4o.indent_spaces); |
|
996 s4o.print("else {\n"); |
|
997 s4o.indent_right(); |
|
998 s4o.print(s4o.indent_spaces); |
|
999 s4o.print("static const "); |
|
1000 this->current_var_type_symbol->accept(*this); |
|
1001 s4o.print(" temp = "); |
981 this->current_var_init_symbol->accept(*this); |
1002 this->current_var_init_symbol->accept(*this); |
|
1003 s4o.print(";\n"); |
|
1004 s4o.print(s4o.indent_spaces); |
|
1005 list->elements[i]->accept(*this); |
|
1006 s4o.print(" = temp;\n"); |
|
1007 s4o.indent_left(); |
|
1008 s4o.print(s4o.indent_spaces); |
|
1009 s4o.print("}\n"); |
982 } |
1010 } |
983 s4o.print(";\n"); |
1011 else { |
|
1012 if (this->current_var_init_symbol != NULL) { |
|
1013 s4o.print(" = "); |
|
1014 this->current_var_init_symbol->accept(*this); |
|
1015 } |
|
1016 s4o.print(";\n"); |
|
1017 } |
984 } |
1018 } |
985 else if (is_fb) |
1019 else if (is_fb) |
986 s4o.print(";\n"); |
1020 s4o.print(";\n"); |
987 else |
1021 else |
988 s4o.print(")\n"); |
1022 s4o.print(")\n"); |
993 for(int i = 0; i < list->n; i++) { |
1027 for(int i = 0; i < list->n; i++) { |
994 finterface_var_count++; |
1028 finterface_var_count++; |
995 s4o.print(nv->get()); |
1029 s4o.print(nv->get()); |
996 s4o.print("\n" + s4o.indent_spaces); |
1030 s4o.print("\n" + s4o.indent_spaces); |
997 this->current_var_type_symbol->accept(*this); |
1031 this->current_var_type_symbol->accept(*this); |
998 if ((current_vartype & output_vt) != 0) |
1032 if ((current_vartype & (output_vt | inoutput_vt)) != 0) |
999 s4o.print(" *__"); |
1033 s4o.print(" *__"); |
1000 else if ((current_vartype & inoutput_vt) != 0) |
|
1001 s4o.print(" *"); |
|
1002 else |
1034 else |
1003 s4o.print(" "); |
1035 s4o.print(" "); |
1004 list->elements[i]->accept(*this); |
1036 list->elements[i]->accept(*this); |
1005 /* We do not print the initial value at function declaration! |
1037 /* We do not print the initial value at function declaration! |
1006 * It is up to the caller to pass the correct default value |
1038 * It is up to the caller to pass the correct default value |
1012 } |
1044 } |
1013 } |
1045 } |
1014 |
1046 |
1015 if (wanted_varformat == foutputassign_vf) { |
1047 if (wanted_varformat == foutputassign_vf) { |
1016 for(int i = 0; i < list->n; i++) { |
1048 for(int i = 0; i < list->n; i++) { |
1017 if ((current_vartype & output_vt) != 0) { |
1049 if ((current_vartype & (output_vt | inoutput_vt)) != 0) { |
1018 s4o.print(s4o.indent_spaces + "if (__"); |
1050 s4o.print(s4o.indent_spaces + "if (__"); |
1019 list->elements[i]->accept(*this); |
1051 list->elements[i]->accept(*this); |
1020 s4o.print(" != NULL) {\n"); |
1052 s4o.print(" != NULL) {\n"); |
1021 s4o.indent_right(); |
1053 s4o.indent_right(); |
1022 s4o.print(s4o.indent_spaces + "*__"); |
1054 s4o.print(s4o.indent_spaces + "*__"); |