[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/beardbolt 1545531849 006/323: Add initial implementatio
From: |
ELPA Syncer |
Subject: |
[elpa] externals/beardbolt 1545531849 006/323: Add initial implementation of filter |
Date: |
Thu, 9 Mar 2023 10:57:48 -0500 (EST) |
branch: externals/beardbolt
commit 15455318490511835138b40f7dfafbd5dfcf584b
Author: Jay Kamat <jaygkamat@gmail.com>
Commit: Jay Kamat <jaygkamat@gmail.com>
Add initial implementation of filter
---
README.org | 9 +++----
rmsbolt.el | 80 +++++++++++++++++++++++++++++++++++++++++++++-----------------
2 files changed, 64 insertions(+), 25 deletions(-)
diff --git a/README.org b/README.org
index e041f7da80..aa72b10163 100644
--- a/README.org
+++ b/README.org
@@ -1,13 +1,14 @@
* RMSbolt
-A basic implementation of the
[[https://github.com/mattgodbolt/compiler-explorer][godbolt compiler-exporter]]
in emacs.
+A basic implementation of the
[[https://github.com/mattgodbolt/compiler-explorer][godbolt compiler-exporter]]
for Emacs.
* Why RMSbolt over godbolt?
- No sending your code to a third party server
- Compilation runs entirely on your machine
-- Faster results
+- Better turnaround time from writing code to seeing disassembly
- Infinitely hackable!
-- Write your code in your preferred editing environment
-- Runs entirely with 0 js
+- Write, compile, and view dissasembly entirely in Emacs
+- Runs entirely without node, npm, or js.
+ - No dependencies other than emacs 25 and your compiler ~:)~
diff --git a/rmsbolt.el b/rmsbolt.el
index 3221f38044..dbeaacd673 100644
--- a/rmsbolt.el
+++ b/rmsbolt.el
@@ -73,12 +73,13 @@
(defvar rmsbolt-defines-function (rx bol (0+ space) ".type"
(0+ any) "," (0+ space) (any "@%")
"function" eol))
-
(defvar rmsbolt-data-defn (rx bol (0+ space) "."
(group (or "string" "asciz" "ascii"
(and
(optional (any "1248")) "byte")
"short" "word" "long" "quad" "value"
"zero"))))
+(defvar rmsbolt-directive (rx bol (0+ space) "." (0+ any) eol))
+(defvar rmsbolt-endblock (rx "." (or "cfi_endproc" "data" "text" "section")))
;;;; Classes
@@ -102,14 +103,14 @@
:documentation "The mode to activate this language in."))
(defvar rmsbolt-languages
- `((c-mode .
- ,(make-rmsbolt-lang :mode 'c
- :options (make-rmsbolt-options
- :compile-cmd "gcc -g -O0")) )
- (c++-mode .
- ,(make-rmsbolt-lang :mode 'c++-mode
- :options (make-rmsbolt-options
- :compile-cmd "g++ -g -O0")) )
+ `((c-mode
+ . ,(make-rmsbolt-lang :mode 'c
+ :options (make-rmsbolt-options
+ :compile-cmd "gcc -g -O0")) )
+ (c++-mode
+ . ,(make-rmsbolt-lang :mode 'c++-mode
+ :options (make-rmsbolt-options
+ :compile-cmd "g++ -g -O0")) )
))
@@ -125,6 +126,8 @@
;;;; Functions
+;; Functions to parse and lint assembly were lifted almost directly from the
compiler-exporter
+
(defun rmsbolt-re-seq (regexp string)
"Get list of all REGEXP match in STRING."
(save-match-data
@@ -162,7 +165,9 @@
(match-string 1 line)))
(when match
(setq current-label match))
- (when (string-match-p rmsbolt-defines-global line)
+ (setq match (and (string-match rmsbolt-defines-global line)
+ (match-string 1 line)))
+ (when match
(cl-pushnew match labels-used :test #'equal))
;; When we have no line or a period started line, skip
(unless (or (= 0 (length line))
@@ -205,18 +210,51 @@
(defun rmsbolt--process-asm-lines (asm-lines)
"Process and filter a set of asm lines."
- (when rmsbot-filter-unused-labels
- (let* ((used-labels (rmsbolt--find-used-labels asm-lines)))
-
+ (when rmsbolt-filter-unused-labels
+ (let ((used-labels (rmsbolt--find-used-labels asm-lines))
+ (result nil)
+ (prev-label nil))
+ (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
+ ;; End block, reset prev-label and source
+ (when (string-match-p rmsbolt-endblock line)
+ (setq prev-label nil))
+
+ ;; continue means we don't add to the ouptut
+ (when match
+ (if (not used-label)
+ ;; Unused label
+ (when rmsbolt-filter-unused-labels
+ (go continue))
+ ;; Real label, set prev-label
+ (setq prev-label raw-match)))
+ (when (and rmsbolt-filter-asm-directives
+ (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))))
+ (push line result)
+ continue)))
+
+ (mapconcat 'identity
+ (nreverse result)
+ "\n")
))
- (when rmsbolt-filter-asm-directives
- (setq asm-lines
- (cl-remove-if
- (apply-partially #'string-match-p +rmsbolt-assembler-pattern+)
- asm-lines)))
- (mapconcat 'identity
- asm-lines
- "\n"))
+
+ ;; (when rmsbolt-filter-asm-directives
+ ;; (setq asm-lines
+ ;; (cl-remove-if
+ ;; (apply-partially #'string-match-p +rmsbolt-assembler-pattern+)
+ ;; asm-lines)))
+ )
(defun rmsbolt--handle-finish-compile (buffer _str)
"Finish hook for compilations."
- [elpa] externals/beardbolt 74b773d370 026/323: Fix crash on quit for real, (continued)
- [elpa] externals/beardbolt 74b773d370 026/323: Fix crash on quit for real, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt a9e5fbfd7a 028/323: Implement line number parsing for disassembled files, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 3b6bb5bd75 030/323: Add basic overlays to view matched lines, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 5ab75b7f56 014/323: Add stubs for dissasembly, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 0a55783f33 029/323: Add skeleton for font-lock, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 8dcd74b511 031/323: Clean up rmsbolt.c by moving starters into helper files, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt aea0966e9d 035/323: Don't add binary asm line data when viewing different files, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt c066da01c4 052/323: Fix ocaml def, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 83e29706f5 005/323: Work on porting used label finder, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 58c77d90c3 008/323: Add outshine comments, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 1545531849 006/323: Add initial implementation of filter,
ELPA Syncer <=
- [elpa] externals/beardbolt d604adae64 015/323: Add initial functions for processing binary asm, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt e0bc9fc409 013/323: Fix starters, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 93f3cad769 017/323: Use local variables instead of custom parsing, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt ce6511f715 024/323: Fix compiler warnings, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 55c26882cd 025/323: Fix crash on quit, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 6239f41d9d 033/323: Add a goto-match feature for easily traversing matches, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt e6081fae6b 032/323: Add unrefined support for ocaml, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt a638324882 039/323: Add OCaml demo, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt e0d917206e 038/323: Improve quality of default matching faces, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt a950515dfc 043/323: Fix spelling mistake, ELPA Syncer, 2023/03/09