00001 // Copyright (C) 2002 Petter Urkedal (petter.urkedal@matfys.lth.se) 00002 // 00003 // This file is free software; you can redistribute it and/or modify 00004 // it under the terms of the GNU General Public License as published by 00005 // the Free Software Foundation; either version 2 of the License, or 00006 // (at your option) any later version. 00007 // 00008 // This file is distributed in the hope that it will be useful, 00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 // GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License 00014 // along with this program; if not, write to the Free Software 00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00016 // 00017 // As a special exception, you may use this file as part of a free 00018 // software library without restriction. Specifically, if other files 00019 // instantiate templates or use macros or inline functions from this 00020 // file, or you compile this file and link it with other files to 00021 // produce an executable, this file does not by itself cause the 00022 // resulting executable to be covered by the GNU General Public 00023 // License. This exception does not however invalidate any other 00024 // reasons why the executable file might be covered by the GNU General 00025 // Public License. 00026 // 00027 // $Id: cx_closure.h,v 1.1 2002/05/30 18:01:37 petter_urkedal Exp $ 00028 00029 // !! EXPERIMENTAL AND UNFINISHED !! 00030 00031 #include <more/lang/cx_expr.h> 00032 #include <more/lang/ct_proto.h> 00033 00034 #ifndef MORE_LANG_CLOSURE_H 00035 #define MORE_LANG_CLOSURE_H 00036 00037 namespace more { 00038 namespace lang { 00039 00040 struct rt_closure_proto : ct_proto 00041 { 00042 virtual void destruct(void*) const; 00043 virtual bool equal(void*, void*) const; 00044 virtual void construct_copy(void*, void*) const; 00045 virtual void print_declaration_pre(std::ostream& printopt_type) const; 00046 virtual void print_declaration_post(std::ostream& printopt_type) const; 00047 }; 00048 00049 struct rt_closure : cx_expr 00050 { 00051 rt_closure_proto(ct_proto* src_proto, argument_selection const& sel); 00052 00053 rt_closure(cx_expr* fn, va_list va); 00054 00055 /** Construct a closure which binds \a fn to those of \a args 00056 which are non-zero, and takes the rest as arguments. */ 00057 rt_closure(cx_expr* fn, cx_expr** args); 00058 00059 virtual void print_as_expr(std::ostream& os) const; 00060 ct_struct const* closure_arg_type() const; 00061 private: 00062 cx_expr* m_fn; 00063 }; 00064 00065 00066 }} 00067 00068 #endif