interp_actions.cc

Go to the documentation of this file.
00001 /*
00002    The lestes compiler suite
00003    Copyright (C) 2002, 2003, 2004, 2005 Miroslav Tichy
00004    Copyright (C) 2002, 2003, 2004, 2005 Petr Zika
00005    Copyright (C) 2002, 2003, 2004, 2005 Vojtech Hala
00006    Copyright (C) 2002, 2003, 2004, 2005 Jiri Kosina
00007    Copyright (C) 2002, 2003, 2004, 2005 Pavel Sanda
00008    Copyright (C) 2002, 2003, 2004, 2005 Jan Zouhar
00009    Copyright (C) 2002, 2003, 2004, 2005 Rudolf Thomas
00010 
00011    This program is free software; you can redistribute it and/or modify
00012    it under the terms of the GNU General Public License as published by
00013    the Free Software Foundation; version 2 of the License.
00014 
00015    This program is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018    GNU General Public License for more details.
00019 
00020    See the full text of the GNU General Public License version 2, and
00021    the limitations in the file doc/LICENSE.
00022 
00023    By accepting the license the licensee waives any and all claims
00024    against the copyright holder(s) related in whole or in part to the
00025    work, its use, and/or the inability to use it.
00026  
00027  */
00028 #include <lestes/common.hh>
00029 #include <lestes/ui/interp.hh>
00030 #include <lestes/ui/interp.g.hh>
00031 #include <lestes/ui/interp_actions.g.hh>
00032 #include <lestes/std/lassert.hh>
00033 #include <iostream>
00034 
00035 package(lestes);
00036 package(ui);
00037 
00038 void car_evaluator::method(ptr < l_object >)
00039 {
00040         r_set(l_interpreter::nil_get());
00041 }
00042 
00043 void car_evaluator::visit_l_cons(ptr < l_cons > c)
00044 {
00045         r_set(c->car_get());
00046 }
00047 
00048 void cdr_evaluator::method(ptr < l_object >)
00049 {
00050         r_set(l_interpreter::nil_get());
00051 }
00052 
00053 void cdr_evaluator::visit_l_cons(ptr < l_cons > c)
00054 {
00055         r_set(c->cdr_get());
00056 }
00057 
00058 void consp_evaluator::method(ptr < l_object >)
00059 {
00060         r_set(l_interpreter::nil_get());
00061 }
00062 
00063 void consp_evaluator::visit_l_cons(ptr < l_cons >)
00064 {
00065         r_set(l_interpreter::t_get());
00066 }
00067 
00068 
00069 void function_evaluator::visit_l_atom(ptr< ::lestes::ui::l_atom > x)
00070 {
00071         lassert(!x->fstack_get()->empty());
00072         r_set(x->fstack_get()->top());
00073 }
00074 
00075 void function_evaluator::method(ptr< ::lestes::ui::l_object > x)
00076 {
00077         r_set(basic_evaluator::instance()->go(x));
00078 }
00079 
00080 void basic_evaluator::visit_l_atom(ptr< ::lestes::ui::l_atom > x)
00081 {
00082         lassert(!x->vstack_get()->empty());
00083         r_set(x->vstack_get()->top());
00084 }
00085 
00086 void basic_evaluator::visit_l_string(ptr< ::lestes::ui::l_string > x)
00087 {
00088         r_set(x);
00089 }
00090 
00091 void basic_evaluator::visit_l_cons(ptr< ::lestes::ui::l_cons > x)
00092 {
00093         lp a = function_evaluator::instance()->go(car(x));
00094         ptr < l_function > f = a.dncast<l_function>();
00095         r_set(f->run(cdr(x)));
00096 }
00097 
00098 void basic_evaluator::visit_l_built_in(ptr< l_built_in > x)
00099 {
00100         r_set(x);
00101 }
00102 
00103 void basic_evaluator::visit_l_lambda(ptr< l_lambda > x)
00104 {
00105         r_set(x);
00106 }
00107 
00108 void basic_evaluator::visit_l_macro(ptr< l_macro > x)
00109 {
00110         r_set(x);
00111 }
00112 
00113 void basic_evaluator::method(ptr< ::lestes::ui::l_object >)
00114 {
00115         lassert(false);
00116 }
00117 
00118 void printer::visit_l_atom( ptr< l_atom > a )
00119 {
00120         *osw->stream_get() << a->name_get();
00121 }
00122 
00123 void printer::visit_l_string( ptr< l_string > a )
00124 {
00125         *osw->stream_get() << a->escaped_get();
00126 }
00127 
00128 void printer::visit_l_cons( ptr< l_cons > a )
00129 {
00130         ::std::ostream & os = *osw->stream_get();
00131         os << "(";
00132         print(car(a));
00133         lp x = a;
00134         while (!endp(x = cdr(x))) {
00135                 os << " ";
00136                 print(car(x));
00137         }
00138         if (x != l_interpreter::nil_get()) {
00139                 os << " . ";
00140                 print(x);
00141         }
00142 
00143         os << ")";
00144 }
00145 
00146 void printer::visit_l_built_in(ptr< l_built_in >)
00147 {
00148         *osw->stream_get() << "#<built-in>";
00149 }
00150 
00151 void printer::visit_l_lambda(ptr< l_lambda >)
00152 {
00153         *osw->stream_get() << "#<lambda>";
00154 }
00155 
00156 void printer::visit_l_macro(ptr< l_macro >)
00157 {
00158         *osw->stream_get() << "#<macro>";
00159 }
00160 
00161 void printer::method(ptr< ::lestes::ui::l_object >)
00162 {
00163         lassert(false);
00164 }
00165 
00166 
00167 end_package(ui);
00168 end_package(lestes);

Generated on Mon Feb 12 18:22:36 2007 for lestes by doxygen 1.5.1-20070107