26 #if defined (HAVE_CONFIG_H)
51 m_arg_nm (), m_dyn_field (), m_word_list_cmd (false) { }
57 m_arg_nm (), m_dyn_field (), m_word_list_cmd (false)
66 m_arg_nm (), m_dyn_field (), m_word_list_cmd (false)
75 m_arg_nm (), m_dyn_field (), m_word_list_cmd (false)
83 m_args.push_back (lst);
89 error (
"invalid use of empty argument (~) in index expression");
99 m_arg_nm.push_back (
n);
110 m_arg_nm.push_back (
"");
111 m_dyn_field.push_back (df);
120 while (! m_args.empty ())
122 auto p = m_args.begin ();
127 while (! m_dyn_field.empty ())
129 auto p = m_dyn_field.begin ();
131 m_dyn_field.erase (p);
141 return m_expr->
name ();
147 std::list<string_vector>::const_iterator p_arg_nm,
148 std::list<tree_expression *>::const_iterator p_dyn_field)
const
150 std::string fn = (*p_arg_nm)(0);
160 fn = t.
xstring_value (
"dynamic structure field names must be strings");
172 std::list<octave_value_list> idx;
174 int n = m_args.size ();
176 auto p_args = m_args.begin ();
177 auto p_arg_nm = m_arg_nm.begin ();
178 auto p_dyn_field = m_dyn_field.begin ();
184 const std::string& index_type,
185 const std::list<octave_value_list>& index_list)
194 for (
int i = 0; i <
n; i++)
203 idx.push_back (tidx);
212 idx.push_back (tidx);
221 idx.push_back (tidx);
229 if (idx.back ().empty ())
230 error (
"invalid empty index list");
248 new_idx_expr->m_expr = (m_expr ? m_expr->
dup (scope) :
nullptr);
250 std::list<tree_argument_list *> new_args;
253 new_args.push_back (elt ? elt->dup (scope) :
nullptr);
255 new_idx_expr->m_args = new_args;
257 new_idx_expr->m_type = m_type;
259 new_idx_expr->m_arg_nm = m_arg_nm;
261 std::list<tree_expression *> new_dyn_field;
264 new_dyn_field.push_back (elt ? elt->dup (scope) :
nullptr);
266 new_idx_expr->m_dyn_field = new_dyn_field;
351 auto p_args = m_args.begin ();
352 auto p_arg_nm = m_arg_nm.begin ();
353 auto p_dyn_field = m_dyn_field.begin ();
355 int n = m_args.size ();
366 std::string nm =
id->name ();
370 bool maybe_binary_op =
false;
371 if ((*p_args) && (*p_args)->length () > 0)
375 std::string ops =
"+-*/\\.^|&";
378 && (ops.find (arg_list(0)[1]) != std::string::npos))
379 maybe_binary_op =
true;
384 advice =
"\nCheck whitespace around potential binary operator.";
386 error (
"variable \"%s\" used as function in command style expression%s",
387 nm.c_str (), advice.c_str ());
396 if (al && al->
length () > 0)
398 unwind_action act ([&tw] (
const std::list<octave_lvalue> *lvl)
427 retval = fcn->
call (tw, nargout, first_args);
444 if (retval.
length () == 0)
445 error (
"indexing undefined value");
447 base_expr_val = retval(0);
466 base_expr_val = m_expr->
evaluate (tw);
478 std::list<octave_value_list> idx_list;
487 const std::string& index_type,
488 const std::list<octave_value_list>& index_list)
499 bool indexing_object = (base_expr_val.
isobject ()
500 || base_expr_val.
isjava ()
506 for (
int i = beg; i <
n; i++)
510 if (! indexing_object)
519 = base_expr_val.
subsref (m_type.substr (beg, i-beg),
525 base_expr_val = partial_expr_val;
530 retval = partial_expr_val;
537 || partial_expr_val.
isjava ()
552 indexing_object =
true;
570 idx_list.push_back (tmp);
578 idx_list.push_back (tmp);
586 idx_list.push_back (tmp);
603 if (! idx_list.empty ())
611 retval = base_expr_val.
subsref (m_type.substr (beg,
n-beg),
638 if (idx_list.size () != 1)
639 error (
"unexpected extra index at end of expression");
641 if (m_type[beg] !=
'(')
642 error (
"invalid index type '%c' for function call",
645 final_args = idx_list.front ();
650 retval = fcn->
call (tw, nargout, final_args);
674 if (! idx_list.empty ())
677 error (
"unexpected extra index at end of expression");
679 if (m_type[beg] !=
'(')
680 error (
"invalid index type '%c' for function call",
683 final_args = idx_list.front ();
686 retval = fcn->
call (tw, nargout, final_args);
701 OCTAVE_END_NAMESPACE(
octave)
std::size_t length() const
symbol_table & get_symbol_table()
virtual octave_value_list call(octave::tree_evaluator &tw, int nargout=0, const octave_value_list &args=octave_value_list())
void set_index(const std::string &t, const std::list< octave_value_list > &i)
octave_value value() const
void stash_name_tags(const string_vector &nm)
octave_idx_type length() const
bool is_undefined() const
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
bool is_classdef_meta() const
octave_function * function_value(bool silent=false) const
std::string xstring_value(const char *fmt,...) const
octave_value find_function(const std::string &name, const symbol_scope &search_scope=symbol_scope::invalid())
string_vector get_arg_names() const
bool has_magic_tilde() const
void set_indexed_object(const octave_value &obj=octave_value())
void final_index_error(index_exception &ie, const tree_expression *expr)
interpreter & get_interpreter()
octave_value_list convert_to_const_vector(tree_argument_list *arg_list)
octave_value indexed_object() const
octave_value_list make_value_list(tree_argument_list *args, const string_vector &arg_nm)
bool is_variable(const std::string &name) const
const std::list< octave_lvalue > * lvalue_list() const
const std::list< octave_value_list > & index_list() const
const std::string & index_type() const
void set_lvalue_list(const std::list< octave_lvalue > *lst)
void append_index_list(char type, const octave_value_list &idx)
void set_index_list(const std::string &index_type, const std::list< octave_value_list > &index_list)
virtual octave_value evaluate(tree_evaluator &tw, int nargout=1)=0
virtual bool is_identifier() const
virtual tree_expression * dup(symbol_scope &scope) const =0
virtual void copy_base(const tree_expression &e)
virtual std::string name() const
virtual octave_lvalue lvalue(tree_evaluator &)
octave_value_list evaluate_n(tree_evaluator &tw, int nargout=1)
tree_index_expression(tree_expression *e=nullptr, tree_argument_list *lst=nullptr, int l=-1, int c=-1, char t='(')
tree_index_expression * dup(symbol_scope &scope) const
bool is_word_list_cmd() const
std::string get_struct_index(tree_evaluator &tw, std::list< string_vector >::const_iterator p_arg_nm, std::list< tree_expression * >::const_iterator p_dyn_field) const
octave_lvalue lvalue(tree_evaluator &tw)
tree_index_expression * append(tree_argument_list *lst=nullptr, char t='(')
virtual int column() const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void() error(const char *fmt,...)
#define panic_impossible()
void err_indexed_cs_list()
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))