| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 |
(require 'backquote) |
|---|
| 158 |
|
|---|
| 159 |
(or (fboundp 'defsubst) |
|---|
| 160 |
|
|---|
| 161 |
(load "byte-run")) |
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
(defmacro byte-compile-single-version () nil) |
|---|
| 166 |
(defmacro byte-compile-version-cond (cond) cond) |
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 |
|
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
|
|---|
| 177 |
|
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 |
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 |
|
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 |
(defgroup bytecomp nil |
|---|
| 196 |
"Emacs Lisp byte-compiler." |
|---|
| 197 |
:group 'lisp) |
|---|
| 198 |
|
|---|
| 199 |
(defcustom emacs-lisp-file-regexp (if (eq system-type 'vax-vms) |
|---|
| 200 |
"\\.EL\\(;[0-9]+\\)?$" |
|---|
| 201 |
"\\.el$") |
|---|
| 202 |
"*Regexp which matches Emacs Lisp source files. |
|---|
| 203 |
You may want to redefine the function `byte-compile-dest-file' |
|---|
| 204 |
if you change this variable." |
|---|
| 205 |
:group 'bytecomp |
|---|
| 206 |
:type 'regexp) |
|---|
| 207 |
|
|---|
| 208 |
|
|---|
| 209 |
|
|---|
| 210 |
|
|---|
| 211 |
(defun byte-compiler-base-file-name (filename) |
|---|
| 212 |
(let ((handler (find-file-name-handler filename |
|---|
| 213 |
'byte-compiler-base-file-name))) |
|---|
| 214 |
(if handler |
|---|
| 215 |
(funcall handler 'byte-compiler-base-file-name filename) |
|---|
| 216 |
filename))) |
|---|
| 217 |
|
|---|
| 218 |
(or (fboundp 'byte-compile-dest-file) |
|---|
| 219 |
|
|---|
| 220 |
|
|---|
| 221 |
(defun byte-compile-dest-file (filename) |
|---|
| 222 |
"Convert an Emacs Lisp source file name to a compiled file name. |
|---|
| 223 |
If FILENAME matches `emacs-lisp-file-regexp' (by default, files |
|---|
| 224 |
with the extension `.el'), add `c' to it; otherwise add `.elc'." |
|---|
| 225 |
(setq filename (byte-compiler-base-file-name filename)) |
|---|
| 226 |
(setq filename (file-name-sans-versions filename)) |
|---|
| 227 |
(cond ((eq system-type 'vax-vms) |
|---|
| 228 |
(concat (substring filename 0 (string-match ";" filename)) "c")) |
|---|
| 229 |
((string-match emacs-lisp-file-regexp filename) |
|---|
| 230 |
(concat (substring filename 0 (match-beginning 0)) ".elc")) |
|---|
| 231 |
(t (concat filename ".elc"))))) |
|---|
| 232 |
|
|---|
| 233 |
|
|---|
| 234 |
(autoload 'byte-compile-inline-expand "byte-opt") |
|---|
| 235 |
|
|---|
| 236 |
|
|---|
| 237 |
(autoload 'byte-optimize-form "byte-opt") |
|---|
| 238 |
|
|---|
| 239 |
(autoload 'byte-optimize-lapcode "byte-opt") |
|---|
| 240 |
(autoload 'byte-compile-unfold-lambda "byte-opt") |
|---|
| 241 |
|
|---|
| 242 |
|
|---|
| 243 |
|
|---|
| 244 |
|
|---|
| 245 |
|
|---|
| 246 |
(autoload 'byte-decompile-bytecode "byte-opt") |
|---|
| 247 |
|
|---|
| 248 |
(defcustom byte-compile-verbose |
|---|
| 249 |
(and (not noninteractive) (> baud-rate search-slow-speed)) |
|---|
| 250 |
"*Non-nil means print messages describing progress of byte-compiler." |
|---|
| 251 |
:group 'bytecomp |
|---|
| 252 |
:type 'boolean) |
|---|
| 253 |
|
|---|
| 254 |
(defcustom byte-compile-compatibility nil |
|---|
| 255 |
"*Non-nil means generate output that can run in Emacs 18. |
|---|
| 256 |
This only means that it can run in principle, if it doesn't require |
|---|
| 257 |
facilities that have been added more recently." |
|---|
| 258 |
:group 'bytecomp |
|---|
| 259 |
:type 'boolean) |
|---|
| 260 |
|
|---|
| 261 |
|
|---|
| 262 |
|
|---|
| 263 |
|
|---|
| 264 |
|
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 |
|
|---|
| 268 |
(defcustom byte-optimize t |
|---|
| 269 |
"*Enable optimization in the byte compiler. |
|---|
| 270 |
Possible values are: |
|---|
| 271 |
nil - no optimization |
|---|
| 272 |
t - all optimizations |
|---|
| 273 |
`source' - source-level optimizations only |
|---|
| 274 |
`byte' - code-level optimizations only" |
|---|
| 275 |
:group 'bytecomp |
|---|
| 276 |
:type '(choice (const :tag "none" nil) |
|---|
| 277 |
(const :tag "all" t) |
|---|
| 278 |
(const :tag "source-level" source) |
|---|
| 279 |
(const :tag "byte-level" byte))) |
|---|
| 280 |
|
|---|
| 281 |
(defcustom byte-compile-delete-errors nil |
|---|
| 282 |
"*If non-nil, the optimizer may delete forms that may signal an error. |
|---|
| 283 |
This includes variable references and calls to functions such as `car'." |
|---|
| 284 |
:group 'bytecomp |
|---|
| 285 |
:type 'boolean) |
|---|
| 286 |
|
|---|
| 287 |
(defvar byte-compile-dynamic nil |
|---|
| 288 |
"If non-nil, compile function bodies so they load lazily. |
|---|
| 289 |
They are hidden in comments in the compiled file, |
|---|
| 290 |
and each one is brought into core when the |
|---|
| 291 |
function is called. |
|---|
| 292 |
|
|---|
| 293 |
To enable this option, make it a file-local variable |
|---|
| 294 |
in the source file you want it to apply to. |
|---|
| 295 |
For example, add -*-byte-compile-dynamic: t;-*- on the first line. |
|---|
| 296 |
|
|---|
| 297 |
When this option is true, if you load the compiled file and then move it, |
|---|
| 298 |
the functions you loaded will not be able to run.") |
|---|
| 299 |
|
|---|
| 300 |
|
|---|
| 301 |
(defvar byte-compile-disable-print-circle nil |
|---|
| 302 |
"If non-nil, disable `print-circle' on printing a byte-compiled code.") |
|---|
| 303 |
|
|---|
| 304 |
|
|---|
| 305 |
(defcustom byte-compile-dynamic-docstrings t |
|---|
| 306 |
"*If non-nil, compile doc strings for lazy access. |
|---|
| 307 |
We bury the doc strings of functions and variables |
|---|
| 308 |
inside comments in the file, and bring them into core only when they |
|---|
| 309 |
are actually needed. |
|---|
| 310 |
|
|---|
| 311 |
When this option is true, if you load the compiled file and then move it, |
|---|
| 312 |
you won't be able to find the documentation of anything in that file. |
|---|
| 313 |
|
|---|
| 314 |
To disable this option for a certain file, make it a file-local variable |
|---|
| 315 |
in the source file. For example, add this to the first line: |
|---|
| 316 |
-*-byte-compile-dynamic-docstrings:nil;-*- |
|---|
| 317 |
You can also set the variable globally. |
|---|
| 318 |
|
|---|
| 319 |
This option is enabled by default because it reduces Emacs memory usage." |
|---|
| 320 |
:group 'bytecomp |
|---|
| 321 |
:type 'boolean) |
|---|
| 322 |
|
|---|
| 323 |
|
|---|
| 324 |
(defcustom byte-optimize-log nil |
|---|
| 325 |
"*If true, the byte-compiler will log its optimizations into *Compile-Log*. |
|---|
| 326 |
If this is 'source, then only source-level optimizations will be logged. |
|---|
| 327 |
If it is 'byte, then only byte-level optimizations will be logged." |
|---|
| 328 |
:group 'bytecomp |
|---|
| 329 |
:type '(choice (const :tag "none" nil) |
|---|
| 330 |
(const :tag "all" t) |
|---|
| 331 |
(const :tag "source-level" source) |
|---|
| 332 |
(const :tag "byte-level" byte))) |
|---|
| 333 |
|
|---|
| 334 |
(defcustom byte-compile-error-on-warn nil |
|---|
| 335 |
"*If true, the byte-compiler reports warnings with `error'." |
|---|
| 336 |
:group 'bytecomp |
|---|
| 337 |
:type 'boolean) |
|---|
| 338 |
|
|---|
| 339 |
(defconst byte-compile-warning-types |
|---|
| 340 |
'(redefine callargs free-vars unresolved |
|---|
| 341 |
obsolete noruntime cl-functions interactive-only) |
|---|
| 342 |
"The list of warning types used when `byte-compile-warnings' is t.") |
|---|
| 343 |
(defcustom byte-compile-warnings t |
|---|
| 344 |
"*List of warnings that the byte-compiler should issue (t for all). |
|---|
| 345 |
|
|---|
| 346 |
Elements of the list may be: |
|---|
| 347 |
|
|---|
| 348 |
free-vars references to variables not in the current lexical scope. |
|---|
| 349 |
unresolved calls to unknown functions. |
|---|
| 350 |
callargs function calls with args that don't match the definition. |
|---|
| 351 |
redefine function name redefined from a macro to ordinary function or vice |
|---|
| 352 |
versa, or redefined to take a different number of arguments. |
|---|
| 353 |
obsolete obsolete variables and functions. |
|---|
| 354 |
noruntime functions that may not be defined at runtime (typically |
|---|
| 355 |
defined only under `eval-when-compile'). |
|---|
| 356 |
cl-functions calls to runtime functions from the CL package (as |
|---|
| 357 |
distinguished from macros and aliases). |
|---|
| 358 |
interactive-only |
|---|
| 359 |
commands that normally shouldn't be called from Lisp code." |
|---|
| 360 |
:group 'bytecomp |
|---|
| 361 |
:type `(choice (const :tag "All" t) |
|---|
| 362 |
(set :menu-tag "Some" |
|---|
| 363 |
(const free-vars) (const unresolved) |
|---|
| 364 |
(const callargs) (const redefine) |
|---|
| 365 |
(const obsolete) (const noruntime) |
|---|
| 366 |
(const cl-functions) (const interactive-only)))) |
|---|
| 367 |
|
|---|
| 368 |
|
|---|
| 369 |
|
|---|
| 370 |
(defun byte-compile-warnings-safe-p (x) |
|---|
| 371 |
(or (booleanp x) |
|---|
| 372 |
(and (listp x) |
|---|
| 373 |
(equal (mapcar |
|---|
| 374 |
(lambda (e) |
|---|
| 375 |
(when (memq e '(free-vars unresolved |
|---|
| 376 |
callargs redefine |
|---|
| 377 |
obsolete noruntime |
|---|
| 378 |
cl-functions interactive-only)) |
|---|
| 379 |
e)) |
|---|
| 380 |
x) |
|---|
| 381 |
x)))) |
|---|
| 382 |
|
|---|
| 383 |
(defvar byte-compile-interactive-only-functions |
|---|
| 384 |
'(beginning-of-buffer end-of-buffer replace-string replace-regexp |
|---|
| 385 |
insert-file insert-buffer insert-file-literally) |
|---|
| 386 |
"List of commands that are not meant to be called from Lisp.") |
|---|
| 387 |
|
|---|
| 388 |
(defvar byte-compile-not-obsolete-var nil |
|---|
| 389 |
"If non-nil, this is a variable that shouldn't be reported as obsolete.") |
|---|
| 390 |
|
|---|
| 391 |
(defcustom byte-compile-generate-call-tree nil |
|---|
| 392 |
"*Non-nil means collect call-graph information when compiling. |
|---|
| 393 |
This records which functions were called and from where. |
|---|
| 394 |
If the value is t, compilation displays the call graph when it finishes. |
|---|
| 395 |
If the value is neither t nor nil, compilation asks you whether to display |
|---|
| 396 |
the graph. |
|---|
| 397 |
|
|---|
| 398 |
The call tree only lists functions called, not macros used. Those functions |
|---|
| 399 |
which the byte-code interpreter knows about directly (eq, cons, etc.) are |
|---|
| 400 |
not reported. |
|---|
| 401 |
|
|---|
| 402 |
The call tree also lists those functions which are not known to be called |
|---|
| 403 |
\(that is, to which no calls have been compiled). Functions which can be |
|---|
| 404 |
invoked interactively are excluded from this list." |
|---|
| 405 |
:group 'bytecomp |
|---|
| 406 |
:type '(choice (const :tag "Yes" t) (const :tag "No" nil) |
|---|
| 407 |
(other :tag "Ask" lambda))) |
|---|
| 408 |
|
|---|
| 409 |
(defvar byte-compile-call-tree nil "Alist of functions and their call tree. |
|---|
| 410 |
Each element looks like |
|---|
| 411 |
|
|---|
| 412 |
\(FUNCTION CALLERS CALLS\) |
|---|
| 413 |
|
|---|
| 414 |
where CALLERS is a list of functions that call FUNCTION, and CALLS |
|---|
| 415 |
is a list of functions for which calls were generated while compiling |
|---|
| 416 |
FUNCTION.") |
|---|
| 417 |
|
|---|
| 418 |
(defcustom byte-compile-call-tree-sort 'name |
|---|
| 419 |
"*If non-nil, sort the call tree. |
|---|
| 420 |
The values `name', `callers', `calls', `calls+callers' |
|---|
| 421 |
specify different fields to sort on." |
|---|
| 422 |
:group 'bytecomp |
|---|
| 423 |
:type '(choice (const name) (const callers) (const calls) |
|---|
| 424 |
(const calls+callers) (const nil))) |
|---|
| 425 |
|
|---|
| 426 |
(defvar byte-compile-debug nil) |
|---|
| 427 |
|
|---|
| 428 |
|
|---|
| 429 |
|
|---|
| 430 |
|
|---|
| 431 |
|
|---|
| 432 |
|
|---|
| 433 |
|
|---|
| 434 |
|
|---|
| 435 |
|
|---|
| 436 |
(defvar byte-compile-constants nil |
|---|
| 437 |
"List of all constants encountered during compilation of this form.") |
|---|
| 438 |
(defvar byte-compile-variables nil |
|---|
| 439 |
"List of all variables encountered during compilation of this form.") |
|---|
| 440 |
(defvar byte-compile-bound-variables nil |
|---|
| 441 |
"List of variables bound in the context of the current form. |
|---|
| 442 |
This list lives partly on the stack.") |
|---|
| 443 |
(defvar byte-compile-const-variables nil |
|---|
| 444 |
"List of variables declared as constants during compilation of this file.") |
|---|
| 445 |
(defvar byte-compile-free-references) |
|---|
| 446 |
(defvar byte-compile-free-assignments) |
|---|
| 447 |
|
|---|
| 448 |
(defvar byte-compiler-error-flag) |
|---|
| 449 |
|
|---|
| 450 |
(defconst byte-compile-initial-macro-environment |
|---|
| 451 |
'( |
|---|
| 452 |
|
|---|
| 453 |
|
|---|
| 454 |
(eval-when-compile . (lambda (&rest body) |
|---|
| 455 |
(list 'quote |
|---|
| 456 |
(byte-compile-eval (byte-compile-top-level |
|---|
| 457 |
(cons 'progn body)))))) |
|---|
| 458 |
(eval-and-compile . (lambda (&rest body) |
|---|
| 459 |
(byte-compile-eval-before-compile (cons 'progn body)) |
|---|
| 460 |
(cons 'progn body)))) |
|---|
| 461 |
"The default macro-environment passed to macroexpand by the compiler. |
|---|
| 462 |
Placing a macro here will cause a macro to have different semantics when |
|---|
| 463 |
expanded by the compiler as when expanded by the interpreter.") |
|---|
| 464 |
|
|---|
| 465 |
(defvar byte-compile-macro-environment byte-compile-initial-macro-environment |
|---|
| 466 |
"Alist of macros defined in the file being compiled. |
|---|
| 467 |
Each element looks like (MACRONAME . DEFINITION). It is |
|---|
| 468 |
\(MACRONAME . nil) when a macro is redefined as a function.") |
|---|
| 469 |
|
|---|
| 470 |
(defvar byte-compile-function-environment nil |
|---|
| 471 |
"Alist of functions defined in the file being compiled. |
|---|
| 472 |
This is so we can inline them when necessary. |
|---|
| 473 |
Each element looks like (FUNCTIONNAME . DEFINITION). It is |
|---|
| 474 |
\(FUNCTIONNAME . nil) when a function is redefined as a macro. |
|---|
| 475 |
It is \(FUNCTIONNAME . t) when all we know is that it was defined, |
|---|
| 476 |
and we don't know the definition.") |
|---|
| 477 |
|
|---|
| 478 |
(defvar byte-compile-unresolved-functions nil |
|---|
| 479 |
"Alist of undefined functions to which calls have been compiled. |
|---|
| 480 |
This variable is only significant whilst compiling an entire buffer. |
|---|
| 481 |
Used for warnings when a function is not known to be defined or is later |
|---|
| 482 |
defined with incorrect args.") |
|---|
| 483 |
|
|---|
| 484 |
(defvar byte-compile-noruntime-functions nil |
|---|
| 485 |
"Alist of functions called that may not be defined when the compiled code is run. |
|---|
| 486 |
Used for warnings about calling a function that is defined during compilation |
|---|
| 487 |
but won't necessarily be defined when the compiled file is loaded.") |
|---|
| 488 |
|
|---|
| 489 |
(defvar byte-compile-tag-number 0) |
|---|
| 490 |
(defvar byte-compile-output nil |
|---|
| 491 |
"Alist describing contents to put in byte code string. |
|---|
| 492 |
Each element is (INDEX . VALUE)") |
|---|
| 493 |
(defvar byte-compile-depth 0 "Current depth of execution stack.") |
|---|
| 494 |
(defvar byte-compile-maxdepth 0 "Maximum depth of execution stack.") |
|---|
| 495 |
|
|---|
| 496 |
|
|---|
| 497 |
|
|---|
| 498 |
|
|---|
| 499 |
(defvar byte-code-vector nil |
|---|
| 500 |
"An array containing byte-code names indexed by byte-code values.") |
|---|
| 501 |
|
|---|
| 502 |
(defvar byte-stack+-info nil |
|---|
| 503 |
"An array with the stack adjustment for each byte-code.") |
|---|
| 504 |
|
|---|
| 505 |
(defmacro byte-defop (opcode stack-adjust opname &optional docstring) |
|---|
| 506 |
|
|---|
| 507 |
|
|---|
| 508 |
|
|---|
| 509 |
|
|---|
| 510 |
|
|---|
| 511 |
|
|---|
| 512 |
|
|---|
| 513 |
(let ((v1 (or (get 'byte-code-vector 'tmp-compile-time-value) |
|---|
| 514 |
(put 'byte-code-vector 'tmp-compile-time-value |
|---|
| 515 |
(make-vector 256 nil)))) |
|---|
| 516 |
(v2 (or (get 'byte-stack+-info 'tmp-compile-time-value) |
|---|
| 517 |
(put 'byte-stack+-info 'tmp-compile-time-value |
|---|
| 518 |
(make-vector 256 nil))))) |
|---|
| 519 |
(aset v1 opcode opname) |
|---|
| 520 |
(aset v2 opcode stack-adjust)) |
|---|
| 521 |
(if docstring |
|---|
| 522 |
(list 'defconst opname opcode (concat "Byte code opcode " docstring ".")) |
|---|
| 523 |
(list 'defconst opname opcode))) |
|---|
| 524 |
|
|---|
| 525 |
(defmacro byte-extrude-byte-code-vectors () |
|---|
| 526 |
(prog1 (list 'setq 'byte-code-vector |
|---|
| 527 |
(get 'byte-code-vector 'tmp-compile-time-value) |
|---|
| 528 |
'byte-stack+-info |
|---|
| 529 |
(get 'byte-stack+-info 'tmp-compile-time-value)) |
|---|
| 530 |
(put 'byte-code-vector 'tmp-compile-time-value nil) |
|---|
| 531 |
(put 'byte-stack+-info 'tmp-compile-time-value nil))) |
|---|
| 532 |
|
|---|
| 533 |
|
|---|
| 534 |
|
|---|
| 535 |
|
|---|
| 536 |
|
|---|
| 537 |
|
|---|
| 538 |
|
|---|
| 539 |
(byte-defop 8 1 byte-varref "for variable reference") |
|---|
| 540 |
(byte-defop 16 -1 byte-varset "for setting a variable") |
|---|
| 541 |
(byte-defop 24 -1 byte-varbind "for binding a variable") |
|---|
| 542 |
(byte-defop 32 0 byte-call "for calling a function") |
|---|
| 543 |
(byte-defop 40 0 byte-unbind "for unbinding special bindings") |
|---|
| 544 |
|
|---|
| 545 |
|
|---|
| 546 |
|
|---|
| 547 |
|
|---|
| 548 |
(byte-defop 56 -1 byte-nth) |
|---|
| 549 |
(byte-defop 57 0 byte-symbolp) |
|---|
| 550 |
(byte-defop 58 0 byte-consp) |
|---|
| 551 |
(byte-defop 59 0 byte-stringp) |
|---|
| 552 |
(byte-defop 60 0 byte-listp) |
|---|
| 553 |
(byte-defop 61 -1 byte-eq) |
|---|
| 554 |
(byte-defop 62 -1 byte-memq) |
|---|
| 555 |
(byte-defop 63 0 byte-not) |
|---|
| 556 |
(byte-defop 64 0 byte-car) |
|---|
| 557 |
(byte-defop 65 0 byte-cdr) |
|---|
| 558 |
(byte-defop 66 -1 byte-cons) |
|---|
| 559 |
(byte-defop 67 0 byte-list1) |
|---|
| 560 |
(byte-defop 68 -1 byte-list2) |
|---|
| 561 |
(byte-defop 69 -2 byte-list3) |
|---|
| 562 |
(byte-defop 70 -3 byte-list4) |
|---|
| 563 |
(byte-defop 71 0 byte-length) |
|---|
| 564 |
(byte-defop 72 -1 byte-aref) |
|---|
| 565 |
(byte-defop 73 -2 byte-aset) |
|---|
| 566 |
(byte-defop 74 0 byte-symbol-value) |
|---|
| 567 |
(byte-defop 75 0 byte-symbol-function) |
|---|
| 568 |
(byte-defop 76 -1 byte-set) |
|---|
| 569 |
(byte-defop 77 -1 byte-fset) |
|---|
| 570 |
(byte-defop 78 -1 byte-get) |
|---|
| 571 |
(byte-defop 79 -2 byte-substring) |
|---|
| 572 |
(byte-defop 80 -1 byte-concat2) |
|---|
| 573 |
(byte-defop 81 -2 byte-concat3) |
|---|
| 574 |
(byte-defop 82 -3 byte-concat4) |
|---|
| 575 |
(byte-defop 83 0 byte-sub1) |
|---|
| 576 |
(byte-defop 84 0 byte-add1) |
|---|
| 577 |
(byte-defop 85 -1 byte-eqlsign) |
|---|
| 578 |
(byte-defop 86 -1 byte-gtr) |
|---|
| 579 |
(byte-defop 87 -1 byte-lss) |
|---|
| 580 |
(byte-defop 88 -1 byte-leq) |
|---|
| 581 |
(byte-defop 89 -1 byte-geq) |
|---|
| 582 |
(byte-defop 90 -1 byte-diff) |
|---|
| 583 |
(byte-defop 91 0 byte-negate) |
|---|
| 584 |
(byte-defop 92 -1 byte-plus) |
|---|
| 585 |
(byte-defop 93 -1 byte-max) |
|---|
| 586 |
(byte-defop 94 -1 byte-min) |
|---|
| 587 |
(byte-defop 95 -1 byte-mult) |
|---|
| 588 |
(byte-defop 96 1 byte-point) |
|---|
| 589 |
(byte-defop 98 0 byte-goto-char) |
|---|
| 590 |
(byte-defop 99 0 byte-insert) |
|---|
| 591 |
(byte-defop 100 1 byte-point-max) |
|---|
| 592 |
(byte-defop 101 1 byte-point-min) |
|---|
| 593 |
(byte-defop 102 0 byte-char-after) |
|---|
| 594 |
(byte-defop 103 1 byte-following-char) |
|---|
| 595 |
(byte-defop 104 1 byte-preceding-char) |
|---|
| 596 |
(byte-defop 105 1 byte-current-column) |
|---|
| 597 |
(byte-defop 106 0 byte-indent-to) |
|---|
| 598 |
(byte-defop 107 0 byte-scan-buffer-OBSOLETE) |
|---|
| 599 |
(byte-defop 108 1 byte-eolp) |
|---|
| 600 |
(byte-defop 109 1 byte-eobp) |
|---|
| 601 |
(byte-defop 110 1 byte-bolp) |
|---|
| 602 |
(byte-defop 111 1 byte-bobp) |
|---|
| 603 |
(byte-defop 112 1 byte-current-buffer) |
|---|
| 604 |
(byte-defop 113 0 byte-set-buffer) |
|---|
| 605 |
(byte-defop 114 0 byte-save-current-buffer |
|---|
| 606 |
"To make a binding to record the current buffer") |
|---|
| 607 |
(byte-defop 115 0 byte-set-mark-OBSOLETE) |
|---|
| 608 |
(byte-defop 116 1 byte-interactive-p) |
|---|
| 609 |
|
|---|
| 610 |
|
|---|
| 611 |
(byte-defop 117 0 byte-forward-char) |
|---|
| 612 |
(byte-defop 118 0 byte-forward-word) |
|---|
| 613 |
(byte-defop 119 -1 byte-skip-chars-forward) |
|---|
| 614 |
(byte-defop 120 -1 byte-skip-chars-backward) |
|---|
| 615 |
(byte-defop 121 0 byte-forward-line) |
|---|
| 616 |
(byte-defop 122 0 byte-char-syntax) |
|---|
| 617 |
(byte-defop 123 -1 byte-buffer-substring) |
|---|
| 618 |
(byte-defop 124 -1 byte-delete-region) |
|---|
| 619 |
(byte-defop 125 -1 byte-narrow-to-region) |
|---|
| 620 |
(byte-defop 126 1 byte-widen) |
|---|
| 621 |
(byte-defop 127 0 byte-end-of-line) |
|---|
| 622 |
|
|---|
| 623 |
|
|---|
| 624 |
|
|---|
| 625 |
|
|---|
| 626 |
(byte-defop 129 1 byte-constant2 |
|---|
| 627 |
"for reference to a constant with vector index >= byte-constant-limit") |
|---|
| 628 |
(byte-defop 130 0 byte-goto "for unconditional jump") |
|---|
| 629 |
(byte-defop 131 -1 byte-goto-if-nil "to pop value and jump if it's nil") |
|---|
| 630 |
(byte-defop 132 -1 byte-goto-if-not-nil "to pop value and jump if it's not nil") |
|---|
| 631 |
(byte-defop 133 -1 byte-goto-if-nil-else-pop |
|---|
| 632 |
"to examine top-of-stack, jump and don't pop it if it's nil, |
|---|
| 633 |
otherwise pop it") |
|---|
| 634 |
(byte-defop 134 -1 byte-goto-if-not-nil-else-pop |
|---|
| 635 |
"to examine top-of-stack, jump and don't pop it if it's non nil, |
|---|
| 636 |
otherwise pop it") |
|---|
| 637 |
|
|---|
| 638 |
(byte-defop 135 -1 byte-return "to pop a value and return it from `byte-code'") |
|---|
| 639 |
(byte-defop 136 -1 byte-discard "to discard one value from stack") |
|---|
| 640 |
(byte-defop 137 1 byte-dup "to duplicate the top of the stack") |
|---|
| 641 |
|
|---|
| 642 |
(byte-defop 138 0 byte-save-excursion |
|---|
| 643 |
"to make a binding to record the buffer, point and mark") |
|---|
| 644 |
(byte-defop 139 0 byte-save-window-excursion |
|---|
| 645 |
"to make a binding to record entire window configuration") |
|---|
| 646 |
(byte-defop 140 0 byte-save-restriction |
|---|
| 647 |
"to make a binding to record the current buffer clipping restrictions") |
|---|
| 648 |
(byte-defop 141 -1 byte-catch |
|---|
| 649 |
"for catch. Takes, on stack, the tag and an expression for the body") |
|---|
| 650 |
(byte-defop 142 -1 byte-unwind-protect |
|---|
| 651 |
"for unwind-protect. Takes, on stack, an expression for the unwind-action") |
|---|
| 652 |
|
|---|
| 653 |
|
|---|
| 654 |
|
|---|
| 655 |
(byte-defop 143 -2 byte-condition-case) |
|---|
| 656 |
|
|---|
| 657 |
|
|---|
| 658 |
|
|---|
| 659 |
|
|---|
| 660 |
|
|---|
| 661 |
(byte-defop 144 0 byte-temp-output-buffer-setup) |
|---|
| 662 |
|
|---|
| 663 |
|
|---|
| 664 |
|
|---|
| 665 |
|
|---|
| 666 |
|
|---|
| 667 |
(byte-defop 145 -1 byte-temp-output-buffer-show) |
|---|
| 668 |
|
|---|
| 669 |
|
|---|
| 670 |
|
|---|
| 671 |
|
|---|
| 672 |
|
|---|
| 673 |
(byte-defop 146 0 byte-unbind-all) |
|---|
| 674 |
|
|---|
| 675 |
|
|---|
| 676 |
(byte-defop 147 -2 byte-set-marker) |
|---|
| 677 |
(byte-defop 148 0 byte-match-beginning) |
|---|
| 678 |
(byte-defop 149 0 byte-match-end) |
|---|
| 679 |
(byte-defop 150 0 byte-upcase) |
|---|
| 680 |
(byte-defop 151 0 byte-downcase) |
|---|
| 681 |
(byte-defop 152 -1 byte-string=) |
|---|
| 682 |
(byte-defop 153 -1 byte-string<) |
|---|
| 683 |
(byte-defop 154 -1 byte-equal) |
|---|
| 684 |
(byte-defop 155 -1 byte-nthcdr) |
|---|
| 685 |
(byte-defop 156 -1 byte-elt) |
|---|
| 686 |
(byte-defop 157 -1 byte-member) |
|---|
| 687 |
(byte-defop 158 -1 byte-assq) |
|---|
| 688 |
(byte-defop 159 0 byte-nreverse) |
|---|
| 689 |
(byte-defop 160 -1 byte-setcar) |
|---|
| 690 |
(byte-defop 161 -1 byte-setcdr) |
|---|
| 691 |
(byte-defop 162 0 byte-car-safe) |
|---|
| 692 |
(byte-defop 163 0 byte-cdr-safe) |
|---|
| 693 |
(byte-defop 164 -1 byte-nconc) |
|---|
| 694 |
(byte-defop 165 -1 byte-quo) |
|---|
| 695 |
(byte-defop 166 -1 byte-rem) |
|---|
| 696 |
(byte-defop 167 0 byte-numberp) |
|---|
| 697 |
(byte-defop 168 0 byte-integerp) |
|---|
| 698 |
|
|---|
| 699 |
|
|---|
| 700 |
(byte-defop 175 nil byte-listN) |
|---|
| 701 |
(byte-defop 176 nil byte-concatN) |
|---|
| 702 |
(byte-defop 177 nil byte-insertN) |
|---|
| 703 |
|
|---|
| 704 |
|
|---|
| 705 |
|
|---|
| 706 |
(byte-defop 192 1 byte-constant "for reference to a constant") |
|---|
| 707 |
|
|---|
| 708 |
(defconst byte-constant-limit 64 |
|---|
| 709 |
"Exclusive maximum index usable in the `byte-constant' opcode.") |
|---|
| 710 |
|
|---|
| 711 |
(defconst byte-goto-ops '(byte-goto byte-goto-if-nil byte-goto-if-not-nil |
|---|
| 712 |
byte-goto-if-nil-else-pop |
|---|
| 713 |
byte-goto-if-not-nil-else-pop) |
|---|
| 714 |
"List of byte-codes whose offset is a pc.") |
|---|
| 715 |
|
|---|
| 716 |
(defconst byte-goto-always-pop-ops '(byte-goto-if-nil byte-goto-if-not-nil)) |
|---|
| 717 |
|
|---|
| 718 |
(byte-extrude-byte-code-vectors) |
|---|
| 719 |
|
|---|
| 720 |
|
|---|
| 721 |
|
|---|
| 722 |
|
|---|
| 723 |
|
|---|
| 724 |
|
|---|
| 725 |
|
|---|
| 726 |
|
|---|
| 727 |
|
|---|
| 728 |
|
|---|
| 729 |
|
|---|
| 730 |
|
|---|
| 731 |
|
|---|
| 732 |
|
|---|
| 733 |
|
|---|
| 734 |
|
|---|
| 735 |
|
|---|
| 736 |
|
|---|
| 737 |
|
|---|
| 738 |
|
|---|
| 739 |
|
|---|
| 740 |
|
|---|
| 741 |
|
|---|
| 742 |
|
|---|
| 743 |
|
|---|
| 744 |
|
|---|
| 745 |
|
|---|
| 746 |
|
|---|
| 747 |
|
|---|
| 748 |
|
|---|
| 749 |
|
|---|
| 750 |
|
|---|
| 751 |
(defun byte-compile-lapcode (lap) |
|---|
| 752 |
"Turns lapcode into bytecode. The lapcode is destroyed." |
|---|
| 753 |
|
|---|
| 754 |
(let ((pc 0) |
|---|
| 755 |
op off |
|---|
| 756 |
(bytes '()) |
|---|
| 757 |
(patchlist nil)) |
|---|
| 758 |
(while lap |
|---|
| 759 |
(setq op (car (car lap)) |
|---|
| 760 |
off (cdr (car lap))) |
|---|
| 761 |
(cond ((not (symbolp op)) |
|---|
| 762 |
(error "Non-symbolic opcode `%s'" op)) |
|---|
| 763 |
((eq op 'TAG) |
|---|
| 764 |
(setcar off pc) |
|---|
| 765 |
(setq patchlist (cons off patchlist))) |
|---|
| 766 |
((memq op byte-goto-ops) |
|---|
| 767 |
(setq pc (+ pc 3)) |
|---|
| 768 |
(setq bytes (cons (cons pc (cdr off)) |
|---|
| 769 |
(cons nil |
|---|
| 770 |
(cons (symbol-value op) bytes)))) |
|---|
| 771 |
(setq patchlist (cons bytes patchlist))) |
|---|
| 772 |
(t |
|---|
| 773 |
(setq bytes |
|---|
| 774 |
(cond ((cond ((consp off) |
|---|
| 775 |
|
|---|
| 7 |
|---|