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

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

[elpa] externals/beardbolt 8cf5134dbe 098/323: add pony lang support (WI


From: ELPA Syncer
Subject: [elpa] externals/beardbolt 8cf5134dbe 098/323: add pony lang support (WIP)
Date: Thu, 9 Mar 2023 10:58:21 -0500 (EST)

branch: externals/beardbolt
commit 8cf5134dbe6b1041526c3f24337e5d6f91790963
Author: Reini Urban <rurban@cpan.org>
Commit: Reini Urban <rurban@cpan.org>

    add pony lang support (WIP)
    
    pony expects only directories for in- and output,
    so copy the files into the temp/pony subdir, and expect
    temp/pony.s as result via -r=asm.
    
    otherwise it is very similar to rust.
---
 README.org            |  4 ++++
 rmsbolt.el            | 29 +++++++++++++++++++++++++++--
 starters/rmsbolt.pony | 21 +++++++++++++++++++++
 3 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/README.org b/README.org
index 47e423c93f..b834d2c1b6 100644
--- a/README.org
+++ b/README.org
@@ -103,6 +103,10 @@ No support for source->asm matching or filtering.
 
 [[https://i.imgur.com/36aNVvf.gif][https://i.imgur.com/36aNVvf.gif]]
 
+** Pony
+
+Parses the output of ~ponyc -r=asm~ without good source->asm matching or 
filtering.
+
 * Adding a Language
 
 Adding support for a new language is fairly easy. The closer it is to existing
diff --git a/rmsbolt.el b/rmsbolt.el
index 36ce6d4fcc..cb1d332069 100644
--- a/rmsbolt.el
+++ b/rmsbolt.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2018 Jay Kamat
 ;; Author: Jay Kamat <jaygkamat@gmail.com>
-;; Version: 0.1.0
+;; Version: 0.1.1
 ;; Keywords: compilation, tools
 ;; URL: http://gitlab.com/jgkamat/rmsbolt
 ;; Package-Requires: ((emacs "25.1"))
@@ -26,7 +26,7 @@
 ;; code input file.
 ;;
 ;; It currently supports: C/C++, OCaml, Haskell, Python, Java, and (limited)
-;; Common Lisp.
+;; Common Lisp and Pony.
 ;;
 ;; Adding support for more languages, if they have an easy manual compilation
 ;; path from source->assembly/bytecode with debug information, should be much
@@ -379,6 +379,23 @@ Outputs assembly file if ASM."
                                  "-Cllvm-args=--x86-asm-syntax=intel"))
                          " ")))
     cmd))
+(cl-defun rmsbolt--pony-compile-cmd (&key src-buffer)
+  "Process a compile command for ponyc."
+  (let* ((cmd (buffer-local-value 'rmsbolt-command src-buffer))
+         (dir (expand-file-name "pony/" rmsbolt--temp-dir))
+         (temp (copy-file (buffer-file-name) (expand-file-name dir 
(buffer-file-name))))
+         (dis (buffer-local-value 'rmsbolt-disassemble src-buffer))
+         (cmd (mapconcat #'identity
+                         (list cmd
+                               ; -r=ir for llvm IR
+                               (if dis
+                                   "-r=obj"
+                                 "-r=asm")
+                               dir)
+                         " "))
+         (temp (copy-file (expand-file-name (if dis "pony.o" "pony.s") 
rmsbolt--temp-dir)
+                          (rmsbolt-output-filename src-buffer))))
+    cmd))
 (cl-defun rmsbolt--py-compile-cmd (&key src-buffer)
   "Process a compile command for python3."
   (let* ((cmd (buffer-local-value 'rmsbolt-command src-buffer)))
@@ -484,6 +501,13 @@ Outputs assembly file if ASM."
                           :demangler "rustfilt"
                           :compile-cmd-function #'rmsbolt--rust-compile-cmd
                           :disass-hidden-funcs nil))
+   (pony-mode
+    . ,(make-rmsbolt-lang :compile-cmd "ponyc"
+                          :supports-asm t
+                          :supports-disass nil
+                          :objdumper 'objdump
+                          :compile-cmd-function #'rmsbolt--pony-compile-cmd
+                          :disass-hidden-funcs nil))
    ;; ONLY SUPPORTS PYTHON 3
    (python-mode
     . ,(make-rmsbolt-lang :compile-cmd "python3"
@@ -996,6 +1020,7 @@ Argument STR compilation finish status."
     ("rust " . "rmsbolt.rs")
     ("python" . "rmsbolt.py")
     ("haskell" . "rmsbolt.hs")
+    ("pony" . "rmsbolt.pony")
     ;; FIXME: Why capital letter?
     ("java" . "Rmsbolt.java")))
 
diff --git a/starters/rmsbolt.pony b/starters/rmsbolt.pony
new file mode 100644
index 0000000000..cd9d810cd3
--- /dev/null
+++ b/starters/rmsbolt.pony
@@ -0,0 +1,21 @@
+// pony rmsbolt starter file
+
+// Local Variables:
+// rmsbolt-command: "ponyc --debug"
+// End:
+
+actor Main
+  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
+



reply via email to

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