ignore .lib and .exe
[prop.git] / prop-src / classdef.h
blob12db7aea2fa78ad97c3f2c2daceee13ee750c8f0
1 //////////////////////////////////////////////////////////////////////////////
2 //
3 // The following class is the base class of all strategies to
4 // generate a special Prop class definition.
5 //
6 //////////////////////////////////////////////////////////////////////////////
7 #ifndef class_definition
8 #define class_definition
10 #include "codegen.h"
11 #include "ir.h"
12 #include "ast.h"
13 #include "hashtab.h"
15 //////////////////////////////////////////////////////////////////////////////
17 // Forward definitions
19 //////////////////////////////////////////////////////////////////////////////
20 class PropVisualizer;
22 //////////////////////////////////////////////////////////////////////////////
24 // This class represents a basic class definition
26 //////////////////////////////////////////////////////////////////////////////
27 class ClassDefinition : public Loc
29 ClassDefinition();
30 ClassDefinition(const ClassDefinition&);
31 void operator = (const ClassDefinition&);
32 public:
33 ///////////////////////////////////////////////////////////////////////////
35 // Types of various subclasses. For matters of convenience, we'll
36 // break the encapsulation and let the base class knows its own
37 // identity.
39 ///////////////////////////////////////////////////////////////////////////
40 enum CLASS_TYPE { DATATYPE_CLASS,
41 REWRITE_CLASS,
42 SYNTAX_CLASS,
43 INFERENCE_CLASS,
44 GRAPHTYPE_CLASS,
45 DATAFLOW_CLASS,
46 DATATYPE_SUBCLASS,
47 ATTRIBUTE_GRAMMAR_CLASS,
48 CONSTRAINT_CLASS,
49 ANY_CLASS,
50 LAST_CLASS
52 static const char * class_type_name[LAST_CLASS];
53 static HashTable defined_classes;
54 public:
55 ///////////////////////////////////////////////////////////////////////////
57 // All classes definition include the following information
59 ///////////////////////////////////////////////////////////////////////////
60 const CLASS_TYPE class_type; //
61 Id class_name; // name of class
62 TyVars parameters; // type parameters
63 Inherits inherited_classes; // all inherited classes
64 TyQual qualifiers; // all qualifiers
65 Decls class_body; // class body
66 Protocols protocols; // protocols
67 Decls constructor_code; // code for constructor
68 Decls destructor_code; // code for destructor
70 enum DefKind { INTERFACE_DEFINITION, // interface in a class
71 INLINE_IMPLEMENTATION, // interface + implementation
72 EXTERNAL_IMPLEMENTATION, // external implementation
73 EXTERNAL_INSTANTIATION, // external (per instance)
74 EXTERNAL_DEFINITION
77 public:
78 ///////////////////////////////////////////////////////////////////////////
80 // Constructors and destructors
82 ///////////////////////////////////////////////////////////////////////////
83 ClassDefinition(CLASS_TYPE, Id, TyVars, Inherits, TyQual, Decls);
84 virtual ~ClassDefinition();
86 ///////////////////////////////////////////////////////////////////////////
88 // Useful methods
90 ///////////////////////////////////////////////////////////////////////////
91 Id mangled_name() const; // name of class mangled
92 Bool is_polymorphic() const; // polymorphic type?
93 Bool is_view() const; // is it a view?
94 void add_base_class (Id, Scope = PUBLICscope, TyQual = QUALnone);
95 void append_base_class (Id, Scope = PUBLICscope, TyQual = QUALnone);
97 ///////////////////////////////////////////////////////////////////////////
99 // Method to generate a class definition
101 ///////////////////////////////////////////////////////////////////////////
102 virtual void gen_class_predefinition(CodeGen&);
103 virtual void gen_class_definition(CodeGen&);
104 virtual void gen_class_postdefinition(CodeGen&);
105 virtual void gen_class_implementation(CodeGen&, Tys, DefKind);
107 ///////////////////////////////////////////////////////////////////////////
109 // Methods to generate code for a class
111 ///////////////////////////////////////////////////////////////////////////
112 virtual void gen_class_constructor(CodeGen&,Tys,DefKind);
113 virtual void gen_class_destructor(CodeGen&,Tys,DefKind);
115 ///////////////////////////////////////////////////////////////////////////
117 // Method for visualizing the class
119 ///////////////////////////////////////////////////////////////////////////
120 virtual void visualize (PropVisualizer&);
122 ///////////////////////////////////////////////////////////////////////////
124 // Retrieve information from class
126 ///////////////////////////////////////////////////////////////////////////
127 static ClassDefinition * lookup_class (CLASS_TYPE, Id name);
128 static ClassDefinition * lookup_class_or_datatype(Id name, Id constr);
129 static void insert_class (ClassDefinition *);
131 ///////////////////////////////////////////////////////////////////////////
133 // Methods to update constructor/destructor information
135 ///////////////////////////////////////////////////////////////////////////
136 static void add_constructor_code(Id name, Id constr, Decls);
137 static void add_destructor_code(Id name, Id destr, Decls);
139 protected:
140 virtual void gen_class_interface(CodeGen&);
141 virtual void gen_class_constructor_parameters(CodeGen&,Tys,DefKind);
142 virtual void gen_class_constructor_initializers(CodeGen&,Tys,DefKind);
143 virtual void gen_class_constructor_body(CodeGen&,Tys,DefKind);
144 virtual void gen_class_destructor_body(CodeGen&,Tys,DefKind);
147 #endif