Commit | Line | Data |
---|---|---|
827dc8dc | 1 | /* Copyright (C) 2001,2008,2009,2010 Free Software Foundation, Inc. |
17e90c5e | 2 | * |
53e28ed9 | 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. | |
17e90c5e | 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 | |
53e28ed9 AW |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
11 | * Lesser General Public License for more details. | |
17e90c5e | 12 | * |
53e28ed9 AW |
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 | |
53e28ed9 AW |
17 | */ |
18 | ||
782a82ee | 19 | /* FIXME! Need to check that the fetch is within the current program */ |
17e90c5e KN |
20 | |
21 | /* This file is included in vm_engine.c */ | |
22 | ||
827dc8dc | 23 | VM_DEFINE_LOADER (101, load_number, "load-number") |
17e90c5e KN |
24 | { |
25 | size_t len; | |
f9e8c09d | 26 | |
17e90c5e | 27 | FETCH_LENGTH (len); |
1865ad56 | 28 | SYNC_REGISTER (); |
b6368dbb | 29 | PUSH (scm_string_to_number (scm_from_locale_stringn ((char *)ip, len), |
9cc649b8 | 30 | SCM_UNDEFINED /* radix = 10 */)); |
f9e8c09d | 31 | /* Was: scm_istring2number (ip, len, 10)); */ |
17e90c5e KN |
32 | ip += len; |
33 | NEXT; | |
34 | } | |
35 | ||
827dc8dc | 36 | VM_DEFINE_LOADER (102, load_string, "load-string") |
17e90c5e KN |
37 | { |
38 | size_t len; | |
94ff26b9 | 39 | char *buf; |
9c44cd45 | 40 | |
17e90c5e | 41 | FETCH_LENGTH (len); |
1865ad56 | 42 | SYNC_REGISTER (); |
94ff26b9 AW |
43 | PUSH (scm_i_make_string (len, &buf)); |
44 | memcpy (buf, (char *) ip, len); | |
45 | ip += len; | |
17e90c5e KN |
46 | NEXT; |
47 | } | |
48 | ||
827dc8dc | 49 | VM_DEFINE_LOADER (103, load_symbol, "load-symbol") |
a80be762 KN |
50 | { |
51 | size_t len; | |
17e90c5e | 52 | FETCH_LENGTH (len); |
1865ad56 | 53 | SYNC_REGISTER (); |
94ff26b9 AW |
54 | /* FIXME: should be scm_from_latin1_symboln */ |
55 | PUSH (scm_from_locale_symboln ((const char*)ip, len)); | |
56 | ip += len; | |
17e90c5e KN |
57 | NEXT; |
58 | } | |
59 | ||
827dc8dc | 60 | VM_DEFINE_LOADER (104, load_program, "load-program") |
17e90c5e | 61 | { |
53e28ed9 AW |
62 | scm_t_uint32 len; |
63 | SCM objs, objcode; | |
17e90c5e | 64 | |
53e28ed9 AW |
65 | POP (objs); |
66 | SYNC_REGISTER (); | |
ac99cb0c | 67 | |
53e28ed9 AW |
68 | if (scm_is_vector (objs) && scm_is_false (scm_c_vector_ref (objs, 0))) |
69 | scm_c_vector_set_x (objs, 0, scm_current_module ()); | |
ac99cb0c | 70 | |
53e28ed9 | 71 | objcode = scm_c_make_objcode_slice (SCM_PROGRAM_OBJCODE (fp[-1]), ip); |
ac47d5f6 | 72 | len = sizeof (struct scm_objcode) + SCM_OBJCODE_TOTAL_LEN (objcode); |
206a0622 | 73 | |
20d47c39 | 74 | PUSH (scm_make_program (objcode, objs, SCM_BOOL_F)); |
2fda0242 | 75 | |
53e28ed9 | 76 | ip += len; |
17e90c5e | 77 | |
17e90c5e KN |
78 | NEXT; |
79 | } | |
80 | ||
827dc8dc | 81 | VM_DEFINE_INSTRUCTION (105, link_now, "link-now", 0, 1, 1) |
17e90c5e | 82 | { |
fd358575 AW |
83 | SCM what; |
84 | POP (what); | |
1865ad56 | 85 | SYNC_REGISTER (); |
b7393ea1 | 86 | PUSH (resolve_variable (what, scm_current_module ())); |
6297d229 AW |
87 | NEXT; |
88 | } | |
89 | ||
827dc8dc | 90 | VM_DEFINE_LOADER (106, load_array, "load-array") |
cd9d95d7 | 91 | { |
94ff26b9 | 92 | SCM type, shape; |
cd9d95d7 | 93 | size_t len; |
cd9d95d7 | 94 | FETCH_LENGTH (len); |
94ff26b9 AW |
95 | POP (shape); |
96 | POP (type); | |
1865ad56 | 97 | SYNC_REGISTER (); |
94ff26b9 AW |
98 | PUSH (scm_from_contiguous_typed_array (type, shape, ip, len)); |
99 | ip += len; | |
cd9d95d7 | 100 | NEXT; |
fdcedea6 KN |
101 | } |
102 | ||
827dc8dc | 103 | VM_DEFINE_LOADER (107, load_wide_string, "load-wide-string") |
782a82ee | 104 | { |
782a82ee | 105 | size_t len; |
94ff26b9 AW |
106 | scm_t_wchar *wbuf; |
107 | ||
782a82ee | 108 | FETCH_LENGTH (len); |
94ff26b9 | 109 | if (SCM_UNLIKELY (len % 4)) |
71fc6438 AW |
110 | { |
111 | finish_args = scm_list_1 (scm_from_size_t (len)); | |
94ff26b9 AW |
112 | goto vm_error_bad_wide_string_length; |
113 | } | |
114 | ||
782a82ee | 115 | SYNC_REGISTER (); |
94ff26b9 AW |
116 | PUSH (scm_i_make_wide_string (len / 4, &wbuf)); |
117 | memcpy ((char *) wbuf, (char *) ip, len); | |
782a82ee AW |
118 | ip += len; |
119 | NEXT; | |
120 | } | |
121 | ||
53e28ed9 AW |
122 | /* |
123 | (defun renumber-ops () | |
124 | "start from top of buffer and renumber 'VM_DEFINE_FOO (\n' sequences" | |
125 | (interactive "") | |
126 | (save-excursion | |
827dc8dc | 127 | (let ((counter 100)) (goto-char (point-min)) |
53e28ed9 AW |
128 | (while (re-search-forward "^VM_DEFINE_[^ ]+ (\\([^,]+\\)," (point-max) t) |
129 | (replace-match | |
130 | (number-to-string (setq counter (1+ counter))) | |
131 | t t nil 1))))) | |
132 | */ | |
133 | ||
17e90c5e KN |
134 | /* |
135 | Local Variables: | |
136 | c-file-style: "gnu" | |
137 | End: | |
138 | */ |