*** empty log message ***
[bpt/guile.git] / src / vm_loader.c
CommitLineData
17e90c5e
KN
1/* Copyright (C) 2000 Free Software Foundation, Inc.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2, or (at your option)
6 * any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; see the file COPYING. If not, write to
15 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
16 * Boston, MA 02111-1307 USA
17 *
18 * As a special exception, the Free Software Foundation gives permission
19 * for additional uses of the text contained in its release of GUILE.
20 *
21 * The exception is that, if you link the GUILE library with other files
22 * to produce an executable, this does not by itself cause the
23 * resulting executable to be covered by the GNU General Public License.
24 * Your use of that executable is in no way restricted on account of
25 * linking the GUILE library code into it.
26 *
27 * This exception does not however invalidate any other reasons why
28 * the executable file might be covered by the GNU General Public License.
29 *
30 * This exception applies only to the code released by the
31 * Free Software Foundation under the name GUILE. If you copy
32 * code from other Free Software Foundation releases into a copy of
33 * GUILE, as the General Public License permits, the exception does
34 * not apply to the code that you add in this way. To avoid misleading
35 * anyone as to the status of such modified files, you must delete
36 * this exception notice from them.
37 *
38 * If you write modifications of your own for GUILE, it is your choice
39 * whether to permit this exception to apply to your modifications.
40 * If you do not wish that, delete this exception notice. */
41
42/* This file is included in vm_engine.c */
43
44VM_DEFINE_INSTRUCTION (load_integer, "load-integer", -1)
45{
46 size_t len;
47 FETCH_LENGTH (len);
48 SCM_MISC_ERROR ("Not implemented yet", SCM_EOL);
49 ip += len;
50 NEXT;
51}
52
53VM_DEFINE_INSTRUCTION (load_symbol, "load-symbol", -1)
54{
55 size_t len;
56 FETCH_LENGTH (len);
57 PUSH (scm_mem2symbol (ip, len));
58 ip += len;
59 NEXT;
60}
61
62VM_DEFINE_INSTRUCTION (load_string, "load-string", -1)
63{
64 size_t len;
65 FETCH_LENGTH (len);
66 PUSH (scm_makfromstr (ip, len, 0));
67 ip += len;
68 NEXT;
69}
70
71VM_DEFINE_INSTRUCTION (load_keyword, "load-keyword", -1)
72{
73 SCM sym;
74 size_t len;
75 FETCH_LENGTH (len);
76 sym = scm_mem2symbol (ip, len);
77 PUSH (scm_make_keyword_from_dash_symbol (sym));
78 ip += len;
79 NEXT;
80}
81
82VM_DEFINE_INSTRUCTION (load_module, "load-module", -1)
83{
84 size_t len;
85 FETCH_LENGTH (len);
86 PUSH (scm_c_lookup_env (scm_mem2symbol (ip, len)));
87 ip += len;
88 NEXT;
89}
90
91VM_DEFINE_INSTRUCTION (load_program, "load-program", -1)
92{
93 size_t len;
94 SCM prog, x;
95
96 FETCH_LENGTH (len);
97 prog = scm_c_make_program (ip, len, program);
98
99 x = sp[0];
100 if (SCM_INUMP (x))
101 {
102 int i = SCM_INUM (x);
103 SCM_PROGRAM_NARGS (prog) = i >> 5; /* 6-5 bits */
104 SCM_PROGRAM_NREST (prog) = (i >> 4) & 1; /* 4 bit */
105 SCM_PROGRAM_NLOCS (prog) = i & 15; /* 3-0 bits */
106 }
107 else
108 {
109 SCM_PROGRAM_NARGS (prog) = SCM_INUM (sp[3]);
110 SCM_PROGRAM_NREST (prog) = SCM_INUM (sp[2]);
111 SCM_PROGRAM_NLOCS (prog) = SCM_INUM (sp[1]);
112 if (SCM_VECTORP (x))
113 SCM_PROGRAM_OBJS (prog) = x;
114 sp += 3;
115 }
116
117 ip += len;
118 *sp = prog;
119 NEXT;
120}
121
122VM_DEFINE_INSTRUCTION (link, "link", 0)
123{
124 sp[1] = scm_c_env_vcell (sp[1], sp[0], 1);
125 DROP ();
126 NEXT;
127}
128
129/*
130 Local Variables:
131 c-file-style: "gnu"
132 End:
133*/