00001 /************************************************************************ 00002 ************************************************************************ 00003 FAUST compiler 00004 Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale 00005 --------------------------------------------------------------------- 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 ************************************************************************ 00020 ************************************************************************/ 00021 00022 #include "floats.hh" 00023 00024 #define FLOATMACRO "FAUSTFLOAT" 00025 #define FLOATCAST "(" FLOATMACRO ")" 00026 00027 //----------------------------------------------- 00028 // float size coding : 00029 //----------------------------------------------- 00030 // 0: external float (macro name) 00031 // 1: single precision float 00032 // 2: double precision float 00033 // 3: long double precision float 00034 00035 extern int gFloatSize; 00036 00037 00038 const char* mathsuffix[] = {"", "f", "", "l"}; // suffix for math functions 00039 const char* numsuffix[] = {"", "f", "", ""}; // suffix for numeric constants 00040 const char* floatname[] = {FLOATMACRO, "float", "double", "quad"}; // float types 00041 const char* castname[] = {FLOATCAST, "(float)", "(double)", "(quad)"}; // float castings 00042 00043 const char* isuffix() { return mathsuffix[gFloatSize]; } 00044 const char* inumix() { return numsuffix [gFloatSize]; } 00045 00046 const char* ifloat() { return floatname[gFloatSize]; } 00047 const char* icast() { return castname[gFloatSize]; } 00048 00049 const char* xfloat() { return floatname[0]; } 00050 const char* xcast() { return castname[0]; } 00051 00052 void printfloatdef (std::ostream& fout) 00053 { 00054 fout << "#ifndef " << FLOATMACRO << std::endl; 00055 fout << "#define " << FLOATMACRO << " " << "float" << std::endl; 00056 fout << "#endif " << std::endl; 00057 fout << std::endl; 00058 fout << "typedef long double quad;" << std::endl; 00059 }