Commit 2d67e9ce authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

switch assignment to external visitor

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

	* vala/valaassignment.vala, vala/valacodevisitor.vala,
	  vala/valamemorymanager.vala, vala/valasemanticanalyzer.vala,
	  vala/valasymbolresolver.vala,
	  gobject/valacodegeneratorassignment.vala: switch assignment to
	  external visitor

svn path=/trunk/; revision=611
parent b1d1dd97
2007-09-17 Jürg Billeter <j@bitron.ch>
* vala/valaassignment.vala, vala/valacodevisitor.vala,
vala/valamemorymanager.vala, vala/valasemanticanalyzer.vala,
vala/valasymbolresolver.vala,
gobject/valacodegeneratorassignment.vala: switch assignment to
external visitor
2007-09-16 Jürg Billeter <j@bitron.ch>
* vala/valamemorymanager.vala: fix memory management when using lambda
......
......@@ -25,7 +25,9 @@ using GLib;
using Gee;
public class Vala.CodeGenerator {
public override void visit_end_assignment (Assignment! a) {
public override void visit_assignment (Assignment! a) {
a.accept_children (this);
MemberAccess ma = null;
if (a.left is MemberAccess) {
......
/* valaassignment.vala
*
* Copyright (C) 2006 Jürg Billeter
* Copyright (C) 2006-2007 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
......@@ -32,9 +32,7 @@ public class Vala.Assignment : Expression {
* Left hand side of the assignment.
*/
public Expression! left {
get {
return _left;
}
get { return _left; }
set construct {
_left = value;
_left.parent_node = this;
......@@ -50,9 +48,7 @@ public class Vala.Assignment : Expression {
* Right hand side of the assignment.
*/
public Expression! right {
get {
return _right;
}
get { return _right; }
set construct {
_right = value;
_right.parent_node = this;
......@@ -65,27 +61,22 @@ public class Vala.Assignment : Expression {
/**
* Creates a new assignment.
*
* @param left left hand side
* @param op assignment operator
* @param right right hand side
* @param source reference to source code
* @return newly created assignment
* @param left left hand side
* @param operator assignment operator
* @param right right hand side
* @param source_reference reference to source code
* @return newly created assignment
*/
public Assignment (Expression! _left, Expression! _right, AssignmentOperator _op = AssignmentOperator.SIMPLE, SourceReference _source = null) {
left = _left;
operator = _op;
right = _right;
source_reference = _source;
public Assignment (construct Expression! left, construct Expression! right, construct AssignmentOperator operator = AssignmentOperator.SIMPLE, construct SourceReference source_reference = null) {
}
public override void accept (CodeVisitor! visitor) {
left.accept (visitor);
visitor.visit_begin_assignment (this);
visitor.visit_assignment (this);
}
public override void accept_children (CodeVisitor! visitor) {
left.accept (visitor);
right.accept (visitor);
visitor.visit_end_assignment (this);
}
public override void replace (CodeNode! old_node, CodeNode! new_node) {
......
......@@ -645,19 +645,11 @@ public abstract class Vala.CodeVisitor : Object {
}
/**
* Visit operation called at beginning of assignments.
* Visit operation called for assignments.
*
* @param a an assignment
*/
public virtual void visit_begin_assignment (Assignment! a) {
}
/**
* Visit operation called at end of assignments.
*
* @param a an assignment
*/
public virtual void visit_end_assignment (Assignment! a) {
public virtual void visit_assignment (Assignment! a) {
}
/**
......
......@@ -268,7 +268,9 @@ public class Vala.MemoryManager : CodeVisitor {
visit_possibly_leaked_expression (expr.right);
}
public override void visit_end_assignment (Assignment! a) {
public override void visit_assignment (Assignment! a) {
a.accept_children (this);
if (a.left is PointerIndirection || a.left.symbol_reference is Signal) {
} else {
if (a.left.static_type.takes_ownership) {
......
......@@ -2548,7 +2548,15 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
l.symbol_reference = l.method;
}
public override void visit_begin_assignment (Assignment! a) {
public override void visit_assignment (Assignment! a) {
a.left.accept (this);
if (a.left.error) {
// skip on error in inner expression
a.error = true;
return;
}
if (a.left is MemberAccess) {
var ma = (MemberAccess) a.left;
......@@ -2579,11 +2587,13 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
} else {
a.error = true;
Report.error (a.source_reference, "unsupported lvalue in assignment");
return;
}
}
public override void visit_end_assignment (Assignment! a) {
if (a.error || a.left.error || a.right.error) {
a.right.accept (this);
if (a.right.error) {
// skip on error in inner expression
a.error = true;
return;
}
......
......@@ -318,4 +318,8 @@ public class Vala.SymbolResolver : CodeVisitor {
public override void visit_array_creation_expression (ArrayCreationExpression! e) {
e.accept_children (this);
}
public override void visit_assignment (Assignment! a) {
a.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