Logo Search packages:      
Sourcecode: vala version File versions

valamemorymanager.c

/* valamemorymanager.vala
 *
 * Copyright (C) 2006-2007  Jürg Billeter, Raffaele Sandrini
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.

 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 * Author:
 *    Jürg Billeter <j@bitron.ch>
 *    Raffaele Sandrini <rasa@gmx.ch>
 */

#include "valamemorymanager.h"
#include <gee/collection.h>
#include <gee/iterable.h>
#include <gee/iterator.h>
#include <vala/valasymbol.h>
#include <vala/valamemorymanager.h>
#include <vala/valatypereference.h>
#include <vala/valadatatype.h>
#include <vala/valainvokable.h>
#include <vala/valaformalparameter.h>
#include <vala/valasemanticanalyzer.h>
#include <vala/valacodenode.h>
#include <vala/valapointerindirection.h>
#include <vala/valasignal.h>

struct _ValaMemoryManagerPrivate {
      ValaSymbol* current_symbol;
};
#define VALA_MEMORY_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALA_TYPE_MEMORY_MANAGER, ValaMemoryManagerPrivate))
enum  {
      VALA_MEMORY_MANAGER_DUMMY_PROPERTY
};
static void vala_memory_manager_visit_possibly_leaked_expression (ValaMemoryManager* self, ValaExpression* expr);
static void vala_memory_manager_visit_possibly_missing_copy_expression (ValaMemoryManager* self, ValaExpression* expr);
static void vala_memory_manager_real_visit_source_file (ValaCodeVisitor* base, ValaSourceFile* source_file);
static void vala_memory_manager_real_visit_class (ValaCodeVisitor* base, ValaClass* cl);
static void vala_memory_manager_real_visit_struct (ValaCodeVisitor* base, ValaStruct* st);
static void vala_memory_manager_real_visit_interface (ValaCodeVisitor* base, ValaInterface* iface);
static void vala_memory_manager_real_visit_field (ValaCodeVisitor* base, ValaField* f);
static void vala_memory_manager_real_visit_method (ValaCodeVisitor* base, ValaMethod* m);
static void vala_memory_manager_real_visit_creation_method (ValaCodeVisitor* base, ValaCreationMethod* m);
static void vala_memory_manager_real_visit_property (ValaCodeVisitor* base, ValaProperty* prop);
static void vala_memory_manager_real_visit_property_accessor (ValaCodeVisitor* base, ValaPropertyAccessor* acc);
static void vala_memory_manager_real_visit_constructor (ValaCodeVisitor* base, ValaConstructor* c);
static void vala_memory_manager_real_visit_destructor (ValaCodeVisitor* base, ValaDestructor* d);
static void vala_memory_manager_real_visit_named_argument (ValaCodeVisitor* base, ValaNamedArgument* n);
static void vala_memory_manager_real_visit_variable_declarator (ValaCodeVisitor* base, ValaVariableDeclarator* decl);
static void vala_memory_manager_real_visit_expression_statement (ValaCodeVisitor* base, ValaExpressionStatement* stmt);
static void vala_memory_manager_real_visit_end_return_statement (ValaCodeVisitor* base, ValaReturnStatement* stmt);
static void vala_memory_manager_real_visit_throw_statement (ValaCodeVisitor* base, ValaThrowStatement* stmt);
static void vala_memory_manager_real_visit_try_statement (ValaCodeVisitor* base, ValaTryStatement* stmt);
static void vala_memory_manager_real_visit_catch_clause (ValaCodeVisitor* base, ValaCatchClause* clause);
static void vala_memory_manager_real_visit_member_access (ValaCodeVisitor* base, ValaMemberAccess* expr);
static void vala_memory_manager_real_visit_end_invocation_expression (ValaCodeVisitor* base, ValaInvocationExpression* expr);
static void vala_memory_manager_real_visit_end_object_creation_expression (ValaCodeVisitor* base, ValaObjectCreationExpression* expr);
static void vala_memory_manager_real_visit_binary_expression (ValaCodeVisitor* base, ValaBinaryExpression* expr);
static void vala_memory_manager_real_visit_end_assignment (ValaCodeVisitor* base, ValaAssignment* a);
static gpointer vala_memory_manager_parent_class = NULL;
static void vala_memory_manager_dispose (GObject * obj);


