2008-02-05 Jürg Billeter <j@bitron.ch>
+ * vala/valacfgbuilder.vala, vala/valapropertyaccessor.vala: build
+ control flow graph for property accessors
+
+2008-02-05 Jürg Billeter <j@bitron.ch>
+
* gee/hashmap.vala, gee/readonlycollection.vala, gee/readonlylist.vala,
gee/readonlymap.vala, gee/readonlyset.vala: remove unreachable
return statements
private CodeContext context;
private BasicBlock current_block;
private bool unreachable_reported;
- private Method current_method;
private Gee.List<JumpTarget> jump_stack = new ArrayList<JumpTarget> ();
public CFGBuilder () {
return;
}
- var old_method = current_method;
- current_method = m;
-
m.entry_block = new BasicBlock.entry ();
m.exit_block = new BasicBlock.exit ();
current_block.connect (m.exit_block);
}
+ }
+
+ public override void visit_property (Property! prop) {
+ prop.accept_children (this);
+ }
+
+ public override void visit_property_accessor (PropertyAccessor! acc) {
+ if (acc.body == null) {
+ return;
+ }
+
+ acc.entry_block = new BasicBlock.entry ();
+ acc.exit_block = new BasicBlock.exit ();
+
+ current_block = new BasicBlock ();
+ acc.entry_block.connect (current_block);
- current_method = old_method;
+ jump_stack.add (new JumpTarget.return_target (acc.exit_block));
+
+ acc.accept_children (this);
+
+ jump_stack.remove_at (jump_stack.size - 1);
+
+ if (current_block != null) {
+ // end of property accessor body reachable
+
+ if (acc.readable) {
+ Report.error (acc.source_reference, "missing return statement at end of property getter body");
+ acc.error = true;
+ }
+
+ current_block.connect (acc.exit_block);
+ }
}
public override void visit_block (Block! b) {
/* valapropertyaccessor.vala
*
- * Copyright (C) 2006-2007 Jürg Billeter
+ * Copyright (C) 2006-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
* The accessor body.
*/
public Block body { get; set; }
-
+
+ public BasicBlock entry_block { get; set; }
+
+ public BasicBlock exit_block { get; set; }
+
/**
* Represents the generated value parameter in a set accessor.
*/