#ifndef __VALUES_SYMBOL_H #define __VALUES_SYMBOL_H /* 5D programming language Copyright (C) 2011 Danny Milosavljevic This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ namespace Values { struct Symbol : Node { const char* name; }; struct SymbolReference : Node { NodeT symbol; int index; public: SymbolReference(NodeT symbol, int index); }; NodeT symbolFromStr(const char* name) G_5D_GNUC_PURE; static inline bool symbol_P(NodeT argument) { return(dynamic_cast(argument) != NULL || dynamic_cast(argument) != NULL); } static inline bool symbol1_P(NodeT argument) { return(dynamic_cast(argument) != NULL); } /* will return NULL if not a Symbol. */ static inline const char* get_symbol_name(NodeT argument) { SymbolReference* r = dynamic_cast(argument); Symbol* s = dynamic_cast(r ? r->symbol : argument); return s ? s->name : NULL; } /* will return NULL if not a Symbol. */ static inline const char* get_symbol1_name(NodeT argument) { Symbol* s = dynamic_cast(argument); return s ? s->name : NULL; } static inline NodeT get_symbol_reference_name(NodeT root) { SymbolReference* refNode = dynamic_cast(root); if(refNode) return(refNode->symbol); else return(NULL); } static inline int get_symbol_reference_index(NodeT root) { SymbolReference* refNode = dynamic_cast(root); if(refNode) return(refNode->index); else return(-1); } static inline bool symbol_reference_P(NodeT root) { return(dynamic_cast(root) != NULL); } }; #endif /* ndef __VALUES_SYMBOL_H */