GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
pt-unop.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1996-2025 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if ! defined (octave_pt_unop_h)
27#define octave_pt_unop_h 1
28
29#include "octave-config.h"
30
31#include <string>
32
33class octave_value;
35
36#include "ov.h"
37#include "pt-exp.h"
38#include "pt-walk.h"
39#include "token.h"
40
42
43class symbol_scope;
44
45// Unary expressions.
46
48{
49protected:
50
53
57
58public:
59
60 OCTAVE_DISABLE_COPY_MOVE (tree_unary_expression)
61
63
64 bool is_unary_expression () const { return true; }
65
66 tree_expression * operand () { return m_op; }
67
68 std::string oper () const;
69
71
72protected:
73
74 // The operator token.
76
77 // The operand for the expression.
79
80 // The type of the expression.
82};
83
84// Prefix expressions.
85
87{
88public:
89
93
94 OCTAVE_DISABLE_COPY_MOVE (tree_prefix_expression)
95
97
98 filepos beg_pos () const { return m_op_tok.beg_pos (); }
99 filepos end_pos () const { return m_op->end_pos (); }
100
101 bool rvalue_ok () const { return true; }
102
103 tree_expression * dup (symbol_scope& scope) const;
104
105 octave_value evaluate (tree_evaluator&, int nargout = 1);
106
108 {
109 return ovl (evaluate (tw, nargout));
110 }
111
113 {
114 tw.visit_prefix_expression (*this);
115 }
116
117 std::string profiler_name () const { return "prefix " + oper (); }
118};
119
120// Postfix expressions.
121
123{
124public:
125
129
130 OCTAVE_DISABLE_COPY_MOVE (tree_postfix_expression)
131
133
134 filepos beg_pos () const { return m_op->beg_pos (); }
135 filepos end_pos () const { return m_op_tok.end_pos (); }
136
137 bool rvalue_ok () const { return true; }
138
139 tree_expression * dup (symbol_scope& scope) const;
140
141 octave_value evaluate (tree_evaluator&, int nargout = 1);
142
144 {
145 return ovl (evaluate (tw, nargout));
146 }
147
149 {
150 tw.visit_postfix_expression (*this);
151 }
152
153 std::string profiler_name () const { return "postfix " + oper (); }
154};
155
156OCTAVE_END_NAMESPACE(octave)
157
158#endif
@ unknown_unary_op
Definition ov.h:88
Definition token.h:42
filepos end_pos() const
Definition token.h:129
filepos beg_pos() const
Definition token.h:128
octave_value evaluate(tree_evaluator &, int nargout=1)
Definition pt-unop.cc:120
bool rvalue_ok() const
Definition pt-unop.h:137
filepos end_pos() const
Definition pt-unop.h:135
tree_expression * dup(symbol_scope &scope) const
Definition pt-unop.cc:109
~tree_postfix_expression()=default
filepos beg_pos() const
Definition pt-unop.h:134
void accept(tree_walker &tw)
Definition pt-unop.h:148
tree_postfix_expression(tree_expression *e, const token &op_tok, octave_value::unary_op t=octave_value::unknown_unary_op)
Definition pt-unop.h:126
std::string profiler_name() const
Definition pt-unop.h:153
octave_value_list evaluate_n(tree_evaluator &tw, int nargout=1)
Definition pt-unop.h:143
bool rvalue_ok() const
Definition pt-unop.h:101
std::string profiler_name() const
Definition pt-unop.h:117
tree_expression * dup(symbol_scope &scope) const
Definition pt-unop.cc:48
filepos beg_pos() const
Definition pt-unop.h:98
octave_value evaluate(tree_evaluator &, int nargout=1)
Definition pt-unop.cc:59
void accept(tree_walker &tw)
Definition pt-unop.h:112
octave_value_list evaluate_n(tree_evaluator &tw, int nargout=1)
Definition pt-unop.h:107
tree_prefix_expression(const token &op_tok, tree_expression *e, octave_value::unary_op t=octave_value::unknown_unary_op)
Definition pt-unop.h:90
filepos end_pos() const
Definition pt-unop.h:99
~tree_prefix_expression()=default
tree_expression * operand()
Definition pt-unop.h:66
octave_value::unary_op m_etype
Definition pt-unop.h:81
tree_expression * m_op
Definition pt-unop.h:78
octave_value::unary_op op_type() const
Definition pt-unop.h:70
bool is_unary_expression() const
Definition pt-unop.h:64
std::string oper() const
Definition pt-unop.cc:40
tree_unary_expression(octave_value::unary_op t=octave_value::unknown_unary_op)
Definition pt-unop.h:51
tree_unary_expression(const token &op_tok, tree_expression *e, octave_value::unary_op t=octave_value::unknown_unary_op)
Definition pt-unop.h:54
virtual void visit_postfix_expression(tree_postfix_expression &)
Definition pt-walk.cc:529
virtual void visit_prefix_expression(tree_prefix_expression &)
Definition pt-walk.cc:538
virtual filepos end_pos() const =0
virtual filepos beg_pos() const =0
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
Definition ovl.h:217