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 00023 00024 #include "prim2.hh" 00025 #include "stdlib.h" 00026 00027 Sym FFUN = symbol ("ForeignFunction"); 00028 00029 Tree ffunction (Tree signature, Tree incfile, Tree libfile) 00030 { 00031 return tree(FFUN, signature, incfile, libfile); 00032 } 00033 00034 bool isffunction(Tree t) 00035 { 00036 return t->node() == Node(FFUN); 00037 } 00038 00039 Tree ffsignature(Tree ff) 00040 { 00041 return ff->branch(0); 00042 } 00043 00044 const char* ffincfile(Tree ff) 00045 { 00046 return tree2str(ff->branch(1)); 00047 } 00048 00049 const char* fflibfile(Tree ff) 00050 { 00051 return tree2str(ff->branch(2)); 00052 } 00053 00054 int ffrestype(Tree t) 00055 { 00056 return tree2int(hd(ffsignature(t))); 00057 } 00058 00059 const char* ffname(Tree t) 00060 { 00061 return tree2str(nth(ffsignature(t),1)); 00062 } 00063 00064 int ffarity(Tree t) 00065 { 00066 return len(ffsignature(t))-2; 00067 } 00068 00069 int ffargtype(Tree t, int i) 00070 { 00071 return tree2int(nth(ffsignature(t), i+2)); 00072 }