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 __BIF_OPER2_RANK_HH_DEFINED__ 22 #define __BIF_OPER2_RANK_HH_DEFINED__ 23 24 #include "PrimitiveOperator.hh" 25 26 //----------------------------------------------------------------------------- 27 /** Primitive operator ⍤ (rank) 28 */ 29 /// The class implementing ⍤ 30 class Bif_OPER2_RANK : public PrimitiveOperator 31 { 32 public: 33 /// constructor Bif_OPER2_RANK()34 Bif_OPER2_RANK() : PrimitiveOperator(TOK_OPER2_RANK) {} 35 36 /// overloaded Function::eval_ALRB() 37 virtual Token eval_ALRB(Value_P A, Token & LO, Token & RO_y, Value_P B); 38 39 /// overloaded Function::eval_ALRXB() 40 virtual Token eval_ALRXB(Value_P A, Token & LO, Token & RO_y, 41 Value_P X, Value_P B); 42 43 /// the 'normalized' implementation of all eval_ALxxx*( functions 44 static Token do_ALyXB(Value_P A, Rank rk_chunk_A, Token & LO, 45 Value_P X, Value_P B, Rank rk_chunk_B); 46 47 /// overloaded Function::eval_LRB() 48 virtual Token eval_LRB(Token & LO, Token & RO_y, Value_P B); 49 50 /// overloaded Function::eval_LRXB() 51 virtual Token eval_LRXB(Token & LO, Token & RO_y, Value_P X, Value_P B); 52 53 /// overloaded Function::may_push_SI() may_push_SI() const54 virtual bool may_push_SI() const 55 { return true; } 56 57 /// the 'normalized' implementation of all eval_Lxxx*( functions 58 Token do_LyXB(Token & LO, Value_P X, Value_P B, Rank rk_chunkB); 59 60 /// split j B into j and B 61 static void split_y123_B(Value_P y123_B, Value_P & y123, Value_P & B); 62 63 static Bif_OPER2_RANK * fun; ///< Built-in function 64 static Bif_OPER2_RANK _fun; ///< Built-in function 65 66 protected: 67 /// convert 1- 2- or 3-element vector y123 to chunk-rank of B 68 static void y123_to_B(Value_P y123, Rank & rk_B); 69 70 /// convert 1- 2- or 3-element vector y123 to chunk-ranks of A and B 71 static void y123_to_AB(Value_P y123, Rank & rk_A, Rank & rk_B); 72 }; 73 //----------------------------------------------------------------------------- 74 75 #endif // __BIF_OPER2_RANK_HH_DEFINED__ 76