/**
 * Analyze memory usage in the specified code context.
 *
 * @param context a code context
 */
void vala_memory_manager_analyze (ValaMemoryManager* self, ValaCodeContext* context)
{
      g_return_if_fail (VALA_IS_MEMORY_MANAGER (self));
      g_return_if_fail (VALA_IS_CODE_CONTEXT (context));
      vala_code_context_accept (context, VALA_CODE_VISITOR (self));
}


static void vala_memory_manager_visit_possibly_leaked_expression (ValaMemoryManager* self, ValaExpression* expr)
{
      g_return_if_fail (VALA_IS_MEMORY_MANAGER (self));
      g_return_if_fail (VALA_IS_EXPRESSION (expr));
      if (vala_expression_get_static_type (expr) != NULL && ((vala_type_reference_get_data_type (vala_expression_get_static_type (expr)) != NULL && vala_data_type_is_reference_type (vala_type_reference_get_data_type (vala_expression_get_static_type (expr)))) || vala_type_reference_get_type_parameter (vala_expression_get_static_type (expr)) != NULL) && vala_type_reference_get_transfers_ownership (vala_expression_get_static_type (expr))) {
            /* mark reference as leaked */
            vala_expression_set_ref_leaked (expr, TRUE);
      }
}


static void vala_memory_manager_visit_possibly_missing_copy_expression (ValaMemoryManager* self, ValaExpression* expr)
{
      g_return_if_fail (VALA_IS_MEMORY_MANAGER (self));
      g_return_if_fail (VALA_IS_EXPRESSION (expr));
      if (vala_expression_get_static_type (expr) != NULL && ((vala_type_reference_get_data_type (vala_expression_get_static_type (expr)) != NULL && vala_data_type_is_reference_type (vala_type_reference_get_data_type (vala_expression_get_static_type (expr)))) || vala_type_reference_get_type_parameter (vala_expression_get_static_type (expr)) != NULL) && !vala_type_reference_get_transfers_ownership (vala_expression_get_static_type (expr))) {
            /* mark reference as missing */
            vala_expression_set_ref_missing (expr, TRUE);
      }
}


static void vala_memory_manager_real_visit_source_file (ValaCodeVisitor* base, ValaSourceFile* source_file)
{
      ValaMemoryManager * self;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_SOURCE_FILE (source_file));
      if (!vala_source_file_get_pkg (source_file)) {
            vala_source_file_accept_children (source_file, VALA_CODE_VISITOR (self));
      }
}


static void vala_memory_manager_real_visit_class (ValaCodeVisitor* base, ValaClass* cl)
{
      ValaMemoryManager * self;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_CLASS (cl));
      vala_code_node_accept_children (VALA_CODE_NODE (cl), VALA_CODE_VISITOR (self));
}


static void vala_memory_manager_real_visit_struct (ValaCodeVisitor* base, ValaStruct* st)
{
      ValaMemoryManager * self;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_STRUCT (st));
      vala_code_node_accept_children (VALA_CODE_NODE (st), VALA_CODE_VISITOR (self));
}


static void vala_memory_manager_real_visit_interface (ValaCodeVisitor* base, ValaInterface* iface)
{
      ValaMemoryManager * self;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_INTERFACE (iface));
      vala_code_node_accept_children (VALA_CODE_NODE (iface), VALA_CODE_VISITOR (self));
}


static void vala_memory_manager_real_visit_field (ValaCodeVisitor* base, ValaField* f)
{
      ValaMemoryManager * self;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_FIELD (f));
      if (vala_field_get_initializer (f) != NULL) {
            if (vala_type_reference_get_takes_ownership (vala_field_get_type_reference (f))) {
                  vala_memory_manager_visit_possibly_missing_copy_expression (self, vala_field_get_initializer (f));
            } else {
                  vala_memory_manager_visit_possibly_leaked_expression (self, vala_field_get_initializer (f));
            }
      }
}


