emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/beardbolt 24ac775643 246/323: Support Nim 1.6.6


From: ELPA Syncer
Subject: [elpa] externals/beardbolt 24ac775643 246/323: Support Nim 1.6.6
Date: Thu, 9 Mar 2023 10:58:35 -0500 (EST)

branch: externals/beardbolt
commit 24ac7756438e1fde72f547f22f374366b921d6f3
Author: Andreas Kröhnke <andreas@krohnke.me>
Commit: Jay Kamat <jaygkamat@gmail.com>

    Support Nim 1.6.6
---
 README.org           |  2 ++
 doc/rmsbolt.org      |  9 +++++++++
 rmsbolt.el           | 31 +++++++++++++++++++++++++++++++
 starters/rmsbolt.nim | 21 +++++++++++++++++++++
 4 files changed, 63 insertions(+)

diff --git a/README.org b/README.org
index c957e0ed2a..97983d4d2b 100644
--- a/README.org
+++ b/README.org
@@ -119,6 +119,8 @@ The main knobs are described in the full documentation.
 [[https://i.imgur.com/36aNVvf.gif][https://i.imgur.com/36aNVvf.gif]]
 ** Swift
 
[[https://gitlab.com/jgkamat/rmsbolt/uploads/80d38e840a149c77951891c3623ca2f2/lFG72Lv_-_Imgur.gif][https://gitlab.com/jgkamat/rmsbolt/uploads/80d38e840a149c77951891c3623ca2f2/lFG72Lv_-_Imgur.gif]]
+** Nim
+[[https://i.imgur.com/8y4jtK9.gif][https://i.imgur.com/8y4jtK9.gif]]
 
 * Community and Support
 
diff --git a/doc/rmsbolt.org b/doc/rmsbolt.org
index 632a5c67f2..fbb1a2b031 100644
--- a/doc/rmsbolt.org
+++ b/doc/rmsbolt.org
@@ -199,6 +199,15 @@ file:
 
 Uses Go's objdump tool to produce viewing-only bytecode. Go must be on the 
path.
 
+** Nim
+
+Builds into object files into a temporary ~nim-cache~ directory generated by
+rmsbolt, which will then be copied and dissassembled.
+C++ backend is also possible to either with ~nim cpp~ or ~nim c
+--passC:-std=gnu++14~ and uses ~c++filt~ demangler.
+
+Use the ~{.exportc.}~ pragma for at least the main procedure that will be 
dissassembled.
+
 * Integrations
 This section covers integrations that RMSbolt provides, which make it easier to
 use RMSbolt with complex projects with many dependencies.
diff --git a/rmsbolt.el b/rmsbolt.el
index ae6a7e1e35..e5b6f6ba75 100644
--- a/rmsbolt.el
+++ b/rmsbolt.el
@@ -672,6 +672,30 @@ https://github.com/derickr/vld";
       (rmsbolt--disassemble-file file-name (current-buffer))
       (rmsbolt--handle-finish-compile src-buffer nil :override-buffer 
(current-buffer)))))
 
+(cl-defun rmsbolt--nim-compile-cmd (&key src-buffer)
+  "Process a compile command for nim."
+  (rmsbolt--with-files
+   src-buffer
+   (let* ((disass (buffer-local-value 'rmsbolt-disassemble src-buffer))
+          (cmd (buffer-local-value 'rmsbolt-command src-buffer))
+         (cmd
+          (let* ((outdir (expand-file-name "nim-cache" rmsbolt--temp-dir)))
+                 (string-join
+                  (list cmd
+                        "--debugger:native"
+                        "--noLinking"
+                        "--colors:off"
+                        (concat "--nimcache:" outdir)
+                        src-filename
+                        (concat "&& cp "
+                                (expand-file-name (concat "@m"
+                                                          (ff-basename 
src-filename)
+                                                          (if (string-match 
(rx "nim cpp") cmd) ".cpp.o" ".c.o"))
+                                                          outdir)
+                                " " output-filename))
+                  " "))))
+     cmd)))
+
 (cl-defun rmsbolt--zig-compile-cmd (&key src-buffer)
   "Process a compile command for zig."
   (rmsbolt--with-files
@@ -902,6 +926,13 @@ return t if successful."
                           :process-asm-custom-fn (lambda (_src-buffer lines)
                                                    lines)
                           :elisp-compile-override 
#'rmsbolt--elisp-compile-override))
+   (nim-mode
+    . ,(make-rmsbolt-lang :compile-cmd "nim c"
+                          :supports-disass t
+                          :objdumper 'objdump
+                          :demangler "c++filt"
+                          :compile-cmd-function #'rmsbolt--nim-compile-cmd
+                          :disass-hidden-funcs rmsbolt--hidden-func-c))
    (zig-mode
     . ,(make-rmsbolt-lang :compile-cmd "zig build-obj -O ReleaseFast"
                           :supports-asm t
diff --git a/starters/rmsbolt.nim b/starters/rmsbolt.nim
new file mode 100644
index 0000000000..bce7e91885
--- /dev/null
+++ b/starters/rmsbolt.nim
@@ -0,0 +1,21 @@
+import strutils
+
+# Nim rmsbolt starter file
+
+# Local Variables:
+# rmsbolt-command: "nim c --opt:size"
+# End:
+
+
+
+proc isRMS(a: char): uint8 {.exportc.} =
+  case a
+  of 'R': result = 1
+  of 'M': result = 2
+  of 'S': result = 3
+  else: result = 0
+
+proc main(): void =
+  const a: char = cast[char](1 + 1)
+  if (isRMS(a) != 0): 
+    echo "$#" % $a



reply via email to

[Prev in Thread] Current Thread [Next in Thread]