ignore .lib and .exe
[prop.git] / prop-src / datatype.h
blobfd79ea504829ccab1d4f2019ac6d4a5fc1113f88
1 ///////////////////////////////////////////////////////////////////////////////
2 // This file is generated automatically using Prop (version 2.3.6),
3 // last updated on Nov 2, 1999.
4 // The original source file is "datatype.ph".
5 ///////////////////////////////////////////////////////////////////////////////
7 #line 1 "datatype.ph"
8 //////////////////////////////////////////////////////////////////////////////
9 //
10 // The following classes are used to generate C++ class definitions
11 // for algebraic datatypes.
13 //////////////////////////////////////////////////////////////////////////////
14 #ifndef datatype_class_definition
15 #define datatype_class_definition
17 #include "classdef.h"
18 #include "ast.h"
19 #include "basics.h"
21 //////////////////////////////////////////////////////////////////////////////
23 // Forward type definitions.
25 //////////////////////////////////////////////////////////////////////////////
26 class DatatypeClass;
27 class DatatypeHierarchy;
29 //////////////////////////////////////////////////////////////////////////////
31 // This class represents one subclass in an algebraic datatype class
32 // hierarchy.
34 //////////////////////////////////////////////////////////////////////////////
35 class DatatypeClass : public ClassDefinition
36 { DatatypeClass();
37 DatatypeClass(const DatatypeClass&);
38 void operator = (const DatatypeClass&);
40 protected:
41 Id constructor_name; // name of constructor
42 Id is_const; // a const type?
43 Cons cons; // the constructor descriptor
44 DatatypeHierarchy * root; // root of the hierarchy
45 Bool generating_list_special_forms;
46 Ty cons_arg_ty; // current constructor argument type
47 Bool is_list; // is it a list
48 Bool is_array; // is it an array
49 Bool has_destructor;
50 public:
51 ///////////////////////////////////////////////////////////////////////////
53 // Constructors and destructors
55 ///////////////////////////////////////////////////////////////////////////
56 DatatypeClass(CLASS_TYPE,
57 Id, Id, TyVars, Inherits, TyQual, Decls, Cons,
58 DatatypeHierarchy *);
59 virtual ~DatatypeClass();
61 void instantiate_datatype(CodeGen&, TyVars);
62 void generate_forward_declarations(CodeGen&);
63 void generate_datatype_constructor(CodeGen&,
64 Tys, DefKind = INLINE_IMPLEMENTATION);
66 virtual void visualize(PropVisualizer&);
68 protected:
70 friend class DatatypeHierarchy;
72 // Methods that adhere to the ClassDefinition protocol
73 virtual void gen_class_destructor_body(CodeGen&, Tys, DefKind);
75 virtual void gen_class_predefinition(CodeGen&);
76 virtual void gen_class_interface(CodeGen&);
77 virtual void gen_class_postdefinition(CodeGen&);
78 virtual void gen_class_implementation(CodeGen&, Tys, DefKind);
80 virtual void gen_class_instantiation(CodeGen&, Tys, DefKind);
82 // Methods for generating the functionality for various features
83 void generate_persistence_interface(CodeGen&);
84 void generate_logic_interface(CodeGen&);
85 void generate_gc_interface(CodeGen&);
86 void generate_inference_interface(CodeGen&);
87 virtual void generate_print_interface(CodeGen&);
89 void generate_persistence_implementation(CodeGen&, Tys, DefKind);
90 void generate_logic_implementation(CodeGen&, Tys, DefKind);
91 void generate_gc_implementation(CodeGen&, Tys, DefKind);
92 void generate_inference_implementation(CodeGen&, Tys, DefKind);
93 virtual void generate_print_implementation(CodeGen&, Tys, DefKind);
95 private:
96 //
97 // Methods for generating class constructor code.
98 virtual void gen_class_constructor(CodeGen&, Tys, DefKind);
99 virtual void gen_class_constructor_parameters(CodeGen&, Tys, DefKind);
100 virtual void gen_class_constructor_initializers(CodeGen&, Tys, DefKind);
101 virtual void gen_class_constructor_body(CodeGen&, Tys, DefKind);
102 void gen_constructor_initializers(CodeGen&, Tys, DefKind, Ty, Id, Id);
103 void gen_array_initializer(CodeGen&, Tys, DefKind, Id, Ty, Id);
106 // Methods for generating garbage collection code
108 void gen_super_class_tracing_methods(CodeGen&, Tys, DefKind);
109 void gen_field_tracing_methods(CodeGen&, Exp, Ty, Tys, DefKind, Bool=false);
112 // Methods for generating persistence I/O code
114 void gen_super_class_persist_IO(CodeGen&, Tys, DefKind, Id);
115 void gen_field_persist_IO(CodeGen&, Exp, Ty, Tys, DefKind, Id, Bool=false);
118 //////////////////////////////////////////////////////////////////////////////
120 // This class is responsible for generating a class hierarchy for a
121 // algebraic datatype.
123 //////////////////////////////////////////////////////////////////////////////
124 class DatatypeHierarchy : public DatatypeClass
126 DatatypeHierarchy(const DatatypeHierarchy&);
127 void operator = (const DatatypeHierarchy&);
129 protected:
130 friend class DatatypeClass;
131 const Id datatype_name; // name of datatype
132 const TermDefs term_defs; // datatype terms
133 DatatypeClass ** subclasses; // subclasses of the hierarchy
134 int number_of_subclasses;
135 int arity; // total number of constructors
136 int unit_constructors; // number of unit constructors
137 int arg_constructors; // number of argument constructors
138 Cons * constructor_terms; // constructor descriptors
139 TyOpt optimizations; // optimizations?
140 Bool inline_methods; // should be inline the methods?
141 Bool has_variant_tag; // do we have a variant tag?
142 Bool use_gc_base; // do we need to trace base class?
143 Bool use_persist_base; // do we need to print base class?
144 Ty datatype_ty; // type of the datatype
145 Bool got_info;
147 void get_info();
148 public:
149 DatatypeHierarchy(Id,TyVars,Inherits,TyQual,TermDefs, Decls);
150 virtual ~DatatypeHierarchy();
152 void generate_forward_declarations(CodeGen&);
153 void generate_datatype_definitions(CodeGen&);
154 void generate_datatype_instantiations(CodeGen&, Tys, Bool);
156 virtual void gen_class_instantiation(CodeGen&, Tys, DefKind);
158 virtual void visualize(PropVisualizer&);
159 protected:
161 // Methods to generate code
162 void generate_forward_class_declarations(CodeGen&);
163 void generate_forward_constructor_declarations(CodeGen&);
164 void generate_unit_constructors(CodeGen&);
165 void generate_constructor_tags(CodeGen&, Id, Id, int, Cons []);
166 void generate_define_tags(CodeGen&, int, Cons []);
167 void generate_untagging_member_functions(CodeGen&);
168 void generate_untagging_functions(CodeGen&);
169 void generate_downcasting_functions(CodeGen&);
170 void generate_datatype_constructors(CodeGen&, Tys, DefKind);
172 // Methods to instantiate templates
173 void gen_untagging_function_instantiation(CodeGen&, Tys, DefKind);
174 void gen_downcasting_function_instantiation(CodeGen&, Tys, DefKind);
176 // Methods that adhere to the ClassDefinition protocol
177 virtual void gen_class_interface(CodeGen&);
178 virtual void gen_class_implementation(CodeGen&, Tys, DefKind);
179 virtual void gen_class_postdefinition(CodeGen&);
181 private:
182 // Methods to constructor the class hierarchy
183 void build_class_hierarchy();
184 DatatypeClass * build_one_subclass(Cons);
185 void build_inheritance_list();
187 // Methods for generating pretty printers
188 virtual void generate_print_interface(CodeGen&);
189 virtual void generate_print_implementation(CodeGen&, Tys, DefKind);
190 void generate_printer(CodeGen&, Tys, DefKind, Ty, Cons);
191 void generate_default_printer(CodeGen&, Tys, DefKind, Ty, Cons, Ty);
192 void generate_formatted_printer(CodeGen&, Tys, DefKind, Ty, Cons, Ty,
193 PrintFormats);
194 void gen_print_field(CodeGen&, Exp, Ty);
197 #endif
198 #line 191 "datatype.ph"
200 ------------------------------- Statistics -------------------------------
201 Merge matching rules = yes
202 Number of DFA nodes merged = 0
203 Number of ifs generated = 0
204 Number of switches generated = 0
205 Number of labels = 0
206 Number of gotos = 0
207 Adaptive matching = enabled
208 Fast string matching = disabled
209 Inline downcasts = enabled
210 --------------------------------------------------------------------------