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

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

[elpa] externals/lmc 47cc7a9 11/14: * lmc.el: Use cl-lib


From: Stefan Monnier
Subject: [elpa] externals/lmc 47cc7a9 11/14: * lmc.el: Use cl-lib
Date: Sat, 28 Nov 2020 23:22:16 -0500 (EST)

branch: externals/lmc
commit 47cc7a98efd2d4eb0449513e809b76a6422cf5b6
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * lmc.el: Use cl-lib
---
 lmc.el | 52 ++++++++++++++++++++++++++--------------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/lmc.el b/lmc.el
index b8c8ee0..0b66bc0 100644
--- a/lmc.el
+++ b/lmc.el
@@ -1,6 +1,6 @@
 ;;; lmc.el --- Little Man Computer in Elisp  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2011, 2013, 2014  Free Software Foundation, Inc.
+;; Copyright (C) 2011, 2013, 2014, 2016  Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
 ;; Version: 1.3
@@ -61,7 +61,7 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
 (require 'hexl)
 
 (defgroup lmc ()
@@ -162,7 +162,7 @@ Also, when nil, evaluation is interrupted when the user 
hits a key.")
                  (car (rassq pos labels)) cmd))
          (t (setq pos cmd))))
        ((and cmd (symbolp cmd))
-        ;; (assert (symbolp cmd))
+        ;; (cl-assert (symbolp cmd))
         (if (assq cmd labels)
             (error "Duplicate label %S" cmd)
           (push (cons cmd pos) labels)))))
@@ -192,7 +192,7 @@ Also, when nil, evaluation is interrupted when the user 
hits a key.")
           (dotimes (_ (- cmd (length words)))
             (funcall newword 0)))
          ((and cmd (symbolp cmd))
-          (assert (eq (cdr (assq cmd labels)) (length words)))
+          (cl-assert (eq (cdr (assq cmd labels)) (length words)))
           (setq ll cmd))
          (t (error "Invalid instruction %S" cmd))))
       (nreverse words))))
@@ -200,7 +200,7 @@ Also, when nil, evaluation is interrupted when the user 
hits a key.")
 ;; (defvar lmc-label-width 8)
 
 (defun lmc--load-word (word addr)
-  (assert (bolp))
+  (cl-assert (bolp))
   (insert (propertize (format " %02d:\t" addr)
                       'read-only t
                       'front-sticky t
@@ -310,8 +310,8 @@ Also, when nil, evaluation is interrupted when the user 
hits a key.")
         (when (integerp (nth 1 code))
           (let* ((addr (nth 1 code))
                  (label (lmc-get-label addr)))
-            (pushnew (lmc-point->addr)
-                     (cdr (aref lmc-label-table addr)))
+            (cl-pushnew (lmc-point->addr)
+                        (cdr (aref lmc-label-table addr)))
             (when label
               (setf (nth 1 code) label))))
         (put-text-property
@@ -569,36 +569,36 @@ Also, when nil, evaluation is interrupted when the user 
hits a key.")
   (interactive)
   (let* ((inst (lmc-get-word lmc-pc 'fix))
          (code (lmc-disassemble-word inst)))
-    (case (car code)
-      (HLT (if (lmc-stopped-p)
+    (pcase (car code)
+      (`HLT (if (lmc-stopped-p)
                (error "Already halted")
              (setq lmc--stopped (lmc--state))
              (force-mode-line-update)
              (message "Done.")))
-      (IN (setq lmc-acc (mod (read-number "Enter a number: ") 1000))
-          (incf lmc-pc))
-      (OUT (message "Output: %03d" lmc-acc)
+      (`IN (setq lmc-acc (mod (read-number "Enter a number: ") 1000))
+          (cl-incf lmc-pc))
+      (`OUT (message "Output: %03d" lmc-acc)
            (push (format "%03d" lmc-acc) lmc-output)
-           (incf lmc-pc))
-      (LDA (setq lmc-acc (lmc-get-word (nth 1 code)))
-           (incf lmc-pc))
-      (STO (lmc-store-word (nth 1 code) lmc-acc)
-           (incf lmc-pc))
-      (ADD (setq lmc-acc (mod (+ lmc-acc (lmc-get-word (nth 1 code)))
+           (cl-incf lmc-pc))
+      (`LDA (setq lmc-acc (lmc-get-word (nth 1 code)))
+           (cl-incf lmc-pc))
+      (`STO (lmc-store-word (nth 1 code) lmc-acc)
+           (cl-incf lmc-pc))
+      (`ADD (setq lmc-acc (mod (+ lmc-acc (lmc-get-word (nth 1 code)))
                               1000))
-           (incf lmc-pc))
-      (SUB (setq lmc-acc (mod (- lmc-acc (lmc-get-word (nth 1 code)))
+           (cl-incf lmc-pc))
+      (`SUB (setq lmc-acc (mod (- lmc-acc (lmc-get-word (nth 1 code)))
                               1000))
-           (incf lmc-pc))
-      (BR (setq lmc-pc (nth 1 code)))
-      (BRZ (setq lmc-pc (if (zerop lmc-acc)
+           (cl-incf lmc-pc))
+      (`BR (setq lmc-pc (nth 1 code)))
+      (`BRZ (setq lmc-pc (if (zerop lmc-acc)
                             (nth 1 code)
                           (1+ lmc-pc))))
-      (BRP (setq lmc-pc (if (< lmc-acc 500)
+      (`BRP (setq lmc-pc (if (< lmc-acc 500)
                             (nth 1 code)
                           (1+ lmc-pc))))
-      ((nil) (error "Invalid instruction %S" inst))
-      (t (error "%S not implemented" code))))
+      (`nil (error "Invalid instruction %S" inst))
+      (_ (error "%S not implemented" code))))
   (lmc-update-pc))
 
 (defun lmc-run ()



reply via email to

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