[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/beardbolt ca92d533ad 061/323: Add basic support for pyt
From: |
ELPA Syncer |
Subject: |
[elpa] externals/beardbolt ca92d533ad 061/323: Add basic support for python |
Date: |
Thu, 9 Mar 2023 10:58:16 -0500 (EST) |
branch: externals/beardbolt
commit ca92d533adb237a4570a194d682a73ccff5b073e
Author: Jay Kamat <jaygkamat@gmail.com>
Commit: Jay Kamat <jaygkamat@gmail.com>
Add basic support for python
---
rmsbolt.el | 184 ++++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 110 insertions(+), 74 deletions(-)
diff --git a/rmsbolt.el b/rmsbolt.el
index ca507f3dcc..c3db0cce83 100644
--- a/rmsbolt.el
+++ b/rmsbolt.el
@@ -433,7 +433,8 @@ Outputs assembly file if ASM."
:supports-disass nil
:starter-file-name "rmsbolt.py"
:compile-cmd-function #'rmsbolt--py-compile-cmd
- :disass-hidden-funcs nil))
+ :disass-hidden-funcs nil
+ :process-asm-custom-fn
#'rmsbolt--process-python-bytecode))
))
;;;; Macros
@@ -581,6 +582,112 @@ Outputs assembly file if ASM."
continue))
(nreverse result)))
+(cl-defun rmsbolt--process-src-asm-lines (src-buffer asm-lines)
+ (let ((used-labels (rmsbolt--find-used-labels src-buffer asm-lines))
+ (result nil)
+ (prev-label nil)
+ (source-linum nil)
+ (source-file nil)
+ (skip-file-match
+ ;; Skip file match if we don't have a current filename
+ (not (buffer-file-name src-buffer))))
+ (dolist (line asm-lines)
+ (let* ((raw-match (or (string-match rmsbolt-label-def line)
+ (string-match rmsbolt-assignment-def line)))
+ (match (when raw-match
+ (match-string 1 line)))
+ (used-label (cl-find match used-labels :test #'equal)))
+ (cl-tagbody
+ ;; Process file name hints
+ (when (string-match rmsbolt-source-file line)
+ (if (match-string 3 line)
+ ;; Clang style match
+ (setq source-file (expand-file-name
+ (match-string 3 line)
+ (match-string 2 line)))
+ (setq source-file (match-string 2 line))))
+ ;; Process any line number hints
+ (when (string-match rmsbolt-source-tag line)
+ (if (or skip-file-match
+ (file-equal-p (buffer-file-name src-buffer) source-file))
+ (setq source-linum (string-to-number
+ (match-string 2 line)))
+ (setq source-linum nil)))
+ (when (string-match rmsbolt-source-stab line)
+ (pcase (string-to-number (match-string 1 line))
+ ;; http://www.math.utah.edu/docs/info/stabs_11.html
+ (68
+ (setq source-linum (match-string 2 line)))
+ ((or 100 132)
+ (setq source-linum nil))))
+
+ ;; End block, reset prev-label and source
+ (when (string-match-p rmsbolt-endblock line)
+ (setq prev-label nil))
+
+ (when (and (buffer-local-value 'rmsbolt-filter-comment-only
src-buffer)
+ (string-match-p rmsbolt-comment-only line))
+ (go continue))
+
+ ;; continue means we don't add to the ouptut
+ (when match
+ (if (not used-label)
+ ;; Unused label
+ (when (buffer-local-value 'rmsbolt-filter-labels src-buffer)
+ (go continue))
+ ;; Real label, set prev-label
+ (setq prev-label raw-match)))
+ (when (and (buffer-local-value 'rmsbolt-filter-directives src-buffer)
+ (not match))
+ (if (and (string-match-p rmsbolt-data-defn line)
+ prev-label)
+ ;; data is being used
+ nil
+ (when (string-match-p rmsbolt-directive line)
+ (go continue))))
+ ;; Add line numbers to mapping
+ (when (and source-linum
+ (rmsbolt--has-opcode-p line))
+ (add-text-properties 0 (length line)
+ `(rmsbolt-src-line ,source-linum) line))
+ ;; Add line
+ (push line result)
+
+ continue)))
+ (nreverse result)))
+
+(cl-defun rmsbolt--process-python-bytecode (_src-buffer asm-lines)
+ (let ((source-linum nil)
+ (result nil))
+ (dolist (line asm-lines)
+ (if (not (string-match (rx bol (repeat 3 (opt space))
+ (group (opt (1+ digit))) (0+ space)
+ (group (opt "-->")) (0+ space)
+ (group (opt ">>")) (0+ space)
+ (group (1+ digit)) (0+ space)
+ (group (1+ (or letter "_"))) (0+ space)
+ (group (opt (1+ digit))) (0+ space)
+ (group (opt (0+ any))))
+ line))
+ ;; just push the var with no linum
+ (push line result)
+ ;; Grab line numbers
+ (unless (string-empty-p (match-string 1 line))
+ (setq source-linum
+ (string-to-number (match-string 1 line))))
+ ;; Reformat line to be more like assembly
+ (setq line (mapconcat 'identity
+ (list (match-string 5 line)
+ (match-string 6 line)
+ (match-string 7 line))
+ "\t"))
+ (when source-linum
+ (add-text-properties 0 (length line)
+ `(rmsbolt-src-line ,source-linum) line))
+ ;; Add line
+ (push line result)))
+ (nreverse result)))
+
(cl-defun rmsbolt--process-asm-lines (src-buffer asm-lines)
"Process and filter a set of asm lines."
(let* ((lang (with-current-buffer src-buffer
@@ -593,78 +700,7 @@ Outputs assembly file if ASM."
((buffer-local-value 'rmsbolt-disassemble src-buffer)
(rmsbolt--process-disassembled-lines src-buffer asm-lines))
(t
- (let ((used-labels (rmsbolt--find-used-labels src-buffer asm-lines))
- (result nil)
- (prev-label nil)
- (source-linum nil)
- (source-file nil)
- (skip-file-match
- ;; Skip file match if we don't have a current filename
- (not (buffer-file-name src-buffer))))
- (dolist (line asm-lines)
- (let* ((raw-match (or (string-match rmsbolt-label-def line)
- (string-match rmsbolt-assignment-def line)))
- (match (when raw-match
- (match-string 1 line)))
- (used-label (cl-find match used-labels :test #'equal)))
- (cl-tagbody
- ;; Process file name hints
- (when (string-match rmsbolt-source-file line)
- (if (match-string 3 line)
- ;; Clang style match
- (setq source-file (expand-file-name
- (match-string 3 line)
- (match-string 2 line)))
- (setq source-file (match-string 2 line))))
- ;; Process any line number hints
- (when (string-match rmsbolt-source-tag line)
- (if (or skip-file-match
- (file-equal-p (buffer-file-name src-buffer)
source-file))
- (setq source-linum (string-to-number
- (match-string 2 line)))
- (setq source-linum nil)))
- (when (string-match rmsbolt-source-stab line)
- (pcase (string-to-number (match-string 1 line))
- ;; http://www.math.utah.edu/docs/info/stabs_11.html
- (68
- (setq source-linum (match-string 2 line)))
- ((or 100 132)
- (setq source-linum nil))))
-
- ;; End block, reset prev-label and source
- (when (string-match-p rmsbolt-endblock line)
- (setq prev-label nil))
-
- (when (and (buffer-local-value 'rmsbolt-filter-comment-only
src-buffer)
- (string-match-p rmsbolt-comment-only line))
- (go continue))
-
- ;; continue means we don't add to the ouptut
- (when match
- (if (not used-label)
- ;; Unused label
- (when (buffer-local-value 'rmsbolt-filter-labels src-buffer)
- (go continue))
- ;; Real label, set prev-label
- (setq prev-label raw-match)))
- (when (and (buffer-local-value 'rmsbolt-filter-directives
src-buffer)
- (not match))
- (if (and (string-match-p rmsbolt-data-defn line)
- prev-label)
- ;; data is being used
- nil
- (when (string-match-p rmsbolt-directive line)
- (go continue))))
- ;; Add line numbers to mapping
- (when (and source-linum
- (rmsbolt--has-opcode-p line))
- (add-text-properties 0 (length line)
- `(rmsbolt-src-line ,source-linum) line))
- ;; Add line
- (push line result)
-
- continue)))
- (nreverse result))))))
+ (rmsbolt--process-src-asm-lines src-buffer asm-lines)))))
;;;;; Handlers
(defun rmsbolt--handle-finish-compile (buffer _str)
@@ -686,7 +722,7 @@ Outputs assembly file if ASM."
src-buffer
(with-temp-buffer
(insert-file-contents (rmsbolt-output-filename
src-buffer t))
- (split-string (buffer-string) "\n" t))))
+ (split-string (buffer-string) "\n" nil))))
(ht (make-hash-table))
(linum 1)
(start-match nil)
- [elpa] externals/beardbolt 547a47e58f 022/323: Fix default commands, (continued)
- [elpa] externals/beardbolt 547a47e58f 022/323: Fix default commands, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 2530003c71 020/323: Remove rmsbolt-options, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt cf7d2787bc 027/323: Implement line number parsing, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 8fc36eacd8 044/323: Add option to force assembling, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt d37f8a0ebf 042/323: Remove reliance on hl-line-mode, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt a0527f16af 045/323: Add very basic support for common lisp, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt d7acfdd127 041/323: Fix rmsbolt temp directory generation being too late, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt f0d13c4ac2 036/323: Add a stronger blacklist for ocaml asm, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 22810d69a7 062/323: Add docs for python, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 503b51ecb8 066/323: Fix typo, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt ca92d533ad 061/323: Add basic support for python,
ELPA Syncer <=
- [elpa] externals/beardbolt fef52d3de3 057/323: Update readme, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 1f50b7bb7f 069/323: Add java framework, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 0e0d82d774 056/323: Override default directory to prevent rouge executables, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 7e4baa833e 068/323: Fix a few comments, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 234e09b81a 065/323: Fix spelling of OCaml, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 285f9bd9be 074/323: Add missing import, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt d126f452d2 077/323: Update README, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 1001531172 073/323: Add java demo, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt db87a0a6a4 080/323: Refactor rmsbolt-temp-dir to be more clear it's a private variable, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 526ed37d71 088/323: Don't add overlays to non-rmsbolt-mode buffers, ELPA Syncer, 2023/03/09