[vala] Reverse free order for local variables
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Reverse free order for local variables
- Date: Thu, 8 Jul 2010 10:46:32 +0000 (UTC)
commit 6d7d3bcbca54367b3d902b15e53b5c387e28348b
Author: Jürg Billeter <j bitron ch>
Date: Thu Jul 8 12:45:12 2010 +0200
Reverse free order for local variables
Last created should be destroyed first.
codegen/valaccodebasemodule.vala | 19 +++++++++++++++----
codegen/valadovabasemodule.vala | 19 +++++++++++++++----
2 files changed, 30 insertions(+), 8 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 4e54057..b06df43 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -1742,7 +1742,12 @@ public class Vala.CCodeBaseModule : CCodeModule {
data.add_field ("GDestroyNotify", get_delegate_target_destroy_notify_cname (get_variable_cname (local.name)));
}
}
-
+ }
+ }
+ // free in reverse order
+ for (int i = local_vars.size - 1; i >= 0; i--) {
+ var local = local_vars[i];
+ if (local.captured) {
if (requires_destroy (local.variable_type)) {
bool old_coroutine = false;
if (current_method != null) {
@@ -1878,7 +1883,9 @@ public class Vala.CCodeBaseModule : CCodeModule {
}
}
- foreach (LocalVariable local in local_vars) {
+ // free in reverse order
+ for (int i = local_vars.size - 1; i >= 0; i--) {
+ var local = local_vars[i];
if (!local.unreachable && !local.floating && !local.captured && requires_destroy (local.variable_type)) {
var ma = new MemberAccess.simple (local.name);
ma.symbol_reference = local;
@@ -3125,7 +3132,9 @@ public class Vala.CCodeBaseModule : CCodeModule {
var b = (Block) sym;
var local_vars = b.get_local_variables ();
- foreach (LocalVariable local in local_vars) {
+ // free in reverse order
+ for (int i = local_vars.size - 1; i >= 0; i--) {
+ var local = local_vars[i];
if (!local.unreachable && local.active && !local.floating && !local.captured && requires_destroy (local.variable_type)) {
var ma = new MemberAccess.simple (local.name);
ma.symbol_reference = local;
@@ -3161,7 +3170,9 @@ public class Vala.CCodeBaseModule : CCodeModule {
var b = (Block) sym;
var local_vars = b.get_local_variables ();
- foreach (LocalVariable local in local_vars) {
+ // free in reverse order
+ for (int i = local_vars.size - 1; i >= 0; i--) {
+ var local = local_vars[i];
if (!local.unreachable && local.active && !local.floating && !local.captured && requires_destroy (local.variable_type)) {
var ma = new MemberAccess.simple (local.name);
ma.symbol_reference = local;
diff --git a/codegen/valadovabasemodule.vala b/codegen/valadovabasemodule.vala
index 4e3662f..c742d95 100644
--- a/codegen/valadovabasemodule.vala
+++ b/codegen/valadovabasemodule.vala
@@ -753,7 +753,12 @@ internal class Vala.DovaBaseModule : CCodeModule {
generate_type_declaration (local.variable_type, source_declarations);
data.add_field (local.variable_type.get_cname (), get_variable_cname (local.name) + local.variable_type.get_cdeclarator_suffix ());
-
+ }
+ }
+ // free in reverse order
+ for (int i = local_vars.size - 1; i >= 0; i--) {
+ var local = local_vars[i];
+ if (local.captured) {
if (requires_destroy (local.variable_type)) {
var ma = new MemberAccess.simple (local.name);
ma.symbol_reference = local;
@@ -881,7 +886,9 @@ internal class Vala.DovaBaseModule : CCodeModule {
}
}
- foreach (LocalVariable local in local_vars) {
+ // free in reverse order
+ for (int i = local_vars.size - 1; i >= 0; i--) {
+ var local = local_vars[i];
if (!local.floating && !local.captured && requires_destroy (local.variable_type)) {
var ma = new MemberAccess.simple (local.name);
ma.symbol_reference = local;
@@ -1386,7 +1393,9 @@ internal class Vala.DovaBaseModule : CCodeModule {
var b = (Block) sym;
var local_vars = b.get_local_variables ();
- foreach (LocalVariable local in local_vars) {
+ // free in reverse order
+ for (int i = local_vars.size - 1; i >= 0; i--) {
+ var local = local_vars[i];
if (local.active && !local.floating && !local.captured && requires_destroy (local.variable_type)) {
var ma = new MemberAccess.simple (local.name);
ma.symbol_reference = local;
@@ -1421,7 +1430,9 @@ internal class Vala.DovaBaseModule : CCodeModule {
var b = (Block) sym;
var local_vars = b.get_local_variables ();
- foreach (LocalVariable local in local_vars) {
+ // free in reverse order
+ for (int i = local_vars.size - 1; i >= 0; i--) {
+ var local = local_vars[i];
if (local.active && !local.floating && !local.captured && requires_destroy (local.variable_type)) {
var ma = new MemberAccess.simple (local.name);
ma.symbol_reference = local;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]