Mercurial > emacs
annotate lisp/emacs-lisp/disass.el @ 83004:7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
lib-src/emacsclient.c (window_change_signal): Renamed to pass_signal_to_emacs.
(init_signal): Pass SIGINT and SIGQUIT to the emacs process.
lisp/faces.el (face-valid-attribute-values): Use the window-system
function, not the variable.
(read-face-attribute, face-spec-set-match-display, frame-set-background-mode)
(face-set-after-frame-default): Ditto.
lisp/frame.el (make-frame-on-tty): Added interactive declaration
(suggested by Robert J. Chassell). Use tty-create-frame-with-faces,
not make-terminal-frame.
src/termhooks.h (struct display_method): Renamed to display for brevity.
(struct display): Added all display hook variables as members of this structure.
Added next_display, reference_count, type and display_info components.
(FRAME_MUST_WRITE_SPACES, FRAME_FAST_CLEAR_END_OF_LINE, FRAME_LINE_INS_DEL_OK)
(FRAME_CHAR_INS_DEL_OK, FRAME_SCROLL_REGION_OK, FRAME_SCROLL_REGION_COST)
(FRAME_MEMORY_BELOW_FRAME, FRAME_RIF): Updated for struct display.
(FRAME_DISPLAY): New macro.
(create_display, delete_display): New prototypes.
src/frame.h (struct frame): Added `display' member, removed display_method.
(FRAME_LIVE_P): Look at f->display, not f->output_data.
src/termchar.h (struct tty_display_info): Removed display_method component.
(FRAME_TTY): Use the display structure, not output_data.
src/term.c (display_list): New variable.
(cursor_to_hook, raw_cursor_to_hook, clear_to_end_hook, clear_frame_hook)
(clear_end_of_line_hook, ins_del_lines_hook, delete_glyphs_hook)
(ring_bell_hook, reset_terminal_modes_hook, set_terminal_modes_hook)
(update_begin_hook, update_end_hook, set_terminal_window_hook)
(insert_glyphs_hook, write_glyphs_hook, delete_glyphs_hoo, read_socket_hook)
(frame_up_to_date_hook, mouse_position_hook, frame_rehighlight_hook)
(frame_raise_lower_hook, set_vertical_scroll_bar_hook, condemn_scroll_bars_hook)
(redeem_scroll_bar_hook, judge_scroll_bars_hook): Moved to struct display.
(tty_display_method_template): Removed.
(syms_of_term): Don't initialize tty_display_method_template.
(ring_bell, set_terminal_modes, reset_terminal_modes, update_begin)
(update_end, set_terminal_window, cursor_to, raw_cursor_to, clear_to_end)
(clear_frame, clear_end_of_line, write_glyphs, insert_glyphs)
(delete_glyphs, ins_del_lines): Access display hooks through the frame pointer.
(Ftty_display_color_p): Use the frame given as a parameter, or else return nil.
(Ftty_display_color_cells): Ditto.
(get_named_tty): Renamed to get_named_tty_display, changed return type to struct display.
(term_dummy_init): Renamed to initial_term_init. Create and return an initial display.
(term_init): Initialize a new struct display and return a pointer to
it instead of tty_display_info. Removed frame initialization kludge.
(Fdelete_tty): Updated for struct display.
(delete_tty): The parameter type is now struct display, not tty_display_info.
Delete the display, too.
(create_tty_output): New function for creating tty_output structures.
(delete_tty_output): New function for deleting tty_output structures.
(create_display): New function for creating and registering display structures.
(delete_display): New function for deleting and unregistering display structures.
src/dispextern.h: Updated prototypes.
src/dispnew.c: Include frame.h before termhooks.h.
(init_display): Updated term_init call to new signature.
src/emacs.c: Include frame.h (for termhooks.h).
src/keymap.c: Ditto.
src/lread.c: Ditto.
src/xsmfns.c: Ditto.
src/process.c: Include frame.h before termhooks.h.
src/frame.c (Fwindow_system): New function.
(syms_of_frame): Initialize it.
(make_terminal_frame): Open the terminal device before creating the new frame.
Disable scrollbars here, term_init cannot do that anymore.
(Fdelete_frame): Use the new delete_frame_hook, don't do display-specific
frame deletion here. Ditto for delete_display_hook.
(Fmouse_position, Fmouse_pixel_position, Fraise_frame, Flower_frame)
(Fredirect_frame_focus): Access display hooks through the frame pointer.
src/keyboard.c: Include frame.h before termhooks.h.
(start_polling, input_polling_used, stop_polling, gobble_input): Ignore read_socket_hook.
(kbd_buffer_get_event, Fset_input_mode): Access display hooks through the frame pointer.
(read_avail_input): Loop through all display devices for and call all read_socket_hook functions. Check ttys even if read_socket_hook returned an error.
src/sysdep.c (discard_tty_input): Ignore read_socket_hook.
(stuff_char): Don't do anything if the current frame is not on a termcap display.
(request_sigio, unrequest_sigio): Ignore read_socket_hook.
(init_sys_modes): Always call narrow_foreground_group. Set up terminal modes and sigio even under X.
src/xdisp.c (message2_nolog, message3_nolog, redisplay_internal)
(set_vertical_scroll_bar, redisplay_window): Access display hooks through the frame pointer.
(echo_area_display): Don't be afraid of termcap frames during an X+tty combo session.
src/xfaces.c: Include termhooks.h.
(Ftty_supports_face_attributes_p): Use the given frame, not selected_frame.
src/xfns.c (x_set_scroll_bar_foreground, x_set_scroll_bar_background): Access display hooks through the frame pointer.
(Fx_create_frame, x_create_tip_frame): Initialize the frame's display structure.
src/xmenu.c: Include termhooks.h after frame.h.
src/xselect.c (x_own_selection, some_frame_on_display, x_get_foreign_selection)
(Fx_disown_selection_internal, Fx_get_cut_buffer_internal)
(Fx_store_cut_buffer_internal, Fx_rotate_cut_buffers_internal): Don't do anything
if the selected frame is not an X frame.
src/xterm.c (x_display_method): Removed.
(x_create_frame_display, x_delete_frame_display): New functions for handling struct display objects.
(x_term_init): Set up a new struct display object, too.
(x_delete_display): Delete the struct display corresponding to the X display.
(x_initialize): Moved hook initialization to x_create_frame_display.
src/xterm.h (x_display_method): Removed.
(struct x_display_info): Added frame_display component.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-44
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Mon, 05 Jan 2004 05:54:35 +0000 |
parents | 695cf19ef79e |
children | 3b81dccc5b32 375f2633d815 |
rev | line source |
---|---|
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
1 ;;; disass.el --- disassembler for compiled Emacs Lisp code |
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
2 |
51581
7ca4059e8636
(disassemble): Accept plain expressions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
3 ;; Copyright (C) 1986, 1991, 2003 Free Software Foundation, Inc. |
845 | 4 |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
5 ;; Author: Doug Cutting <doug@csli.stanford.edu> |
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
6 ;; Jamie Zawinski <jwz@lucid.com> |
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
7 ;; Maintainer: Jamie Zawinski <jwz@lucid.com> |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1821
diff
changeset
|
8 ;; Keywords: internal |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
9 |
757 | 10 ;; This file is part of GNU Emacs. |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
806 | 14 ;; the Free Software Foundation; either version 2, or (at your option) |
757 | 15 ;; any later version. |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
14169 | 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
757 | 26 |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
27 ;;; Commentary: |
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
28 |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
29 ;; The single entry point, `disassemble', disassembles a code object generated |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
30 ;; by the Emacs Lisp byte-compiler. This doesn't invert the compilation |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
31 ;; operation, not by a long shot, but it's useful for debugging. |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
32 |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
33 ;; |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
34 ;; Original version by Doug Cutting (doug@csli.stanford.edu) |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
35 ;; Substantially modified by Jamie Zawinski <jwz@lucid.com> for |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
36 ;; the new lapcode-based byte compiler. |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
37 |
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
38 ;;; Code: |
757 | 39 |
40 ;;; The variable byte-code-vector is defined by the new bytecomp.el. | |
802 | 41 ;;; The function byte-decompile-lapcode is defined in byte-opt.el. |
42 ;;; Since we don't use byte-decompile-lapcode, let's try not loading byte-opt. | |
1606
4303c30b29de
* disass.el (byte-compile): Specify that the 'byte-compile feature
Jim Blandy <jimb@redhat.com>
parents:
845
diff
changeset
|
43 (require 'byte-compile "bytecomp") |
757 | 44 |
8293
74218ea236fe
(disassemble-1): Display the pc values.
Richard M. Stallman <rms@gnu.org>
parents:
4789
diff
changeset
|
45 (defvar disassemble-column-1-indent 8 "*") |
757 | 46 (defvar disassemble-column-2-indent 10 "*") |
47 | |
48 (defvar disassemble-recursive-indent 3 "*") | |
49 | |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1606
diff
changeset
|
50 ;;;###autoload |
757 | 51 (defun disassemble (object &optional buffer indent interactive-p) |
52 "Print disassembled code for OBJECT in (optional) BUFFER. | |
53 OBJECT can be a symbol defined as a function, or a function itself | |
54 \(a lambda expression or a compiled-function object). | |
55 If OBJECT is not already compiled, we compile it, but do not | |
56 redefine OBJECT if it is a symbol." | |
57 (interactive (list (intern (completing-read "Disassemble function: " | |
58 obarray 'fboundp t)) | |
59 nil 0 t)) | |
51581
7ca4059e8636
(disassemble): Accept plain expressions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
60 (if (consp object) |
757 | 61 (setq object (list 'lambda () object))) |
62 (or indent (setq indent 0)) ;Default indent to zero | |
63 (save-excursion | |
64 (if (or interactive-p (null buffer)) | |
65 (with-output-to-temp-buffer "*Disassemble*" | |
66 (set-buffer "*Disassemble*") | |
67 (disassemble-internal object indent (not interactive-p))) | |
68 (set-buffer buffer) | |
69 (disassemble-internal object indent nil))) | |
70 nil) | |
71 | |
72 | |
73 (defun disassemble-internal (obj indent interactive-p) | |
74 (let ((macro 'nil) | |
75 (name 'nil) | |
76 (doc 'nil) | |
77 args) | |
78 (while (symbolp obj) | |
79 (setq name obj | |
80 obj (symbol-function obj))) | |
81 (if (subrp obj) | |
82 (error "Can't disassemble #<subr %s>" name)) | |
3767
660b7b4e3e40
(disassemble-internal): If function is autoload, load it.
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
83 (if (and (listp obj) (eq (car obj) 'autoload)) |
660b7b4e3e40
(disassemble-internal): If function is autoload, load it.
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
84 (progn |
660b7b4e3e40
(disassemble-internal): If function is autoload, load it.
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
85 (load (nth 1 obj)) |
660b7b4e3e40
(disassemble-internal): If function is autoload, load it.
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
86 (setq obj (symbol-function name)))) |
757 | 87 (if (eq (car-safe obj) 'macro) ;handle macros |
88 (setq macro t | |
89 obj (cdr obj))) | |
4789
86318d7728f5
(disassemble-internal): Allow a call to byte-code as argument.
Richard M. Stallman <rms@gnu.org>
parents:
3767
diff
changeset
|
90 (if (and (listp obj) (eq (car obj) 'byte-code)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
22995
diff
changeset
|
91 (setq obj (list 'lambda nil obj))) |
757 | 92 (if (and (listp obj) (not (eq (car obj) 'lambda))) |
93 (error "not a function")) | |
94 (if (consp obj) | |
95 (if (assq 'byte-code obj) | |
96 nil | |
97 (if interactive-p (message (if name | |
98 "Compiling %s's definition..." | |
99 "Compiling definition...") | |
100 name)) | |
101 (setq obj (byte-compile obj)) | |
102 (if interactive-p (message "Done compiling. Disassembling...")))) | |
103 (cond ((consp obj) | |
104 (setq obj (cdr obj)) ;throw lambda away | |
105 (setq args (car obj)) ;save arg list | |
106 (setq obj (cdr obj))) | |
14960
8fe7e5e09773
(disassemble-internal): Graceful error if compile failed.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
107 ((byte-code-function-p obj) |
8fe7e5e09773
(disassemble-internal): Graceful error if compile failed.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
108 (setq args (aref obj 0))) |
8fe7e5e09773
(disassemble-internal): Graceful error if compile failed.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
109 (t (error "Compilation failed"))) |
757 | 110 (if (zerop indent) ; not a nested function |
111 (progn | |
112 (indent-to indent) | |
113 (insert (format "byte code%s%s%s:\n" | |
114 (if (or macro name) " for" "") | |
115 (if macro " macro" "") | |
116 (if name (format " %s" name) ""))))) | |
117 (let ((doc (if (consp obj) | |
118 (and (stringp (car obj)) (car obj)) | |
13340
53bbedbefdb2
(disassemble-internal): Handle lazy-loaded doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
8293
diff
changeset
|
119 ;; Use documentation to get lazy-loaded doc string |
53bbedbefdb2
(disassemble-internal): Handle lazy-loaded doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
8293
diff
changeset
|
120 (documentation obj t)))) |
757 | 121 (if (and doc (stringp doc)) |
122 (progn (and (consp obj) (setq obj (cdr obj))) | |
123 (indent-to indent) | |
124 (princ " doc: " (current-buffer)) | |
125 (if (string-match "\n" doc) | |
126 (setq doc (concat (substring doc 0 (match-beginning 0)) | |
127 " ..."))) | |
128 (insert doc "\n")))) | |
129 (indent-to indent) | |
130 (insert " args: ") | |
131 (prin1 args (current-buffer)) | |
132 (insert "\n") | |
133 (let ((interactive (cond ((consp obj) | |
134 (assq 'interactive obj)) | |
135 ((> (length obj) 5) | |
136 (list 'interactive (aref obj 5)))))) | |
137 (if interactive | |
138 (progn | |
139 (setq interactive (nth 1 interactive)) | |
140 (if (eq (car-safe (car-safe obj)) 'interactive) | |
141 (setq obj (cdr obj))) | |
142 (indent-to indent) | |
143 (insert " interactive: ") | |
144 (if (eq (car-safe interactive) 'byte-code) | |
145 (progn | |
146 (insert "\n") | |
147 (disassemble-1 interactive | |
148 (+ indent disassemble-recursive-indent))) | |
149 (let ((print-escape-newlines t)) | |
150 (prin1 interactive (current-buffer)))) | |
151 (insert "\n")))) | |
152 (cond ((and (consp obj) (assq 'byte-code obj)) | |
153 (disassemble-1 (assq 'byte-code obj) indent)) | |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1606
diff
changeset
|
154 ((byte-code-function-p obj) |
757 | 155 (disassemble-1 obj indent)) |
156 (t | |
157 (insert "Uncompiled body: ") | |
158 (let ((print-escape-newlines t)) | |
159 (prin1 (if (cdr obj) (cons 'progn obj) (car obj)) | |
160 (current-buffer)))))) | |
161 (if interactive-p | |
162 (message ""))) | |
163 | |
164 | |
165 (defun disassemble-1 (obj indent) | |
166 "Prints the byte-code call OBJ in the current buffer. | |
167 OBJ should be a call to BYTE-CODE generated by the byte compiler." | |
168 (let (bytes constvec) | |
169 (if (consp obj) | |
170 (setq bytes (car (cdr obj)) ;the byte code | |
171 constvec (car (cdr (cdr obj)))) ;constant vector | |
13340
53bbedbefdb2
(disassemble-internal): Handle lazy-loaded doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
8293
diff
changeset
|
172 ;; If it is lazy-loaded, load it now |
53bbedbefdb2
(disassemble-internal): Handle lazy-loaded doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
8293
diff
changeset
|
173 (fetch-bytecode obj) |
22995
bc5bd04bf914
(disassemble-1): Move the call to
Richard M. Stallman <rms@gnu.org>
parents:
22055
diff
changeset
|
174 (setq bytes (aref obj 1) |
757 | 175 constvec (aref obj 2))) |
22995
bc5bd04bf914
(disassemble-1): Move the call to
Richard M. Stallman <rms@gnu.org>
parents:
22055
diff
changeset
|
176 (let ((lap (byte-decompile-bytecode (string-as-unibyte bytes) constvec)) |
8293
74218ea236fe
(disassemble-1): Display the pc values.
Richard M. Stallman <rms@gnu.org>
parents:
4789
diff
changeset
|
177 op arg opname pc-value) |
757 | 178 (let ((tagno 0) |
179 tmp | |
180 (lap lap)) | |
181 (while (setq tmp (assq 'TAG lap)) | |
182 (setcar (cdr tmp) (setq tagno (1+ tagno))) | |
183 (setq lap (cdr (memq tmp lap))))) | |
184 (while lap | |
8293
74218ea236fe
(disassemble-1): Display the pc values.
Richard M. Stallman <rms@gnu.org>
parents:
4789
diff
changeset
|
185 ;; Take off the pc value of the next thing |
74218ea236fe
(disassemble-1): Display the pc values.
Richard M. Stallman <rms@gnu.org>
parents:
4789
diff
changeset
|
186 ;; and put it in pc-value. |
74218ea236fe
(disassemble-1): Display the pc values.
Richard M. Stallman <rms@gnu.org>
parents:
4789
diff
changeset
|
187 (setq pc-value nil) |
74218ea236fe
(disassemble-1): Display the pc values.
Richard M. Stallman <rms@gnu.org>
parents:
4789
diff
changeset
|
188 (if (numberp (car lap)) |
74218ea236fe
(disassemble-1): Display the pc values.
Richard M. Stallman <rms@gnu.org>
parents:
4789
diff
changeset
|
189 (setq pc-value (car lap) |
74218ea236fe
(disassemble-1): Display the pc values.
Richard M. Stallman <rms@gnu.org>
parents:
4789
diff
changeset
|
190 lap (cdr lap))) |
74218ea236fe
(disassemble-1): Display the pc values.
Richard M. Stallman <rms@gnu.org>
parents:
4789
diff
changeset
|
191 ;; Fetch the next op and its arg. |
757 | 192 (setq op (car (car lap)) |
193 arg (cdr (car lap))) | |
8293
74218ea236fe
(disassemble-1): Display the pc values.
Richard M. Stallman <rms@gnu.org>
parents:
4789
diff
changeset
|
194 (setq lap (cdr lap)) |
757 | 195 (indent-to indent) |
196 (if (eq 'TAG op) | |
8293
74218ea236fe
(disassemble-1): Display the pc values.
Richard M. Stallman <rms@gnu.org>
parents:
4789
diff
changeset
|
197 (progn |
74218ea236fe
(disassemble-1): Display the pc values.
Richard M. Stallman <rms@gnu.org>
parents:
4789
diff
changeset
|
198 ;; We have a label. Display it, but first its pc value. |
74218ea236fe
(disassemble-1): Display the pc values.
Richard M. Stallman <rms@gnu.org>
parents:
4789
diff
changeset
|
199 (if pc-value |
74218ea236fe
(disassemble-1): Display the pc values.
Richard M. Stallman <rms@gnu.org>
parents:
4789
diff
changeset
|
200 (insert (format "%d:" pc-value))) |
74218ea236fe
(disassemble-1): Display the pc values.
Richard M. Stallman <rms@gnu.org>
parents:
4789
diff
changeset
|
201 (insert (int-to-string (car arg)))) |
74218ea236fe
(disassemble-1): Display the pc values.
Richard M. Stallman <rms@gnu.org>
parents:
4789
diff
changeset
|
202 ;; We have an instruction. Display its pc value first. |
74218ea236fe
(disassemble-1): Display the pc values.
Richard M. Stallman <rms@gnu.org>
parents:
4789
diff
changeset
|
203 (if pc-value |
74218ea236fe
(disassemble-1): Display the pc values.
Richard M. Stallman <rms@gnu.org>
parents:
4789
diff
changeset
|
204 (insert (format "%d" pc-value))) |
757 | 205 (indent-to (+ indent disassemble-column-1-indent)) |
206 (if (and op | |
207 (string-match "^byte-" (setq opname (symbol-name op)))) | |
208 (setq opname (substring opname 5)) | |
209 (setq opname "<not-an-opcode>")) | |
210 (if (eq op 'byte-constant2) | |
211 (insert " #### shouldn't have seen constant2 here!\n ")) | |
212 (insert opname) | |
213 (indent-to (+ indent disassemble-column-1-indent | |
214 disassemble-column-2-indent | |
215 -1)) | |
216 (insert " ") | |
217 (cond ((memq op byte-goto-ops) | |
218 (insert (int-to-string (nth 1 arg)))) | |
219 ((memq op '(byte-call byte-unbind | |
220 byte-listN byte-concatN byte-insertN)) | |
221 (insert (int-to-string arg))) | |
222 ((memq op '(byte-varref byte-varset byte-varbind)) | |
223 (prin1 (car arg) (current-buffer))) | |
224 ((memq op '(byte-constant byte-constant2)) | |
225 ;; it's a constant | |
226 (setq arg (car arg)) | |
227 ;; but if the value of the constant is compiled code, then | |
228 ;; recursively disassemble it. | |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1606
diff
changeset
|
229 (cond ((or (byte-code-function-p arg) |
757 | 230 (and (eq (car-safe arg) 'lambda) |
231 (assq 'byte-code arg)) | |
232 (and (eq (car-safe arg) 'macro) | |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1606
diff
changeset
|
233 (or (byte-code-function-p (cdr arg)) |
757 | 234 (and (eq (car-safe (cdr arg)) 'lambda) |
235 (assq 'byte-code (cdr arg)))))) | |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1606
diff
changeset
|
236 (cond ((byte-code-function-p arg) |
757 | 237 (insert "<compiled-function>\n")) |
238 ((eq (car-safe arg) 'lambda) | |
239 (insert "<compiled lambda>")) | |
240 (t (insert "<compiled macro>\n"))) | |
241 (disassemble-internal | |
242 arg | |
243 (+ indent disassemble-recursive-indent 1) | |
244 nil)) | |
245 ((eq (car-safe arg) 'byte-code) | |
246 (insert "<byte code>\n") | |
247 (disassemble-1 ;recurse on byte-code object | |
248 arg | |
249 (+ indent disassemble-recursive-indent))) | |
250 ((eq (car-safe (car-safe arg)) 'byte-code) | |
251 (insert "(<byte code>...)\n") | |
252 (mapcar ;recurse on list of byte-code objects | |
253 '(lambda (obj) | |
254 (disassemble-1 | |
255 obj | |
256 (+ indent disassemble-recursive-indent))) | |
257 arg)) | |
258 (t | |
259 ;; really just a constant | |
260 (let ((print-escape-newlines t)) | |
261 (prin1 arg (current-buffer)))))) | |
262 ) | |
8293
74218ea236fe
(disassemble-1): Display the pc values.
Richard M. Stallman <rms@gnu.org>
parents:
4789
diff
changeset
|
263 (insert "\n"))))) |
757 | 264 nil) |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
265 |
18383 | 266 (provide 'disass) |
267 | |
52401 | 268 ;;; arch-tag: 89482fe4-a087-4761-8dc6-d771054e763a |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
806
diff
changeset
|
269 ;;; disass.el ends here |