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>
27 * Represents a basic block, i.e. a straight-line piece of code without any
28 * jumps or jump targets.
30 public class Vala
.BasicBlock
{
31 private Gee
.List
<CodeNode
> nodes
= new ArrayList
<CodeNode
> ();
34 private Gee
.List
<weak BasicBlock
> predecessors
= new ArrayList
<weak BasicBlock
> ();
35 private Gee
.List
<BasicBlock
> successors
= new ArrayList
<BasicBlock
> ();
38 public BasicBlock parent
{ get; private set; }
39 Gee
.List
<BasicBlock
> children
= new ArrayList
<BasicBlock
> ();
40 Set
<BasicBlock
> df
= new HashSet
<BasicBlock
> ();
42 Set
<PhiFunction
> phi_functions
= new HashSet
<PhiFunction
> ();
44 public BasicBlock () {
47 public BasicBlock
.entry () {
50 public BasicBlock
.exit () {
53 public void add_node (CodeNode node
) {
57 public Gee
.List
<CodeNode
> get_nodes () {
61 public void connect (BasicBlock target
) {
62 if (!successors
.contains (target
)) {
63 successors
.add (target
);
65 if (!target
.predecessors
.contains (this
)) {
66 target
.predecessors
.add (this
);
70 public Gee
.List
<weak BasicBlock
> get_predecessors () {
71 return new ReadOnlyList
<weak BasicBlock
> (predecessors
);
74 public Gee
.List
<weak BasicBlock
> get_successors () {
75 return new ReadOnlyList
<weak BasicBlock
> (successors
);
78 public void add_child (BasicBlock block
) {
83 public Gee
.List
<BasicBlock
> get_children () {
87 public void add_dominator_frontier (BasicBlock block
) {
91 public Gee
.Set
<BasicBlock
> get_dominator_frontier () {
95 public void add_phi_function (PhiFunction phi
) {
96 phi_functions
.add (phi
);
99 public Gee
.Set
<PhiFunction
> get_phi_functions () {
100 return phi_functions
;