use typename
[prop.git] / prop-src / datagen.h.old
blobfa1e1cef237fa46f6aa7069455bea72862d32e38
1 ///////////////////////////////////////////////////////////////////////////////
2 //  The Datatype compiler
3 ///////////////////////////////////////////////////////////////////////////////
4 #ifndef datatype_compiler_h
5 #define datatype_compiler_h
7 #include "codegen.h"
8 #include "labelgen.h"
9 #include "ir.h"
10 #include "ast.h"
12 class DatatypeCompiler : virtual public CodeGen {
13    DatatypeCompiler(const DatatypeCompiler&);  // no copy constructor
14    void operator = (const DatatypeCompiler&);  // no assignment
15 public:
16    ////////////////////////////////////////////////////////////////////////////
17    //  Constructor and destructor
18    ////////////////////////////////////////////////////////////////////////////
19             DatatypeCompiler(TyOpt opt, int embedded_tags);
20    virtual ~DatatypeCompiler();
22    void preprocess_def (DatatypeDef);
24 private:
26    TyOpt optimizations;     // optimizations in place
27    int   max_embedded_tags; // maximum tags that can be embedded into the
28                             // lower bits of a pointer. 
29    int   max_embedded_bits;
30    LabelGen temp_vars;
32 protected:
33    ////////////////////////////////////////////////////////////////////////////
34    //  Methods for mapping datatypes into C++ classes. 
35    ////////////////////////////////////////////////////////////////////////////
36    void gen_datatype                 (DatatypeDefs, ViewDefs, LawDefs, TyDefs);
37    void gen_forward_def              (DatatypeDef);
38    void gen_forward_class_def        (Id, TyVars, TyQual);
39    void gen_type_def                 (TyDef);
40    void gen_unit_constructors        (Id, int, Cons [], Bool, Bool = false);
41    void gen_class_hierarchy          (DatatypeDef);
42    void gen_forward_arg_constructors (Id, TyVars, int, int, TyOpt, Cons []);
43    Bool gen_base_class               (Id, TyVars, int, int, TyOpt, Cons [], 
44                                       Inherits, TyQual, Decls);
45    void pr_subclass                  (Bool&, Id);
46    void gen_subclass                 (Id, TyVars, int, int, TyOpt, TyQual, Cons);
47    void gen_class_interface          (Id, TyVars, Id, TyQual, TyOpt, TyQual);
48    void gen_class_constructor        (Id, TyVars, Id, int, int, TyOpt, Ty, Bool, TyQual);
49    void gen_class_destructor         (Id, TyVars, Id, Ty, TyQual, TyOpt, Bool);
50    void gen_datatype_constructor     (Id, TyVars, Id, int, int, TyOpt, Ty, Bool, TyQual);
51    void gen_untagging_functions      (Id, TyVars, int, int, TyQual, TyOpt);
52    void gen_downcasting_functions    (Id, TyVars, int, Cons [], TyQual);
54    ////////////////////////////////////////////////////////////////////////////
55    //  Methods for generating datatype laws
56    ////////////////////////////////////////////////////////////////////////////
57    void gen_law_defs    (LawDefs);
58    void gen_law_inverse (Id, Ids, Exp, Ty);
60    ////////////////////////////////////////////////////////////////////////////
61    //  Methods for generating datatype instantiation code.
62    ////////////////////////////////////////////////////////////////////////////
63    void instantiate_datatypes (Bool, Tys);
64    void instantiate_datatype  (Bool, Id, TyVars,
65             Tys, int, int, int, int, Ty, Inherits, Cons []);
67    ////////////////////////////////////////////////////////////////////////////
68    //  Methods for generating garbage collection code.
69    ////////////////////////////////////////////////////////////////////////////
70    Bool gen_gc_trace (Bool, Id, TyVars, Tys, Id, Ty, Ty, int, Inherits, Bool);
71    void gen_trace    (Ty, Id); 
72    
73    ////////////////////////////////////////////////////////////////////////////
74    //  Methods for generating pretty printing code.
75    ////////////////////////////////////////////////////////////////////////////
76    void gen_pretty_printer    (Bool, Ty, Tys);
77    void gen_formated_printer  (Cons, Ty, PrintFormats);
78    void gen_default_printer   (Cons, Ty);
80    ////////////////////////////////////////////////////////////////////////////
81    //  Methods for generating persistence stream reading/writing code.
82    ////////////////////////////////////////////////////////////////////////////
83    Bool gen_persistence(Bool, Id, TyVars, Tys, Id, Ty, Ty, int, Inherits, Bool);
84    Bool gen_persist_IO_body (Id, TyVars, Tys, Id, Ty, Id, Inherits, Bool);
85    void gen_persist_IO      (Ty, Id, Id);
88 #endif