diff libinterp/parse-tree/pt-binop.cc @ 23075:4e3d47dc7e25

move parse tree classes inside octave namespace * lex.h, lex.ll, oct-parse.in.yy, parse.h, pt-all.h, pt-arg-list.cc, pt-arg-list.h, pt-array-list.cc, pt-array-list.h, pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h, pt-cbinop.cc, pt-cbinop.h, pt.cc, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h, pt-classdef.cc, pt-classdef.h, pt-cmd.cc, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc, pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-funcall.cc, pt-funcall.h, pt.h, pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.cc, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-stmt.cc, pt-stmt.h, pt-unop.cc, pt-unop.h, pt-walk.h, token.cc, token.h: Move classes and most functions inside octave namespace. Change all uses.
author John W. Eaton <jwe@octave.org>
date Thu, 19 Jan 2017 23:41:54 -0500
parents 3a2b891d0b33
children ef4d915df748
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-binop.cc	Thu Jan 19 14:47:19 2017 -0500
+++ b/libinterp/parse-tree/pt-binop.cc	Thu Jan 19 23:41:54 2017 -0500
@@ -34,224 +34,225 @@
 #include "pt-walk.h"
 #include "variables.h"
 
-
-// Binary expressions.
-
-octave_value_list
-tree_binary_expression::rvalue (int nargout)
-{
-  octave_value_list retval;
-
-  if (nargout > 1)
-    error ("binary operator '%s': invalid number of output arguments",
-           oper ().c_str ());
-
-  retval = rvalue1 (nargout);
-
-  return retval;
-}
-
-void
-tree_binary_expression::matlab_style_short_circuit_warning (const char *op)
-{
-  warning_with_id ("Octave:possible-matlab-short-circuit-operator",
-                   "Matlab-style short-circuit operation performed for operator %s",
-                   op);
-
-  braindead_shortcircuit_warning_issued = true;
-}
-
-octave_value
-tree_binary_expression::rvalue1 (int)
-{
-  octave_value retval;
-
-  if (eligible_for_braindead_shortcircuit)
-    {
-      if (op_lhs)
-        {
-          octave_value a = op_lhs->rvalue1 ();
-
-          if (a.ndims () == 2 && a.rows () == 1 && a.columns () == 1)
-            {
-              bool result = false;
-
-              bool a_true = a.is_true ();
-
-              if (a_true)
-                {
-                  if (etype == octave_value::op_el_or)
-                    {
-                      matlab_style_short_circuit_warning ("|");
-                      return octave_value (true);
-                    }
-                }
-              else
-                {
-                  if (etype == octave_value::op_el_and)
-                    {
-                      matlab_style_short_circuit_warning ("&");
-                      return octave_value (false);
-                    }
-                }
-
-              if (op_rhs)
-                {
-                  octave_value b = op_rhs->rvalue1 ();
-
-                  result = b.is_true ();
-                }
-
-              return octave_value (result);
-            }
-        }
-    }
-
-  if (op_lhs)
-    {
-      octave_value a = op_lhs->rvalue1 ();
-
-      if (a.is_defined () && op_rhs)
-        {
-          octave_value b = op_rhs->rvalue1 ();
-
-          if (b.is_defined ())
-            {
-              BEGIN_PROFILER_BLOCK (tree_binary_expression)
-
-              // Note: The profiler does not catch the braindead
-              // short-circuit evaluation code above, but that should be
-              // ok.  The evaluation of operands and the operator itself
-              // is entangled and it's not clear where to start/stop
-              // timing the operator to make it reasonable.
-
-              retval = ::do_binary_op (etype, a, b);
-
-              END_PROFILER_BLOCK
-            }
-        }
-    }
-
-  return retval;
-}
-
-std::string
-tree_binary_expression::oper (void) const
-{
-  return octave_value::binary_op_as_string (etype);
-}
-
-tree_expression *
-tree_binary_expression::dup (symbol_table::scope_id scope,
-                             symbol_table::context_id context) const
+namespace octave
 {
-  tree_binary_expression *new_be
-    = new tree_binary_expression (op_lhs ? op_lhs->dup (scope, context) : 0,
-                                  op_rhs ? op_rhs->dup (scope, context) : 0,
-                                  line (), column (), etype);
+  // Binary expressions.
+
+  octave_value_list
+  tree_binary_expression::rvalue (int nargout)
+  {
+    octave_value_list retval;
 
-  new_be->copy_base (*this);
+    if (nargout > 1)
+      error ("binary operator '%s': invalid number of output arguments",
+             oper ().c_str ());
 
-  return new_be;
-}
+    retval = rvalue1 (nargout);
+
+    return retval;
+  }
 