static void vala_memory_manager_real_visit_method (ValaCodeVisitor* base, ValaMethod* m)
{
      ValaMemoryManager * self;
      ValaSymbol* __temp0;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_METHOD (m));
      __temp0 = NULL;
      self->priv->current_symbol = (__temp0 = VALA_SYMBOL (g_object_ref (m)), (self->priv->current_symbol == NULL ? NULL : (self->priv->current_symbol = (g_object_unref (self->priv->current_symbol), NULL))), __temp0);
      vala_code_node_accept_children (VALA_CODE_NODE (m), VALA_CODE_VISITOR (self));
}


static void vala_memory_manager_real_visit_creation_method (ValaCodeVisitor* base, ValaCreationMethod* m)
{
      ValaMemoryManager * self;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_CREATION_METHOD (m));
      vala_code_visitor_visit_method (VALA_CODE_VISITOR (self), VALA_METHOD (m));
}


static void vala_memory_manager_real_visit_property (ValaCodeVisitor* base, ValaProperty* prop)
{
      ValaMemoryManager * self;
      ValaSymbol* __temp1;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_PROPERTY (prop));
      __temp1 = NULL;
      self->priv->current_symbol = (__temp1 = VALA_SYMBOL (g_object_ref (prop)), (self->priv->current_symbol == NULL ? NULL : (self->priv->current_symbol = (g_object_unref (self->priv->current_symbol), NULL))), __temp1);
      vala_code_node_accept_children (VALA_CODE_NODE (prop), VALA_CODE_VISITOR (self));
}


static void vala_memory_manager_real_visit_property_accessor (ValaCodeVisitor* base, ValaPropertyAccessor* acc)
{
      ValaMemoryManager * self;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_PROPERTY_ACCESSOR (acc));
      vala_code_node_accept_children (VALA_CODE_NODE (acc), VALA_CODE_VISITOR (self));
}


static void vala_memory_manager_real_visit_constructor (ValaCodeVisitor* base, ValaConstructor* c)
{
      ValaMemoryManager * self;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_CONSTRUCTOR (c));
      vala_code_node_accept_children (VALA_CODE_NODE (c), VALA_CODE_VISITOR (self));
}


static void vala_memory_manager_real_visit_destructor (ValaCodeVisitor* base, ValaDestructor* d)
{
      ValaMemoryManager * self;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_DESTRUCTOR (d));
      vala_code_node_accept_children (VALA_CODE_NODE (d), VALA_CODE_VISITOR (self));
}


static void vala_memory_manager_real_visit_named_argument (ValaCodeVisitor* base, ValaNamedArgument* n)
{
      ValaMemoryManager * self;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_NAMED_ARGUMENT (n));
      vala_memory_manager_visit_possibly_leaked_expression (self, vala_named_argument_get_argument (n));
}


static void vala_memory_manager_real_visit_variable_declarator (ValaCodeVisitor* base, ValaVariableDeclarator* decl)
{
      ValaMemoryManager * self;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_VARIABLE_DECLARATOR (decl));
      if (vala_variable_declarator_get_initializer (decl) != NULL) {
            if (vala_type_reference_get_takes_ownership (vala_variable_declarator_get_type_reference (decl))) {
                  vala_memory_manager_visit_possibly_missing_copy_expression (self, vala_variable_declarator_get_initializer (decl));
            } else {
                  vala_memory_manager_visit_possibly_leaked_expression (self, vala_variable_declarator_get_initializer (decl));
            }
      }
}


static void vala_memory_manager_real_visit_expression_statement (ValaCodeVisitor* base, ValaExpressionStatement* stmt)
{
      ValaMemoryManager * self;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_EXPRESSION_STATEMENT (stmt));
      vala_memory_manager_visit_possibly_leaked_expression (self, vala_expression_statement_get_expression (stmt));
}


