Hormiga 1.0

/var/www/hormigaproject.com.ar/files/src/symboltable.h

Go to the documentation of this file.
00001 
00002 /*
00003 # Hormiga - Software de cálculo programable.
00004 #
00005 # Copyright (C) 2008, 2009 Leonardo Román, Hugo J. Curti, Norma  Ercoli,
00006 # Universidad Nacional del Centro de la Provincia de Buenos Aires
00007 # (UNCPBA)
00008 #
00009 # Este programa es parte de Hormiga.
00010 #
00011 # Hormiga es software libre. Puede redistribuirlo y/o modificarlo
00012 # bajo los términos de la Licencia Pública General de GNU según es
00013 # publicada por la Free Software Foundation, versión 2. Vea el archivo
00014 # COPIA (español, no oficial) o COPYING (inglés, oficial) en directorio
00015 # raíz.
00016 #
00017 # Hormiga se distribuye con la esperanza de que sea útil, pero SIN
00018 # NINGUNA GARANTÍA, incluso sin la garantía MERCANTIL implícita o sin
00019 # garantizar la CONVENIENCIA PARA UN PROPÓSITO PARTICULAR. Véase la
00020 # Licencia Pública General de GNU para más detalles.
00021 #
00022 # Debería haber recibido una copia de la Licencia Pública General junto
00023 # con Hormiga. Si no ha sido así, escriba a la Free Software
00024 # Foundation, Inc., en 675 Mass Ave, Cambridge, MA 02139, EEUU.
00025 # Añada también información sobre cómo contactar con usted mediante
00026 # correo electrónico y postal.
00027 #
00028 # This file is part of Hormiga.
00029 #
00030 # Hormiga is free software; you can redistribute it and/or modify
00031 # it under the terms of the GNU General Public License version 2
00032 # as published by the Free Software Foundation; see the file COPYING
00033 # in the top directory for details.
00034 #
00035 # Hormiga is distributed in the hope that it will be useful,
00036 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00037 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00038 # GNU General Public License for more details.
00039 #
00040 # You should have received a copy of the GNU General Public License
00041 # along with Hormiga; if not, write to the Free Software
00042 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00043 # USA
00044 */
00045 
00046 #ifndef SYMBOLTABLE_H
00047 #define SYMBOLTABLE_H
00048 
00049 #include "defines.h"
00050 
00051 #include "function/function.h"
00052 #include "oper/operand.h"
00053 #include "step/step.h"
00054 #include "types/type.h"
00055 #include "types/unit.h"
00056 
00057 class SymbolTable
00058 {
00059 public:
00060     SymbolTable ( SymbolTable *parentContext = NULL ) ;
00061     ~SymbolTable () ;
00062 
00063     SymbolTable* getParentSymbolTable () ;
00064 
00069     bool populateSymbol ( Operand *o ) ;
00070 
00078     Operand* getSymbol ( T_STRING &key ) const ;
00079 
00083     Operand* getLocalSymbol ( T_STRING &key ) const ;
00084 
00085     Operand* setLocalSymbol ( T_STRING &key, Operand *o ) ;
00086 
00090     Type* getType ( T_STRING &key ) const ;
00091     Type* getLocalType ( T_STRING &key ) const ;
00092     Type* setLocalType ( T_STRING &key , Type *t ) ;
00093 
00097     Unit* getUnit ( T_STRING &key ) const ;
00098     Unit* getLocalUnit ( T_STRING &key ) const ;
00099     Unit* setLocalUnit ( T_STRING &key , Unit *f ) ;
00100 
00104     Function* getFunction ( T_STRING &key ) const ;
00105     Function* getLocalFunction ( T_STRING &key ) const ;
00106     Function* setLocalFunction ( T_STRING &key , Function *f ) ;
00107 
00111     Step* getStep ( T_STRING &key ) const ;
00112     Step* getLocalStep ( T_STRING &key ) const ;
00113     Step* setLocalStep ( T_STRING &key , Step *f ) ;
00114     
00115     T_STRING toString () ;
00116 
00117 protected:
00118     // For Symbols:
00119     T_ST_HASH symbols ;
00120     // For Types:
00121     T_TYPE_HASH types ;
00122     // For Units:
00123     T_UNIT_HASH units ;
00124     // For Functions:
00125     T_FUNC_HASH funcs ;
00126     // For Steps:
00127     T_STEPS_HASH steps ;
00128     // Parent Symbol Table ( Global Scope )
00129     SymbolTable *parent ;
00130 };
00131 
00132 class CoreFunctionsBuilder
00133 {
00134     /* Aca deberiamos implementar la carga de plugins para soportar agregado de
00135      * funciones. Ver "tools-echoplugin.html" de la doc de QT para ver un ejemplo
00136      */
00137 public:
00138     Function* getFunction ( T_STRING &key ) ;
00139 protected:
00140     Function* setFunction ( T_STRING &key , Function *f ) ;
00141     T_FUNC_HASH funcs ;
00142 };
00143 
00144 #endif // SYMBOLTABLE_H