-void
-tree_binary_expression::accept (tree_walker& tw)
-{
-  tw.visit_binary_expression (*this);
-}
+  void
+  tree_binary_expression::matlab_style_short_circuit_warning (const char *op)
+  {
+    warning_with_id ("Octave:possible-matlab-short-circuit-operator",
+                     "Matlab-style short-circuit operation performed for operator %s",
+                     op);
+
+    braindead_shortcircuit_warning_issued = true;
+  }
 
-// Boolean expressions.
+  octave_value
+  tree_binary_expression::rvalue1 (int)
+  {
+    octave_value retval;
 
-octave_value_list
-tree_boolean_expression::rvalue (int nargout)
-{
-  octave_value_list retval;
+    if (eligible_for_braindead_shortcircuit)
+      {
+        if (op_lhs)
+          {
+            octave_value a = op_lhs->rvalue1 ();
+
+            if (a.ndims () == 2 && a.rows () == 1 && a.columns () == 1)
+              {
+                bool result = false;
+
+                bool a_true = a.is_true ();
 
-  if (nargout > 1)
-    error ("binary operator '%s': invalid number of output arguments",
-           oper ().c_str ());
+                if (a_true)
+                  {
+                    if (etype == octave_value::op_el_or)
+                      {
+                        matlab_style_short_circuit_warning ("|");
+                        return octave_value (true);
+                      }
+                  }
+                else
+                  {
+                    if (etype == octave_value::op_el_and)
+                      {
+                        matlab_style_short_circuit_warning ("&");
+                        return octave_value (false);
+                      }
+                  }
 
-  retval = rvalue1 (nargout);
+                if (op_rhs)
+                  {
+                    octave_value b = op_rhs->rvalue1 ();
 
-  return retval;
-}
+                    result = b.is_true ();
+                  }
+
+                return octave_value (result);
+              }
+          }
+      }
 
-octave_value
-tree_boolean_expression::rvalue1 (int)
-{
-  octave_value retval;
+    if (op_lhs)
+      {
+        octave_value a = op_lhs->rvalue1 ();
 
-  bool result = false;
+        if (a.is_defined () && op_rhs)
+          {
+            octave_value b = op_rhs->rvalue1 ();
+
+            if (b.is_defined ())
+              {
+                BEGIN_PROFILER_BLOCK (tree_binary_expression)
 
-  // This evaluation is not caught by the profiler, since we can't find
-  // a reasonable place where to time.  Note that we don't want to
-  // include evaluation of LHS or RHS into the timing, but this is
-  // entangled together with short-circuit evaluation here.
+                  // Note: The profiler does not catch the braindead
+                  // short-circuit evaluation code above, but that should be
+                  // ok.  The evaluation of operands and the operator itself
+                  // is entangled and it's not clear where to start/stop
+                  // timing the operator to make it reasonable.
+
+                  retval = ::do_binary_op (etype, a, b);
 
-  if (op_lhs)
-    {
-      octave_value a = op_lhs->rvalue1 ();
+                END_PROFILER_BLOCK
+                  }
+          }
+      }
 
-      bool a_true = a.is_true ();
+    return retval;
+  }
+
+  std::string
+  tree_binary_expression::oper (void) const
+  {
+    return octave_value::binary_op_as_string (etype);
+  }
 
-      if (a_true)
-        {
-          if (etype == bool_or)
-            return octave_value (true);
-        }
-      else
-        {
-          if (etype == bool_and)
-            return octave_value (false);
-        }
+  tree_expression *
+  tree_binary_expression::dup (symbol_table::scope_id scope,
+                               symbol_table::context_id context) const
+  {
+    tree_binary_expression *new_be
+      = new tree_binary_expression (op_lhs ? op_lhs->dup (scope, context) : 0,
+                                    op_rhs ? op_rhs->dup (scope, context) : 0,
+                                    line (), column (), etype);
+
+    new_be->copy_base (*this);
+
+    return new_be;
+  }
+
+  void
+  tree_binary_expression::accept (tree_walker& tw)
+  {
+    tw.visit_binary_expression (*this);
+  }
+
+  // Boolean expressions.
+
+  octave_value_list
+  tree_boolean_expression::rvalue (int nargout)
+  {
+    octave_value_list retval;
 
-      if (op_rhs)
-        {
-          octave_value b = op_rhs->rvalue1 ();
+    if (nargout > 1)
+      error ("binary operator '%s': invalid number of output arguments",
+             oper ().c_str ());
 
-          result = b.is_true ();
-        }
+    retval = rvalue1 (nargout);
+
+    return retval;
+  }
 
-      retval = octave_value (result);
-    }
+  octave_value
+  tree_boolean_expression::rvalue1 (int)
+  {
+    octave_value retval;
+
+    bool result = false;
 
-  return retval;
-}
+    // This evaluation is not caught by the profiler, since we can't find
+    // a reasonable place where to time.  Note that we don't want to
+    // include evaluation of LHS or RHS into the timing, but this is
+    // entangled together with short-circuit evaluation here.
 
-std::string
-tree_boolean_expression::oper (void) const
-{
-  std::string retval = "<unknown>";
+    if (op_lhs)
+      {
+        octave_value a = op_lhs->rvalue1 ();
+
+        bool a_true = a.is_true ();
 
-  switch (etype)
-    {
-    case bool_and:
-      retval = "&&";
-      break;
+        if (a_true)
+          {
+            if (etype == bool_or)
+              return octave_value (true);
+          }
+        else
+          {
+            if (etype == bool_and)
+              return octave_value (false);
+          }
+
+        if (op_rhs)
+          {
+            octave_value b = op_rhs->rvalue1 ();
+
+            result = b.is_true ();
+          }
+
+        retval = octave_value (result);
+      }
+
+    return retval;
+  }
+
+  std::string
+  tree_boolean_expression::oper (void) const
+  {
+    std::string retval = "<unknown>";
 
-    case bool_or:
-      retval = "||";
-      break;
+    switch (etype)
+      {
+      case bool_and:
+        retval = "&&";
+        break;
+
+      case bool_or:
+        retval = "||";
+        break;
+
+      default:
+        break;
+      }
 
-    default:
-      break;
-    }
+    return retval;
+  }
 
-  return retval;
+  tree_expression *
+  tree_boolean_expression::dup (symbol_table::scope_id scope,
+                                symbol_table::context_id context) const
+  {
+    tree_boolean_expression *new_be
+      = new tree_boolean_expression (op_lhs ? op_lhs->dup (scope, context) : 0,
+                                     op_rhs ? op_rhs->dup (scope, context) : 0,
+                                     line (), column (), etype);
+
+    new_be->copy_base (*this);
+
+    return new_be;
+  }
 }
-
-tree_expression *
-tree_boolean_expression::dup (symbol_table::scope_id scope,
-                              symbol_table::context_id context) const
-{
-  tree_boolean_expression *new_be
-    = new tree_boolean_expression (op_lhs ? op_lhs->dup (scope, context) : 0,
-                                   op_rhs ? op_rhs->dup (scope, context) : 0,
-                                   line (), column (), etype);
-
-  new_be->copy_base (*this);
-
-  return new_be;
-}
-