[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/beardbolt e6081fae6b 032/323: Add unrefined support for
From: |
ELPA Syncer |
Subject: |
[elpa] externals/beardbolt e6081fae6b 032/323: Add unrefined support for ocaml |
Date: |
Thu, 9 Mar 2023 10:57:56 -0500 (EST) |
branch: externals/beardbolt
commit e6081fae6b65447542648bc29e17ca57e8e5631e
Author: Jay Kamat <jaygkamat@gmail.com>
Commit: Jay Kamat <jaygkamat@gmail.com>
Add unrefined support for ocaml
---
rmsbolt.el | 55 ++++++++++++++++++++++++++++++++++++++++++++++------
starters/rmsbolt.c | 4 +++-
starters/rmsbolt.cpp | 4 +++-
starters/rmsbolt.ml | 22 +++++++++++++++++++++
4 files changed, 77 insertions(+), 8 deletions(-)
diff --git a/rmsbolt.el b/rmsbolt.el
index de142cae19..4a227cf105 100644
--- a/rmsbolt.el
+++ b/rmsbolt.el
@@ -73,6 +73,11 @@
:type 'boolean
:safe 'booleanp
:group 'rmsbolt)
+(defcustom rmsbolt-ignore-binary-limit nil
+ "Whether to ignore the binary limit. Could hang emacs..."
+ :type 'boolean
+ :safe 'booleanp
+ :group 'rmsbolt)
;;;; Faces
@@ -209,7 +214,7 @@
:documentation "A function which takes in a compile command (could be the
default) and adds needed args to it."))
-(defun rmsbolt--c-compile-cmd (src-buffer)
+(cl-defun rmsbolt--c-compile-cmd (&key src-buffer)
"Process a compile command for gcc/clang."
(let* ((cmd (buffer-local-value 'rmsbolt-command src-buffer))
(cmd (mapconcat 'identity
@@ -224,6 +229,35 @@
"-masm=intel"))
" ")))
cmd))
+(cl-defun rmsbolt--ocaml-compile-cmd (&key src-buffer)
+ "Process a compile command for gcc/clang.
+
+Needed as ocaml cannot output asm to a non-hardcoded file"
+ (let* ((diss (buffer-local-value 'rmsbolt-dissasemble src-buffer))
+ (output-filename (rmsbolt-output-filename src-buffer))
+ (predicted-asm-filename (concat (file-name-sans-extension
(buffer-file-name)) ".s"))
+ (cmd (buffer-local-value 'rmsbolt-command src-buffer))
+ (cmd (mapconcat 'identity
+ (list cmd
+ "-g"
+ (if (buffer-local-value 'rmsbolt-dissasemble
src-buffer)
+ ""
+ "-S")
+ (buffer-file-name)
+ (mapconcat #'identity
+ (cond
+ (diss
+ (list "-o" output-filename))
+ ((equal predicted-asm-filename
output-filename)
+ nil)
+ (t
+ (list "&&" "mv"
+ (concat
(file-name-sans-extension (buffer-file-name))
+ ".s")
+ output-filename)))
+ " "))
+ " ")))
+ cmd))
(defvar rmsbolt--hidden-func-c (rx bol (or (and "__" (0+ any))
(and "_" (or "init" "start" "fini"))
(and (opt "de")
"register_tm_clones")
@@ -248,9 +282,16 @@
:supports-asm t
:starter-file-name "rmsbolt.cpp"
:compile-cmd-function #'rmsbolt--c-compile-cmd
+ :dissas-hidden-funcs rmsbolt--hidden-func-c))
+ ;; In order to parse ocaml files, you need the emacs ocaml mode, tuareg
+ (tuareg-mode
+ . ,(make-rmsbolt-lang :mode 'tuareg-mode
+ :compile-cmd "ocamlopt"
+ :supports-asm t
+ :starter-file-name "rmsbolt.ml"
+ :compile-cmd-function #'rmsbolt--ocaml-compile-cmd
:dissas-hidden-funcs rmsbolt--hidden-func-c))))
-
;;;; Macros
(defmacro rmsbolt-with-display-buffer-no-window (&rest body)
@@ -363,7 +404,8 @@
(source-linum nil))
(dolist (line asm-lines)
(cl-tagbody
- (when (> (length result) rmsbolt-binary-asm-limit)
+ (when (and (> (length result) rmsbolt-binary-asm-limit)
+ (not (buffer-local-value 'rmsbolt-ignore-binary-limit
src-buffer)))
(cl-return-from rmsbolt--process-dissasembled-lines
'("Aborting processing due to exceeding the binary limit.")))
(when (string-match rmsbolt-dissas-line line)
@@ -527,7 +569,7 @@
(let* ((src-buffer (current-buffer))
(lang (rmsbolt--get-lang))
(func (rmsbolt-l-compile-cmd-function lang))
- (cmd (funcall func src-buffer)))
+ (cmd (funcall func :src-buffer src-buffer)))
(when (buffer-local-value 'rmsbolt-dissasemble src-buffer)
(pcase
@@ -590,6 +632,7 @@
(rmsbolt-starter ,mode)))
(rmsbolt-defstarter "c" 'c-mode)
(rmsbolt-defstarter "c++" 'c++-mode)
+(rmsbolt-defstarter "ocaml" 'tuareg-mode)
;;;; Font lock matcher
(defun rmsbolt--goto-line (line)
@@ -615,8 +658,8 @@
(if (eq (current-buffer) src-buffer)
current-line
(get-text-property (point) 'rmsbolt-src-line)))
- (asm-lines (gethash src-current-line
- (buffer-local-value 'rmsbolt-line-mapping
src-buffer)))
+ (hash-table (buffer-local-value 'rmsbolt-line-mapping src-buffer))
+ (asm-lines (gethash src-current-line hash-table))
;; TODO also consider asm
(src-pts
(with-current-buffer src-buffer
diff --git a/starters/rmsbolt.c b/starters/rmsbolt.c
index ea7b750eff..63dc6d69cc 100644
--- a/starters/rmsbolt.c
+++ b/starters/rmsbolt.c
@@ -1,7 +1,9 @@
#include <stdio.h>
+// C rmsbolt starter file
+
// Local Variables:
-// rmsbolt-command: "gcc -O3"
+// rmsbolt-command: "gcc -O0"
// rmsbolt-dissasemble: nil
// End:
diff --git a/starters/rmsbolt.cpp b/starters/rmsbolt.cpp
index 49e401e021..aa4dee0f0e 100644
--- a/starters/rmsbolt.cpp
+++ b/starters/rmsbolt.cpp
@@ -1,7 +1,9 @@
#include <iostream>
+// C++ rmsbolt starter file
+
// Local Variables:
-// rmsbolt-command: "g++ -O3"
+// rmsbolt-command: "g++ -O0"
// rmsbolt-dissasemble: nil
// End:
diff --git a/starters/rmsbolt.ml b/starters/rmsbolt.ml
new file mode 100644
index 0000000000..deee3757a5
--- /dev/null
+++ b/starters/rmsbolt.ml
@@ -0,0 +1,22 @@
+
+
+(* OCaml rmsbolt starter *)
+
+(*
+Local Variables:
+rmsbolt-command: "ocamlopt"
+rmsbolt-dissasemble: nil
+End:
+*)
+
+
+let rec fib num =
+ if num <= 1 then
+ num
+ else
+ fib (num - 1) + fib (num - 2);;
+
+let print_fib num =
+ Printf.printf "Fibonacci result of %d is %d.\n" num (fib 20);;
+
+print_fib 20
- [elpa] externals/beardbolt c066da01c4 052/323: Fix ocaml def, (continued)
- [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, 2023/03/09
- [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 <=
- [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
- [elpa] externals/beardbolt 4213316f23 037/323: Fix recentering when not needed, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 545a366472 049/323: Add more tests, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 2e6163c95a 047/323: Add testing framework, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 5efa347027 046/323: Update readme, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 082cbc7b1c 048/323: Add new tests, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt ff6f376d87 053/323: Update README.org, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 3ca3f35cdb 050/323: Add very basic support for rust, ELPA Syncer, 2023/03/09