basix_doc 0.1
/Users/mourrain/Devel/mmx/basix/include/basix/primitive.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : primitive.hpp
00004 * DESCRIPTION: Abstract primitives for evaluators
00005 * COPYRIGHT  : (C) 2006  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license and comes WITHOUT
00008 * ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
00009 * If you don't have this file, write to the Free Software Foundation, Inc.,
00010 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00011 ******************************************************************************/
00012 
00013 #ifndef __PRIMITIVE_HPP
00014 #define __PRIMITIVE_HPP
00015 #include <basix/syntactic.hpp>
00016 #include <basix/identifiers.hpp>
00017 #include <basix/wrap.hpp>
00018 
00020 
00021 namespace mmx {
00022 
00023 class routine;
00024 class primitive;
00025 class primitive_rep: public rep_struct {
00026 public:
00027   generic name;
00028 public:
00029   inline primitive_rep (const generic& name2): name (name2) {}
00030   virtual inline ~primitive_rep () {}
00031   inline virtual generic apply (const generic& x) const { return x; }
00032 };
00033 
00034 class primitive {
00035 INDIRECT_PROTO (primitive, primitive_rep)
00036 public:
00037   inline const primitive_rep* operator * () const { return rep; }
00038   inline primitive (): rep (NULL) {}
00039   primitive (const generic& name, generic (*prim) (const generic&));
00040   primitive (const routine& fun);
00041   friend inline bool is_nil (const primitive& fun);
00042 };
00043 INDIRECT_NULL_IMPL (primitive, primitive_rep)
00044 
00045 inline bool is_nil (const primitive& fun) {
00046   return fun.rep == NULL; }
00047 inline syntactic flatten (const primitive& fun) {
00048   if (is_nil (fun)) return as_syntactic (GEN_NIL);
00049   else return as_syntactic (fun->name); }
00050 
00051 WRAP_INDIRECT_IMPL(inline,primitive)
00052 
00053 } // namespace mmx
00054 #endif // __PRIMITIVE_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines