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 __SHARED_VARIABLES_HH_DEFINED__ 22 #define __SHARED_VARIABLES_HH_DEFINED__ 23 24 #include "QuadFunction.hh" 25 #include "SystemVariable.hh" 26 27 //----------------------------------------------------------------------------- 28 /** some helper functions to start auxiliary processors */ 29 /// Base class for ⎕SVC, ⎕SVE, ⎕SVO, ⎕SVQ, ⎕SVR, and ⎕SVS 30 class Quad_SVx 31 { 32 public: 33 /// start the auxiliary processor \b proc 34 static void start_AP(AP_num proc); 35 36 protected: 37 /// return true iff \b filename is executable by everybody 38 static bool is_executable(const char * filename); 39 40 /// disconnect from auxiliary processor proc if connected. 41 static void disconnect(AP_num proc); 42 }; 43 //----------------------------------------------------------------------------- 44 /** 45 The system function ⎕SVC (Shared Variable Control). 46 */ 47 /// The class implementing ⎕SVC 48 class Quad_SVC : public QuadFunction, Quad_SVx 49 { 50 public: 51 /// Constructor. Quad_SVC()52 Quad_SVC() : QuadFunction(TOK_Quad_SVC) {} 53 54 static Quad_SVC * fun; ///< Built-in function. 55 static Quad_SVC _fun; ///< Built-in function. 56 57 protected: 58 /// Overloaded Function::eval_AB(). 59 virtual Token eval_AB(Value_P A, Value_P B); 60 61 /// Overloaded Function::eval_AB(). 62 virtual Token eval_B(Value_P B); 63 }; 64 //----------------------------------------------------------------------------- 65 /** 66 The system variable ⎕SVE (Shared Variable Event). 67 */ 68 /// The implementation of ⎕SVE 69 class Quad_SVE : public NL_SystemVariable, Quad_SVx 70 { 71 public: 72 /// Constructor. 73 Quad_SVE(); 74 75 protected: 76 /// overloaded Symbol::assign() 77 virtual void assign(Value_P value, bool clone, const char * loc); 78 79 /// Overloaded Symbol::get_apl_value(). 80 virtual Value_P get_apl_value() const; 81 82 /// when the current ⎕SVE timer expires (as float) 83 static APL_time_us timer_end; 84 }; 85 //----------------------------------------------------------------------------- 86 /** 87 The system function Quad-SVO (Shared Variable Offer). 88 */ 89 /// The implementation of ⎕SVO 90 class Quad_SVO : public QuadFunction, Quad_SVx 91 { 92 public: 93 /// Constructor. Quad_SVO()94 Quad_SVO() : QuadFunction(TOK_Quad_SVO) {} 95 96 static Quad_SVO * fun; ///< Built-in function. 97 static Quad_SVO _fun; ///< Built-in function. 98 99 protected: 100 /// Overloaded Function::eval_AB(). 101 virtual Token eval_AB(Value_P A, Value_P B); 102 103 /// Overloaded Function::eval_AB(). 104 virtual Token eval_B(Value_P B); 105 106 /// share one variable 107 SV_key share_one_variable(AP_num proc, const uint32_t * vname, 108 SV_Coupling & coupling); 109 }; 110 //----------------------------------------------------------------------------- 111 /** 112 The system function Quad-SVQ (Shared Variable Query). 113 */ 114 /// The implementation of ⎕SVQ 115 class Quad_SVQ : public QuadFunction, Quad_SVx 116 { 117 public: 118 /// Constructor. Quad_SVQ()119 Quad_SVQ() : QuadFunction(TOK_Quad_SVQ) {} 120 121 static Quad_SVQ * fun; ///< Built-in function. 122 static Quad_SVQ _fun; ///< Built-in function. 123 124 protected: 125 /// Overloaded Function::eval_AB(). 126 virtual Token eval_B(Value_P B); 127 128 /// return processors with matching offers 129 Value_P get_processors(); 130 131 /// return variables offered by processor proc 132 Value_P get_variables(AP_num proc); 133 }; 134 //----------------------------------------------------------------------------- 135 /** 136 The system function ⎕SVR (shared Variable Retraction). 137 */ 138 /// The implementation of ⎕SVR 139 class Quad_SVR : public QuadFunction, Quad_SVx 140 { 141 public: 142 /// Constructor. Quad_SVR()143 Quad_SVR() : QuadFunction(TOK_Quad_SVR) {} 144 145 static Quad_SVR * fun; ///< Built-in function. 146 static Quad_SVR _fun; ///< Built-in function. 147 148 protected: 149 /// Overloaded Function::eval_AB(). 150 virtual Token eval_B(Value_P B); 151 }; 152 //============================================================================= 153 /** 154 The system function ⎕SVS (Shared Variable State). 155 */ 156 /// The implementation of ⎕SVS 157 class Quad_SVS : public QuadFunction, Quad_SVx 158 { 159 public: 160 /// Constructor. Quad_SVS()161 Quad_SVS() : QuadFunction(TOK_Quad_SVS) {} 162 163 static Quad_SVS * fun; ///< Built-in function. 164 static Quad_SVS _fun; ///< Built-in function. 165 166 protected: 167 /// Overloaded Function::eval_AB(). 168 virtual Token eval_B(Value_P B); 169 }; 170 //----------------------------------------------------------------------------- 171 172 #endif // __SHARED_VARIABLES_HH_DEFINED__ 173