Commit | Line | Data |
---|---|---|
e20d7001 | 1 | /* Copyright (C) 1998,1999,2000,2001,2002,2003, 2006, 2008, 2009 Free Software Foundation, Inc. |
40cf7e92 | 2 | * |
73be1d9e | 3 | * This library is free software; you can redistribute it and/or |
53befeb7 NJ |
4 | * modify it under the terms of the GNU Lesser General Public License |
5 | * as published by the Free Software Foundation; either version 3 of | |
6 | * the License, or (at your option) any later version. | |
40cf7e92 | 7 | * |
53befeb7 NJ |
8 | * This library is distributed in the hope that it will be useful, but |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
73be1d9e MV |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
11 | * Lesser General Public License for more details. | |
40cf7e92 | 12 | * |
73be1d9e MV |
13 | * You should have received a copy of the GNU Lesser General Public |
14 | * License along with this library; if not, write to the Free Software | |
53befeb7 NJ |
15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
16 | * 02110-1301 USA | |
73be1d9e | 17 | */ |
1bbd0b84 | 18 | |
1bbd0b84 | 19 | |
40cf7e92 | 20 | \f |
dbb605f5 LC |
21 | #ifdef HAVE_CONFIG_H |
22 | # include <config.h> | |
23 | #endif | |
40cf7e92 | 24 | |
a0599745 MD |
25 | #include "libguile/_scm.h" |
26 | #include "libguile/eval.h" | |
7e73eaee | 27 | #include "libguile/fluids.h" |
f58c472a | 28 | #include "libguile/modules.h" |
40cf7e92 | 29 | |
a0599745 MD |
30 | #include "libguile/validate.h" |
31 | #include "libguile/evalext.h" | |
40cf7e92 | 32 | |
5ec1d2c8 | 33 | SCM_DEFINE (scm_defined_p, "defined?", 1, 1, 0, |
dab1ed37 LC |
34 | (SCM sym, SCM module), |
35 | "Return @code{#t} if @var{sym} is defined in the module " | |
36 | "@var{module} or the current module when @var{module} is not" | |
37 | "specified.") | |
5ec1d2c8 | 38 | #define FUNC_NAME s_scm_defined_p |
40cf7e92 | 39 | { |
86d31dfe | 40 | SCM var; |
40cf7e92 | 41 | |
34d19ef6 | 42 | SCM_VALIDATE_SYMBOL (1, sym); |
40cf7e92 | 43 | |
dab1ed37 LC |
44 | if (SCM_UNBNDP (module)) |
45 | module = scm_current_module (); | |
b325a6c8 | 46 | else |
dab1ed37 LC |
47 | SCM_VALIDATE_MODULE (2, module); |
48 | ||
49 | var = scm_module_variable (module, sym); | |
50 | ||
7888309b | 51 | return (scm_is_false (var) || SCM_UNBNDP (SCM_VARIABLE_REF (var)) |
b325a6c8 MD |
52 | ? SCM_BOOL_F |
53 | : SCM_BOOL_T); | |
40cf7e92 | 54 | } |
1bbd0b84 | 55 | #undef FUNC_NAME |
40cf7e92 | 56 | |
63dd3413 | 57 | |
1bbd0b84 | 58 | SCM_REGISTER_PROC (s_map_in_order, "map-in-order", 2, 0, 1, scm_map); |
285302e1 | 59 | |
f58c472a | 60 | |
93f26b7b MD |
61 | SCM_DEFINE (scm_self_evaluating_p, "self-evaluating?", 1, 0, 0, |
62 | (SCM obj), | |
63 | "Return #t for objects which Guile considers self-evaluating") | |
64 | #define FUNC_NAME s_scm_self_evaluating_p | |
65 | { | |
66 | switch (SCM_ITAG3 (obj)) | |
67 | { | |
68 | case scm_tc3_int_1: | |
69 | case scm_tc3_int_2: | |
70 | /* inum */ | |
71 | return SCM_BOOL_T; | |
72 | case scm_tc3_imm24: | |
73 | /* characters, booleans, other immediates */ | |
d2e53ed6 | 74 | return scm_from_bool (!scm_is_null (obj)); |
93f26b7b MD |
75 | case scm_tc3_cons: |
76 | switch (SCM_TYP7 (obj)) | |
77 | { | |
78 | case scm_tcs_closures: | |
79 | case scm_tc7_vector: | |
80 | case scm_tc7_wvect: | |
534c55a9 | 81 | case scm_tc7_number: |
93f26b7b MD |
82 | case scm_tc7_string: |
83 | case scm_tc7_smob: | |
93f26b7b | 84 | case scm_tc7_pws: |
2fb924f6 | 85 | case scm_tc7_program: |
807e5a66 | 86 | case scm_tc7_bytevector: |
93f26b7b MD |
87 | case scm_tcs_subrs: |
88 | case scm_tcs_struct: | |
89 | return SCM_BOOL_T; | |
90 | default: | |
91 | return SCM_BOOL_F; | |
92 | } | |
93 | } | |
94 | SCM_MISC_ERROR ("Internal error: Object ~S has unknown type", | |
95 | scm_list_1 (obj)); | |
96 | return SCM_UNSPECIFIED; /* never reached */ | |
97 | } | |
98 | #undef FUNC_NAME | |
99 | ||
40cf7e92 MD |
100 | void |
101 | scm_init_evalext () | |
102 | { | |
a0599745 | 103 | #include "libguile/evalext.x" |
40cf7e92 | 104 | } |
89e00824 ML |
105 | |
106 | /* | |
107 | Local Variables: | |
108 | c-file-style: "gnu" | |
109 | End: | |
110 | */ |