static void vala_memory_manager_real_visit_end_return_statement (ValaCodeVisitor* base, ValaReturnStatement* stmt)
{
      ValaMemoryManager * self;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_RETURN_STATEMENT (stmt));
      if (vala_return_statement_get_return_expression (stmt) != NULL) {
            if (VALA_IS_METHOD (self->priv->current_symbol)) {
                  ValaMethod* __temp2;
                  ValaMethod* m;
                  __temp2 = NULL;
                  m = (__temp2 = VALA_METHOD (self->priv->current_symbol), (__temp2 == NULL ? NULL : g_object_ref (__temp2)));
                  if (vala_type_reference_get_transfers_ownership (vala_method_get_return_type (m))) {
                        vala_memory_manager_visit_possibly_missing_copy_expression (self, vala_return_statement_get_return_expression (stmt));
                  } else {
                        vala_memory_manager_visit_possibly_leaked_expression (self, vala_return_statement_get_return_expression (stmt));
                  }
                  (m == NULL ? NULL : (m = (g_object_unref (m), NULL)));
            } else {
                  /* property get accessor */
                  vala_memory_manager_visit_possibly_leaked_expression (self, vala_return_statement_get_return_expression (stmt));
            }
      }
}


static void vala_memory_manager_real_visit_throw_statement (ValaCodeVisitor* base, ValaThrowStatement* stmt)
{
      ValaMemoryManager * self;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_THROW_STATEMENT (stmt));
      vala_code_node_accept_children (VALA_CODE_NODE (stmt), VALA_CODE_VISITOR (self));
}


static void vala_memory_manager_real_visit_try_statement (ValaCodeVisitor* base, ValaTryStatement* stmt)
{
      ValaMemoryManager * self;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_TRY_STATEMENT (stmt));
      vala_code_node_accept_children (VALA_CODE_NODE (stmt), VALA_CODE_VISITOR (self));
}


static void vala_memory_manager_real_visit_catch_clause (ValaCodeVisitor* base, ValaCatchClause* clause)
{
      ValaMemoryManager * self;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_CATCH_CLAUSE (clause));
      vala_code_node_accept_children (VALA_CODE_NODE (clause), VALA_CODE_VISITOR (self));
}


static void vala_memory_manager_real_visit_member_access (ValaCodeVisitor* base, ValaMemberAccess* expr)
{
      ValaMemoryManager * self;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_MEMBER_ACCESS (expr));
      if (vala_member_access_get_inner (expr) != NULL) {
            vala_memory_manager_visit_possibly_leaked_expression (self, vala_member_access_get_inner (expr));
      }
}


