LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cjump.hxx
Go to the documentation of this file.
1 
6 #ifndef TREE_CJUMP_HXX
7 # define TREE_CJUMP_HXX
8 
9 # include <tree/cjump.hh>
10 # include <misc/contract.hh>
11 # include <temp/label.hh>
12 
13 namespace tree
14 {
15  inline
17  const rExp& left, const rExp& right,
18  const rName& iftrue, const rName& iffalse)
19  : Stm()
20  , relop_(relop)
21  {
22  child_push_back(left);
23  child_push_back(right);
24  child_push_back(iftrue);
25  child_push_back(iffalse);
26  }
27 
28  inline rExp
30  {
31  return child_get(0).cast<Exp>();
32  }
33 
34  inline rExp
36  {
37  return child_get(1).cast<Exp>();
38  }
39 
40  inline temp::Label
42  {
43  const rName name = child_get(2).cast<Name>();
44  return name->label_get();
45  }
46 
47  inline temp::Label
49  {
50  const rName name = child_get(3).cast<Name>();
51  return name->label_get();
52  }
53 
54  inline void
55  Cjump::label_false_set(const temp::Label& false_label)
56  {
57  children_.pop_back();
58  children_.push_back(new Name(false_label));
59  }
60 
63  {
65  return res;
66  }
67 
68  inline void
70  {
71  precondition(children_.size() == 4);
72  rTree iftrue = child_get(2);
73  rTree iffalse = child_get(3);
74  children_.pop_back();
75  children_.pop_back();
76  children_.push_back(iffalse);
77  children_.push_back(iftrue);
78  switch (relop_)
79  {
80  case eq: relop_ = ne; break;
81  case ne: relop_ = eq; break;
82  case lt: relop_ = ge; break;
83  case gt: relop_ = le; break;
84  case le: relop_ = gt; break;
85  case ge: relop_ = lt; break;
86  case ult: relop_ = uge; break;
87  case ugt: relop_ = ule; break;
88  case ule: relop_ = ugt; break;
89  case uge: relop_ = ult; break;
90  }
91  }
92 
93  inline const Cjump::Relop&
95  {
96  return relop_;
97  }
98 
99 }
100 
101 #endif // !TREE_CJUMP_HXX