branch: externals/beardbolt commit 15aa590bcfcc36df91eb20ac6c5a2865e7c68fba Author: Jay Kamat <jaygka...@gmail.com> Commit: Jay Kamat <jaygka...@gmail.com>
Add ability to specify moved initial src file --- rmsbolt.el | 34 ++++++++++++++++++++++------------ starters/rmsbolt.pony | 30 ++++++++++++++++-------------- 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/rmsbolt.el b/rmsbolt.el index 4f38a86709..eab2e3bd13 100644 --- a/rmsbolt.el +++ b/rmsbolt.el @@ -177,6 +177,9 @@ Please DO NOT modify this blindly, as this directory will get deleted on Emacs e (defvar-local rmsbolt-src-buffer nil) +(defvar-local rmsbolt--real-src-file nil + "If set, the real filename that we compiled from, probably due to a copy from this file.") + ;;;; Variable-like funcs (defun rmsbolt-output-filename (src-buffer &optional asm) "Function for generating an output filename for SRC-BUFFER. @@ -409,6 +412,11 @@ Outputs assembly file if ASM." (if dis object-filename asm-filename) (rmsbolt-output-filename src-buffer)) " "))) + (with-current-buffer src-buffer + (setq-local rmsbolt--real-src-file + (expand-file-name (file-name-nondirectory + (buffer-file-name)) + dir))) cmd)) (cl-defun rmsbolt--py-compile-cmd (&key src-buffer) "Process a compile command for python3." @@ -664,7 +672,10 @@ Argument SRC-BUFFER source buffer." ;; TODO godbolt does not handle disassembly with filter=off, but we should. (cl-defun rmsbolt--process-disassembled-lines (src-buffer asm-lines) "Process and filter disassembled ASM-LINES from SRC-BUFFER." - (let* ((result nil) + (let* ((src-file-name + (or (buffer-local-value 'rmsbolt--real-src-file src-buffer) + (buffer-file-name src-buffer))) + (result nil) (func nil) (source-linum nil)) (dolist (line asm-lines) @@ -675,7 +686,7 @@ Argument SRC-BUFFER source buffer." '("Aborting processing due to exceeding the binary limit."))) (when (string-match rmsbolt-disass-line line) ;; Don't add linums from files which we aren't inspecting - (if (file-equal-p (buffer-file-name src-buffer) + (if (file-equal-p src-file-name (match-string 1 line)) (setq source-linum (string-to-number (match-string 2 line))) (setq source-linum nil)) @@ -702,14 +713,13 @@ Argument SRC-BUFFER source buffer." (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)))) + (let* ((used-labels (rmsbolt--find-used-labels src-buffer asm-lines)) + (src-file-name (or (buffer-local-value 'rmsbolt--real-src-file src-buffer) + (buffer-file-name src-buffer))) + (result nil) + (prev-label nil) + (source-linum nil) + (source-file nil)) (dolist (line asm-lines) (let* ((raw-match (or (string-match rmsbolt-label-def line) (string-match rmsbolt-assignment-def line))) @@ -727,8 +737,8 @@ Argument SRC-BUFFER source buffer." (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)) + (if (or (not src-file-name) ;; Skip file match if we don't have a current filename + (file-equal-p src-file-name source-file)) (setq source-linum (string-to-number (match-string 2 line))) (setq source-linum nil))) diff --git a/starters/rmsbolt.pony b/starters/rmsbolt.pony index 167f427333..088921f9cb 100644 --- a/starters/rmsbolt.pony +++ b/starters/rmsbolt.pony @@ -1,21 +1,23 @@ // pony rmsbolt starter file +// Passing '--debug' is reccomended to pony because without it LOC hints are optimized out + // Local Variables: -// rmsbolt-command: "ponyc" -// rmsbolt-disassemble: t +// rmsbolt-command: "ponyc --debug" +// rmsbolt-disassemble: nil // End: actor Main - new create(env: Env) => - var a: U8 = 1 + 1 - if is_rms(a) != 0 then - env.out.print(a.string()) - end + new create(env: Env) => + var a: U8 = 1 + 1 + if is_rms(a) != 0 then + env.out.print(a.string()) + end -fun ref is_rms(a: U8): I32 => - match a - | 'R' => 1 - | 'M' => 2 - | 'S' => 3 - else 0 - end + fun ref is_rms(a: U8): I32 => + match a + | 'R' => 1 + | 'M' => 2 + | 'S' => 3 + else 0 + end