gtk+-4.0: Update to 3.93.0+f4c1a404
[vala-gnome.git] / vala / valabasicblock.vala
blobf1c3ea810596983289cf9fbde41dd0aa017f5b16
1 /* valabasicblock.vala
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
19 * Author:
20 * Jürg Billeter <j@bitron.ch>
23 using GLib;
25 /**
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> ();
32 // control flow graph
33 private List<weak BasicBlock> predecessors = new ArrayList<weak BasicBlock> ();
34 private List<BasicBlock> successors = new ArrayList<BasicBlock> ();
36 // dominator tree
37 public BasicBlock parent { get; private set; }
38 List<BasicBlock> children = new ArrayList<BasicBlock> ();
39 Set<BasicBlock> df = new HashSet<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) {
56 nodes.add (node);
59 public List<CodeNode> get_nodes () {
60 return 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 () {
73 return predecessors;
76 public List<BasicBlock> get_successors () {
77 return successors;
80 public void add_child (BasicBlock block) {
81 children.add (block);
82 block.parent = this;
85 public List<BasicBlock> get_children () {
86 return children;
89 public void add_dominator_frontier (BasicBlock block) {
90 df.add (block);
93 public Set<BasicBlock> get_dominator_frontier () {
94 return df;
97 public void add_phi_function (PhiFunction phi) {
98 phi_functions.add (phi);
101 public Set<PhiFunction> get_phi_functions () {
102 return phi_functions;