~ubuntu-branches/ubuntu/wily/vala/wily

« back to all changes in this revision

Viewing changes to codegen/valaccodearraymodule.vala

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2011-02-15 11:44:25 UTC
  • mfrom: (1.5.16 upstream)
  • Revision ID: james.westby@ubuntu.com-20110215114425-8vtvfqmnely5x8tt
Tags: 0.11.6-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
178
178
                        var lit = indices[0] as IntegerLiteral;
179
179
                        var memberaccess = expr.container as MemberAccess;
180
180
                        if (lit != null && memberaccess != null) {
181
 
                                int dim = lit.value.to_int ();
 
181
                                int dim = int.parse (lit.value);
182
182
                                set_cvalue (expr, get_array_length_cexpression (memberaccess.inner, dim + 1));
183
183
                        } else {
184
184
                                Report.error (expr.source_reference, "only integer literals supported as index");
449
449
                }
450
450
        }
451
451
 
 
452
        public override CCodeExpression destroy_variable (Variable variable, CCodeExpression? inner = null) {
 
453
                var array_type = variable.variable_type as ArrayType;
 
454
                if (array_type != null && array_type.fixed_length) {
 
455
                        requires_array_free = true;
 
456
 
 
457
                        var ccall = new CCodeFunctionCall (get_destroy_func_expression (variable.variable_type));
 
458
                        var value = get_variable_cvalue (variable);
 
459
 
 
460
                        ccall = new CCodeFunctionCall (new CCodeIdentifier ("_vala_array_destroy"));
 
461
                        ccall.add_argument (get_cvalue_ (value));
 
462
                        ccall.add_argument (new CCodeConstant ("%d".printf (array_type.length)));
 
463
                        ccall.add_argument (new CCodeCastExpression (get_destroy_func_expression (array_type.element_type), "GDestroyNotify"));
 
464
 
 
465
                        return ccall;
 
466
                }
 
467
 
 
468
                return base.destroy_variable (variable, inner);
 
469
        }
 
470
 
452
471
        public override CCodeExpression destroy_value (TargetValue value, bool is_macro_definition = false) {
453
472
                var type = value.value_type;
454
473