Remove stack programs, objcode, and the old VM.
[bpt/guile.git] / libguile / programs.h
1 /* Copyright (C) 2001, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
2 *
3 * This library is free software; you can redistribute it and/or
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.
7 *
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
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
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 * 02110-1301 USA
17 */
18
19 #ifndef _SCM_PROGRAMS_H_
20 #define _SCM_PROGRAMS_H_
21
22 #include <libguile.h>
23
24 /*
25 * The new RTL programs.
26 */
27
28 #define SCM_RTL_PROGRAM_P(x) (SCM_HAS_TYP7 (x, scm_tc7_rtl_program))
29 #define SCM_RTL_PROGRAM_CODE(x) ((scm_t_uint32 *) SCM_CELL_WORD_1 (x))
30 #define SCM_RTL_PROGRAM_FREE_VARIABLES(x) (SCM_CELL_OBJECT_LOC (x, 2))
31 #define SCM_RTL_PROGRAM_FREE_VARIABLE_REF(x,i) (SCM_RTL_PROGRAM_FREE_VARIABLES (x)[i])
32 #define SCM_RTL_PROGRAM_FREE_VARIABLE_SET(x,i,v) (SCM_RTL_PROGRAM_FREE_VARIABLES (x)[i]=(v))
33 #define SCM_RTL_PROGRAM_NUM_FREE_VARIABLES(x) (SCM_CELL_WORD_0 (x) >> 16)
34 #define SCM_VALIDATE_RTL_PROGRAM(p,x) SCM_MAKE_VALIDATE (p, x, RTL_PROGRAM_P)
35
36 static inline SCM
37 scm_i_make_rtl_program (const scm_t_uint32 *code)
38 {
39 return scm_cell (scm_tc7_rtl_program, (scm_t_bits)code);
40 }
41
42 SCM_INTERNAL SCM scm_make_rtl_program (SCM bytevector, SCM byte_offset, SCM free_variables);
43 SCM_INTERNAL SCM scm_rtl_program_p (SCM obj);
44 SCM_INTERNAL SCM scm_rtl_program_code (SCM program);
45
46 SCM_INTERNAL SCM scm_primitive_p (SCM obj);
47 SCM_INTERNAL SCM scm_primitive_call_ip (SCM prim);
48
49 SCM_INTERNAL SCM scm_i_rtl_program_name (SCM program);
50 SCM_INTERNAL SCM scm_i_rtl_program_documentation (SCM program);
51 SCM_INTERNAL SCM scm_i_rtl_program_properties (SCM program);
52
53 SCM_INTERNAL SCM scm_find_source_for_addr (SCM ip);
54
55 /*
56 * Programs
57 */
58
59 #define SCM_F_PROGRAM_IS_BOOT 0x100
60 #define SCM_F_PROGRAM_IS_PRIMITIVE 0x200
61 #define SCM_F_PROGRAM_IS_PRIMITIVE_GENERIC 0x400
62 #define SCM_F_PROGRAM_IS_CONTINUATION 0x800
63 #define SCM_F_PROGRAM_IS_PARTIAL_CONTINUATION 0x1000
64 #define SCM_F_PROGRAM_IS_FOREIGN 0x2000
65
66 #define SCM_PROGRAM_IS_BOOT(x) (SCM_CELL_WORD_0 (x) & SCM_F_PROGRAM_IS_BOOT)
67 #define SCM_PROGRAM_IS_PRIMITIVE(x) (SCM_CELL_WORD_0 (x) & SCM_F_PROGRAM_IS_PRIMITIVE)
68 #define SCM_PROGRAM_IS_PRIMITIVE_GENERIC(x) (SCM_CELL_WORD_0 (x) & SCM_F_PROGRAM_IS_PRIMITIVE_GENERIC)
69 #define SCM_PROGRAM_IS_CONTINUATION(x) (SCM_CELL_WORD_0 (x) & SCM_F_PROGRAM_IS_CONTINUATION)
70 #define SCM_PROGRAM_IS_PARTIAL_CONTINUATION(x) (SCM_CELL_WORD_0 (x) & SCM_F_PROGRAM_IS_PARTIAL_CONTINUATION)
71 #define SCM_PROGRAM_IS_FOREIGN(x) (SCM_CELL_WORD_0 (x) & SCM_F_PROGRAM_IS_FOREIGN)
72
73 SCM_API SCM scm_program_source (SCM program, SCM ip, SCM sources);
74 SCM_API SCM scm_program_num_free_variables (SCM program);
75 SCM_API SCM scm_program_free_variable_ref (SCM program, SCM i);
76 SCM_API SCM scm_program_free_variable_set_x (SCM program, SCM i, SCM x);
77
78 SCM_INTERNAL int scm_i_program_arity (SCM program, int *req, int *opt, int *rest);
79 SCM_INTERNAL void scm_i_program_print (SCM program, SCM port,
80 scm_print_state *pstate);
81 SCM_INTERNAL void scm_bootstrap_programs (void);
82 SCM_INTERNAL void scm_init_programs (void);
83
84 #endif /* _SCM_PROGRAMS_H_ */
85
86 /*
87 Local Variables:
88 c-file-style: "gnu"
89 End:
90 */