1 /*
2     This file is part of GNU APL, a free implementation of the
3     ISO/IEC Standard 13751, "Programming Language APL, Extended"
4 
5     Copyright (C) 2008-2015  Dr. Jürgen Sauermann
6 
7     This program is free software: you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation, either version 3 of the License, or
10     (at your option) any later version.
11 
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16 
17     You should have received a copy of the GNU General Public License
18     along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef __PRIMITIVE_OPERATOR_HH_DEFINED__
22 #define __PRIMITIVE_OPERATOR_HH_DEFINED__
23 
24 #include "PrimitiveFunction.hh"
25 #include "StateIndicator.hh"
26 
27 class BeamIterator;
28 
29 //-----------------------------------------------------------------------------
30 /// Base class for all primitive APL operators
31 class PrimitiveOperator : public PrimitiveFunction
32 {
33 public:
34    /// Constructor.
PrimitiveOperator(TokenTag tag)35    PrimitiveOperator(TokenTag tag) : PrimitiveFunction(tag) {}
36 
37    /// overloaded Function::is_operator()
is_operator() const38    virtual bool is_operator() const   { return true; }
39 
40    /// overloaded Function::get_fun_valence()
get_fun_valence() const41    virtual int get_fun_valence() const   { return 2; }
42 
43    /// overloaded Function::get_oper_valence(). Most primitive operators are
44    /// monadic, so we return 1 and overload dyadic operators (i.e. inner/outer
45    /// product) to return 2
get_oper_valence() const46    virtual int get_oper_valence() const   { return 1; }
47 
48    /// evaluate the fill function with arguments A and B
49    static Token fill(const Shape shape_Z, Value_P A, Function * fun,
50                      Value_P B, const char * loc);
51 };
52 //-----------------------------------------------------------------------------
53 
54 #endif // __PRIMITIVE_OPERATOR_HH_DEFINED__
55