Commit d4b0b21e authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

switch return statement to external visitor

2007-09-17  Juerg Billeter  <j@bitron.ch>

	* vala/valacodevisitor.vala, vala/valamemorymanager.vala,
	  vala/valareturnstatement.vala, vala/valasemanticanalyzer.vala,
	  vala/valasymbolresolver.vala, gobject/valacodegenerator.vala: switch
	  return statement to external visitor

svn path=/trunk/; revision=613
parent 6b906cd7
2007-09-17 Jürg Billeter <j@bitron.ch>
* vala/valacodevisitor.vala, vala/valamemorymanager.vala,
vala/valareturnstatement.vala, vala/valasemanticanalyzer.vala,
vala/valasymbolresolver.vala, gobject/valacodegenerator.vala: switch
return statement to external visitor
2007-09-17 Jürg Billeter <j@bitron.ch>
* vala/valablock.vala, vala/valacodevisitor.vala,
......
......@@ -1799,7 +1799,7 @@ public class Vala.CodeGenerator : CodeVisitor {
expr.temp_vars.add (return_expr_decl);
}
public override void visit_begin_return_statement (ReturnStatement! stmt) {
public override void visit_return_statement (ReturnStatement! stmt) {
if (stmt.return_expression != null) {
// avoid unnecessary ref/unref pair
if (stmt.return_expression.ref_missing &&
......@@ -1816,9 +1816,9 @@ public class Vala.CodeGenerator : CodeVisitor {
}
}
}
}
public override void visit_end_return_statement (ReturnStatement! stmt) {
stmt.accept_children (this);
if (stmt.return_expression == null) {
stmt.ccodenode = new CCodeReturnStatement ();
......
......@@ -348,19 +348,11 @@ public abstract class Vala.CodeVisitor : Object {
}
/**
* Visit operation called at beginning of return statements.
* Visit operation called for return statements.
*
* @param stmt a return statement
*/
public virtual void visit_begin_return_statement (ReturnStatement! stmt) {
}
/**
* Visit operation called at end of return statements.
*
* @param stmt a return statement
*/
public virtual void visit_end_return_statement (ReturnStatement! stmt) {
public virtual void visit_return_statement (ReturnStatement! stmt) {
}
/**
......
......@@ -157,7 +157,9 @@ public class Vala.MemoryManager : CodeVisitor {
stmt.accept_children (this);
}
public override void visit_end_return_statement (ReturnStatement! stmt) {
public override void visit_return_statement (ReturnStatement! stmt) {
stmt.accept_children (this);
if (stmt.return_expression != null) {
if (current_symbol is Method) {
var m = (Method) current_symbol;
......
......@@ -30,9 +30,7 @@ public class Vala.ReturnStatement : CodeNode, Statement {
* The optional expression to return.
*/
public Expression return_expression {
get {
return _return_expression;
}
get { return _return_expression; }
set {
_return_expression = value;
if (_return_expression != null) {
......@@ -46,25 +44,23 @@ public class Vala.ReturnStatement : CodeNode, Statement {
/**
* Creates a new return statement.
*
* @param result the return expression
* @param source reference to source code
* @return newly created return statement
* @param return_expression the return expression
* @param source_reference reference to source code
* @return newly created return statement
*/
public ReturnStatement (Expression result = null, SourceReference source = null) {
return_expression = result;
source_reference = source;
public ReturnStatement (construct Expression return_expression = null, construct SourceReference source_reference = null) {
}
public override void accept (CodeVisitor! visitor) {
visitor.visit_begin_return_statement (this);
visitor.visit_return_statement (this);
}
public override void accept_children (CodeVisitor! visitor) {
if (return_expression != null) {
return_expression.accept (visitor);
visitor.visit_end_full_expression (return_expression);
}
visitor.visit_end_return_statement (this);
}
public override void replace (CodeNode! old_node, CodeNode! new_node) {
......
......@@ -933,7 +933,9 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
stmt.tree_can_fail = stmt.collection.tree_can_fail || stmt.body.tree_can_fail;
}
public override void visit_end_return_statement (ReturnStatement! stmt) {
public override void visit_return_statement (ReturnStatement! stmt) {
stmt.accept_children (this);
if (stmt.return_expression != null && stmt.return_expression.error) {
// ignore inner error
stmt.error = true;
......
......@@ -315,6 +315,10 @@ public class Vala.SymbolResolver : CodeVisitor {
stmt.accept_children (this);
}
public override void visit_return_statement (ReturnStatement! stmt) {
stmt.accept_children (this);
}
public override void visit_throw_statement (ThrowStatement! stmt) {
stmt.accept_children (this);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment