2007-09-17 Jürg Billeter <j@bitron.ch>
+ * vala/valablock.vala, vala/valacodevisitor.vala,
+ vala/valaforeachstatement.vala, vala/valamemorymanager.vala,
+ vala/valasemanticanalyzer.vala, vala/valaswitchsection.vala,
+ vala/valasymbolresolver.vala, gobject/valacodegenerator.vala: switch
+ block to external visitor
+
+2007-09-17 Jürg Billeter <j@bitron.ch>
+
* vala/valaassignment.vala, vala/valacodevisitor.vala,
vala/valamemorymanager.vala, vala/valasemanticanalyzer.vala,
vala/valasymbolresolver.vala,
d.accept_children (this);
}
- public override void visit_begin_block (Block! b) {
+ public override void visit_block (Block! b) {
current_symbol = b;
- }
- public override void visit_end_block (Block! b) {
+ b.accept_children (this);
+
var local_vars = b.get_local_variables ();
foreach (VariableDeclarator decl in local_vars) {
decl.active = false;
cswitchblock.append (ctopstmt);
}
+ public override void visit_switch_section (SwitchSection! section) {
+ visit_block (section);
+ }
+
public override void visit_while_statement (WhileStatement! stmt) {
stmt.ccodenode = new CCodeWhileStatement ((CCodeExpression) stmt.condition.ccodenode, (CCodeStatement) stmt.body.ccodenode);
create_temp_decl (stmt, stmt.condition.temp_vars);
}
- public override void visit_begin_foreach_statement (ForeachStatement! stmt) {
+ public override void visit_foreach_statement (ForeachStatement! stmt) {
stmt.variable_declarator.active = true;
stmt.collection_variable_declarator.active = true;
if (stmt.iterator_variable_declarator != null) {
stmt.iterator_variable_declarator.active = true;
}
- }
- public override void visit_end_foreach_statement (ForeachStatement! stmt) {
+ visit_block (stmt);
+
var cblock = new CCodeBlock ();
// sets #line
stmt.ccodenode = cblock;
public Collection<VariableDeclarator> get_local_variables () {
return new ReadOnlyCollection<VariableDeclarator> (local_variables);
}
-
+
public override void accept (CodeVisitor! visitor) {
- visitor.visit_begin_block (this);
+ visitor.visit_block (this);
+ }
+ public override void accept_children (CodeVisitor! visitor) {
foreach (Statement! stmt in statement_list) {
stmt.accept (visitor);
}
-
- visitor.visit_end_block (this);
}
}
}
/**
- * Visit operation called at beginning of blocks.
+ * Visit operation called for blocks.
*
* @param b a block
*/
- public virtual void visit_begin_block (Block! b) {
- }
-
- /**
- * Visit operation called at end of blocks.
- *
- * @param b a block
- */
- public virtual void visit_end_block (Block! b) {
+ public virtual void visit_block (Block! b) {
}
/**
}
/**
- * Visit operation called at beginning of foreach statements.
- *
- * @param stmt a foreach statement
- */
- public virtual void visit_begin_foreach_statement (ForeachStatement! stmt) {
- }
-
- /**
- * Visit operation called at end of foreach statements.
+ * Visit operation called for foreach statements.
*
* @param stmt a foreach statement
*/
- public virtual void visit_end_foreach_statement (ForeachStatement! stmt) {
+ public virtual void visit_foreach_statement (ForeachStatement! stmt) {
}
/**
}
public override void accept (CodeVisitor! visitor) {
- visitor.visit_begin_foreach_statement (this);
-
- visitor.visit_begin_block (this);
+ visitor.visit_foreach_statement (this);
+ }
+ public override void accept_children (CodeVisitor! visitor) {
type_reference.accept (visitor);
collection.accept (visitor);
visitor.visit_end_full_expression (collection);
body.accept (visitor);
-
- visitor.visit_end_block (this);
-
- visitor.visit_end_foreach_statement (this);
}
public override void replace (CodeNode! old_node, CodeNode! new_node) {
visit_possibly_leaked_expression (n.argument);
}
+ public override void visit_block (Block! b) {
+ b.accept_children (this);
+ }
+
public override void visit_variable_declarator (VariableDeclarator! decl) {
decl.accept_children (this);
visit_possibly_leaked_expression (stmt.expression);
}
+ public override void visit_switch_section (SwitchSection! section) {
+ section.accept_children (this);
+ }
+
+ public override void visit_foreach_statement (ForeachStatement! stmt) {
+ stmt.accept_children (this);
+ }
+
public override void visit_end_return_statement (ReturnStatement! stmt) {
if (stmt.return_expression != null) {
if (current_symbol is Method) {
public override void visit_named_argument (NamedArgument! n) {
}
- public override void visit_begin_block (Block! b) {
+ public override void visit_block (Block! b) {
b.owner = current_symbol.scope;
current_symbol = b;
- }
- public override void visit_end_block (Block! b) {
+ b.accept_children (this);
+
foreach (VariableDeclarator decl in b.get_local_variables ()) {
decl.active = false;
}
}
}
+ public override void visit_switch_section (SwitchSection! section) {
+ foreach (SwitchLabel label in section.get_labels ()) {
+ label.accept (this);
+ }
+
+ section.owner = current_symbol.scope;
+ current_symbol = section;
+
+ foreach (Statement st in section.get_statements ()) {
+ st.accept (this);
+ }
+
+ foreach (VariableDeclarator decl in section.get_local_variables ()) {
+ decl.active = false;
+ }
+
+ current_symbol = current_symbol.parent_symbol;
+ }
+
public override void visit_while_statement (WhileStatement! stmt) {
if (stmt.condition.error) {
/* if there was an error in the condition, skip this check */
}
}
- public override void visit_begin_foreach_statement (ForeachStatement! stmt) {
+ public override void visit_foreach_statement (ForeachStatement! stmt) {
if (stmt.type_reference.data_type != null) {
current_source_file.add_symbol_dependency (stmt.type_reference.data_type, SourceFileDependencyType.SOURCE);
}
stmt.body.add_local_variable (stmt.variable_declarator);
stmt.variable_declarator.active = true;
- }
- public override void visit_end_foreach_statement (ForeachStatement! stmt) {
+ stmt.owner = current_symbol.scope;
+ current_symbol = stmt;
+
+ stmt.accept_children (this);
+
+ foreach (VariableDeclarator decl in stmt.get_local_variables ()) {
+ decl.active = false;
+ }
+
+ current_symbol = current_symbol.parent_symbol;
+
if (stmt.collection.error) {
// ignore inner error
stmt.error = true;
}
public override void accept (CodeVisitor! visitor) {
+ visitor.visit_switch_section (this);
+ }
+
+ public override void accept_children (CodeVisitor! visitor) {
foreach (SwitchLabel label in labels) {
label.accept (visitor);
}
- visitor.visit_begin_block (this);
-
foreach (Statement st in statement_list) {
st.accept (visitor);
}
-
- visitor.visit_switch_section (this);
- visitor.visit_end_block (this);
}
}
d.accept_children (this);
}
+ public override void visit_block (Block! b) {
+ b.accept_children (this);
+ }
+
public override void visit_namespace_reference (NamespaceReference! ns) {
ns.namespace_symbol = current_scope.lookup (ns.name);
if (ns.namespace_symbol == null) {
list.accept_children (this);
}
+ public override void visit_switch_section (SwitchSection! section) {
+ section.accept_children (this);
+ }
+
+ public override void visit_foreach_statement (ForeachStatement! stmt) {
+ stmt.accept_children (this);
+ }
+
public override void visit_throw_statement (ThrowStatement! stmt) {
stmt.accept_children (this);
}