branch: externals/beardbolt commit 68af010f0230747ea53657d17cccc8be58c29475 Author: Jay Kamat <jaygka...@gmail.com> Commit: Jay Kamat <jaygka...@gmail.com>
Add support for haskell --- README.org | 7 +++++++ rmsbolt.el | 25 ++++++++++++++++++++++++- starters/rmsbolt.hs | 31 +++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index 6ae9085b26..78a5768049 100644 --- a/README.org +++ b/README.org @@ -59,6 +59,13 @@ demangling is done with rustfilt if available [[https://s25.postimg.cc/h7npjnnun/output-2018-08-01-19_30_52.gif][https://s25.postimg.cc/h7npjnnun/output-2018-08-01-19_30_52.gif]] +** Haskell + +demangling is done with the compiler-explorer demangler, named +to ~haskell-demangler~. + +[[https://s25.postimg.cc/4d5167yr3/output-2018-08-08-23_17_59.gif][https://s25.postimg.cc/4d5167yr3/output-2018-08-08-23_17_59.gif]] + ** Python Support for viewing bytecode only. Python [[https://bugs.python.org/issue2506][dosen't have many options]], so most diff --git a/rmsbolt.el b/rmsbolt.el index 6de3344d13..2a3ce2e497 100644 --- a/rmsbolt.el +++ b/rmsbolt.el @@ -344,13 +344,27 @@ Outputs assembly file if ASM." " "))) cmd)) (cl-defun rmsbolt--py-compile-cmd (&key src-buffer) - "Process a compile command for rustc." + "Process a compile command for python3." (let* ((cmd (buffer-local-value 'rmsbolt-command src-buffer))) (mapconcat 'identity (list cmd "-m" "dis" (buffer-file-name) ">" (rmsbolt-output-filename src-buffer)) " "))) +(cl-defun rmsbolt--hs-compile-cmd (&key src-buffer) + "Process a compile command for ghc." + (let* ((cmd (buffer-local-value 'rmsbolt-command src-buffer)) + (cmd (mapconcat 'identity + (list cmd + "-g" + (if (buffer-local-value 'rmsbolt-disassemble src-buffer) + "" + "-S") + (buffer-file-name) + "-o" (rmsbolt-output-filename src-buffer)) + " "))) + cmd)) + (defvar rmsbolt--hidden-func-c (rx bol (or (and "__" (0+ any)) (and "_" (or "init" "start" "fini")) @@ -435,6 +449,15 @@ Outputs assembly file if ASM." :compile-cmd-function #'rmsbolt--py-compile-cmd :disass-hidden-funcs nil :process-asm-custom-fn #'rmsbolt--process-python-bytecode)) + (haskell-mode + . ,(make-rmsbolt-lang :mode 'haskell-mode + :compile-cmd "ghc" + :supports-asm t + :supports-disass nil + :demangler "haskell-demangler" + :starter-file-name "rmsbolt.hs" + :compile-cmd-function #'rmsbolt--hs-compile-cmd + :disass-hidden-funcs nil)) )) ;;;; Macros diff --git a/starters/rmsbolt.hs b/starters/rmsbolt.hs new file mode 100644 index 0000000000..d21c7c2152 --- /dev/null +++ b/starters/rmsbolt.hs @@ -0,0 +1,31 @@ +-- Haskell rmsbolt starter file + +-- Haskell demangler support can be gained by placing the binary +-- generated from this folder on your path under the name +-- 'haskell-demangler' +-- https://github.com/mattgodbolt/compiler-explorer/tree/master/haskell + +-- Local Variables: +-- rmsbolt-command: "ghc -O0" +-- End: + +module Rmsbolt where + +import Data.Char + +isRMS :: Char -> Bool +isRMS letter + | letter == 'R' = True + | letter == 'M' = True + | letter == 'S' = True + | otherwise = False + +main :: IO() +main = + let num = Data.Char.chr 2 in + let out = isRMS num in + let out_str = + if out then + "True" else + "False" in + putStrLn out_str