static void vala_memory_manager_real_visit_end_invocation_expression (ValaCodeVisitor* base, ValaInvocationExpression* expr)
{
      ValaMemoryManager * self;
      ValaInvokable* __temp3;
      ValaInvokable* msym;
      GeeCollection* params;
      GeeIterator* params_it;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_INVOCATION_EXPRESSION (expr));
      __temp3 = NULL;
      msym = (__temp3 = VALA_INVOKABLE (vala_expression_get_symbol_reference (vala_invocation_expression_get_call (expr))), (__temp3 == NULL ? NULL : g_object_ref (__temp3)));
      params = vala_invokable_get_parameters (msym);
      params_it = gee_iterable_iterator (GEE_ITERABLE (params));
      {
            GeeCollection* arg_collection;
            GeeIterator* arg_it;
            arg_collection = vala_invocation_expression_get_argument_list (expr);
            arg_it = gee_iterable_iterator (GEE_ITERABLE (arg_collection));
            while (gee_iterator_next (arg_it)) {
                  ValaExpression* arg;
                  arg = gee_iterator_get (arg_it);
                  {
                        if (gee_iterator_next (params_it)) {
                              ValaFormalParameter* param;
                              param = gee_iterator_get (params_it);
                              if (!vala_formal_parameter_get_ellipsis (param) && ((vala_type_reference_get_data_type (vala_formal_parameter_get_type_reference (param)) != NULL && vala_data_type_is_reference_type (vala_type_reference_get_data_type (vala_formal_parameter_get_type_reference (param)))) || vala_type_reference_get_type_parameter (vala_formal_parameter_get_type_reference (param)) != NULL)) {
                                    gboolean is_ref;
                                    is_ref = vala_type_reference_get_takes_ownership (vala_formal_parameter_get_type_reference (param));
                                    if (is_ref && vala_type_reference_get_type_parameter (vala_formal_parameter_get_type_reference (param)) != NULL) {
                                          if (VALA_IS_MEMBER_ACCESS (vala_invocation_expression_get_call (expr))) {
                                                ValaMemberAccess* __temp4;
                                                ValaMemberAccess* ma;
                                                ValaTypeReference* param_type;
                                                __temp4 = NULL;
                                                ma = (__temp4 = VALA_MEMBER_ACCESS (vala_invocation_expression_get_call (expr)), (__temp4 == NULL ? NULL : g_object_ref (__temp4)));
                                                param_type = vala_semantic_analyzer_get_actual_type (vala_expression_get_static_type (vala_member_access_get_inner (ma)), VALA_SYMBOL (msym), vala_formal_parameter_get_type_reference (param), VALA_CODE_NODE (expr));
                                                if (param_type != NULL) {
                                                      is_ref = vala_type_reference_get_takes_ownership (param_type);
                                                }
                                                (ma == NULL ? NULL : (ma = (g_object_unref (ma), NULL)));
                                                (param_type == NULL ? NULL : (param_type = (g_object_unref (param_type), NULL)));
                                          }
                                    }
                                    if (is_ref) {
                                          vala_memory_manager_visit_possibly_missing_copy_expression (self, arg);
                                    } else {
                                          vala_memory_manager_visit_possibly_leaked_expression (self, arg);
                                    }
                              } else {
                                    vala_memory_manager_visit_possibly_leaked_expression (self, arg);
                              }
                              (param == NULL ? NULL : (param = (g_object_unref (param), NULL)));
                        } else {
                              vala_memory_manager_visit_possibly_leaked_expression (self, arg);
                        }
                        (arg == NULL ? NULL : (arg = (g_object_unref (arg), NULL)));
                  }
            }
            (arg_collection == NULL ? NULL : (arg_collection = (g_object_unref (arg_collection), NULL)));
            (arg_it == NULL ? NULL : (arg_it = (g_object_unref (arg_it), NULL)));
      }
      (msym == NULL ? NULL : (msym = (g_object_unref (msym), NULL)));
      (params == NULL ? NULL : (params = (g_object_unref (params), NULL)));
      (params_it == NULL ? NULL : (params_it = (g_object_unref (params_it), NULL)));
}


