[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/beardbolt 2bb741e6f1 183/323: Merge branch 'add-swift-s
From: |
ELPA Syncer |
Subject: |
[elpa] externals/beardbolt 2bb741e6f1 183/323: Merge branch 'add-swift-support' into 'master' |
Date: |
Thu, 9 Mar 2023 10:58:29 -0500 (EST) |
branch: externals/beardbolt
commit 2bb741e6f19a29021833f83c56eb451c860dc443
Merge: 73dcaca98d 73a547856c
Author: Jay Kamat <jaygkamat@gmail.com>
Commit: Jay Kamat <jaygkamat@gmail.com>
Merge branch 'add-swift-support' into 'master'
Add Swift language support
See merge request jgkamat/rmsbolt!9
---
README.org | 2 ++
rmsbolt.el | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++
starters/rmsbolt.swift | 28 ++++++++++++++++++++++++++
3 files changed, 83 insertions(+)
diff --git a/README.org b/README.org
index 82cd4d752c..bd11419b80 100644
--- a/README.org
+++ b/README.org
@@ -113,6 +113,8 @@ The main knobs are described in the full documentation.
[[https://i.imgur.com/uYrQ7En.gif][https://i.imgur.com/uYrQ7En.gif]]
** Common Lisp
[[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]]
* Community and Support
diff --git a/rmsbolt.el b/rmsbolt.el
index d220d6f58b..aa574cf4dd 100644
--- a/rmsbolt.el
+++ b/rmsbolt.el
@@ -667,6 +667,23 @@ https://github.com/derickr/vld"
" ")))
cmd)))
+(cl-defun rmsbolt--swift-compile-cmd (&key src-buffer)
+ "Process a compile command for swiftc."
+ (rmsbolt--with-files
+ src-buffer
+ (let* ((asm-format (buffer-local-value 'rmsbolt-asm-format src-buffer))
+ (cmd (buffer-local-value 'rmsbolt-command src-buffer))
+ (cmd (mapconcat #'identity
+ (list cmd
+ "-g"
+ "-emit-assembly"
+ src-filename
+ "-o" output-filename
+ (when (not (booleanp asm-format))
+ (concat "-Xllvm --x86-asm-syntax="
asm-format)))
+ " ")))
+ cmd)))
+
;;;;; Hidden Function Definitions
(defvar rmsbolt--hidden-func-c
@@ -701,7 +718,35 @@ https://github.com/derickr/vld"
(and (0+ any) "@plt" (0+ any)))
eol))
+;;;;; Demangling Functions
+
+(defun rmsbolt--path-to-swift-demangler ()
+ "Return the path to the configured Swift demangler, depending
+ on the active toolchain."
+ (rmsbolt--path-to-swift-tool "swift-demangle"))
+
;;;;; Language Integrations
+
+(defun rmsbolt--path-to-swift-compiler ()
+ "Return the path to the configured Swift compiler, depending on
+ the active toolchain."
+ (rmsbolt--path-to-swift-tool "swiftc"))
+
+(defun rmsbolt--path-to-swift-tool (swift-tool)
+ "Return the path to SWIFT-TOOL, depending on the active
+toolchain."
+ (let* ((swift-tool-binary swift-tool)
+ (swift-tool-toolchain-path (shell-command-to-string (format "echo -n
`xcrun --find %s`" swift-tool-binary))))
+ ;; If we have the Swift tool in PATH, just return it (this is the
+ ;; typical case in Linux systems). If it's not in PATH, look for a
+ ;; toolchain-specific path.
+ (cond
+ ((executable-find swift-tool-binary)
+ swift-tool-binary)
+ ((executable-find swift-tool-toolchain-path)
+ swift-tool-toolchain-path)
+ (t nil))))
+
(defun rmsbolt--parse-compile-commands (comp-cmds file)
"Parse COMP-CMDS and extract a compilation dir and command for FILE."
(when-let ((json-object-type 'alist)
@@ -839,6 +884,13 @@ return t if successful."
:objdumper 'go-objdump
:compile-cmd-function #'rmsbolt--go-compile-cmd
:process-asm-custom-fn
#'rmsbolt--process-go-asm-lines))
+ (swift-mode
+ . ,(make-rmsbolt-lang :compile-cmd (rmsbolt--path-to-swift-compiler)
+ :supports-asm t
+ :supports-disass nil
+ :objdumper 'objdump
+ :demangler (rmsbolt--path-to-swift-demangler)
+ :compile-cmd-function #'rmsbolt--swift-compile-cmd))
))
(make-obsolete-variable 'rmsbolt-languages
'rmsbolt-language-descriptor "RMSBolt-0.2")
@@ -1477,6 +1529,7 @@ Are you running two compilations at the same time?"))
("d" . "rmsbolt.d")
("zig" . "rmsbolt.zig")
("go" . "rmsbolt.go")
+ ("swift" . "rmsbolt.swift")
;; Rmsbolt is capitalized here because of Java convention of Capitalized
;; class names.
("java" . "Rmsbolt.java")))
diff --git a/starters/rmsbolt.swift b/starters/rmsbolt.swift
new file mode 100644
index 0000000000..9ecd0c6920
--- /dev/null
+++ b/starters/rmsbolt.swift
@@ -0,0 +1,28 @@
+import Foundation
+
+// Swift rmsbolt starter file
+
+// Local Variables:
+// rmsbolt-disassemble: nil
+// End:
+
+func isRMS(_ a: Character) -> Int {
+ switch (a) {
+ case "R":
+ return 1
+ case "M":
+ return 2
+ case "S":
+ return 3
+ default:
+ return 0
+ }
+}
+
+func main() -> Int {
+ let a: Character = "N"
+ if isRMS(a) == 0 {
+ print(a)
+ }
+ return 0
+}
- [elpa] externals/beardbolt 5f998f34d7 137/323: Update README, (continued)
- [elpa] externals/beardbolt 5f998f34d7 137/323: Update README, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 4679974da1 141/323: Add documentation and starter file for PHP support, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 345dd21d24 145/323: Fix typo in docstring, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 33c687fae5 151/323: Implement helpers for compile_commands parsing, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 708260ac56 163/323: Add sharplab to README, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 79de946e68 161/323: Add IRC channel to README, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt cc4347908c 179/323: Inline demo screencast, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt b6e105190c 168/323: Actually use hidden-func-zig, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 10b70ca151 181/323: Add custom logic for finding swiftc, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 565d4a44ee 180/323: Convert if chain into cond, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 2bb741e6f1 183/323: Merge branch 'add-swift-support' into 'master',
ELPA Syncer <=
- [elpa] externals/beardbolt 73a547856c 182/323: Remove rmsbolt-command from local variables in starter file, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 7045b8116a 185/323: Fixed spelling mistake, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 8ad27e8490 176/323: Added basic documentation for Go support, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 25cd95a3b3 174/323: Fix a typo, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt af0a8a6ec9 189/323: Merge branch 'master' of gitlab.com:jgkamat/rmsbolt, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt fcefc0509d 184/323: Add basic documentation for Swift, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 1b015e8d9b 212/323: Update ci to use alpine directly, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 62e68ea2d4 194/323: Fix overlays not working on first compile with popup, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 536a699d1f 193/323: Clean up overlays and mappings if compilation fails, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt ea3e0e4257 200/323: Fix incorrect matching of filenames for compile_commands.json, ELPA Syncer, 2023/03/09