Commit | Line | Data |
---|---|---|
a2230b65 | 1 | /* Copyright (C) 1998,1999,2000,2001,2002,2003, 2006, 2008, 2009, 2010, 2011 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 | |
93f26b7b MD |
58 | SCM_DEFINE (scm_self_evaluating_p, "self-evaluating?", 1, 0, 0, |
59 | (SCM obj), | |
60 | "Return #t for objects which Guile considers self-evaluating") | |
61 | #define FUNC_NAME s_scm_self_evaluating_p | |
62 | { | |
63 | switch (SCM_ITAG3 (obj)) | |
64 | { | |
65 | case scm_tc3_int_1: | |
66 | case scm_tc3_int_2: | |
67 | /* inum */ | |
68 | return SCM_BOOL_T; | |
69 | case scm_tc3_imm24: | |
70 | /* characters, booleans, other immediates */ | |
7c4aad9c | 71 | return scm_from_bool (!scm_is_null_and_not_nil (obj)); |
93f26b7b MD |
72 | case scm_tc3_cons: |
73 | switch (SCM_TYP7 (obj)) | |
74 | { | |
93f26b7b MD |
75 | case scm_tc7_vector: |
76 | case scm_tc7_wvect: | |
5b46a8c2 | 77 | case scm_tc7_pointer: |
c99de5aa | 78 | case scm_tc7_hashtable: |
9ea31741 AW |
79 | case scm_tc7_fluid: |
80 | case scm_tc7_dynamic_state: | |
6f3b0cc2 AW |
81 | case scm_tc7_frame: |
82 | case scm_tc7_objcode: | |
83 | case scm_tc7_vm: | |
84 | case scm_tc7_vm_cont: | |
534c55a9 | 85 | case scm_tc7_number: |
93f26b7b MD |
86 | case scm_tc7_string: |
87 | case scm_tc7_smob: | |
2fb924f6 | 88 | case scm_tc7_program: |
807e5a66 | 89 | case scm_tc7_bytevector: |
b2637c98 | 90 | case scm_tc7_array: |
ff1feca9 | 91 | case scm_tc7_bitvector: |
93f26b7b MD |
92 | case scm_tcs_struct: |
93 | return SCM_BOOL_T; | |
94 | default: | |
95 | return SCM_BOOL_F; | |
96 | } | |
97 | } | |
98 | SCM_MISC_ERROR ("Internal error: Object ~S has unknown type", | |
99 | scm_list_1 (obj)); | |
100 | return SCM_UNSPECIFIED; /* never reached */ | |
101 | } | |
102 | #undef FUNC_NAME | |
103 | ||
40cf7e92 MD |
104 | void |
105 | scm_init_evalext () | |
106 | { | |
a0599745 | 107 | #include "libguile/evalext.x" |
40cf7e92 | 108 | } |
89e00824 ML |
109 | |
110 | /* | |
111 | Local Variables: | |
112 | c-file-style: "gnu" | |
113 | End: | |
114 | */ |