diff libinterp/parse-tree/pt-funcall.cc @ 18423:9ca314e79956

Allow to call superclass constructor without arguments. * ov-classdef.cc (octave_classdef_superclass_ref::function_value): New method. * pt-funcall.h (tree_funcall::rvalue): Move definition to C++. * pt-funcall.cc (tree_funcall::rvalue): Moved from header. If the result of the function call is a single function object, re-index the function to yield the proper result it required (similar logic as in pt-id.cc).
author Michael Goffioul <michael.goffioul@gmail.com>
date Thu, 23 Jan 2014 21:24:43 -0500
parents c4f5c781c3ca
children bae00174787c
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-funcall.cc
+++ b/libinterp/parse-tree/pt-funcall.cc
@@ -81,3 +81,31 @@
 {
   tw.visit_funcall (*this);
 }
+
+octave_value_list
+tree_funcall::rvalue (int nargout)
+{
+  octave_value_list retval;
+
+  retval = feval (fcn.function_value (), args, nargout);
+
+  if (retval.length () == 1 && retval(0).is_function ())
+    {
+      // The return object is a function. We may need to re-index it using the
+      // same logic as for identifier. This is primarily used for superclass
+      // references in classdef.
+
+      octave_value val = retval(0);
+      octave_function *f = val.function_value (true);
+
+      if (f && ! (is_postfix_indexed ()
+                  && f->is_postfix_index_handled (postfix_index ())))
+        {
+          octave_value_list tmp_args;
+
+          retval = val.do_multi_index_op (nargout, tmp_args);
+        }
+    }
+
+  return retval;
+}