1 /* Copyright (C) 2001,2008,2009 Free Software Foundation, Inc.
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
8 * This library 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 GNU
11 * Lesser General Public License for more details.
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 02110-1301 USA
19 /* This file is included in vm_engine.c */
21 VM_DEFINE_LOADER (59, load_unsigned_integer
, "load-unsigned-integer")
26 if (SCM_LIKELY (len
<= 4))
30 val
= (val
<< 8U) + FETCH ();
32 PUSH (scm_from_uint (val
));
36 SCM_MISC_ERROR ("load-unsigned-integer: not implemented yet", SCM_EOL
);
39 VM_DEFINE_LOADER (60, load_integer
, "load-integer")
44 if (SCM_LIKELY (len
<= 4))
48 val
= (val
<< 8) + FETCH ();
50 PUSH (scm_from_int (val
));
54 SCM_MISC_ERROR ("load-integer: not implemented yet", SCM_EOL
);
57 VM_DEFINE_LOADER (61, load_number
, "load-number")
63 PUSH (scm_string_to_number (scm_from_locale_stringn ((char *)ip
, len
),
64 SCM_UNDEFINED
/* radix = 10 */));
65 /* Was: scm_istring2number (ip, len, 10)); */
70 VM_DEFINE_LOADER (62, load_string
, "load-string")
75 PUSH (scm_from_locale_stringn ((char *)ip
, len
));
76 /* Was: scm_makfromstr (ip, len, 0) */
81 VM_DEFINE_LOADER (63, load_symbol
, "load-symbol")
86 PUSH (scm_from_locale_symboln ((char *)ip
, len
));
91 VM_DEFINE_LOADER (64, load_keyword
, "load-keyword")
96 PUSH (scm_from_locale_keywordn ((char *)ip
, len
));
101 VM_DEFINE_LOADER (65, load_program
, "load-program")
109 if (scm_is_vector (objs
) && scm_is_false (scm_c_vector_ref (objs
, 0)))
110 scm_c_vector_set_x (objs
, 0, scm_current_module ());
112 objcode
= scm_c_make_objcode_slice (SCM_PROGRAM_OBJCODE (fp
[-1]), ip
);
113 len
= sizeof (struct scm_objcode
) + SCM_OBJCODE_TOTAL_LEN (objcode
);
115 PUSH (scm_make_program (objcode
, objs
, SCM_EOL
));
122 VM_DEFINE_INSTRUCTION (66, link_now
, "link-now", 0, 1, 1)
127 if (SCM_LIKELY (SCM_SYMBOLP (what
)))
129 PUSH (scm_lookup (what
)); /* might longjmp */
134 /* compilation of @ or @@
135 `what' is a three-element list: (MODNAME SYM INTERFACE?)
136 INTERFACE? is #t if we compiled @ or #f if we compiled @@
138 mod
= scm_resolve_module (SCM_CAR (what
));
139 if (scm_is_true (SCM_CADDR (what
)))
140 mod
= scm_module_public_interface (mod
);
141 if (SCM_FALSEP (mod
))
143 finish_args
= scm_list_1 (SCM_CAR (what
));
144 goto vm_error_no_such_module
;
147 PUSH (scm_module_lookup (mod
, SCM_CADR (what
)));
153 VM_DEFINE_LOADER (67, define
, "define")
160 sym
= scm_from_locale_symboln ((char *)ip
, len
);
164 PUSH (scm_sym2var (sym
, scm_current_module_lookup_closure (), SCM_BOOL_T
));
169 (defun renumber-ops ()
170 "start from top of buffer and renumber 'VM_DEFINE_FOO (\n' sequences"
173 (let ((counter 59)) (goto-char (point-min))
174 (while (re-search-forward "^VM_DEFINE_[^ ]+ (\\([^,]+\\)," (point-max) t)
176 (number-to-string (setq counter (1+ counter)))