static void vala_memory_manager_real_visit_end_object_creation_expression (ValaCodeVisitor* base, ValaObjectCreationExpression* expr)
{
      ValaMemoryManager * self;
      ValaInvokable* __temp5;
      ValaInvokable* msym;
      GeeCollection* params;
      GeeIterator* params_it;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_OBJECT_CREATION_EXPRESSION (expr));
      if (!(VALA_IS_INVOKABLE (vala_expression_get_symbol_reference (((ValaExpression*) expr))))) {
            return;
      }
      __temp5 = NULL;
      msym = (__temp5 = VALA_INVOKABLE (vala_expression_get_symbol_reference (((ValaExpression*) expr))), (__temp5 == NULL ? NULL : g_object_ref (__temp5)));
      params = vala_invokable_get_parameters (msym);
      params_it = gee_iterable_iterator (GEE_ITERABLE (params));
      {
            GeeCollection* arg_collection;
            GeeIterator* arg_it;
            arg_collection = vala_object_creation_expression_get_argument_list (expr);
            arg_it = gee_iterable_iterator (GEE_ITERABLE (arg_collection));
            while (gee_iterator_next (arg_it)) {
                  ValaExpression* arg;
                  arg = gee_iterator_get (arg_it);
                  {
                        if (gee_iterator_next (params_it)) {
                              ValaFormalParameter* param;
                              param = gee_iterator_get (params_it);
                              if (!vala_formal_parameter_get_ellipsis (param) && ((vala_type_reference_get_data_type (vala_formal_parameter_get_type_reference (param)) != NULL && vala_data_type_is_reference_type (vala_type_reference_get_data_type (vala_formal_parameter_get_type_reference (param)))) || vala_type_reference_get_type_parameter (vala_formal_parameter_get_type_reference (param)) != NULL)) {
                                    gboolean is_ref;
                                    is_ref = vala_type_reference_get_takes_ownership (vala_formal_parameter_get_type_reference (param));
                                    if (is_ref && vala_type_reference_get_type_parameter (vala_formal_parameter_get_type_reference (param)) != NULL) {
                                          ValaTypeReference* param_type;
                                          param_type = vala_semantic_analyzer_get_actual_type (vala_object_creation_expression_get_type_reference (expr), VALA_SYMBOL (msym), vala_formal_parameter_get_type_reference (param), VALA_CODE_NODE (expr));
                                          if (param_type != NULL) {
                                                is_ref = vala_type_reference_get_takes_ownership (param_type);
                                          }
                                          (param_type == NULL ? NULL : (param_type = (g_object_unref (param_type), NULL)));
                                    }
                                    if (is_ref) {
                                          vala_memory_manager_visit_possibly_missing_copy_expression (self, arg);
                                    } else {
                                          vala_memory_manager_visit_possibly_leaked_expression (self, arg);
                                    }
                              } else {
                                    vala_memory_manager_visit_possibly_leaked_expression (self, arg);
                              }
                              (param == NULL ? NULL : (param = (g_object_unref (param), NULL)));
                        } else {
                              vala_memory_manager_visit_possibly_leaked_expression (self, arg);
                        }
                        (arg == NULL ? NULL : (arg = (g_object_unref (arg), NULL)));
                  }
            }
            (arg_collection == NULL ? NULL : (arg_collection = (g_object_unref (arg_collection), NULL)));
            (arg_it == NULL ? NULL : (arg_it = (g_object_unref (arg_it), NULL)));
      }
      (msym == NULL ? NULL : (msym = (g_object_unref (msym), NULL)));
      (params == NULL ? NULL : (params = (g_object_unref (params), NULL)));
      (params_it == NULL ? NULL : (params_it = (g_object_unref (params_it), NULL)));
}


static void vala_memory_manager_real_visit_binary_expression (ValaCodeVisitor* base, ValaBinaryExpression* expr)
{
      ValaMemoryManager * self;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_BINARY_EXPRESSION (expr));
      vala_memory_manager_visit_possibly_leaked_expression (self, vala_binary_expression_get_left (expr));
      vala_memory_manager_visit_possibly_leaked_expression (self, vala_binary_expression_get_right (expr));
}


static void vala_memory_manager_real_visit_end_assignment (ValaCodeVisitor* base, ValaAssignment* a)
{
      ValaMemoryManager * self;
      self = ((ValaMemoryManager*) base);
      g_return_if_fail (VALA_IS_ASSIGNMENT (a));
      if (VALA_IS_POINTER_INDIRECTION (vala_assignment_get_left (a)) || VALA_IS_SIGNAL (vala_expression_get_symbol_reference (vala_assignment_get_left (a)))) {
      } else {
            if (vala_type_reference_get_takes_ownership (vala_expression_get_static_type (vala_assignment_get_left (a)))) {
                  vala_memory_manager_visit_possibly_missing_copy_expression (self, vala_assignment_get_right (a));
            } else {
                  vala_memory_manager_visit_possibly_leaked_expression (self, vala_assignment_get_right (a));
            }
      }
}


