funcNode.h
Ir a la documentación de este archivo.
1 //funcNode.h
2 //-------------------------------------------------------------------------------------------
3 /*
4  * Fco. Javier Bohórquez Ogalla
5  * 75766599-E
6  * Puerto Real (Cádiz)
7  * powersgame@gmail.com
8  */
9 //-------------------------------------------------------------------------------------------
10 /*
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
24  * MA 02110-1301, USA.
25  */
26 //-------------------------------------------------------------------------------------------
35 //-------------------------------------------------------------------------------------------
36 #ifndef _RUN_TABLE_FUNCNODE_
37 #define _RUN_TABLE_FUNCNODE_
38 
39 #include "idNode.h"
40 #include "../tree/expNode.h"
41 //-------------------------------------------------------------------------------------------
42 
43 //-------------------------------------------------------------------------------------------
85 class functionNode :
86  public fexpNode {
87  public:
98  functionNode (runNode* id, runNode* params, runNode* body, bool priv = false);
103  void run ();
109  string print () const;
129  runNode* call (runNode* params, sTable * context = NULL);
134  runNode* getID ();
140  runNode* setID (runNode* id);
145  string name ();
150  runNode * getParams ();
155  runNode * getBody ();
160  void setObj (runNode * obj );
166  void setStaticLink (runNode * static_link );
171  void setParent (classNode * parent );
172  static classNode * class_link;
173  protected:
174  runNode *id_, *params_, *body_;
175  private:
176  sTable *extern_s_;
177  symbols *level_create;
178  bool extern_;
179  runNode *object_, *static_link_, *id_save_;
180  classNode *parent_;
181  bool exec_;
182 };
183 //-------------------------------------------------------------------------------------------
184 
185 //-------------------------------------------------------------------------------------------
201  public nexpNode {
202  public:
208  functioncallNode (runNode* id, runNode* params);
224  void run (bool excep, runNode* obj = NULL, classNode* parent = NULL, sTable * context = NULL);
234  void run ();
235  private:
236  runNode *id_, *params_;
237  bool exec_;
238 };
239 //-------------------------------------------------------------------------------------------
240 
241 //-------------------------------------------------------------------------------------------
250  public nexpNode {
251  public:
256  functiongetNode (runNode* id);
261  void run ();
262  private:
263  runNode *id_;
264 };
265 //-------------------------------------------------------------------------------------------
266 
267 //-------------------------------------------------------------------------------------------
277  public exception {
278  public:
283  returnException (runNode* resp);
287  const char* what() const throw();
291  runNode* val () const;
292  private:
293  runNode* resp_;
294 };
295 //-------------------------------------------------------------------------------------------
296 
297 //-------------------------------------------------------------------------------------------
308 class returnNode :
309  public runNode {
310  public:
315  returnNode (runNode* value);
319  void run ();
320  private:
321  runNode* value_;
322 };
323 //-------------------------------------------------------------------------------------------
324 
325 //-------------------------------------------------------------------------------------------
339  public runNode {
340  public:
345  refparamNode (runNode* value);
350  void run ();
354  inline runNode* getValue () { return value_; }
355  private:
356  runNode* value_;
357 };
358 //-------------------------------------------------------------------------------------------
359 
360 //-------------------------------------------------------------------------------------------
368 class contextFunction : public nexpNode {
369  public:
373  contextFunction ();
377  void run ();
378 };
379 //-------------------------------------------------------------------------------------------
380 
381 //-------------------------------------------------------------------------------------------
391  public:
400  partialFunctionNode (runNode * params, runNode *id, bool isrun = false);
405  void run();
413  static runNode* diffParams (runNode *pparams, runNode *fparams);
422  static bool existAllParams (runNode *pparams, runNode *fparams);
423  private:
424  runNode * params_, *id_;
425  bool isrun_;
426 };
427 //-------------------------------------------------------------------------------------------
428 
429 //-------------------------------------------------------------------------------------------
430 #endif
431 //-------------------------------------------------------------------------------------------
432 //Fco. Javier Bohórquez Ogalla
Nodo obtener función.
Definition: funcNode.h:249
returnException(runNode *resp)
Definition: funcNode.cpp:450
void setStaticLink(runNode *static_link)
Definition: funcNode.cpp:311
Nodos relacionados con identificadores.
Nodo return.
Definition: funcNode.h:308
void setParent(classNode *parent)
Definition: funcNode.cpp:315
Nodo de llamada a función.
Definition: funcNode.h:200
Nodo clase.
Definition: classNode.h:89
Nodo aplicación parcial.
Definition: funcNode.h:390
runNode * getValue()
Definition: funcNode.h:354
Tabla de símbolos.
Definition: symbols.h:65
void run()
Definition: funcNode.cpp:414
returnNode(runNode *value)
Definition: funcNode.cpp:463
void run()
Definition: funcNode.cpp:421
runNode * getID()
Definition: funcNode.cpp:282
Nodo ejecutable.
Definition: runTree.h:123
void run()
Definition: funcNode.cpp:523
void run()
Definition: funcNode.cpp:465
Nodo expresiones funciones.
Definition: expNode.h:503
const char * what() const
Definition: funcNode.cpp:452
runNode * call(runNode *params, sTable *context=NULL)
Definition: funcNode.cpp:84
Nodo de parámetro por referencia.
Definition: funcNode.h:338
static runNode * diffParams(runNode *pparams, runNode *fparams)
Definition: funcNode.cpp:590
runNode * setID(runNode *id)
Definition: funcNode.cpp:286
partialFunctionNode(runNode *params, runNode *id, bool isrun=false)
Definition: funcNode.cpp:521
Exepcion return.
Definition: funcNode.h:276
void run()
Definition: funcNode.cpp:51
Función de contexto.
Definition: funcNode.h:368
string name()
Definition: funcNode.cpp:291
void run()
Definition: funcNode.cpp:505
functiongetNode(runNode *id)
Definition: funcNode.cpp:419
Contexto de tablas de símbolos.
Definition: sTable.h:121
functionNode(runNode *id, runNode *params, runNode *body, bool priv=false)
Definition: funcNode.cpp:41
functioncallNode(runNode *id, runNode *params)
Definition: funcNode.cpp:322
runNode * val() const
Definition: funcNode.cpp:456
refparamNode(runNode *value)
Definition: funcNode.cpp:503
contextFunction()
Definition: funcNode.cpp:510
runNode * getParams()
Definition: funcNode.cpp:299
string print() const
Definition: funcNode.cpp:82
Nodo función.
Definition: funcNode.h:85
void run()
Definition: funcNode.cpp:512
Nodo expresión de tipo no definido.
Definition: expNode.h:164
runNode * getBody()
Definition: funcNode.cpp:303
void setObj(runNode *obj)
Definition: funcNode.cpp:307
static bool existAllParams(runNode *pparams, runNode *fparams)
Definition: funcNode.cpp:561