3 * Copyright (C) 2008 Jürg Billeter
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * Jürg Billeter <j@bitron.ch>
26 * Represents a basic block, i.e. a straight-line piece of code without any
27 * jumps or jump targets.
29 public class Vala
.BasicBlock
{
30 private List
<CodeNode
> nodes
= new ArrayList
<CodeNode
> ();
33 private List
<weak BasicBlock
> predecessors
= new ArrayList
<weak BasicBlock
> ();
34 private List
<weak BasicBlock
> successors
= new ArrayList
<weak BasicBlock
> ();
37 public weak BasicBlock parent
{ get; private set; }
38 List
<weak BasicBlock
> children
= new ArrayList
<weak BasicBlock
> ();
39 Set
<weak BasicBlock
> df
= new HashSet
<weak BasicBlock
> ();
41 Set
<PhiFunction
> phi_functions
= new HashSet
<PhiFunction
> ();
43 public bool postorder_visited
{ get; set; }
44 public int postorder_number
{ get; set; }
46 public BasicBlock () {
49 public BasicBlock
.entry () {
52 public BasicBlock
.exit () {
55 public void add_node (CodeNode node
) {
59 public List
<CodeNode
> get_nodes () {
63 public void connect (BasicBlock target
) {
64 if (!successors
.contains (target
)) {
65 successors
.add (target
);
67 if (!target
.predecessors
.contains (this
)) {
68 target
.predecessors
.add (this
);
72 public List
<weak BasicBlock
> get_predecessors () {
76 public List
<weak BasicBlock
> get_successors () {
80 public void add_child (BasicBlock block
) {
85 public List
<weak BasicBlock
> get_children () {
89 public void add_dominator_frontier (BasicBlock block
) {
93 public Set
<weak BasicBlock
> get_dominator_frontier () {
97 public void add_phi_function (PhiFunction phi
) {
98 phi_functions
.add (phi
);
101 public Set
<PhiFunction
> get_phi_functions () {
102 return phi_functions
;