view src/pt-cell.cc @ 15466:d174210ce1ec stable

use ' instead of ` in error messages, warnings and most comments * intro.txi, io.txi, munge-texi.cc, octave.texi, cmd-edit.cc, data-conv.cc, file-ops.cc, glob-match.h, kpse.cc, oct-env.cc, oct-locbuf.h, oct-md5.cc, oct-rand.cc, general/interp2.m, doc.m, get_first_help_sentence.m, help.m, print_usage.m, __additional_help_message__.m, type.m, unimplemented.m, which.m, cast.m, dir.m, license.m, mkoctfile.m, recycle.m, tempdir.m, optimset.m, pkg/pkg.m, closereq.m, colstyle.m, __fltk_print__.m, __gnuplot_print__.m, __go_draw_figure__.m, __pie__.m, __pltopt__.m, __print_parse_opts__.m, uigetdir.m, uigetfile.m, uiputfile.m, stft.m, mean.m, anova.m, cor_test.m, t_test_regression.m, __magick_read__.cc, dlmread.cc, schur.cc, data.cc, debug.cc, defun-dld.h, defun.cc, defun.h, dynamic-ld.cc, error.cc, error.h, gl-render.cc, graphics.cc, gripes.cc, input.cc, lex.ll, load-path.cc, load-save.cc, ls-hdf5.cc, ls-mat-ascii.cc, ls-mat4.cc, ls-mat5.cc, ls-oct-ascii.cc, ls-oct-binary.cc, oct-hist.cc, oct-parse.yy, oct-stream.cc, oct-stream.h, octave.cc, ov-base-diag.cc, ov-base.cc, ov-class.cc, ov-colon.h, ov-struct.cc, ov-typeinfo.cc, ov.cc, pager.cc, pr-output.cc, pt-binop.cc, pt-eval.cc, pt-id.cc, pt-idx.cc, pt-misc.cc, pt-unop.cc, symtab.cc, symtab.h, toplev.cc, txt-eng-ft.cc, utils.cc, variables.cc, test_eval-catch.m, test_try.m: Use ' instead of ` in error messages, warnings, and most comments.
author John W. Eaton <jwe@octave.org>
date Mon, 01 Oct 2012 17:18:49 -0400
parents 72c96de7a403
children
line wrap: on
line source

/*

Copyright (C) 1999-2012 John W. Eaton

This file is part of Octave.

Octave is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.

Octave 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 General Public License
for more details.

You should have received a copy of the GNU General Public License
along with Octave; see the file COPYING.  If not, see
<http://www.gnu.org/licenses/>.

*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <iostream>

#include "Cell.h"
#include "defun.h"
#include "error.h"
#include "oct-obj.h"
#include "pt-arg-list.h"
#include "pt-bp.h"
#include "pt-exp.h"
#include "pt-cell.h"
#include "pt-walk.h"
#include "utils.h"
#include "ov.h"
#include "variables.h"

octave_value
tree_cell::rvalue1 (int)
{
  octave_value retval;

  octave_idx_type nr = length ();
  octave_idx_type nc = -1;

  Cell val;

  int i = 0;

  for (iterator p = begin (); p != end (); p++)
    {
      tree_argument_list *elt = *p;

      octave_value_list row = elt->convert_to_const_vector ();

      if (nr == 1)
        // Optimize the single row case.
        val = row.cell_value ();
      else if (nc < 0)
        {
          nc = row.length ();

          val = Cell (nr, nc);
        }
      else
        {
          octave_idx_type this_nc = row.length ();

          if (nc != this_nc)
            {
              ::error ("number of columns must match");
              return retval;
            }
        }

      for (octave_idx_type j = 0; j < nc; j++)
        val(i,j) = row(j);

      i++;
    }

  retval = val;

  return retval;
}

octave_value_list
tree_cell::rvalue (int nargout)
{
  octave_value_list retval;

  if (nargout > 1)
    error ("invalid number of output arguments for cell array");
  else
    retval = rvalue1 (nargout);

  return retval;
}

tree_expression *
tree_cell::dup (symbol_table::scope_id scope,
                symbol_table::context_id context) const
{
  tree_cell *new_cell = new tree_cell (0, line (), column ());

  for (const_iterator p = begin (); p != end (); p++)
    {
      const tree_argument_list *elt = *p;

      new_cell->append (elt ? elt->dup (scope, context) : 0);
    }

  new_cell->copy_base (*this);

  return new_cell;
}

void
tree_cell::accept (tree_walker& tw)
{
  tw.visit_cell (*this);
}