1 ///////////////////////////////////////////////////////////////////////////////
3 // This file describes the interface of the SETL-like sublanguage compiler.
5 ///////////////////////////////////////////////////////////////////////////////
6 #ifndef SETL_data_mapping_compiler_h
7 #define SETL_data_mapping_compiler_h
13 ///////////////////////////////////////////////////////////////////////////////
15 // Forward declarations
17 ///////////////////////////////////////////////////////////////////////////////
18 datatype Time and Space;
20 ///////////////////////////////////////////////////////////////////////////////
22 // Type checking methods
24 ///////////////////////////////////////////////////////////////////////////////
25 extern Ty type_of (Exp, const Env&); // type checking an expression
26 extern Tys type_of (Exps, const Env&); // type checking an expression list
27 extern .[Id,Ty] type_of (LabExp, const Env&); // type checking an labeled expression
28 extern .[Ids,Tys] type_of (LabExps, const Env&); // type checking an labeled expression list
29 extern Env type_of (Def, const Env&); // type checking a definition
30 extern Env type_of (Defs, const Env&); // type checking a definition list
31 extern void type_of (Stmt, const Env&); // type checking a statement
32 extern void type_of (Stmts, const Env&); // type checking a statement list
34 ///////////////////////////////////////////////////////////////////////////////
36 // We inherit from the code generator and the match compiler.
38 ///////////////////////////////////////////////////////////////////////////////
39 class SETLCompiler : virtual public CodeGen,
40 virtual public MatchCompiler
42 SETLCompiler(const SETLCompiler&); // no copy constructor
43 void operator = (const SETLCompiler&); // no assignment
45 ////////////////////////////////////////////////////////////////////////////
47 // Constructor and destructor
49 ////////////////////////////////////////////////////////////////////////////
51 virtual ~SETLCompiler();
53 ////////////////////////////////////////////////////////////////////////////
55 // Generate SETL-like statements and definitions
57 ////////////////////////////////////////////////////////////////////////////
63 ////////////////////////////////////////////////////////////////////////////
65 // Domain inference methods
67 ////////////////////////////////////////////////////////////////////////////
69 ////////////////////////////////////////////////////////////////////////////
71 // Time and space complexity inference methods
73 ////////////////////////////////////////////////////////////////////////////
74 .[Time,Space] complexity_of (Exp, const Env&);
75 .[Time,Space] complexity_of (Stmt, const Env&);
77 ////////////////////////////////////////////////////////////////////////////
79 // Code generation methods
81 ////////////////////////////////////////////////////////////////////////////
82 void gen_def (Def); // code generation for definitions
83 void gen_defs (Defs); // code generation for definition lists
84 void gen_stmt (Stmt); // code generation for statements
85 void gen_stmts (Stmts); // code generation for statement lists
86 void gen_exp (Exp); // code generation for expressions
87 void gen_exps (Exps); // code generation for expression lists