blob: e5665dfca55449c833e9026bda85d6942605017f [file] [log] [blame]
/* translation of file(s)
"abs.k"
"main.k"
"parse.k"
"error.k"
"occur.k"
"util.k"
"gen.k"
"gutil.k"
"pat.k"
*/
/* generated by:
* @(#)$Author$
*/
#define KC_UNPARSE
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include "k.h"
#include "unpk.h"
namespace kc {
base_uview_class base_uview;
view_filename_class view_filename;
view_error_class view_error;
view_error_tID_class view_error_tID;
view_check_class view_check;
view_check_count_class view_check_count;
view_check_count1_class view_check_count1;
view_check_outmostopers_in_phylum_class view_check_outmostopers_in_phylum;
view_set_type_class view_set_type;
view_check_is_var_class view_check_is_var;
view_gen_initializephyla_c_class view_gen_initializephyla_c;
view_check_u_class view_check_u;
view_check_r_class view_check_r;
view_check_viewnames_class view_check_viewnames;
view_check_uniq_class view_check_uniq;
view_check_uniq1_class view_check_uniq1;
view_check_uniq2_class view_check_uniq2;
view_make_patternreps_class view_make_patternreps;
view_printer_outputfileline_class view_printer_outputfileline;
view_printer_reset_class view_printer_reset;
view_no_of_printed_string_chars_reset_class view_no_of_printed_string_chars_reset;
view_open_namespace_class view_open_namespace;
view_close_namespace_class view_close_namespace;
view_gen_k_h_class view_gen_k_h;
view_gen_end_k_h_class view_gen_end_k_h;
view_gen_k_c_class view_gen_k_c;
view_gen_alloc_h_class view_gen_alloc_h;
view_gen_alloc_c_class view_gen_alloc_c;
view_gen_deprecated_class view_gen_deprecated;
view_gen_enumphyla_h_class view_gen_enumphyla_h;
view_gen_enumoperators_h_class view_gen_enumoperators_h;
view_gen_operatormap_type_h_class view_gen_operatormap_type_h;
view_gen_phylummap_c_class view_gen_phylummap_c;
view_gen_operatormap_c_class view_gen_operatormap_c;
view_count_args_class view_count_args;
view_count_attrs_class view_count_attrs;
view_count_nonstaticmembers_class view_count_nonstaticmembers;
view_gen_operatormap_subphyla_class view_gen_operatormap_subphyla;
view_gen_operatormap_attributes_class view_gen_operatormap_attributes;
view_gen_uniqmap_c_class view_gen_uniqmap_c;
view_gen_uniqmap_c_1_class view_gen_uniqmap_c_1;
view_gen_uniqmap_c_2_class view_gen_uniqmap_c_2;
view_gen_nodetypedefs_h_class view_gen_nodetypedefs_h;
view_gen_nodetypes_h_class view_gen_nodetypes_h;
view_gen_yaccstacktype_h_class view_gen_yaccstacktype_h;
view_gen_noofoperators_h_class view_gen_noofoperators_h;
view_gen_assertmacros_h_class view_gen_assertmacros_h;
view_gen_assertmacros_c_class view_gen_assertmacros_c;
view_gen_operatordecls_h_class view_gen_operatordecls_h;
view_gen_operatorcast_h_class view_gen_operatorcast_h;
view_gen_operatordefs_c_class view_gen_operatordefs_c;
view_gen_operatordefs_c_0_class view_gen_operatordefs_c_0;
view_gen_operatordefs_c_1_class view_gen_operatordefs_c_1;
view_gen_operatordefs_c_2_class view_gen_operatordefs_c_2;
view_gen_initializephyla_whiletest_c_class view_gen_initializephyla_whiletest_c;
view_gen_initializephyla_init_el_c_class view_gen_initializephyla_init_el_c;
view_gen_initializephyla_update_loop_c_class view_gen_initializephyla_update_loop_c;
view_gen_operatordefs_nonhash_c_class view_gen_operatordefs_nonhash_c;
view_gen_operatordefs_hash_c_class view_gen_operatordefs_hash_c;
view_gen_access_functions_class view_gen_access_functions;
view_gen_create_function_class view_gen_create_function;
view_gen_attributeOf_function_class view_gen_attributeOf_function;
view_gen_argseqnr_class view_gen_argseqnr;
view_gen_fnarg_asserts_class view_gen_fnarg_asserts;
view_gen_fnarg_and_decls_class view_gen_fnarg_and_decls;
view_gen_fnarg_and_decls_predef_class view_gen_fnarg_and_decls_predef;
view_gen_assignments_class view_gen_assignments;
view_gen_assignment_inis_class view_gen_assignment_inis;
view_gen_user_assignment_inis_class view_gen_user_assignment_inis;
view_gen_assignments_predef_class view_gen_assignments_predef;
view_gen_assignments_predef_ini_class view_gen_assignments_predef_ini;
view_gen_test_class view_gen_test;
view_gen_error_decls_h_class view_gen_error_decls_h;
view_gen_error_defs_c_class view_gen_error_defs_c;
view_gen_printdotdecls_h_class view_gen_printdotdecls_h;
view_gen_printdotdefs_c_class view_gen_printdotdefs_c;
view_gen_printdotedges_c_class view_gen_printdotedges_c;
view_gen_listdecls_h_class view_gen_listdecls_h;
view_gen_listdefs_c_class view_gen_listdefs_c;
view_gen_includes_class view_gen_includes;
view_do_gen_includes_class view_do_gen_includes;
view_gen_csgio_start_h_class view_gen_csgio_start_h;
view_gen_csgio_end_h_class view_gen_csgio_end_h;
view_gen_csgio_h_class view_gen_csgio_h;
view_gen_csgio_start_c_class view_gen_csgio_start_c;
view_gen_csgio_c_class view_gen_csgio_c;
view_gen_copy_attributes_c_class view_gen_copy_attributes_c;
view_gen_copydefs_c_class view_gen_copydefs_c;
view_gen_rewritek_h_class view_gen_rewritek_h;
view_gen_end_rewritek_h_class view_gen_end_rewritek_h;
view_gen_rewritek_c_class view_gen_rewritek_c;
view_gen_rewritedefs_c_class view_gen_rewritedefs_c;
view_gen_rewritedefs_default_c_class view_gen_rewritedefs_default_c;
view_gen_rewritedefs_other_c_class view_gen_rewritedefs_other_c;
view_gen_rewritedefs_rewritearg_c_class view_gen_rewritedefs_rewritearg_c;
view_gen_rewritedefs_nl_arg_c_class view_gen_rewritedefs_nl_arg_c;
view_gen_rewritedefs_testarg_c_class view_gen_rewritedefs_testarg_c;
view_gen_rewritedefs_dotestarg_c_class view_gen_rewritedefs_dotestarg_c;
view_gen_rewritedefs_args_c_class view_gen_rewritedefs_args_c;
view_gen_rewritedefs_body_c_class view_gen_rewritedefs_body_c;
view_gen_withcases_and_default_class view_gen_withcases_and_default;
view_rw_predicates_class view_rw_predicates;
view_wc_predicates_class view_wc_predicates;
view_unp_predicates_class view_unp_predicates;
view_wc_bindings_class view_wc_bindings;
view_unp_bindings_class view_unp_bindings;
view_rw_bindings_class view_rw_bindings;
view_gen_fnk_h_class view_gen_fnk_h;
view_gen_fnkdecls_c_class view_gen_fnkdecls_c;
view_gen_fnk_c_class view_gen_fnk_c;
view_gen_fn_pointer_name_class view_gen_fn_pointer_name;
view_gen_fnkargs_class view_gen_fnkargs;
view_gen_fnkdecls_class view_gen_fnkdecls;
view_gen_fns_start_h_class view_gen_fns_start_h;
view_gen_fns_end_h_class view_gen_fns_end_h;
view_gen_fns_start_c_class view_gen_fns_start_c;
view_gen_fns_owninclude_c_class view_gen_fns_owninclude_c;
view_gen_unpk_h_class view_gen_unpk_h;
view_gen_unparsedecls_h_class view_gen_unparsedecls_h;
view_gen_rewritedecls_h_class view_gen_rewritedecls_h;
view_uview_def_class view_uview_def;
view_gen_end_unpk_h_class view_gen_end_unpk_h;
view_gen_unpk_c_class view_gen_unpk_c;
view_gen_default_types_unpk_c_class view_gen_default_types_unpk_c;
view_gen_unparsedefs_c_class view_gen_unparsedefs_c;
view_gen_unparsedefs_other_c_class view_gen_unparsedefs_other_c;
view_gen_unpstr_c_class view_gen_unpstr_c;
view_gen_user_predicates_class view_gen_user_predicates;
view_predicate_bindings_class view_predicate_bindings;
view_checklanguagenames_class view_checklanguagenames;
view_output_collection_class view_output_collection;
view_gen_classdecls1_h_class view_gen_classdecls1_h;
view_gen_classdecls2_h_class view_gen_classdecls2_h;
view_gen_classdefs_c_class view_gen_classdefs_c;
view_gen_subphylumdefs_c_class view_gen_subphylumdefs_c;
view_gen_cast_class view_gen_cast;
view_gen_hashtables_h_class view_gen_hashtables_h;
view_gen_hashtables_c_class view_gen_hashtables_c;
view_gen_yxx_union_h_class view_gen_yxx_union_h;
view_gen_member_dcl_h_class view_gen_member_dcl_h;
view_gen_set_subphylumdefs_c_class view_gen_set_subphylumdefs_c;
view_gen_viewvars_c_class view_gen_viewvars_c;
view_gen_argseqnr_rec_class view_gen_argseqnr_rec;
view_gen_opt_const_class view_gen_opt_const;
view_uview_class_decl_class view_uview_class_decl;
view_uview_class_def_class view_uview_class_def;
view_rview_class_decl_class view_rview_class_decl;
view_rview_class_def_class view_rview_class_def;
view_collect_strings_class view_collect_strings;
view_class_of_op_class view_class_of_op;
view_class_of_phy_class view_class_of_phy;
impl_uviews uviews[] = {
{"base_uview",&base_uview},
{"view_error_format", 0},
{"view_filename",&view_filename},
{"view_error",&view_error},
{"view_error_tID",&view_error_tID},
{"view_check",&view_check},
{"view_check_count",&view_check_count},
{"view_check_count1",&view_check_count1},
{"view_check_outmostopers_in_phylum",&view_check_outmostopers_in_phylum},
{"view_set_type",&view_set_type},
{"view_check_is_var",&view_check_is_var},
{"view_gen_initializephyla_c",&view_gen_initializephyla_c},
{"view_check_u",&view_check_u},
{"view_check_r",&view_check_r},
{"view_check_viewnames",&view_check_viewnames},
{"view_check_uniq",&view_check_uniq},
{"view_check_uniq1",&view_check_uniq1},
{"view_check_uniq2",&view_check_uniq2},
{"view_make_patternreps",&view_make_patternreps},
{"view_printer_outputfileline",&view_printer_outputfileline},
{"view_printer_reset",&view_printer_reset},
{"view_no_of_printed_string_chars_reset",&view_no_of_printed_string_chars_reset},
{"view_open_namespace",&view_open_namespace},
{"view_close_namespace",&view_close_namespace},
{"view_gen_k_h",&view_gen_k_h},
{"view_gen_end_k_h",&view_gen_end_k_h},
{"view_gen_k_c",&view_gen_k_c},
{"view_gen_alloc_h",&view_gen_alloc_h},
{"view_gen_alloc_c",&view_gen_alloc_c},
{"view_gen_deprecated",&view_gen_deprecated},
{"view_gen_enumphyla_h",&view_gen_enumphyla_h},
{"view_gen_enumoperators_h",&view_gen_enumoperators_h},
{"view_gen_operatormap_type_h",&view_gen_operatormap_type_h},
{"view_gen_phylummap_c",&view_gen_phylummap_c},
{"view_gen_operatormap_c",&view_gen_operatormap_c},
{"view_count_args",&view_count_args},
{"view_count_attrs",&view_count_attrs},
{"view_count_nonstaticmembers",&view_count_nonstaticmembers},
{"view_gen_operatormap_subphyla",&view_gen_operatormap_subphyla},
{"view_gen_operatormap_attributes",&view_gen_operatormap_attributes},
{"view_gen_uniqmap_c",&view_gen_uniqmap_c},
{"view_gen_uniqmap_c_1",&view_gen_uniqmap_c_1},
{"view_gen_uniqmap_c_2",&view_gen_uniqmap_c_2},
{"view_gen_nodetypedefs_h",&view_gen_nodetypedefs_h},
{"view_gen_nodetypes_h",&view_gen_nodetypes_h},
{"view_gen_yaccstacktype_h",&view_gen_yaccstacktype_h},
{"view_gen_noofoperators_h",&view_gen_noofoperators_h},
{"view_gen_assertmacros_h",&view_gen_assertmacros_h},
{"view_gen_assertmacros_c",&view_gen_assertmacros_c},
{"view_gen_operatordecls_h",&view_gen_operatordecls_h},
{"view_gen_operatorcast_h",&view_gen_operatorcast_h},
{"view_gen_operatordefs_c",&view_gen_operatordefs_c},
{"view_gen_operatordefs_c_0",&view_gen_operatordefs_c_0},
{"view_gen_operatordefs_c_1",&view_gen_operatordefs_c_1},
{"view_gen_operatordefs_c_2",&view_gen_operatordefs_c_2},
{"view_gen_initializephyla_whiletest_c",&view_gen_initializephyla_whiletest_c},
{"view_gen_initializephyla_init_el_c",&view_gen_initializephyla_init_el_c},
{"view_gen_initializephyla_update_loop_c",&view_gen_initializephyla_update_loop_c},
{"view_gen_operatordefs_nonhash_c",&view_gen_operatordefs_nonhash_c},
{"view_gen_operatordefs_hash_c",&view_gen_operatordefs_hash_c},
{"view_gen_access_functions",&view_gen_access_functions},
{"view_gen_create_function",&view_gen_create_function},
{"view_gen_attributeOf_function",&view_gen_attributeOf_function},
{"view_gen_argseqnr",&view_gen_argseqnr},
{"view_gen_fnarg_asserts",&view_gen_fnarg_asserts},
{"view_gen_fnarg_and_decls",&view_gen_fnarg_and_decls},
{"view_gen_fnarg_and_decls_predef",&view_gen_fnarg_and_decls_predef},
{"view_gen_assignments",&view_gen_assignments},
{"view_gen_assignment_inis",&view_gen_assignment_inis},
{"view_gen_user_assignment_inis",&view_gen_user_assignment_inis},
{"view_gen_assignments_predef",&view_gen_assignments_predef},
{"view_gen_assignments_predef_ini",&view_gen_assignments_predef_ini},
{"view_gen_test",&view_gen_test},
{"view_gen_error_decls_h",&view_gen_error_decls_h},
{"view_gen_error_defs_c",&view_gen_error_defs_c},
{"view_gen_printdotdecls_h",&view_gen_printdotdecls_h},
{"view_gen_printdotdefs_c",&view_gen_printdotdefs_c},
{"view_gen_printdotedges_c",&view_gen_printdotedges_c},
{"view_gen_listdecls_h",&view_gen_listdecls_h},
{"view_gen_listdefs_c",&view_gen_listdefs_c},
{"view_gen_includes",&view_gen_includes},
{"view_do_gen_includes",&view_do_gen_includes},
{"view_gen_csgio_start_h",&view_gen_csgio_start_h},
{"view_gen_csgio_end_h",&view_gen_csgio_end_h},
{"view_gen_csgio_h",&view_gen_csgio_h},
{"view_gen_csgio_start_c",&view_gen_csgio_start_c},
{"view_gen_csgio_c",&view_gen_csgio_c},
{"view_gen_copy_attributes_c",&view_gen_copy_attributes_c},
{"view_gen_copydefs_c",&view_gen_copydefs_c},
{"view_gen_rewritek_h",&view_gen_rewritek_h},
{"view_gen_end_rewritek_h",&view_gen_end_rewritek_h},
{"view_gen_rewritek_c",&view_gen_rewritek_c},
{"view_gen_rewritedefs_c",&view_gen_rewritedefs_c},
{"view_gen_rewritedefs_default_c",&view_gen_rewritedefs_default_c},
{"view_gen_rewritedefs_other_c",&view_gen_rewritedefs_other_c},
{"view_gen_rewritedefs_rewritearg_c",&view_gen_rewritedefs_rewritearg_c},
{"view_gen_rewritedefs_nl_arg_c",&view_gen_rewritedefs_nl_arg_c},
{"view_gen_rewritedefs_testarg_c",&view_gen_rewritedefs_testarg_c},
{"view_gen_rewritedefs_dotestarg_c",&view_gen_rewritedefs_dotestarg_c},
{"view_gen_rewritedefs_args_c",&view_gen_rewritedefs_args_c},
{"view_gen_rewritedefs_body_c",&view_gen_rewritedefs_body_c},
{"view_gen_withcases_and_default",&view_gen_withcases_and_default},
{"view_rw_predicates",&view_rw_predicates},
{"view_wc_predicates",&view_wc_predicates},
{"view_unp_predicates",&view_unp_predicates},
{"view_wc_bindings",&view_wc_bindings},
{"view_unp_bindings",&view_unp_bindings},
{"view_rw_bindings",&view_rw_bindings},
{"view_gen_fnk_h",&view_gen_fnk_h},
{"view_gen_fnkdecls_c",&view_gen_fnkdecls_c},
{"view_gen_fnk_c",&view_gen_fnk_c},
{"view_gen_fn_pointer_name",&view_gen_fn_pointer_name},
{"view_gen_fnkargs",&view_gen_fnkargs},
{"view_gen_fnkdecls",&view_gen_fnkdecls},
{"view_gen_fns_start_h",&view_gen_fns_start_h},
{"view_gen_fns_end_h",&view_gen_fns_end_h},
{"view_gen_fns_start_c",&view_gen_fns_start_c},
{"view_gen_fns_owninclude_c",&view_gen_fns_owninclude_c},
{"view_gen_unpk_h",&view_gen_unpk_h},
{"view_gen_unparsedecls_h",&view_gen_unparsedecls_h},
{"view_gen_rewritedecls_h",&view_gen_rewritedecls_h},
{"view_uview_def",&view_uview_def},
{"view_gen_end_unpk_h",&view_gen_end_unpk_h},
{"view_gen_unpk_c",&view_gen_unpk_c},
{"view_gen_default_types_unpk_c",&view_gen_default_types_unpk_c},
{"view_gen_unparsedefs_c",&view_gen_unparsedefs_c},
{"view_gen_unparsedefs_default_c", 0},
{"view_gen_unparsedefs_other_c",&view_gen_unparsedefs_other_c},
{"view_gen_unpstr_c",&view_gen_unpstr_c},
{"view_gen_user_predicates",&view_gen_user_predicates},
{"view_predicate_bindings",&view_predicate_bindings},
{"view_checklanguagenames",&view_checklanguagenames},
{"view_output_collection",&view_output_collection},
{"view_gen_classdecls1_h",&view_gen_classdecls1_h},
{"view_gen_classdecls2_h",&view_gen_classdecls2_h},
{"view_gen_classdefs_c",&view_gen_classdefs_c},
{"view_gen_subphylumdefs_c",&view_gen_subphylumdefs_c},
{"view_gen_cast",&view_gen_cast},
{"view_gen_hashtables_h",&view_gen_hashtables_h},
{"view_gen_hashtables_c",&view_gen_hashtables_c},
{"view_gen_yxx_union_h",&view_gen_yxx_union_h},
{"view_gen_member_dcl_h",&view_gen_member_dcl_h},
{"view_gen_set_subphylumdefs_c",&view_gen_set_subphylumdefs_c},
{"view_gen_viewvars_c",&view_gen_viewvars_c},
{"view_gen_argseqnr_rec",&view_gen_argseqnr_rec},
{"view_gen_opt_const",&view_gen_opt_const},
{"view_uview_class_decl",&view_uview_class_decl},
{"view_uview_class_def",&view_uview_class_def},
{"view_rview_class_decl",&view_rview_class_decl},
{"view_rview_class_def",&view_rview_class_def},
{"view_collect_strings",&view_collect_strings},
{"view_class_of_op",&view_class_of_op},
{"view_class_of_phy",&view_class_of_phy},
{0,0}
};
} // namespace kc
namespace kc { }
using namespace kc;
/* included stuff */
//
// The Termprocessor Kimwitu++
//
// Copyright (C) 1991 University of Twente, Dept TIOS.
// Copyright (C) 1998-2003 Humboldt-University of Berlin, Institute of Informatics
// All rights reserved.
//
// Kimwitu++ is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Kimwitu++ is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Kimwitu++; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "util.h"
#include "occur.h"
static int cl_scope = 0;
#include <stack>
static std::stack<operators> outmostoperators;
static std::stack<dollarvarstatus> dollarvarsallowed;
static std::stack<int> inforeachcontext;
static std::stack<arguments> argumentsstack;
static std::stack<ID> phylumstack;
static std::stack<phylumnames> phylumnamesstack;
static std::stack<withexpressions> withexpressionsstack;
static std::stack<ID> operatorstack;
static std::stack<variables> variablesstack;
#include "parse.h"
static ID cl_uniqueID = 0;
static ID cl_storageID = 0;
#include "pat.h" /* for syn_outmostpatterns and v_resetbindingidmarks */
extern unparseitems The_current_unparseitems;
#include "defs.h"
#define FMOP 38
#define FMSZ 3
#define FMNCR 8
#define FMNCRD 8
#define FMEXIST 8
#define FMFRNC 8
#define FMFRRC 8
#define FMFREED 8
#define FMREM 8
#define FMTOT 9
const char* preDefTypeAndName[][2] = { {"", ""}, {"kc_char_t const*", "name"}, {"kc_char_t const*", "name"},
{"REAL", "value"}, {"INTEGER", "value"}, {"void*", "pointer"}};
#include "gen.h"
// Definition of the view class for view_gen_unparsedefs_default_c;
// it contains an additional var to indicate whether we are unparsing a list pylum
// and another to show whether the user has supplied rules for the base view
struct view_gen_unparsedefs_default_c_class :view_gen_unparsedefs_default_c_baseclass
{
bool isList;
bool isOnlyDefault;
view_gen_unparsedefs_default_c_class(bool LonL, bool oD):
isList(LonL), isOnlyDefault(oD) { }
};
view_gen_unparsedefs_default_c_class view_gen_unparsedefs_default_c(false, false);
// To avoid covariant return types for broken compilers, we want to have three choices:
// Use them, don't use them, generate both and decide with preprocessor macros
// extended version: typename also in function name
void
covariant_choice(ID yest, const char* yess1, const char* yess2, const char *no1, const char *no2,
printer_functor kc_printer, uview kc_current_view)
{
kc_printer("\n", kc_current_view);
if (g_options.covariant == 'p') kc_printer("#ifndef NO_COVARIANT_RETURN\n", kc_current_view);
if (g_options.covariant != 'n') {
yest->unparse(kc_printer, kc_current_view);
kc_printer(yess1, kc_current_view);
if (yess2!=0) {
yest->unparse(kc_printer, kc_current_view);
kc_printer(yess2, kc_current_view);
}
}
if (g_options.covariant == 'p') kc_printer("\n#else\n", kc_current_view);
if (g_options.covariant != 'y') {
kc_printer(no1, kc_current_view);
if (no2!=0) {
yest->unparse(kc_printer, kc_current_view);
kc_printer(no2, kc_current_view);
}
}
if (g_options.covariant == 'p') kc_printer("\n#endif // NO_COVARIANT_RETURN\n", kc_current_view);
}
// short version: typename exactly once
inline void
covariant_choice(ID yest, const char* yess, const char *no, printer_functor kc_printer, uview kc_current_view)
{ covariant_choice(yest, yess, 0, no, 0, kc_printer, kc_current_view); }
// This printer functor doesn't print, but instead counts each of
// its invocations. Handy to find out whether a future unparsing
// will produce any output at all.
class count_printer: public printer_functor_class {
int count;
public:
count_printer(): count(0) { }
virtual void operator()(const char* s, uview v) { count++;}
int operator()() { return count;}
};
#include "gutil.h"
#include <map>
#include <string>
#include <stack>
namespace { // everything here is local to unpk.cc
int g_no_of_phyla;
int g_no_of_operators;
int gl_no_of_args;
int gl_generic_counter;
bool gl_isnotlist;
std::map<string, path> gl_bindings;
const int PHYLUMNUMBEROFFSET=0; /* should be >= 0; == the index of the last dummy element */
const int OPERATORNUMBEROFFSET=0; /* should be >= 0; == the index of the last dummy element */
std::stack<ID> selvarstack;
#define cf_pushselvar(o) do { selvarstack.push(o); \
g_ctext_level++; \
} while(0)
#define cf_topselvar() selvarstack.top()
#define cf_popselvar() do { selvarstack.pop();\
g_ctext_level--; \
} while(0)
std::stack<ID> dollarvarstack;
std::stack<ID> dollarvarextstack;
ID gl_phylum = 0;
phylumdeclaration gl_phydecl = 0;
ID gl_view = 0;
ID gl_operator = 0;
alternative gl_alternative = 0;
Ccode_option gl_cco = 0;
storageoption gl_storageoption = 0;
bool gl_atomicity;
arguments gl_args = 0;
ac_identifier_list gl_idents = 0;
fndeclarations gl_members = 0;
rewriterulesinfo gl_rewrite_rewriteinfo = 0;
const char *g_emptystring = "";
int g_ctext_level = 0;
int g_withexpr_nr = 0;
int g_fe_selvar_nr = 0;
const char *gl_return_type = "";
ID gl_return_ID = 0;
int gl_star_count = 0;
const char *gl_function = "";
ID gl_sto = 0;
bool gl_rewrite_goto_used = false;
bool gl_unparse_goto_used = false;
ID gl_type = 0;
int gl_j = 0;
bool gl_print_line_directive = false;
uview_enum gl_outer_view;
}
/* end included stuff */
namespace kc {
#ifndef KC_TRACE_PROVIDED
#define KC_TRACE_PROVIDED(COND,FILE,LINE,NODE) COND
#endif
void
impl_abstract_phylum::unparse(printer_function opf, uview uv)
{
printer_functor_function_wrapper pf(opf);
do_unparse(pf, uv);
}
// Everything given as a pointer is expected to have an unparse-method (we
// believe it's a phylum), unless there's a specialisation for it
void
unparse(abstract_phylum kc_p, printer_functor kc_printer, uview kc_current_view)
{
kc_p->unparse(kc_printer, kc_current_view);
}
void
unparse(void *kc_p, printer_functor kc_printer, uview kc_current_view)
{
// MPi: 20020628 there shouldn't be any left
assertionFailed("Unparse called for untyped pointer");
// MPi: cast should be unnecessary, but there are still void*
reinterpret_cast<impl_abstract_phylum*>(kc_p)->unparse(kc_printer, kc_current_view);
}
void
unparse(int kc_v, printer_functor kc_printer, uview kc_current_view)
{
kc_char kc_string[200];
kc_print_integer(kc_string,kc_v);
kc_printer(kc_string, kc_current_view);
}
void
unparse(double kc_v, printer_functor kc_printer, uview kc_current_view)
{
kc_char kc_string[200];
kc_print_real(kc_string,kc_v);
kc_printer(kc_string, kc_current_view);
}
void
unparse(kc_char *kc_v, printer_functor kc_printer, uview kc_current_view)
{
kc_printer(kc_v, kc_current_view);
}
void
unparse(kc_string_t kc_v, printer_functor kc_printer, uview kc_current_view)
{
kc_printer(kc_v.c_str(), kc_current_view);
}
void
impl_abstract_phylum::default_unparse(printer_functor kc_printer, uview kc_current_view)
{
register int no_sons = operator_info[prod_sel()].no_sons;
for (int i=0; i < no_sons; i++)
subphylum(i)->unparse(kc_printer, kc_current_view);
}
void
impl_casestring__Str::do_unparse(printer_functor kc_printer, uview kc_current_view)
{
kc::unparse(name, kc_printer, kc_current_view);
}
void
impl_nocasestring_NoCaseStr::do_unparse(printer_functor kc_printer, uview kc_current_view)
{
kc::unparse(name, kc_printer, kc_current_view);
}
void
impl_integer__Int::do_unparse(printer_functor kc_printer, uview kc_current_view)
{
kc::unparse(value, kc_printer, kc_current_view);
}
void
impl_real__Real::do_unparse(printer_functor kc_printer, uview kc_current_view)
{
kc::unparse(value, kc_printer, kc_current_view);
}
void
impl_voidptr__VoidPtr::do_unparse(printer_functor kc_printer, uview kc_current_view)
{
kc::unparse(pointer, kc_printer, kc_current_view);
}
void
impl_uniqID_Str::do_unparse(printer_functor kc_printer, uview kc_current_view_base)
{
switch(kc_current_view_base) {
case view_error_enum: {
view_error_class& kc_current_view=static_cast<view_error_class&>(kc_current_view_base);
{
const casestring cs = this->casestring_1;
kc::unparse(cs, kc_printer, kc_current_view);
}
break;
}
default:
case base_uview_enum: {
uview kc_current_view=kc_current_view_base;
{ /* Alternative( *, args ) -> [view_gen_unparsedefs_default_c: */
default_unparse(kc_printer, kc_current_view );
}
break;
}
}
}
void
impl_ID_Id::do_unparse(printer_functor kc_printer, uview kc_current_view_base)
{
switch(kc_current_view_base) {
case view_class_of_phy_enum: {
view_class_of_phy_class& kc_current_view=static_cast<view_class_of_phy_class&>(kc_current_view_base);
{
const uniqID pid = this->uniqID_1;
{ kc_printer(kc_t("impl_"), kc_current_view); }
kc::unparse(pid, kc_printer, kc_current_view);
}
break;
}
case view_class_of_op_enum: {
view_class_of_op_class& kc_current_view=static_cast<view_class_of_op_class&>(kc_current_view_base);
{
const uniqID oid = this->uniqID_1;
ID pid=f_phylumofoperator(this);
if (f_listelementphylum(pid)->eq(f_emptyId()))
{
kc::unparse(pid, kc_printer, view_class_of_phy);
{ kc_printer(kc_t("_"), kc_current_view); }
kc::unparse(oid, kc_printer, kc_current_view);
}
else
{
kc::unparse(pid, kc_printer, view_class_of_phy);
}
}
break;
}
case view_output_collection_enum: {
view_output_collection_class& kc_current_view=static_cast<view_output_collection_class&>(kc_current_view_base);
{
const ID id = this/**/;
{ kc_printer(kc_t("char* kc_language_"), kc_current_view); }
kc::unparse(id, kc_printer, base_uview);
{ kc_printer(kc_t(" [] = {\n"), kc_current_view); }
}
break;
}
case view_gen_fn_pointer_name_enum: {
view_gen_fn_pointer_name_class& kc_current_view=static_cast<view_gen_fn_pointer_name_class&>(kc_current_view_base);
if ((this->uniqID_1->prod_sel() == sel_Str)) {
const ID id = this/**/;
const uniqID uniqId = this->uniqID_1;
const casestring s = phylum_cast<const impl_uniqID_Str*>(this->uniqID_1)->casestring_1;
if(f_ispredefinedphylum(id) && strncmp(s->name, "abstract_", 9)!=0)
{
{ kc_printer(kc_t("impl_"), kc_current_view); }
kc::unparse(uniqId, kc_printer, kc_current_view);
{ kc_printer(kc_t("_"), kc_current_view); }
UNPARSE(f_operatorofphylum(id, 1));
}
else if(f_isphylum(id))
{
{ kc_printer(kc_t("impl_"), kc_current_view); }
kc::unparse(uniqId, kc_printer, kc_current_view);
}
else if(f_alternativeofoperator(id))
{
UNPARSE(f_phylumofoperator(id));
{ kc_printer(kc_t("_"), kc_current_view); }
kc::unparse(uniqId, kc_printer, kc_current_view);
}
else
{
kc::unparse(uniqId, kc_printer, kc_current_view);
}
} else
goto kc_unparsing_default;
break;
}
case view_error_tID_enum: {
view_error_tID_class& kc_current_view=static_cast<view_error_tID_class&>(kc_current_view_base);
{
const uniqID uid = this->uniqID_1;
kc::unparse(uid->type, kc_printer, kc_current_view);
{ kc_printer(kc_t(" "), kc_current_view); }
kc::unparse(uid, kc_printer, kc_current_view);
if (uid->line != 0)
{
{ kc_printer(kc_t(" (introduced at "), kc_current_view); }
kc::unparse(uid->file, kc_printer, kc_current_view);
{ kc_printer(kc_t(":"), kc_current_view); }
kc::unparse(uid->line, kc_printer, kc_current_view);
{ kc_printer(kc_t(")"), kc_current_view); }
}
}
break;
}
case view_error_enum: {
view_error_class& kc_current_view=static_cast<view_error_class&>(kc_current_view_base);
{
const uniqID uid = this->uniqID_1;
kc::unparse(uid, kc_printer, kc_current_view);
if (uid->line != 0)
{
{ kc_printer(kc_t(" (introduced at "), kc_current_view); }
kc::unparse(uid->file, kc_printer, kc_current_view);
{ kc_printer(kc_t(":"), kc_current_view); }
kc::unparse(uid->line, kc_printer, kc_current_view);
{ kc_printer(kc_t(")"), kc_current_view); }
}
}
break;
}
default:
kc_unparsing_default:
case base_uview_enum: {
uview kc_current_view=kc_current_view_base;
{ /* Alternative( *, args ) -> [view_gen_unparsedefs_default_c: */
default_unparse(kc_printer, kc_current_view );
}
break;
}
}
}
void
impl_INT_Int::do_unparse(printer_functor kc_printer, uview kc_current_view_base)
{
switch(kc_current_view_base) {
case view_error_enum: {
view_error_class& kc_current_view=static_cast<view_error_class&>(kc_current_view_base);
{
const integer i = this->integer_1;
kc::unparse(i, kc_printer, kc_current_view);
}
break;
}
default:
case base_uview_enum: {
uview kc_current_view=kc_current_view_base;
{ /* Alternative( *, args ) -> [view_gen_unparsedefs_default_c: */
default_unparse(kc_printer, kc_current_view );
}
break;
}
}
}
void
impl_STRING_String::do_unparse(printer_functor kc_printer, uview kc_current_view_base)
{
switch(kc_current_view_base) {
default:
case base_uview_enum: {
uview kc_current_view=kc_current_view_base;
{ /* Alternative( *, args ) -> [view_gen_unparsedefs_default_c: */
default_unparse(kc_printer, kc_current_view );
}
break;
}
}
}
void
impl_phylumdeclarationsroot_PhylumDeclarations::do_unparse(printer_functor kc_printer, uview kc_current_view_base)
{
switch(kc_current_view_base) {
case view_rview_class_decl_enum: {
view_rview_class_decl_class& kc_current_view=static_cast<view_rview_class_decl_class&>(kc_current_view_base);
{
{ kc_printer(kc_t("\
\ntypedef enum {\
\n"), kc_current_view); }
kc::unparse(Therviewnames, kc_printer, view_gen_rewritek_h);
{ kc_printer(kc_t("last_rview\
\n} rview_enum;\
\n\
\nstruct impl_rviews {\
\n const char *name;\
\n rview_class *view;\
\n};\
\nextern struct impl_rviews rviews[];\
\nclass "), kc_current_view); }
if(g_options.dllexports!="") {
PRINT(g_options.dllexports.c_str());
PRINT(" ");
}
{ kc_printer(kc_t("rview_class {\
\n\rprotected:\v\
\n // only used in derivations\
\n rview_class(rview_enum v): m_view(v) { }\
\n rview_class(const rview_class&): m_view(base_rview_enum)\
\n \v{ /* do not copy"), kc_current_view );
kc_printer(kc_t(" m_view */ }\r\
\n\rpublic:\v\
\n const char* name() const\
\n \v{ return rviews[m_view].name; }\r\
\n operator rview_enum() const\
\n \v{ return m_view; }\r\
\n bool operator==(const rview_cl"), kc_current_view );
kc_printer(kc_t("ass& other) const\
\n \v{ return m_view == other.m_view; }\r\
\n"), kc_current_view); }
if(g_options.rw_loop)
{
{ kc_printer(kc_t(" // Called when the rewrite_loop enters a node (just before the call\
\n // to do_rewrite and before entering its sons).\
\n // The result of this function is used instead of current in the "), kc_current_view );
kc_printer(kc_t("rewrite process.\
\n // If skip_current is set to true (default is false), the result is not rewritten\
\n // any further (neither do_rewrite() nor post_rewrite() are called).\
\n virtual ab"), kc_current_view );
kc_printer(kc_t("stract_phylum pre_rewrite(abstract_phylum current, bool& /* skip_current */)\
\n \v{ return current; }\r\
\n // Called when the rewrite_loop leaves current node (after the call to do_rewrite).\
\n "), kc_current_view );
kc_printer(kc_t(" // Current is the finally rewritten node.\
\n // The result is used instead of the argument to build the final tree.\
\n // If again is set to true (default is false) the result node is rewritt"), kc_current_view );
kc_printer(kc_t("en again.\
\n virtual abstract_phylum post_rewrite(abstract_phylum current, bool& /* again */)\
\n \v{ return current; }\r\
\n"), kc_current_view); }
}
{ kc_printer(kc_t("\rprivate:\v\
\n rview_enum m_view;\
\n};\
\n"), kc_current_view); }
}
break;
}
case view_uview_class_decl_enum: {
view_uview_class_decl_class& kc_current_view=static_cast<view_uview_class_decl_class&>(kc_current_view_base);
{
{ kc_printer(kc_t("\
\ntypedef enum {\
\n"), kc_current_view); }
kc::unparse(Theuviewnames, kc_printer, view_uview_def);
{ kc_printer(kc_t(" last_uview\
\n} uview_enum;\
\n\
\nstruct impl_uviews {\
\n const char *name;\
\n uview_class *view;\
\n};\
\nextern impl_uviews uviews[];\
\nclass "), kc_current_view); }
if(g_options.dllexports!="") {
PRINT(g_options.dllexports.c_str());
PRINT(" ");
}
{ kc_printer(kc_t("uview_class {\
\n\rprotected:\v\
\n // only used in derivations\
\n uview_class(uview_enum v): m_view(v) { }\
\n uview_class(c_uview): m_view(base_uview_enum)\
\n \v{ /* do not copy m_view */ "), kc_current_view );
kc_printer(kc_t("}\r\
\n\rpublic:\v\
\n const char* name() const\
\n \v{ return uviews[m_view].name; }\r\
\n operator uview_enum() const\
\n \v{ return m_view; }\r\
\n bool operator==(const uview_class& other)"), kc_current_view );
kc_printer(kc_t(" const\
\n \v{ return m_view == other.m_view; }\r\
\n\rprivate:\v\
\n uview_enum m_view;\
\n};\
\n\
\nclass "), kc_current_view); }
if(g_options.dllexports!="") {
PRINT(g_options.dllexports.c_str());
PRINT(" ");
}
{ kc_printer(kc_t("printer_functor_class {\
\n\rpublic:\v\
\n virtual void operator()(const kc_char_t*, uview) { }\
\n virtual ~printer_functor_class() { }\
\n};\
\n\
\nclass "), kc_current_view); }
if(g_options.dllexports!="") {
PRINT(g_options.dllexports.c_str());
PRINT(" ");
}
{ kc_printer(kc_t("printer_functor_function_wrapper : public printer_functor_class {\
\n\rpublic:\v\
\n printer_functor_function_wrapper(const printer_function opf =0): m_old_printer(opf) { }\
\n virtual ~printer_f"), kc_current_view );
kc_printer(kc_t("unctor_function_wrapper() { }\
\n virtual void operator()(const kc_char_t* s, uview v)\
\n \v{ if(m_old_printer) m_old_printer(s, v); }\r\
\n\rprivate:\v\
\n printer_function m_old_printer;\
\n};"), kc_current_view );
kc_printer(kc_t("\
\n"), kc_current_view); }
}
break;
}
case view_gen_yxx_union_h_enum: {
view_gen_yxx_union_h_class& kc_current_view=static_cast<view_gen_yxx_union_h_class&>(kc_current_view_base);
{
const phylumdeclarations d = this->phylumdeclarations_1;
{ kc_printer(kc_t("union {\
\n"), kc_current_view); }
kc::unparse(d, kc_printer, kc_current_view);
{ kc_printer(kc_t("};\
\n"), kc_current_view); }
}
break;
}
case view_gen_hashtables_c_enum: {
view_gen_hashtables_c_class& kc_current_view=static_cast<view_gen_hashtables_c_class&>(kc_current_view_base);
{
{ kc_printer(kc_t("\
\nextern const char* kc_storageclassnames[];\
\n\
\n#ifdef KC_STATISTICS\
\nvoid do_print_operator_statistics(FILE * kc_f)\
\n{\
\n unsigned int kc_i;\
\n assertNonNull( kc_f );\
\n fprintf("), kc_current_view );
kc_printer(kc_t("kc_f, \"%-*s| %-*s| %-*s| %-*s| %-*s| %-*s| %-*s| %-*s| %-*s| %-*s\\n\", 38 , \"Operator\", 3, \"Sz\", 8, \"#oper\", 8, \"#new\", 8, \"#exist\", 8, \"#frnrec\", 8, \"#frrec\", 8, \"#freed\", 8, \"#rem\""), kc_current_view );
kc_printer(kc_t(", 9, \"total (bytes)\");\
\n fprintf(kc_f, \"%-*s|%*s |%*d |%*d |%*d |%*d |%*d |%*d |%*d |%*d\\n\", 38, \"case sensitive strings\", 3, \"-\", 8, operator_statistics[sel__Str].created, 8, operator_st"), kc_current_view );
kc_printer(kc_t("atistics[sel__Str].existing_not_found, 8, operator_statistics[sel__Str].created-operator_statistics[sel__Str].existing_not_found, 8, 0, 8, 0, 8, 0, 8, 0, 9, kc_casestring_strlen);\
\n fprintf(kc_f, "), kc_current_view );
kc_printer(kc_t("\"%-*s|%*s |%*d |%*d |%*d |%*d |%*d |%*d |%*d |%*d\\n\", 38, \"case insensitive strings\", 3, \"-\", 8, operator_statistics[sel_NoCaseStr].created, 8, operator_statistics[sel_NoCaseStr].existing_not_fo"), kc_current_view );
kc_printer(kc_t("und, 8, operator_statistics[sel_NoCaseStr].created-operator_statistics[sel_NoCaseStr].existing_not_found, 8, 0, 8, 0, 8, 0, 8, 0, 9, kc_nocasestring_strlen);\
\n for (kc_i = one_before_first_operato"), kc_current_view );
kc_printer(kc_t("r+1; kc_i < last_operator; kc_i++) {\
\n fprintf(kc_f, \"%-*s|%*d |%*d |%*d |%*d |%*d |%*d |%*d |%*d |%*d\\n\", 38, operator_info[kc_i].name, 3, operator_info[kc_i].size, 8, operator_statistics[kc_i].c"), kc_current_view );
kc_printer(kc_t("reated, 8, operator_statistics[kc_i].existing_not_found, 8, operator_statistics[kc_i].created-operator_statistics[kc_i].existing_not_found, 8, operator_statistics[kc_i].free_called[false], 8, operator_"), kc_current_view );
kc_printer(kc_t("statistics[kc_i].free_called[true], 8, operator_statistics[kc_i].freed[false]+operator_statistics[kc_i].freed[true], 8, operator_statistics[kc_i].existing_not_found-(operator_statistics[kc_i].freed[fal"), kc_current_view );
kc_printer(kc_t("se]+operator_statistics[kc_i].freed[true]), 9, operator_info[kc_i].size*(operator_statistics[kc_i].existing_not_found-(operator_statistics[kc_i].freed[false]+operator_statistics[kc_i].freed[true])));\
\n"), kc_current_view );
kc_printer(kc_t(" }\
\n}\
\n#endif // KC_STATISTICS\
\n\
\n"), kc_current_view); }
if(!g_options.no_hashtables)
{
{ kc_printer(kc_t("\
\nvoid\
\nht_static(kc_storageclass_t kc_a_storageclass_t)\
\n{\
\n hashtables[kc_a_storageclass_t]->ht_static();\
\n}\
\n\
\nvoid\
\nht_dynamic(kc_storageclass_t kc_a_storageclass_t)\
\n{\
\n "), kc_current_view );
kc_printer(kc_t("hashtables[kc_a_storageclass_t]->ht_dynamic();\
\n}\
\n\
\nvoid\
\nht_inc_level(kc_storageclass_t kc_a_storageclass_t)\
\n{\
\n hashtables[kc_a_storageclass_t]->ht_inc_level();\
\n}\
\n\
\nvoid\
\nh"), kc_current_view );
kc_printer(kc_t("t_dec_level(kc_storageclass_t kc_a_storageclass_t)\
\n{\
\n hashtables[kc_a_storageclass_t]->ht_dec_level();\
\n}\
\n\
\nvoid\
\nht_free_level(kc_storageclass_t kc_a_storageclass_t)\
\n{\
\n hash"), kc_current_view );
kc_printer(kc_t("tables[kc_a_storageclass_t]->ht_free_level();\
\n}\
\n\
\nhashtable_t\
\nht_create_simple()\
\n{\
\n hashtable_t kc_ht=new hashtable_struct_t;\
\n kc_ht->set_to_be_freed();\
\n return kc_ht;\
\n"), kc_current_view );
kc_printer(kc_t("}\
\n\
\nhashtable_t\
\nht_assign(hashtable_t kc_a_hashtable_t, kc_storageclass_t kc_a_storageclass_t, bool still_unique)\
\n{\
\n hashtable_t kc_tmp = hashtables[kc_a_storageclass_t];\
\n hashta"), kc_current_view );
kc_printer(kc_t("bles[kc_a_storageclass_t] = kc_a_hashtable_t;\
\n kc_storageclass_still_uniq[kc_a_storageclass_t] = still_unique;\
\n return kc_tmp;\
\n}\
\n\
\nhashtable_t\
\nht_assigned(kc_storageclass_t kc_a_"), kc_current_view );
kc_printer(kc_t("storageclass_t)\
\n{\
\n return hashtables[kc_a_storageclass_t];\
\n}\
\n\
\nvoid\
\nht_clear(hashtable_t kc_a_hashtable_t)\
\n{\
\n kc_a_hashtable_t->ht_clear();\
\n}\
\n\
\nvoid\
\nht_delete(ha"), kc_current_view );
kc_printer(kc_t("shtable_t kc_a_hashtable_t)\
\n{\
\n if(kc_a_hashtable_t->to_be_freed())\
\n delete kc_a_hashtable_t;\
\n}\
\n"), kc_current_view); }
}
}
break;
}
case view_gen_hashtables_h_enum: {
view_gen_hashtables_h_class& kc_current_view=static_cast<view_gen_hashtables_h_class&>(kc_current_view_base);
{
{ kc_printer(kc_t("\
\ntypedef struct {\
\n int created;\
\n int existing_not_found;\
\n int free_called[2];\
\n int freed[2];\
\n} KC_OPERATOR_STATISTICS;\
\n\
\n#ifdef KC_STATISTICS\
\n# define print_operat"), kc_current_view );
kc_printer(kc_t("or_statistics(kc_f) do_print_operator_statistics(kc_f)\
\n void do_print_operator_statistics(FILE*);\
\n#else\
\n# define print_operator_statistics(kc_f)\
\n#endif\
\n\
\ntypedef class hashtable_struc"), kc_current_view );
kc_printer(kc_t("t_t* hashtable_t;\
\n"), kc_current_view); }
if(!g_options.no_hashtables)
{
{ kc_printer(kc_t("void ht_static (kc_storageclass_t);\
\nvoid ht_dynamic (kc_storageclass_t);\
\nvoid ht_inc_level (kc_storageclass_t);\
\nvoid ht_dec_level (kc_storageclass_t);\
\nvoid ht_free_level (kc_storageclass_t)"), kc_current_view );
kc_printer(kc_t(";\
\nhashtable_t ht_create_simple ();\
\nhashtable_t ht_assign (hashtable_t, kc_storageclass_t, bool still_unique=false);\
\nhashtable_t ht_assigned (kc_storageclass_t);\
\nvoid ht_clear (hashtable_t);"), kc_current_view );
kc_printer(kc_t("\
\nvoid ht_delete (hashtable_t);\
\n"), kc_current_view); }
}
}
break;
}
case view_gen_classdecls2_h_enum: {
view_gen_classdecls2_h_class& kc_current_view=static_cast<view_gen_classdecls2_h_class&>(kc_current_view_base);
{
const phylumdeclarations pds = this->phylumdeclarations_1;
{ kc_printer(kc_t("\
\n//namespace Phylum {\r\
\n"), kc_current_view); }
{ kc_printer(kc_t("\
\nclass "), kc_current_view); }
if(g_options.dllexports!="") {
PRINT(g_options.dllexports.c_str());
PRINT(" ");
}
{ kc_printer(kc_t("impl_abstract_phylum"), kc_current_view); }
{
baseclass_list kc_selvar_0_1 = phylum_cast<baseclass_list>(The_abstract_phylum_decl->base_classes);
if ((kc_selvar_0_1->prod_sel() == sel_Consbaseclass_list)) {
PRINT("\b :\b ");
UNPARSE(The_abstract_phylum_decl->base_classes);
} else
{
}
}
{ kc_printer(kc_t(" {\
\n\rpublic:\v\
\n virtual enum_operators prod_sel() const =0;\
\n static const enum_phyla phylum_sel_;\
\n enum_phyla phylum() const;\
\n const char* phylum_name() const;\
\n const c"), kc_current_view );
kc_printer(kc_t("har* op_name() const;\
\n virtual abstract_phylum subphylum(int) const;\
\n virtual void set_subphylum(int, abstract_phylum);\
\n void free(bool recursive=true);\
\n bool eq(c_abstract_phyl"), kc_current_view );
kc_printer(kc_t("um) const;\
\n void print();\
\n void fprint(FILE *);\
\n abstract_phylum copy(bool kc_copy_attributes) const;\n"), kc_current_view); }
if(!g_options.no_unparse)
{
{ kc_printer(kc_t(" void unparse(printer_functor pf, uview uv)\
\n \v{ do_unparse(pf, uv); }\r\
\n void unparse(printer_function opf, uview uv);\n"), kc_current_view); }
}
if(!g_options.no_printdot)
{
{ kc_printer(kc_t("\
\n void printdot_add_edge (c_abstract_phylum, int, int*, kc_dotedgenode_t*, const char*) const;\
\n void do_printdot_id (FILE*, bool, c_abstract_phylum, int) const;\
\n void do_printdot (FILE*, bool,"), kc_current_view );
kc_printer(kc_t(" int*, kc_dotedgenode_t*, const char*, bool, bool, c_abstract_phylum, int) const;\
\n\
\n virtual void fprintdot(FILE *,\
\n const char *root_label_prefix, const char *edge_label_prefix, const char *ed"), kc_current_view );
kc_printer(kc_t("ge_attributes,\
\n bool print_node_labels, bool use_context_when_sharing_leaves, bool print_prologue_and_epilogue) const =0;\
\n"), kc_current_view); }
}
if(!g_options.no_csgio)
{
{ kc_printer(kc_t(" void CSGIOwrite(FILE *) const;\
\n"), kc_current_view); }
}
if(!g_options.no_rewrite)
{
if(!g_options.rw_loop)
{
{ kc_printer(kc_t(" virtual abstract_phylum rewrite(rview v) { return do_rewrite(v); }\
\n"), kc_current_view); }
}
else
{
{ kc_printer(kc_t(" abstract_phylum rewrite(rview v) {\
\n return rewrite_loop(v); }\
\n abstract_phylum rewrite_loop(rview v);\
\n"), kc_current_view); }
}
{ kc_printer(kc_t(" virtual abstract_phylum do_rewrite(rview) { return this;}\
\n // called if a subphylum of an op is rewritten and a new op is created by default rule\
\n virtual void rewrite_members(abstract_phylum fr"), kc_current_view );
kc_printer(kc_t("om) {} \
\n"), kc_current_view); }
}
if(!f_post_create_in_phylumdecl(The_abstract_phylum_decl))
{
{ kc_printer(kc_t(" virtual void post_create(){}\
\n"), kc_current_view); }
}
fndeclarations tapam = The_abstract_phylum_decl->additional_members;
kc::unparse(tapam, kc_printer, view_gen_member_dcl_h);
kc::unparse(tapam, kc_printer, view_count_nonstaticmembers);
if(g_options.smart_pointer)
{
if(!f_constructors_in_phylumdecl(The_abstract_phylum_decl))
{
{ kc_printer(kc_t(" impl_abstract_phylum()"), kc_current_view); }
if(gl_no_of_args!=0)
{
{ kc_printer(kc_t(": "), kc_current_view); }
kc::unparse(gl_members, kc_printer, view_gen_user_assignment_inis);
}
{ kc_printer(kc_t("\v\
\n { _ref=0; }\r\
\n "), kc_current_view); }
}
if(!f_destructors_in_phylumdecl(The_abstract_phylum_decl))
{
{ kc_printer(kc_t(" virtual ~impl_abstract_phylum() {\
\n if(_ref)\
\n _ref->reset_phylum();\
\n }\
\n"), kc_current_view); }
}
{ kc_printer(kc_t(" impl_abstract_phylum(const impl_abstract_phylum&) {\
\n _ref=0;\
\n }\
\n abstract_phylum_ref* get_ref() const {\
\n return _ref;\
\n }\
\n abstract_phylum_ref* add_ref() {\
\n if(!_ref)\
\n"), kc_current_view );
kc_printer(kc_t(" _ref=new_phylum_ref();\
\n return _ref;\
\n }\
\n void set_ref(abstract_phylum_ref* r) {\
\n _ref=r;\
\n }\
\n virtual abstract_phylum_ref* new_phylum_ref()=0;\
\n abstract_phylum return_ptr("), kc_current_view );
kc_printer(kc_t(") { if(get_ref()) get_ref()->lock(); return this; }\
\n\rprivate:\v\
\n abstract_phylum_ref*_ref;\
\n"), kc_current_view); }
}
else
{
if (!f_constructors_in_phylumdecl(The_abstract_phylum_decl) && gl_no_of_args!=0)
{
{ kc_printer(kc_t("explicit impl_abstract_phylum()\v\n: "), kc_current_view); }
kc::unparse(gl_members, kc_printer, view_gen_user_assignment_inis);
{ kc_printer(kc_t(" { }\r\n"), kc_current_view); }
}
if(!f_destructors_in_phylumdecl(The_abstract_phylum_decl))
{
{ kc_printer(kc_t(" virtual ~impl_abstract_phylum() { }\
\n"), kc_current_view); }
}
}
if(!g_options.no_unparse)
{
{ kc_printer(kc_t("\rprivate:\v\
\n virtual void do_unparse(printer_functor, uview) =0;\
\n\rprotected:\v\
\n virtual void default_unparse(printer_functor, uview);\n"), kc_current_view); }
}
{ kc_printer(kc_t("};\n\n"), kc_current_view); }
if(g_options.smart_pointer)
{
{ kc_printer(kc_t("template <>\
\nclass phylum_ptr<impl_abstract_phylum> {\
\n\rpublic:\v\
\n"), kc_current_view); }
if(g_options.weak_pointer)
{
{ kc_printer(kc_t(" phylum_ptr(bool weak=false) { _ref=0; _weak=weak; }\
\n phylum_ptr(impl_abstract_phylum* t,bool weak=false) {\
\n _ref=0; _weak=weak;\
\n if(t) set_ref(t->add_ref());\
\n }\
\n phylum_ptr(c"), kc_current_view );
kc_printer(kc_t("onst phylum_ptr<impl_abstract_phylum>& p, bool weak=false) {\
\n _ref=0; _weak=weak;\
\n set_ref(p.get_ref());\
\n }\
\n"), kc_current_view); }
}
else
{
{ kc_printer(kc_t(" phylum_ptr() { _ref=0; }\
\n phylum_ptr(impl_abstract_phylum* t) {\
\n _ref=0;\
\n if(t) set_ref(t->add_ref());\
\n }\
\n phylum_ptr(const phylum_ptr<impl_abstract_phylum>& p) {\
\n _ref=0;"), kc_current_view );
kc_printer(kc_t("\
\n set_ref(p.get_ref());\
\n }\
\n"), kc_current_view); }
}
{ kc_printer(kc_t("\
\n ~phylum_ptr() { set_ref(0); }\
\n\
\n template <typename T>\
\n phylum_ptr<impl_abstract_phylum>& operator=(T* t) {\
\n if(t)\
\n set_ref(t->add_ref());\
\n else\
\n set_ref(0);\
\n"), kc_current_view );
kc_printer(kc_t(" return *this;\
\n }\
\n\
\n template <typename T>\
\n phylum_ptr<impl_abstract_phylum>& operator=(const phylum_ptr<T>& p) {\
\n set_ref(p.get_ref());\
\n return *this;\
\n }\
\n\
\n imp"), kc_current_view );
kc_printer(kc_t("l_abstract_phylum* get_phylum() const {\
\n return _ref?_ref->get_abstract_phylum():0;\
\n }\
\n\
\n operator impl_abstract_phylum*() const { return get_phylum(); }\
\n impl_abstract_phylum* o"), kc_current_view );
kc_printer(kc_t("perator()() const { return get_phylum(); }\
\n impl_abstract_phylum* operator->() const { return get_phylum(); }\
\n operator bool() const { return get_phylum()!=0; }\
\n bool operator!() cons"), kc_current_view );
kc_printer(kc_t("t { return get_phylum()==0; }\
\n\
\n abstract_phylum return_ptr() { if(_ref) _ref->lock(); return get_phylum(); }\
\n\
\n bool operator==(int null) const { return null?false:(get_phylum()==0); }"), kc_current_view );
kc_printer(kc_t("\
\n template <typename T>\
\n bool operator==(const T* t) const { return get_phylum()==t; }\
\n template <typename T>\
\n bool operator==(const phylum_ptr<T>& t) const { return get_phylum("), kc_current_view );
kc_printer(kc_t(")==t.get_phylum(); }\
\n\
\n bool operator!=(int null) const { return null?true:(get_phylum()!=0); }\
\n template <typename T>\
\n bool operator!=(const T* t) const { return get_phylum()!=t; }"), kc_current_view );
kc_printer(kc_t("\
\n template <typename T>\
\n bool operator!=(const phylum_ptr<T>& t) const { return get_phylum()!=t.get_phylum(); }\
\n\
\n abstract_phylum_ref* get_ref() const { return _ref; }\
\n\
\n\rpro"), kc_current_view );
kc_printer(kc_t("tected:\v\
\n"), kc_current_view); }
if(g_options.weak_pointer)
{
{ kc_printer(kc_t(" void set_ref(abstract_phylum_ref* r) {\
\n if(_ref!=r) {\
\n if(_weak) {\
\n if(r) r->weak_ref();\
\n if(_ref) _ref->weak_unref();\
\n }\
\n else {\
\n if(r) r->ref();\
\n if(_ref) _"), kc_current_view );
kc_printer(kc_t("ref->unref();\
\n }\
\n _ref=r;\
\n }\
\n }\
\n"), kc_current_view); }
}
else
{
{ kc_printer(kc_t(" void set_ref(abstract_phylum_ref* r) {\
\n if(_ref!=r) {\
\n if(r) r->ref();\
\n if(_ref) _ref->unref();\
\n _ref=r;\
\n }\
\n }\
\n"), kc_current_view); }
}
{ kc_printer(kc_t("\
\n\rprivate:\v\
\n abstract_phylum_ref* _ref;\
\n"), kc_current_view); }
if(g_options.weak_pointer)
{
{ kc_printer(kc_t(" bool _weak;\n"), kc_current_view); }
}
{ kc_printer(kc_t("};\n"), kc_current_view); }
}
{ kc_printer(kc_t("\
\nclass "), kc_current_view); }
if(g_options.dllexports!="") {
PRINT(g_options.dllexports.c_str());
PRINT(" ");
}
{ kc_printer(kc_t("impl_abstract_list: "), kc_current_view); }
{
baseclass_list kc_selvar_0_1 = phylum_cast<baseclass_list>(The_abstract_list_decl->base_classes);
if ((kc_selvar_0_1->prod_sel() == sel_Consbaseclass_list)) {
UNPARSE(The_abstract_list_decl->base_classes);
} else
{
PRINT("public impl_abstract_phylum");
}
}
{ kc_printer(kc_t("{\
\n\rprivate:\v\
\n void fprint_list(FILE *);\
\n friend class impl_abstract_phylum;\
\n\rprotected:\v\
\n abstract_phylum do_concat(c_abstract_phylum other, enum_operators) const;\
\n ab"), kc_current_view );
kc_printer(kc_t("stract_phylum do_reverse(c_abstract_phylum tail, enum_operators) const;\
\n abstract_phylum do_map(abstract_phylum (*kc_fp)(abstract_phylum), enum_operators);\
\n abstract_phylum do_filter(bool ("), kc_current_view );
kc_printer(kc_t("*kc_fp)(abstract_phylum), enum_operators);\
\n abstract_list do_append(abstract_phylum, abstract_list);\
\n abstract_phylum do_merge(abstract_list,abstract_phylum (*kc_fp)(abstract_phylum,abstr"), kc_current_view );
kc_printer(kc_t("act_phylum), enum_operators);\
\n abstract_phylum do_reduce(abstract_phylum neutral, abstract_phylum (*kc_fp)(abstract_phylum,abstract_phylum));\
\n\rpublic:\v\n"), kc_current_view); }
tapam = The_abstract_list_decl->additional_members;
kc::unparse(tapam, kc_printer, view_count_nonstaticmembers);
if (!f_constructors_in_phylumdecl(The_abstract_list_decl) && gl_no_of_args!=0)
{
{ kc_printer(kc_t("explicit impl_abstract_list()\v\n: "), kc_current_view); }
kc::unparse(gl_members, kc_printer, view_gen_user_assignment_inis);
{ kc_printer(kc_t(" { }\r\n"), kc_current_view); }
}
{ kc_printer(kc_t(" virtual bool is_nil() const =0;\
\n virtual abstract_list reverse() const =0;\
\n int length() const;\
\n abstract_phylum last() const;\
\n // Non-virtual, non-existing... Type must be "), kc_current_view );
kc_printer(kc_t("known exactly anyway because\
\n // of the function given as a parameter\
\n //virtual abstract_list map( abstract_phylum (*)( abstract_phylum )) =0;\
\n //virtual abstract_list filter(bool (*"), kc_current_view );
kc_printer(kc_t(")(abstract_phylum)) =0;\
\n void freelist();\
\n"), kc_current_view); }
if(g_options.smart_pointer)
{
{ kc_printer(kc_t(" impl_abstract_list* return_ptr() { if(get_ref()) get_ref()->lock(); return this; }\n"), kc_current_view); }
}
The_abstract_list_decl->additional_members->unparse(
kc_printer,view_gen_member_dcl_h);
{ kc_printer(kc_t("};\
\n"), kc_current_view); }
kc::unparse(pds, kc_printer, kc_current_view);
{ kc_printer(kc_t("\
\n//} // namespace Phylum\
\n\
\n"), kc_current_view); }
}
break;
}
case view_gen_classdecls1_h_enum: {
view_gen_classdecls1_h_class& kc_current_view=static_cast<view_gen_classdecls1_h_class&>(kc_current_view_base);
{
const phylumdeclarations pds = this->phylumdeclarations_1;
{ kc_printer(kc_t("\
\nclass impl_abstract_phylum;\
\ntypedef impl_abstract_phylum * abstract_phylum;\
\ntypedef const impl_abstract_phylum * c_abstract_phylum;\
\nclass impl_abstract_list;\
\ntypedef impl_abstract_list "), kc_current_view );
kc_printer(kc_t("* abstract_list;\
\ntypedef const impl_abstract_list * c_abstract_list;\
\n"), kc_current_view); }
if(g_options.smart_pointer)
{
{ kc_printer(kc_t("\
\n// Reference to a phylum (abstract base class)\
\nclass abstract_phylum_ref {\
\n\rprotected:\v\
\n abstract_phylum_ref() {\
\n _locked=false;\
\n _ref_count=0;\
\n"), kc_current_view); }
if(g_options.weak_pointer)
{
{ kc_printer(kc_t(" _weak_ref_count=0;\
\n"), kc_current_view); }
}
{ kc_printer(kc_t(" }\
\n\
\n\rpublic:\v\
\n void lock() {\
\n _locked=true;\
\n }\
\n void unlock() {\
\n if(_locked) {\
\n _locked=false;\
\n if(_ref_count==0 "), kc_current_view); }
if(g_options.weak_pointer)
{
{ kc_printer(kc_t("&& _weak_ref_count==0"), kc_current_view); }
}
{ kc_printer(kc_t(") {\
\n reset_ref();\
\n reset_phylum();\
\n delete this;\
\n }\
\n }\
\n }\
\n int get_ref_count() const {\
\n return _ref_count;\
\n }\
\n void ref() {\
\n _locked=false;\
\n ++_re"), kc_current_view );
kc_printer(kc_t("f_count;\
\n }\
\n void unref() {\
\n if(_ref_count)\
\n --_ref_count;\
\n if(_ref_count==0 && !_locked) {\
\n clear();\
\n"), kc_current_view); }
if(g_options.weak_pointer)
{
{ kc_printer(kc_t(" if(_weak_ref_count==0)\
\n"), kc_current_view); }
}
{ kc_printer(kc_t(" delete this;\
\n }\
\n }\
\n"), kc_current_view); }
if(g_options.weak_pointer)
{
{ kc_printer(kc_t(" int get_weak_ref_count() const {\
\n return _weak_ref_count;\
\n }\
\n void weak_ref() {\
\n _locked=false;\
\n ++_weak_ref_count;\
\n }\
\n void weak_unref() {\
\n if(_weak_ref_count)\
\n"), kc_current_view );
kc_printer(kc_t(" --_weak_ref_count;\
\n if(_weak_ref_count==0 && _ref_count==0 && !_locked) {\
\n reset_ref();\
\n delete this;\
\n }\
\n }\
\n"), kc_current_view); }
}
{ kc_printer(kc_t("\
\n virtual impl_abstract_phylum* get_abstract_phylum() const=0;\
\n virtual void reset_phylum()=0;\
\n"), kc_current_view); }
The_abstract_phylum_ref_decl->additional_members->unparse(
kc_printer,view_gen_member_dcl_h);
{ kc_printer(kc_t("\rprotected:\v\
\n virtual void clear()=0;\
\n virtual void reset_ref()=0;\
\n\rprivate:\v\
\n int _ref_count;\
\n"), kc_current_view); }
if(g_options.weak_pointer)
{
{ kc_printer(kc_t(" int _weak_ref_count;\
\n"), kc_current_view); }
}
{ kc_printer(kc_t(" bool _locked;\
\n};\n"), kc_current_view); }
{ kc_printer(kc_t("// Template reference for each phylum\
\ntemplate <typename T>\
\nclass phylum_ref: public abstract_phylum_ref {\
\n\rpublic:\v\
\n phylum_ref(T* t) { _phylum=t; }\
\n\
\n T* get_phylum() const {"), kc_current_view );
kc_printer(kc_t(" return _phylum; }\
\n impl_abstract_phylum* get_abstract_phylum() const { return _phylum; }\
\n\
\n phylum_ref<T>& operator=(const T& t) {\
\n abstract_phylum_ref* ref=t.get_ref();\
\n if(ref)\
\n"), kc_current_view );
kc_printer(kc_t(" set_phylum(static_cast<T*>(t.copy(true)));\
\n else\
\n set_phylum(const_cast<T*>(&t));\
\n return *this;\
\n }\
\n phylum_ref<T>& operator=(const phylum_ref<T>& r) {\
\n T* t=r.get_phyl"), kc_current_view );
kc_printer(kc_t("um();\
\n if(t) return operator=(*t);\
\n set_phylum(0);\
\n return *this;\
\n }\
\n\
\n void reset_phylum() { _phylum=0; }\
\n void set_phylum(T* t) {\
\n if(_phylum!=t) {\
\n _phylum->se"), kc_current_view );
kc_printer(kc_t("t_ref(0);\
\n _phylum->free();\
\n _phylum=t;\
\n if(_phylum)\
\n _phylum->set_ref(this);\
\n }\
\n }\
\n\rprotected:\v\
\n void clear() { if(_phylum) { reset_ref(); _phylum->free();"), kc_current_view );
kc_printer(kc_t(" _phylum=0; } }\
\n void reset_ref() { if(_phylum) _phylum->set_ref(0); }\
\n\rprivate:\v\
\n T* _phylum;\
\n};\n"), kc_current_view); }
{ kc_printer(kc_t("// Smart pointer containing a reference\
\ntemplate <typename T>\
\nclass phylum_ptr {\
\n\rpublic:\v\
\n"), kc_current_view); }
if(g_options.weak_pointer)
{
{ kc_printer(kc_t(" phylum_ptr(bool weak=false) { _ref=0; _weak=weak; }\
\n phylum_ptr(T* t,bool weak=false) {\
\n _ref=0; _weak=weak;\
\n if(t) set_ref(static_cast<phylum_ref<T>*>(t->add_ref()));\
\n }\
\n ph"), kc_current_view );
kc_printer(kc_t("ylum_ptr(const phylum_ptr<T>& p, bool weak=false) {\
\n _ref=0; _weak=weak;\
\n set_ref(p.get_ref());\
\n }\
\n"), kc_current_view); }
}
else
{
{ kc_printer(kc_t(" phylum_ptr() { _ref=0; }\
\n phylum_ptr(T* t) {\
\n _ref=0;\
\n if(t) set_ref(static_cast<phylum_ref<T>*>(t->add_ref()));\
\n }\
\n phylum_ptr(const phylum_ptr<T>& p) {\
\n _ref=0;\
\n set_"), kc_current_view );
kc_printer(kc_t("ref(p.get_ref());\
\n }\
\n"), kc_current_view); }
}
{ kc_printer(kc_t(" ~phylum_ptr() { set_ref(0); }\
\n\
\n phylum_ptr<T>& operator=(T* t) {\
\n if(t)\
\n set_ref(static_cast<phylum_ref<T>*>(t->add_ref()));\
\n else\
\n set_ref(0);\
\n return *this;\
\n "), kc_current_view );
kc_printer(kc_t("}\
\n\
\n phylum_ptr<T>& operator=(const phylum_ptr<T>& p) {\
\n set_ref(p.get_ref());\
\n return *this;\
\n }\
\n\
\n T* get_phylum() const { return _ref?_ref->get_phylum():0; }\
\n\
\n op"), kc_current_view );
kc_printer(kc_t("erator T*() const { return get_phylum(); }\
\n T* operator()() const { return get_phylum(); }\
\n T* operator->() const { return get_phylum(); }\
\n operator bool() const { return get_phylum()"), kc_current_view );
kc_printer(kc_t("!=0; }\
\n bool operator!() const { return get_phylum()==0; }\
\n\
\n T* return_ptr() const { if(_ref) _ref->lock(); return get_phylum(); }\
\n\
\n bool operator==(int null) const { return nul"), kc_current_view );
kc_printer(kc_t("l?false:(get_phylum()==0); }\
\n bool operator==(const T* t) const { return get_phylum()==t; }\
\n bool operator==(const phylum_ptr<T>& t) const { return get_phylum()==t.get_phylum(); }\
\n bo"), kc_current_view );
kc_printer(kc_t("ol operator!=(int null) const { return null?true:(get_phylum()!=0); }\
\n bool operator!=(const T* t) const { return get_phylum()!=t; }\
\n bool operator!=(const phylum_ptr<T>& t) const { return "), kc_current_view );
kc_printer(kc_t("get_phylum()!=t.get_phylum(); }\
\n\
\n phylum_ref<T>& operator*(){ return *add_ref(); }\
\n const phylum_ref<T>& operator*() const {\
\n return *const_cast<phylum_ptr<T>*>(this)->add_ref();\
\n "), kc_current_view );
kc_printer(kc_t(" }\
\n\
\n phylum_ref<T>* get_ref() const { return _ref; }\
\n\
\n phylum_ref<T>* add_ref() {\
\n if(!_ref) set_ref(new phylum_ref<T>(0));\
\n return _ref;\
\n }\
\n\rprotected:\v\
\n"), kc_current_view); }
if(g_options.weak_pointer)
{
{ kc_printer(kc_t(" void set_ref(phylum_ref<T>* r) {\
\n if(_ref!=r) {\
\n if(_weak) {\
\n if(r) r->weak_ref();\
\n if(_ref) _ref->weak_unref();\
\n }\
\n else {\
\n if(r) r->ref();\
\n if(_ref) _ref->u"), kc_current_view );
kc_printer(kc_t("nref();\
\n }\
\n _ref=r;\
\n }\
\n }\
\n"), kc_current_view); }
}
else
{
{ kc_printer(kc_t(" void set_ref(phylum_ref<T>* r) {\
\n if(_ref!=r) {\
\n if(r) r->ref();\
\n if(_ref) _ref->unref();\
\n _ref=r;\
\n }\
\n }\
\n"), kc_current_view); }
}
{ kc_printer(kc_t("\
\n\rprivate:\v\
\n phylum_ref<T>* _ref;\
\n"), kc_current_view); }
if(g_options.weak_pointer)
{
{ kc_printer(kc_t(" bool _weak;\
\n"), kc_current_view); }
}
{ kc_printer(kc_t("};\
\ntypedef phylum_ptr<impl_abstract_phylum> abstract_phylum_ptr;\
\n"), kc_current_view); }
if(g_options.weak_pointer)
{
{ kc_printer(kc_t("\
\ntemplate <typename T>\
\nclass weak_phylum_ptr: public phylum_ptr<T> {\
\n\rpublic:\v\
\n weak_phylum_ptr(): phylum_ptr<T>(true){}\
\n weak_phylum_ptr(T* t):phylum_ptr<T>(t,true){}\
\n wea"), kc_current_view );
kc_printer(kc_t("k_phylum_ptr(const weak_phylum_ptr<T>& p):phylum_ptr<T>(p,true){}\
\n weak_phylum_ptr(const phylum_ptr<T>& p):phylum_ptr<T>(p,true){}\
\n\
\n weak_phylum_ptr<T>& operator=(T* t) {\
\n if(t)\
\n "), kc_current_view );
kc_printer(kc_t(" set_ref(static_cast<phylum_ref<T>*>(t->add_ref()));\
\n else\
\n set_ref(0);\
\n return *this;\
\n }\
\n\
\n weak_phylum_ptr<T>& operator=(const phylum_ptr<T>& p) {\
\n set_ref(p.get_ref()"), kc_current_view );
kc_printer(kc_t(");\
\n return *this;\
\n }\
\n};\
\ntypedef weak_phylum_ptr<impl_abstract_phylum> weak_abstract_phylum_ptr;\
\n"), kc_current_view); }
}
{ kc_printer(kc_t("\
\ntemplate <typename P, typename T>\
\nP phylum_cast(phylum_ptr<T>& t) {\
\n return static_cast<P>(t());\
\n}\
\ntemplate <typename P, typename T>\
\nconst P phylum_cast(const phylum_ptr<T>& t) {\
\n"), kc_current_view );
kc_printer(kc_t(" return static_cast<const P>(t());\
\n}\
\n"), kc_current_view); }
}
{ kc_printer(kc_t("\
\ntemplate <typename P, typename T>\
\nP phylum_cast(T* t) {\
\n return static_cast<P>(t);\
\n}\
\ntemplate <typename P, typename T>\
\nconst P phylum_cast(const T* t) {\
\n return static_cast<"), kc_current_view );
kc_printer(kc_t("const P>(t);\
\n}\
\n"), kc_current_view); }
kc::unparse(pds, kc_printer, kc_current_view);
{ kc_printer(kc_t("\
\n\
\nvoid kc_invalid_operator( const char *kc_func_prefix, enum_phyla kc_phy, int kc_line,\
\n const char *kc_file, enum_operators kc_oper ) __attribute__ ((noreturn));\
\n\
\ntypedef enum_phyla *en"), kc_current_view );
kc_printer(kc_t("um_phyla_list;\
\n\
\n/*\
\n * make sure that the first 'real' storage class _always_ gets a value > 0\
\n * and kc_not_uniq gets a value == 0\
\n * (because then we can use it as a C boolean)\
\n */\
\n"), kc_current_view );
kc_printer(kc_t("enum kc_storageclass_t {\
\n "), kc_current_view); }
kc::unparse(Thestorageclasses, kc_printer, view_gen_operatormap_type_h);
{ kc_printer(kc_t(",\
\nlast_storageclass\
\n};\
\n\
\ntypedef struct {\
\n const char *name; // name of the phylum\
\n enum_operators first_operator; // index in operator_info[]\
\n enum_operators last_operat"), kc_current_view );
kc_printer(kc_t("or; // index in operator_info[]\
\n kc_storageclass_t uniq_stored; // storage class\
\n} KC_PHYLUM_INFO;\
\n\
\ntypedef struct {\
\n const char *name; // name of the operator\
\n size_t no_s"), kc_current_view );
kc_printer(kc_t("ons; // number of sons\
\n bool atomicity; // atomic type or not\
\n enum_phyla phylum; // index in phylum_info[]\
\n enum_phyla_list subphylum; // indexes in phylum_info[]\
\n int n"), kc_current_view );
kc_printer(kc_t("o_attrs; // number of attributes\
\n enum_phyla_list attribute; // indexes in phylum_info[]\
\n size_t size; // size of operator (for statistics)\
\n} KC_OPERATOR_INFO;\
\n\
\ntypedef enum_p"), kc_current_view );
kc_printer(kc_t("hyla_list KC_UNIQ_INFO;\
\n\
\nextern KC_OPERATOR_INFO operator_info[];\
\nextern KC_PHYLUM_INFO phylum_info[];\
\nextern KC_UNIQ_INFO kc_UniqInfo[];\
\n\
\n#define KC_OP_NAME(op) (operator_info[op].na"), kc_current_view );
kc_printer(kc_t("me)\
\n#define KC_NO_SONS(prod) (operator_info[prod].no_sons)\
\n#define KC_ATOMICITY(prod) (operator_info[prod].atomicity)\
\n\
\n"), kc_current_view); }
}
break;
}
case view_gen_unparsedefs_c_enum: {
view_gen_unparsedefs_c_class& kc_current_view=static_cast<view_gen_unparsedefs_c_class&>(kc_current_view_base);
{
const phylumdeclarations pds = this->phylumdeclarations_1;
kc::unparse(pds, kc_printer, kc_current_view);
}
break;
}
case view_gen_default_types_unpk_c_enum: {
view_gen_default_types_unpk_c_class& kc_current_view=static_cast<view_gen_default_types_unpk_c_class&>(kc_current_view_base);
{
{ kc_printer(kc_t("\
\n#ifndef KC_TRACE_PROVIDED\
\n#define KC_TRACE_PROVIDED(COND,FILE,LINE,NODE) COND\
\n#endif\
\n\
\nvoid\
\nimpl_abstract_phylum::unparse(printer_function opf, uview uv)\
\n{\
\n printer_functor_f"), kc_current_view );
kc_printer(kc_t("unction_wrapper pf(opf);\
\n do_unparse(pf, uv);\
\n}\
\n\
\n// Everything given as a pointer is expected to have an unparse-method (we\
\n// believe it's a phylum), unless there's a specialisation "), kc_current_view );
kc_printer(kc_t("for it\
\n\
\nvoid\
\nunparse(abstract_phylum kc_p, printer_functor kc_printer, uview kc_current_view)\
\n{\
\n kc_p->unparse(kc_printer, kc_current_view);\
\n}\
\n\
\nvoid\
\nunparse(void *kc_p, pr"), kc_current_view );
kc_printer(kc_t("inter_functor kc_printer, uview kc_current_view)\
\n{\
\n // MPi: 20020628 there shouldn't be any left\
\n assertionFailed(\"Unparse called for untyped pointer\");\
\n // MPi: cast should be u"), kc_current_view );
kc_printer(kc_t("nnecessary, but there are still void*\
\n reinterpret_cast<impl_abstract_phylum*>(kc_p)->unparse(kc_printer, kc_current_view);\
\n}\
\n\
\nvoid\
\nunparse(int kc_v, printer_functor kc_printer, uview"), kc_current_view );
kc_printer(kc_t(" kc_current_view)\
\n{\
\n kc_char_t kc_string[200];\
\n kc_print_integer(kc_string, kc_v);\
\n kc_printer(kc_string, kc_current_view);\
\n}\
\n\
\nvoid\
\nunparse(double kc_v, printer_functor"), kc_current_view );
kc_printer(kc_t(" kc_printer, uview kc_current_view)\
\n{\
\n kc_char_t kc_string[200];\
\n kc_print_real(kc_string, kc_v);\
\n kc_printer(kc_string, kc_current_view);\
\n}\
\n\
\nvoid\
\nunparse(kc_char_t *kc"), kc_current_view );
kc_printer(kc_t("_v, printer_functor kc_printer, uview kc_current_view)\
\n{\
\n kc_printer(kc_v, kc_current_view);\
\n}\
\n\
\nvoid\
\nunparse(kc_string_t kc_v, printer_functor kc_printer, uview kc_current_view)\
\n"), kc_current_view );
kc_printer(kc_t("{\
\n kc_printer(kc_v.c_str(), kc_current_view);\
\n}\
\n"), kc_current_view); }
kc::unparse(g_emptystring, kc_printer, view_printer_outputfileline);
assertReason(!g_options.no_unparse, "shouldn't create unpk.cc when not even generating unparse stuff");
if (!g_options.no_unparse)
{
{ kc_printer(kc_t("void\
\nimpl_abstract_phylum::default_unparse(printer_functor kc_printer, uview kc_current_view)\
\n{\
\n register int no_sons = operator_info[prod_sel()].no_sons;\
\n for (int i=0; i < no_sons; "), kc_current_view );
kc_printer(kc_t("i++)\
\n subphylum(i)->unparse(kc_printer, kc_current_view);\
\n}\
\n\
\nvoid\
\nimpl_casestring__Str::do_unparse(printer_functor kc_printer, uview kc_current_view)\
\n{\
\n kc::unparse(name, kc_pri"), kc_current_view );
kc_printer(kc_t("nter, kc_current_view);\
\n}\
\n\
\nvoid\
\nimpl_nocasestring_NoCaseStr::do_unparse(printer_functor kc_printer, uview kc_current_view)\
\n{\
\n kc::unparse(name, kc_printer, kc_current_view);\
\n}\
\n"), kc_current_view );
kc_printer(kc_t("\
\nvoid\
\nimpl_integer__Int::do_unparse(printer_functor kc_printer, uview kc_current_view)\
\n{\
\n kc::unparse(value, kc_printer, kc_current_view);\
\n}\
\n\
\nvoid\
\nimpl_real__Real::do_unparse"), kc_current_view );
kc_printer(kc_t("(printer_functor kc_printer, uview kc_current_view)\
\n{\
\n kc::unparse(value, kc_printer, kc_current_view);\
\n}\
\n\
\nvoid\
\nimpl_voidptr__VoidPtr::do_unparse(printer_functor kc_printer, uview "), kc_current_view );
kc_printer(kc_t("kc_current_view)\
\n{\
\n kc::unparse(pointer, kc_printer, kc_current_view);\
\n}\
\n\
\n"), kc_current_view); }
}
}
break;
}
case view_gen_unpk_c_enum: {
view_gen_unpk_c_class& kc_current_view=static_cast<view_gen_unpk_c_class&>(kc_current_view_base);
{
{ kc_printer(kc_t("/* translation of file(s)\n"), kc_current_view); }
kc::unparse(Thefnfiles, kc_printer, kc_current_view);
{ kc_printer(kc_t(" */\
\n/* generated by:\
\n * "), kc_current_view); }
kc::unparse(kimwitu_copyright, kc_printer, kc_current_view);
{ kc_printer(kc_t("\
\n */\
\n#define KC_UNPARSE\
\n"), kc_current_view); }
if(g_options.stdafx!="") {
PRINT("#include \"");
PRINT(g_options.stdafx.c_str());
PRINT("\"\n");
}
{ kc_printer(kc_t("\
\n#include <stdio.h>\
\n#include <string>\
\n#include <stdlib.h>\
\n#include \""), kc_current_view); }
PRINT(g_options.prefix.c_str());
{ kc_printer(kc_t("k.h\"\
\n#include \""), kc_current_view); }
PRINT(g_options.prefix.c_str());
{ kc_printer(kc_t("unpk.h\"\
\n\
\n"), kc_current_view); }
kc::unparse(this, kc_printer, view_open_namespace);
kc::unparse(Theuviewnames, kc_printer, view_gen_viewvars_c);
{ kc_printer(kc_t("\
\nimpl_uviews uviews[] = {\
\n"), kc_current_view); }
kc::unparse(Theuviewnames, kc_printer, kc_current_view);
{ kc_printer(kc_t(" {0,0}\
\n};\
\n"), kc_current_view); }
if(pg_languageshavebeendefined)
{
{ kc_printer(kc_t("\n"), kc_current_view); }
{ kc_printer(kc_t("#ifndef LANG_TEXT\n"), kc_current_view); }
{ kc_printer(kc_t("#define LANG_TEXT(i) kc_language[i]\n"), kc_current_view); }
{ kc_printer(kc_t("#endif\n\n"), kc_current_view); }
}
}
break;
}
case view_gen_end_unpk_h_enum: {
view_gen_end_unpk_h_class& kc_current_view=static_cast<view_gen_end_unpk_h_class&>(kc_current_view_base);
{
{ kc_printer(kc_t("#endif // KC_UNPARSE_HEADER\
\n"), kc_current_view); }
}
break;
}
case view_gen_rewritedecls_h_enum: {
view_gen_rewritedecls_h_class& kc_current_view=static_cast<view_gen_rewritedecls_h_class&>(kc_current_view_base);
{
const phylumdeclarations pds = this->phylumdeclarations_1;
{ kc_printer(kc_t("\
\n/* Use rviews instead\
\nextern char *kc_rview_names[];\
\n*/\
\n"), kc_current_view); }
kc::unparse(Therviewnames, kc_printer, view_rview_class_def);
}
break;
}
case view_gen_unparsedecls_h_enum: {
view_gen_unparsedecls_h_class& kc_current_view=static_cast<view_gen_unparsedecls_h_class&>(kc_current_view_base);
{
const phylumdeclarations pds = this->phylumdeclarations_1;
if(pg_languageshavebeendefined)
{
{ kc_printer(kc_t("\n"), kc_current_view); }
{ kc_printer(kc_t("#ifndef is_language\n"), kc_current_view); }
{ kc_printer(kc_t("#define is_language(L) kc_language==kc_language_##L\n"), kc_current_view); }
{ kc_printer(kc_t("#endif\n\n"), kc_current_view); }
{ kc_printer(kc_t("#ifndef set_language\n"), kc_current_view); }
{ kc_printer(kc_t("#define set_language(L) kc_language=kc_language_##L\n"), kc_current_view); }
{ kc_printer(kc_t("#endif\n\n"), kc_current_view); }
{ kc_printer(kc_t("extern char** kc_language;\n"), kc_current_view); }
kc::unparse(Thelanguages, kc_printer, kc_current_view);
}
{ kc_printer(kc_t("\
\n/* Use uviews instead\
\nextern char *kc_view_names[];\
\n*/\
\n"), kc_current_view); }
kc::unparse(Theuviewnames, kc_printer, view_uview_class_def);
{ kc_printer(kc_t("\
\nvoid unparse(abstract_phylum kc_p, printer_functor kc_printer, uview kc_current_view);\
\nvoid unparse(void *kc_p, printer_functor kc_printer, uview kc_current_view);\
\nvoid unparse(int kc_v, prin"), kc_current_view );
kc_printer(kc_t("ter_functor kc_printer, uview kc_current_view);\
\nvoid unparse(double kc_v, printer_functor kc_printer, uview kc_current_view);\
\nvoid unparse(kc_char_t *kc_v, printer_functor kc_printer, uview kc_cu"), kc_current_view );
kc_printer(kc_t("rrent_view);\
\nvoid unparse(kc_string_t kc_v, printer_functor kc_printer, uview kc_current_view);\
\n#define PRINT(string) kc_printer(string,kc_current_view)\
\n#define UNPARSE(node) node->unparse(kc_"), kc_current_view );
kc_printer(kc_t("printer,kc_current_view)\
\n"), kc_current_view); }
}
break;
}
case view_gen_unpk_h_enum: {
view_gen_unpk_h_class& kc_current_view=static_cast<view_gen_unpk_h_class&>(kc_current_view_base);
{
{ kc_printer(kc_t("/* translation of file(s)\n"), kc_current_view); }
kc::unparse(Thefnfiles, kc_printer, kc_current_view);
{ kc_printer(kc_t(" */\
\n/* generated by:\
\n * "), kc_current_view); }
kc::unparse(kimwitu_copyright, kc_printer, kc_current_view);
{ kc_printer(kc_t("\
\n */\
\n#ifndef KC_UNPARSE_HEADER\
\n#define KC_UNPARSE_HEADER\
\n\
\n"), kc_current_view); }
}
break;
}
case view_gen_fns_owninclude_c_enum: {
view_gen_fns_owninclude_c_class& kc_current_view=static_cast<view_gen_fns_owninclude_c_class&>(kc_current_view_base);
{
{ kc_printer(kc_t("#include \""), kc_current_view); }
PRINT(g_options.hfilename.c_str());
{ kc_printer(kc_t("\"\
\n"), kc_current_view); }
}
break;
}
case view_gen_fns_start_c_enum: {
view_gen_fns_start_c_class& kc_current_view=static_cast<view_gen_fns_start_c_class&>(kc_current_view_base);
{
char *printablefilename = f_make_identifier_basename( g_options.ccfilename.c_str() );
{ kc_printer(kc_t("/* translation of file \""), kc_current_view); }
kc::unparse(pg_filename, kc_printer, kc_current_view);
{ kc_printer(kc_t("\" */\
\n/* generated by:\
\n * "), kc_current_view); }
kc::unparse(kimwitu_copyright, kc_printer, kc_current_view);
{ kc_printer(kc_t("\
\n */\
\n#define KC_FUNCTIONS_"), kc_current_view); }
kc::unparse(printablefilename, kc_printer, kc_current_view);
{ kc_printer(kc_t("\
\n"), kc_current_view); }
if(g_options.stdafx!="") {
PRINT("#include \"");
PRINT(g_options.stdafx.c_str());
PRINT("\"\n");
}
{ kc_printer(kc_t("\
\n#include <stdlib.h>\
\n#include \""), kc_current_view); }
PRINT(g_options.prefix.c_str());
{ kc_printer(kc_t("k.h\"\
\n"), kc_current_view); }
delete[] printablefilename;
}
break;
}
case view_gen_fns_end_h_enum: {
view_gen_fns_end_h_class& kc_current_view=static_cast<view_gen_fns_end_h_class&>(kc_current_view_base);
{
char *printablefilename = f_make_identifier_basename( g_options.hfilename.c_str() );
{ kc_printer(kc_t("\
\n#endif // ! KC_FUNCTIONS_"), kc_current_view); }
kc::unparse(printablefilename, kc_printer, kc_current_view);
{ kc_printer(kc_t("_HEADER\
\n\
\n"), kc_current_view); }
delete[] printablefilename;
}
break;
}
case view_gen_fns_start_h_enum: {
view_gen_fns_start_h_class& kc_current_view=static_cast<view_gen_fns_start_h_class&>(kc_current_view_base);
{
char *printablefilename = f_make_identifier_basename( g_options.hfilename.c_str() );
{ kc_printer(kc_t("/* translation of file \""), kc_current_view); }
kc::unparse(pg_filename, kc_printer, kc_current_view);
{ kc_printer(kc_t("\" */\
\n/* generated by:\
\n * "), kc_current_view); }
kc::unparse(kimwitu_copyright, kc_printer, kc_current_view);
{ kc_printer(kc_t("\
\n */\
\n#ifndef KC_FUNCTIONS_"), kc_current_view); }
kc::unparse(printablefilename, kc_printer, kc_current_view);
{ kc_printer(kc_t("_HEADER\
\n#define KC_FUNCTIONS_"), kc_current_view); }
kc::unparse(printablefilename, kc_printer, kc_current_view);
{ kc_printer(kc_t("_HEADER\
\n#include \""), kc_current_view); }
PRINT(g_options.prefix.c_str());
{ kc_printer(kc_t("k.h\" // in case a user forgets\
\n\
\n"), kc_current_view); }
delete[] printablefilename;
}
break;
}
case view_gen_rewritedefs_c_enum: {
view_gen_rewritedefs_c_class& kc_current_view=static_cast<view_gen_rewritedefs_c_class&>(kc_current_view_base);
{
const phylumdeclarations pds = this->phylumdeclarations_1;
{ kc_printer(kc_t("\
\n#ifndef KC_TRACE_PROVIDED\
\n#define KC_TRACE_PROVIDED(COND,FILE,LINE,NODE) COND\
\n#endif\
\n#ifndef KC_TRACE_REWRITE_MATCH\
\n#define KC_TRACE_REWRITE_MATCH(VIEW,FILE,LINE,NODE)\
\n#endif\
\n#ifn"), kc_current_view );
kc_printer(kc_t("def KC_TRACE_REWRITE_RESULT\
\n#define KC_TRACE_REWRITE_RESULT(VIEW,FILE,LINE,NODE)\
\n#endif\
\n "), kc_current_view); }
kc::unparse(pds, kc_printer, kc_current_view);
}
break;
}
case view_gen_rewritek_c_enum: {
view_gen_rewritek_c_class& kc_current_view=static_cast<view_gen_rewritek_c_class&>(kc_current_view_base);
{
{ kc_printer(kc_t("/* translation of file(s)\n"), kc_current_view); }
kc::unparse(Thefnfiles, kc_printer, kc_current_view);
{ kc_printer(kc_t(" */\
\n/* generated by:\
\n * "), kc_current_view); }
kc::unparse(kimwitu_copyright, kc_printer, kc_current_view);
{ kc_printer(kc_t("\
\n */\
\n#define KC_REWRITE\
\n"), kc_current_view); }
if(g_options.stdafx!="") {
PRINT("#include \"");
PRINT(g_options.stdafx.c_str());
PRINT("\"\n");
}
{ kc_printer(kc_t("\
\n#include <stdio.h>\
\n#include <sys/types.h>\
\n#include <stdlib.h>\
\n#include \""), kc_current_view); }
PRINT(g_options.prefix.c_str());
{ kc_printer(kc_t("k.h\"\
\n#include \""), kc_current_view); }
PRINT(g_options.prefix.c_str());
{ kc_printer(kc_t("rk.h\"\
\n\
\n"), kc_current_view); }
if(g_options.rw_loop)
{
{ kc_printer(kc_t("#include <deque>\
\n#include <stack>\
\n#include <vector>\
\n"), kc_current_view); }
}
kc::unparse(this, kc_printer, view_open_namespace);
kc::unparse(Therviewnames, kc_printer, view_gen_viewvars_c);
{ kc_printer(kc_t("\
\nimpl_rviews rviews[] = {\
\n"), kc_current_view); }
kc::unparse(Therviewnames, kc_printer, kc_current_view);
{ kc_printer(kc_t(" {0,0}\
\n};\
\n"), kc_current_view); }
if(g_options.rw_loop)
{
string how_smart = "";
if(g_options.smart_pointer) how_smart="_ptr";
{ kc_printer(kc_t("\
\n\
\nstatic inline int\
\nkc_sons(abstract_phylum ph) {\
\n return KC_NO_SONS(ph->prod_sel());\
\n}\
\n\
\nstatic abstract_phylum\
\nkc_create_op(enum_operators kc_op, std::vector<abstract_phylum"), kc_current_view); }
kc::unparse(how_smart, kc_printer, kc_current_view);
{ kc_printer(kc_t(">& sons, size_t no_of_sons) {\
\n size_t son_offset = sons.size()-no_of_sons;\
\n switch(no_of_sons) {\n"), kc_current_view); }
kc::unparse(Theargsnumbers, kc_printer, kc_current_view);
{ kc_printer(kc_t(" default:\v\
\n assertionFailed(\"unexpected number of sub-phyla\");\r\
\n }\r\
\n}\
\n\
\nstatic void\
\ninitialize_sons_stack(abstract_phylum"), kc_current_view); }
kc::unparse(how_smart, kc_printer, kc_current_view);
{ kc_printer(kc_t("& kc_p, bool& skip,\
\n std::stack<abstract_phylum"), kc_current_view); }
kc::unparse(how_smart, kc_printer, kc_current_view);
{ kc_printer(kc_t(">& node_stack, std::stack<int>& sons_todo,\
\n rview kc_current_view_base)\
\n{\
\n // Initialize stack for depth first rewrite\
\n assertCond(kc_p);\
\n size_t no_of_sons=kc_sons(kc_p);\
\n "), kc_current_view );
kc_printer(kc_t(" while(!skip && (no_of_sons>0)) {\
\n sons_todo.push(no_of_sons);\
\n abstract_phylum parent = kc_p;\
\n for(int i = no_of_sons-1; i>=0; --i) {\
\n node_stack.push(kc_p);\
\n kc_p = parent->s"), kc_current_view );
kc_printer(kc_t("ubphylum(i);\
\n }\
\n kc_p = kc_current_view_base.pre_rewrite(kc_p, skip);\
\n assertCond(kc_p);\
\n no_of_sons = kc_sons(kc_p);\
\n }\
\n // The deepest first son is now in kc_p.\
\n // On t"), kc_current_view );
kc_printer(kc_t("he node_stack are the siblings and then the parent.\
\n}\
\n\
\nstatic bool\
\nsons_changed(abstract_phylum"), kc_current_view); }
kc::unparse(how_smart, kc_printer, kc_current_view);
{ kc_printer(kc_t(" current_son, const std::vector<abstract_phylum"), kc_current_view); }
kc::unparse(how_smart, kc_printer, kc_current_view);
{ kc_printer(kc_t(">& sons_done, size_t no_of_sons)\
\n{\
\n bool changed = false;\
\n for(int i=no_of_sons-1; i>=0; --i) {\
\n if(sons_done[sons_done.size()-no_of_sons+i] != current_son->subphylum(i)) {\
\n ch"), kc_current_view );
kc_printer(kc_t("anged=true;\
\n break;\
\n }\
\n }\
\n return changed;\
\n}\
\n\
\nabstract_phylum impl_abstract_phylum::rewrite_loop(rview kc_current_view_base) {\
\n std::stack<abstract_phylum"), kc_current_view); }
kc::unparse(how_smart, kc_printer, kc_current_view);
{ kc_printer(kc_t("> node_stack;\
\n std::stack<int> sons_todo;\
\n std::vector<abstract_phylum"), kc_current_view); }
kc::unparse(how_smart, kc_printer, kc_current_view);
{ kc_printer(kc_t("> sons_done;\
\n\
\n abstract_phylum"), kc_current_view); }
kc::unparse(how_smart, kc_printer, kc_current_view);
{ kc_printer(kc_t(" current_son=this;\
\n\
\n do {\
\n bool skip=false;\
\n current_son = kc_current_view_base.pre_rewrite(current_son, skip);\
\n initialize_sons_stack(current_son, skip, node_stack, sons_todo, kc_cur"), kc_current_view );
kc_printer(kc_t("rent_view_base);\
\n \
\n bool changed=true;\
\n do {\
\n assertCond(current_son);\
\n\
\n abstract_phylum"), kc_current_view); }
kc::unparse(how_smart, kc_printer, kc_current_view);
{ kc_printer(kc_t(" res=current_son;\
\n if(!skip)\
\n res=current_son->do_rewrite(kc_current_view_base);\
\n\
\n assertCond(res);\
\n changed=true;\
\n\
\n if(res==current_son) { // nothing has been cha"), kc_current_view );
kc_printer(kc_t("nged, current_son is completely rewritten\
\n if(!skip) { // call post_rewrite if this node is not skipped\
\n bool again=false;\
\n current_son=kc_current_view_base.post_rewrite(current_son"), kc_current_view );
kc_printer(kc_t(", again);\
\n assertCond(current_son);\
\n if(again)\
\n \vbreak;\r // starts the whole rewrite_loop for the post_rewritten node again\
\n }\
\n else\
\n skip=false;\
\n\
\n sons_do"), kc_current_view );
kc_printer(kc_t("ne.push_back(current_son); // move this son to sons_done\
\n\
\n if(!node_stack.empty()) { // else all is done\
\n assertCond(!sons_todo.empty());\
\n assertCond(sons_todo.top()>0);\
\n "), kc_current_view );
kc_printer(kc_t(" --sons_todo.top(); // one less to todo\
\n\
\n if(sons_todo.top()==0) { // all sons done\
\n sons_todo.pop(); // forget it\
\n\
\n current_son=node_stack.top(); // the parent of the original "), kc_current_view );
kc_printer(kc_t("last done sons\
\n node_stack.pop();\
\n // the last (rewritten) son of this parent is\
\n // on top of sons_done (sons_done[sons_done.size()-1])\
\n\
\n size_t no_of_sons=kc_sons(current_son);"), kc_current_view );
kc_printer(kc_t("\
\n assertCond(sons_done.size() >= no_of_sons);\
\n changed = sons_changed(current_son, sons_done, no_of_sons);\
\n if(changed) { // some sons are different ->\
\n \v\v// create a new operat"), kc_current_view );
kc_printer(kc_t("or and make it the current\
\n \r\rabstract_phylum"), kc_current_view); }
kc::unparse(how_smart, kc_printer, kc_current_view);
{ kc_printer(kc_t(" new_son =\
\n \vkc_create_op(current_son->prod_sel(), sons_done, no_of_sons);\r\
\n new_son->rewrite_members(current_son);\
\n current_son = new_son;\
\n // the sons do not need t"), kc_current_view );
kc_printer(kc_t("o be rewritten again\
\n changed=false;\
\n }\
\n // The current node must still be rewritten,\
\n // but not its sons anymore (changed == false).\
\n // Those sons are in the current nod"), kc_current_view );
kc_printer(kc_t("e, so no-one needs\
\n // them anymore and they are popped off the stack.\
\n sons_done.resize(sons_done.size() - no_of_sons);\
\n }\
\n else { // make the complete loop with the next son"), kc_current_view );
kc_printer(kc_t(" (changed == true)\
\n current_son = node_stack.top();\
\n node_stack.pop();\
\n }\
\n }\
\n else {\
\n current_son = 0; // terminates the loop\
\n }\
\n }\
\n else // somethin"), kc_current_view );
kc_printer(kc_t("g has been changed -> start rewrite with the changed node again\
\n current_son=res;\
\n } while(!changed);\
\n } while(current_son);\
\n\
\n assertCond(sons_todo.size()==0);\
\n assertCond(s"), kc_current_view );
kc_printer(kc_t("ons_done.size()==1);\
\n return sons_done[0]"), kc_current_view); }
if(g_options.smart_pointer)
{
{ kc_printer(kc_t(".return_ptr()"), kc_current_view); }
}
{ kc_printer(kc_t("; // done.top()\
\n}\
\n"), kc_current_view); }
}
}
break;
}
case view_gen_end_rewritek_h_enum: {
view_gen_end_rewritek_h_class& kc_current_view=static_cast<view_gen_end_rewritek_h_class&>(kc_current_view_base);
{
{ kc_printer(kc_t("#endif // KC_REWRITE_HEADER\n"), kc_current_view); }
}
break;
}
case view_gen_rewritek_h_enum: {
view_gen_rewritek_h_class& kc_current_view=static_cast<view_gen_rewritek_h_class&>(kc_current_view_base);
{
{ kc_printer(kc_t("/* translation of file(s)\n"), kc_current_view); }
kc::unparse(Thefnfiles, kc_printer, kc_current_view);
{ kc_printer(kc_t(" */\
\n/* generated by:\
\n * "), kc_current_view); }
kc::unparse(kimwitu_copyright, kc_printer, kc_current_view);
{ kc_printer(kc_t("\
\n */\
\n#ifndef KC_REWRITE_HEADER\
\n#define KC_REWRITE_HEADER\
\n\
\n"), kc_current_view); }
}
break;
}
case view_gen_copydefs_c_enum: {
view_gen_copydefs_c_class& kc_current_view=static_cast<view_gen_copydefs_c_class&>(kc_current_view_base);
{
const phylumdeclarations pds = this->phylumdeclarations_1;
{ kc_printer(kc_t("abstract_phylum\
\nimpl_abstract_phylum::copy(bool kc_copy_attributes) const\
\n{\
\n enum_phyla kc_phy = phylum(); // XXX - implement special cases in subclasses - MvL\
\n KC_OPERATOR_INFO *kc_o"), kc_current_view );
kc_printer(kc_t("p_info = &operator_info[prod_sel()];\
\n kc_storageclass_t kc_st = phylum_info[kc_op_info->phylum].uniq_stored;\
\n if (kc_st && kc_storageclass_still_uniq[kc_st])\
\n return const_cast<abstract_"), kc_current_view );
kc_printer(kc_t("phylum>(this);\
\n abstract_phylum kc_answer=0;\
\n if (kc_phy == phylum_casestring) {\
\n kc_answer=mkcasestring((dynamic_cast<c_casestring>(this))->name);\
\n } else if (kc_phy == phylum_noc"), kc_current_view );
kc_printer(kc_t("asestring) {\