Commit 5bed9071 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

, vala/valadestructor.vala, vala/valasemanticanalyzer.vala,

2008-04-19  Juerg Billeter  <j@bitron.ch>

	* vala/valaclass.vala:, vala/valadestructor.vala,
	  vala/valasemanticanalyzer.vala, gobject/valaccodeclassbinding.vala:
	  support `this' access in destructors, fixes bug 527997

svn path=/trunk/; revision=1273
parent 11964f8c
2008-04-19 Jürg Billeter <j@bitron.ch>
* vala/valaclass.vala:, vala/valadestructor.vala,
vala/valasemanticanalyzer.vala, gobject/valaccodeclassbinding.vala:
support `this' access in destructors, fixes bug 527997
2008-04-19 Jürg Billeter <j@bitron.ch>
* vala/valasemanticanalyzer.vala: don't check for `pointer' struct
......
......@@ -334,7 +334,7 @@ public class Vala.CCodeClassBinding : CCodeTypesymbolBinding {
}
/* set dispose function */
if (cl.get_fields ().size > 0) {
if (cl.get_fields ().size > 0 || cl.destructor != null) {
var ccast = new CCodeFunctionCall (new CCodeIdentifier ("G_OBJECT_CLASS"));
ccast.add_argument (new CCodeIdentifier ("klass"));
init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess.pointer (ccast, "dispose"), new CCodeIdentifier ("%s_dispose".printf (cl.get_lower_case_cname (null))))));
......
......@@ -97,13 +97,27 @@ public class Vala.Class : Typesymbol {
/**
* Specifies the instance destructor.
*/
public Destructor destructor { get; set; }
public Destructor? destructor {
get { return _destructor; }
set {
_destructor = value;
if (_destructor != null) {
if (_destructor.this_parameter != null) {
_destructor.scope.remove (_destructor.this_parameter.name);
}
_destructor.this_parameter = new FormalParameter ("this", new ClassType (this));
_destructor.scope.add (_destructor.this_parameter.name, _destructor.this_parameter);
}
}
}
/**
* Specifies whether this class denotes an error base.
*/
public bool is_error_base { get; set ; }
Destructor? _destructor;
/**
* Creates a new class.
*
......
/* valadestructor.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
......@@ -31,16 +31,16 @@ public class Vala.Destructor : Symbol {
*/
public Block body { get; set; }
private bool _instance = true;
/**
* Specifies the generated `this' parameter for instance methods.
*/
public FormalParameter this_parameter { get; set; }
/**
* Specifies whether this is an instance or a class destructor.
*/
public bool instance {
get { return _instance; }
set { _instance = value; }
}
public bool instance { get; set; default = true; }
/**
* Creates a new destructor.
*
......
......@@ -2166,6 +2166,8 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
} else if (sym is Constructor) {
var c = (Constructor) sym;
return c.instance;
} else if (sym is Destructor) {
return true;
} else if (sym is Property) {
return true;
}
......
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