gcc config
[prop.git] / prop-src / setlgen.pcc
blob2075b9760ef50217d08384fa3cd86fb92af10ae5
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 //  This file implements the data structure mapping component of the
4 //  SETL sublanguage.
5 //
6 ///////////////////////////////////////////////////////////////////////////////
7 #include "ir.ph"
8 #include "ast.ph"
9 #include "setl-ast.ph"
10 #include "setlgen.h"
11 #include "type.h"
13 ///////////////////////////////////////////////////////////////////////////////
15 //  Constructor and destructor
17 ///////////////////////////////////////////////////////////////////////////////
18 SETLCompiler:: SETLCompiler() {}
19 SETLCompiler::~SETLCompiler() {}
21 ///////////////////////////////////////////////////////////////////////////////
23 //  Entry points of the SETL data structure mapping compiler
25 ///////////////////////////////////////////////////////////////////////////////
27 ///////////////////////////////////////////////////////////////////////////////
29 //  Generate a SETL statement
31 ///////////////////////////////////////////////////////////////////////////////
32 void SETLCompiler::gen_setl (Stmt stmt)
33 {  
34    bug("SETL sublanguage is not implemented");
35    gen_stmt(stmt);
38 ///////////////////////////////////////////////////////////////////////////////
40 //  Generate a SETL definition
42 ///////////////////////////////////////////////////////////////////////////////
43 void SETLCompiler::gen_setl (Def def)
44 {  pr ("%^/*\n");
45    gen_def(def);
46    pr ("%^*/\n");
49 ///////////////////////////////////////////////////////////////////////////////
51 //  Code generation method for definitions
53 ///////////////////////////////////////////////////////////////////////////////
54 void SETLCompiler::gen_def (Def def)
58 ///////////////////////////////////////////////////////////////////////////////
60 //  Code generation method for a list of definitions
62 ///////////////////////////////////////////////////////////////////////////////
63 void SETLCompiler::gen_defs (Defs defs)
64 {  match while (defs)
65    {  #[ one ... rest ]: { gen_def(one); defs = rest; }
66    }
69 ///////////////////////////////////////////////////////////////////////////////
71 //  Code generation method for statements
73 ///////////////////////////////////////////////////////////////////////////////
74 void SETLCompiler::gen_stmt (Stmt stmt)
75 {   match (stmt) of
76        NOstmt: // skip
77     |  ASSIGNstmt(a,b):
78     |  BLOCKstmt(defs,stmts):
79     |  WHILEstmt(c, s):
80     |  IFstmt(cond,yes,no):   
81     |  MATCHstmt decl:        pr("%D",decl);
82     |  REWRITEstmt decl:      pr("%D",decl); 
83     |  REPLACEMENTstmt decl:  pr("%D",decl); 
84     |  FORALLstmt (_,_): // skip
85     |  RETURNstmt e:          pr("return %e;",e);
86     end match;
89 ///////////////////////////////////////////////////////////////////////////////
91 //  Code generation method for a list of statements
93 ///////////////////////////////////////////////////////////////////////////////
94 void SETLCompiler::gen_stmts (Stmts stmts)
95 {  match while (stmts)
96    {  #[ one ... rest ]: { gen_stmt(one); stmts = rest; }
97    }
100 ///////////////////////////////////////////////////////////////////////////////
102 //  Code generation method for expressions
104 ///////////////////////////////////////////////////////////////////////////////
105 void SETLCompiler::gen_exp (Exp exp)
109 ///////////////////////////////////////////////////////////////////////////////
111 //  Code generation method for an expression list
113 ///////////////////////////////////////////////////////////////////////////////
114 void SETLCompiler::gen_exps (Exps exps)
115 {  match while (exps)
116    {  #[one]:           { gen_exp(one); exps = #[]; }
117    |  #[one ... rest]:  { gen_exp(one); exps = rest; }
118    }