Back to index

plt-scheme  4.2.1
builtin.c
Go to the documentation of this file.
00001 /*
00002   MzScheme
00003   Copyright (c) 2004-2009 PLT Scheme Inc.
00004   Copyright (c) 2000-2001 Matthew Flatt
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library 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 GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public
00017     License along with this library; if not, write to the Free
00018     Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301 USA.
00020 
00021   libscheme
00022   Copyright (c) 1994 Brent Benson
00023   All rights reserved.
00024 */
00025 
00026 #include "schpriv.h"
00027 #include "schminc.h"
00028 
00029 /* On the Mac, 68K, store the built-in Scheme code as pc-relative */
00030 #if defined(__MWERKS__)
00031 #if !defined(__POWERPC__)
00032 #pragma pcrelstrings on
00033 #endif
00034 #endif
00035 
00036 Scheme_Object *scheme_eval_compiled_sized_string_with_magic(const char *str, int len, Scheme_Env *env,
00037                                                      Scheme_Object *magic_sym, Scheme_Object *magic_val,
00038                                                      int multi_ok)
00039 {
00040   Scheme_Object *port, *expr;
00041   Scheme_Config *config;
00042 
00043   config = scheme_current_config();
00044 
00045   port = scheme_make_sized_byte_string_input_port(str, -len); /* negative means it's constant */
00046 
00047   if (!env)
00048     env = scheme_get_env(NULL);
00049     
00050   expr = scheme_internal_read(port, NULL, 1, 1, 0, 0, 0, -1, NULL, 
00051                               magic_sym, magic_val,
00052                               NULL);
00053 
00054   if (multi_ok)
00055     return _scheme_eval_compiled_multi(expr, env);
00056   else
00057     return _scheme_eval_compiled(expr, env);
00058 }
00059 
00060 Scheme_Object *scheme_eval_compiled_sized_string(const char *str, int len, Scheme_Env *env)
00061 {
00062   return scheme_eval_compiled_sized_string_with_magic(str, len, env, NULL, NULL, 0);
00063 }
00064 
00065 void scheme_add_embedded_builtins(Scheme_Env *env)
00066 {
00067 #define EVAL_ONE_STR(str) scheme_eval_module_string(str, env)
00068 #define EVAL_ONE_SIZED_STR(str, len) scheme_eval_compiled_sized_string(str, len, env)
00069 
00070 #if USE_COMPILED_STARTUP
00071 # include "cstartup.inc"
00072 #else
00073 # include "startup.inc"
00074 #endif
00075 }
00076 
00077 #if defined(__MWERKS__)
00078 #if !defined(__POWERPC__)
00079 #pragma pcrelstrings reset
00080 #endif
00081 #endif