LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
translation.hh
Go to the documentation of this file.
1 
17 #ifndef TRANSLATE_TRANSLATION_HH
18 # define TRANSLATE_TRANSLATION_HH
19 
20 # include <frame/frame.hh>
21 # include <translate/fwd.hh>
22 
23 namespace translate
24 {
25 
26  /*--------.
27  | /Var/. |
28  `--------*/
29 
32 
33  // The USE_LEVEL wants to use THIS Access. Return a Tree expression
34  // computing this access (including all the static links
35  // manipulations).
36  rExp simple_var(const Access& access, const Level& use_level);
37  rExp field_var(rExp var_exp, int index);
38  rExp subscript_var(rExp var_exp, rExp index_exp);
39 
41 
42 
43  /*--------.
44  | /Exp/. |
45  `--------*/
46 
49 
50  rExp nil_exp();
51  rExp int_exp(int value);
52 
53  // Strings cannot be used as values, rather, we need to store them
54  // somewhere with a label, and return a NAME to that label.
55  // FRAGMENT is set to the snippet which defines the string.
56  rExp string_exp(const std::string& value, tree::Fragment*& fragment);
57 
58  rExp record_exp(std::list<rExp> args);
59 
63  rExp static_link(const Level* decl, const Level* use);
64 
66  rExp call_exp(const temp::Label& label, std::list<rExp> args);
68  rExp call_exp(const std::string& label, rExp arg1, rExp arg2 = nullptr);
69 
71  rExp op_exp(const ast::OpExp::Oper oper, rExp left, rExp right);
72 
73 
75  rExp seq_exp(std::list<rExp>& exps);
76 
77  // Try to produce simple code for simple cases.
78  rExp eseq_exp(std::list<rExp>& exps);
79 
80  rExp assign_exp(rExp dst, rExp src);
81 
82  // All the work is delayed until we know how the IfExp will be used,
83  // i.e., once the Ix is "un'ed".
84  rExp if_exp(rExp test, rExp then_clause, rExp else_clause);
85 
86 
87 
88  rExp while_exp(rExp test, rExp body, const temp::Label& ldone);
89 
90  // FIXME: Some code was deleted here (for_exp -- "for" loop translation).
91 
92  rExp break_exp(const temp::Label& loop_end);
93  rExp array_exp(rExp array_size, rExp init_val);
94 
96 
97  /*--------.
98  | /Dec/. |
99  `--------*/
100 
103 
104  // A function or a procedure being declared has no value by itself.
105  // Just store its body in a FRAGMENT which will be handled later on.
106 
108  const misc::symbol& name,
109  rExp body,
110  frame::Frame* frame);
111 
112  // A function must save its value into the `return value' register.
114  const misc::symbol& name,
115  rExp value,
116  frame::Frame* frame);
117 
119 }
120 
121 #endif // !TRANSLATE_TRANSLATION_HH