static void vala_memory_manager_class_init (ValaMemoryManagerClass * klass)
{
      vala_memory_manager_parent_class = g_type_class_peek_parent (klass);
      g_type_class_add_private (klass, sizeof (ValaMemoryManagerPrivate));
      G_OBJECT_CLASS (klass)->dispose = vala_memory_manager_dispose;
      VALA_CODE_VISITOR_CLASS (klass)->visit_source_file = vala_memory_manager_real_visit_source_file;
      VALA_CODE_VISITOR_CLASS (klass)->visit_class = vala_memory_manager_real_visit_class;
      VALA_CODE_VISITOR_CLASS (klass)->visit_struct = vala_memory_manager_real_visit_struct;
      VALA_CODE_VISITOR_CLASS (klass)->visit_interface = vala_memory_manager_real_visit_interface;
      VALA_CODE_VISITOR_CLASS (klass)->visit_field = vala_memory_manager_real_visit_field;
      VALA_CODE_VISITOR_CLASS (klass)->visit_method = vala_memory_manager_real_visit_method;
      VALA_CODE_VISITOR_CLASS (klass)->visit_creation_method = vala_memory_manager_real_visit_creation_method;
      VALA_CODE_VISITOR_CLASS (klass)->visit_property = vala_memory_manager_real_visit_property;
      VALA_CODE_VISITOR_CLASS (klass)->visit_property_accessor = vala_memory_manager_real_visit_property_accessor;
      VALA_CODE_VISITOR_CLASS (klass)->visit_constructor = vala_memory_manager_real_visit_constructor;
      VALA_CODE_VISITOR_CLASS (klass)->visit_destructor = vala_memory_manager_real_visit_destructor;
      VALA_CODE_VISITOR_CLASS (klass)->visit_named_argument = vala_memory_manager_real_visit_named_argument;
      VALA_CODE_VISITOR_CLASS (klass)->visit_variable_declarator = vala_memory_manager_real_visit_variable_declarator;
      VALA_CODE_VISITOR_CLASS (klass)->visit_expression_statement = vala_memory_manager_real_visit_expression_statement;
      VALA_CODE_VISITOR_CLASS (klass)->visit_end_return_statement = vala_memory_manager_real_visit_end_return_statement;
      VALA_CODE_VISITOR_CLASS (klass)->visit_throw_statement = vala_memory_manager_real_visit_throw_statement;
      VALA_CODE_VISITOR_CLASS (klass)->visit_try_statement = vala_memory_manager_real_visit_try_statement;
      VALA_CODE_VISITOR_CLASS (klass)->visit_catch_clause = vala_memory_manager_real_visit_catch_clause;
      VALA_CODE_VISITOR_CLASS (klass)->visit_member_access = vala_memory_manager_real_visit_member_access;
      VALA_CODE_VISITOR_CLASS (klass)->visit_end_invocation_expression = vala_memory_manager_real_visit_end_invocation_expression;
      VALA_CODE_VISITOR_CLASS (klass)->visit_end_object_creation_expression = vala_memory_manager_real_visit_end_object_creation_expression;
      VALA_CODE_VISITOR_CLASS (klass)->visit_binary_expression = vala_memory_manager_real_visit_binary_expression;
      VALA_CODE_VISITOR_CLASS (klass)->visit_end_assignment = vala_memory_manager_real_visit_end_assignment;
}


static void vala_memory_manager_init (ValaMemoryManager * self)
{
      self->priv = VALA_MEMORY_MANAGER_GET_PRIVATE (self);
}


static void vala_memory_manager_dispose (GObject * obj)
{
      ValaMemoryManager * self;
      ValaMemoryManagerClass * klass;
      GObjectClass * parent_class;
      self = VALA_MEMORY_MANAGER (obj);
      (self->priv->current_symbol == NULL ? NULL : (self->priv->current_symbol = (g_object_unref (self->priv->current_symbol), NULL)));
      klass = VALA_MEMORY_MANAGER_CLASS (g_type_class_peek (VALA_TYPE_MEMORY_MANAGER));
      parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
      parent_class->dispose (obj);
}


GType vala_memory_manager_get_type (void)
{
      static GType vala_memory_manager_type_id = 0;
      if (G_UNLIKELY (vala_memory_manager_type_id == 0)) {
            static const GTypeInfo g_define_type_info = { sizeof (ValaMemoryManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_memory_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaMemoryManager), 0, (GInstanceInitFunc) vala_memory_manager_init };
            vala_memory_manager_type_id = g_type_register_static (VALA_TYPE_CODE_VISITOR, "ValaMemoryManager", &g_define_type_info, 0);
      }
      return vala_memory_manager_type_id;
}





Generated by  Doxygen 1.6.0   Back to index