diff options
author | Juerg Billeter <j@bitron.ch> | 2008-01-23 15:26:07 +0000 |
---|---|---|
committer | Jürg Billeter <juergbi@src.gnome.org> | 2008-01-23 15:26:07 +0000 |
commit | 92a2bd696c9d174bbd579b44ea6823a88bef9a97 (patch) | |
tree | 71a7d7ef5efb4ad8e5dcf90f922f5861e3c7ec57 /vala/valabasicblock.vala | |
parent | d8d589fb944d1991dd9feca866b90dac3ac52377 (diff) | |
download | vala-92a2bd696c9d174bbd579b44ea6823a88bef9a97.tar.gz |
build control flow graph, report error for missing return statement in
2008-01-23 Juerg Billeter <j@bitron.ch>
* vala/Makefile.am, vala/valabasicblock.vala, vala/valacfgbuilder.vala,
vala/valadostatement.vala, vala/valaforstatement.vala,
vala/valaifstatement.vala, vala/valamemorymanager.vala,
vala/valamethod.vala, vala/valasemanticanalyzer.vala,
vala/valasymbolresolver.vala, vala/valawhilestatement.vala,
gobject/valaccodegenerator.vala, compiler/valacompiler.vala: build
control flow graph, report error for missing return statement in
non-void methods, and report warning for unreachable code,
fixes bug 508480
* tests/exceptions.vala: add missing return statement
svn path=/trunk/; revision=894
Diffstat (limited to 'vala/valabasicblock.vala')
-rw-r--r-- | vala/valabasicblock.vala | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/vala/valabasicblock.vala b/vala/valabasicblock.vala new file mode 100644 index 000000000..bee017147 --- /dev/null +++ b/vala/valabasicblock.vala @@ -0,0 +1,65 @@ +/* valabasicblock.vala + * + * Copyright (C) 2008 Jürg Billeter + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Author: + * Jürg Billeter <j@bitron.ch> + */ + +using GLib; +using Gee; + +/** + * Represents a basic block, i.e. a straight-line piece of code without any + * jumps or jump targets. + */ +public class Vala.BasicBlock : Object { + private Gee.List<CodeNode> nodes = new ArrayList<CodeNode> (); + + private Gee.List<weak BasicBlock> predecessors = new ArrayList<weak BasicBlock> (); + private Gee.List<BasicBlock> successors = new ArrayList<BasicBlock> (); + + public BasicBlock () { + } + + public BasicBlock.entry () { + } + + public BasicBlock.exit () { + } + + public void add_node (CodeNode node) { + nodes.add (node); + } + + public void connect (BasicBlock target) { + if (!successors.contains (target)) { + successors.add (target); + } + if (!target.predecessors.contains (this)) { + target.predecessors.add (this); + } + } + + public Gee.List<weak BasicBlock> get_predecessors () { + return new ReadOnlyList<weak BasicBlock> (predecessors); + } + + public Gee.List<weak BasicBlock> get_successors () { + return new ReadOnlyList<weak BasicBlock> (successors); + } +} |