00001 /* Part of the culibs project, <http://www.eideticdew.org/culibs/>. 00002 * Copyright (C) 2006--2007 Petter Urkedal <urkedal@nbi.dk> 00003 * 00004 * This program is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #ifndef CUEX_FPVAR_H 00019 #define CUEX_FPVAR_H 00020 00021 #include <cuex/var.h> 00022 00023 CU_BEGIN_DECLARATIONS 00024 /*!\defgroup cuex_fpvar_h cuex/fpvar.h: Formal Function Parameter Variables 00025 * @{\ingroup cuex_mod 00026 * This is a variable type suited for formal function parameters if hash-cons 00027 * equivalence is required. These variables are identified by argument number 00028 * and type. Note that local functions, if supported by the application, may 00029 * have clashing variables, and this must be dealt with when traversing 00030 * expression trees. It this is not feasible, it is suggested to give up 00031 * hash-cons equivalence and use \ref cuex_tvar "cuex_tvar_t" instead. */ 00032 00033 #define cuex_fpvarmeta(index) \ 00034 cuex_varmeta_kqis(cuex_varkind_fpvar, cuex_qcode_u, index, \ 00035 sizeof(cuex_t)/sizeof(cu_word_t)) 00036 #define cuex_is_fpvarmeta(meta) cuex_is_varmeta_k(meta, cuex_varkind_fpvar) 00037 00038 /*!A formal parameter variable. */ 00039 struct cuex_fpvar 00040 { 00041 CUOO_HCOBJ 00042 cuex_t type; 00043 }; 00044 00045 /*!Hash-cons a function parameter variable based on the argument number and 00046 * its type. */ 00047 cuex_fpvar_t cuex_fpvar(int index, cuex_t type); 00048 00049 /*!True iff \a e is a formal function parameter variable. */ 00050 CU_SINLINE cu_bool_t cuex_is_fpvar(cuex_t e) 00051 { return cuex_is_fpvarmeta(cuex_meta(e)); } 00052 00053 /*!The index of \a v. */ 00054 CU_SINLINE int cuex_fpvar_index(cuex_fpvar_t v) 00055 { return cuex_varmeta_index(cuex_meta(v)); } 00056 00057 /*!The type of \a v. */ 00058 CU_SINLINE cuex_t cuex_fpvar_type(cuex_fpvar_t v) { return v->type; } 00059 00060 CU_END_DECLARATIONS 00061 00062 /*!@}*/ 00063 #endif