Skip to content

Instantly share code, notes, and snippets.

;; Base class which is often derived into domain specific caching items.
;; It is acceptable that a derived cache-item also contain references to
;; additional cache-items if needed.
(defclass cache-item (lock:lockable)
(;; An opaque object the user can do whatever they want with.
(%opaque-data :accessor opaque-data :initarg :opaque-data :initform nil)
;; policy can be :unlocked (generally evictable), :locked (not evictable),
;; etc
(%policy :accessor policy :initarg :policy :initform :unlocked)
;; Can be :cold (never cached), :reserved (in cache, value not
(c:define-texture-map cube-map-right (:2d :unique)
(texmap:mipmap (textures cube-map-right)))
(c:define-texture-map cube-map-left (:2d :unique)
(texmap:mipmap (textures cube-map-left)))
(c:define-texture-map cube-map-top (:2d :unique)
(texmap:mipmap (textures cube-map-top)))
(c:define-texture-map cube-map-bottom (:2d :unique)
(texmap:mipmap (textures cube-map-bottom)))
(c:define-texture-map cube-map-back (:2d :unique)
(texmap:mipmap (textures cube-map-back)))
(docentry classify-symbol (:function)
(synopsis "This is one line that describes the function.")
(arguments
(a "Describe arg a") ; args conspire to be in package of symbol
(b "Describe arg b"))
(returns
(value "value 1 desc")
(value "value 2 desc")
(value "value N desc"))
(side-effects "None.")
(docentry xxx-0 (:function)
(synopsis "This is one line that describes the function.")
(arguments
(a "Describe arg a")
(b "Describe arg b"))
(return-values
(value "value 1 desc")
(value "value 2 desc")
(value "value N desc"))
(description
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <string.h>
#include <errno.h>
typedef unsigned char machine_code;
/* A function that we will manually "JIT" into an executable sequence of
instructions stored in an array. Note the 'func' argument. It is through
;; TODO: This function really needs some documentation. It is used to
;; partition a pile of forms in a list into group based upon a categorization
;; function.
(defun sieve (pred sequ &key (key #'identity)
(collector nil)
(values t)
(pred-range-sort nil)
(initial-key-pool nil) ;; ensure all buckets present!
(result-transformer-func #'identity)
(eval-when (:compile-toplevel :load-toplevel :execute)
(defparameter *regdb*
(let ((data
`(;; register symbol names as values
(regsyms-gp8 (al cl dl bl ah ch dh bh))
(regsyms-gp8-ext (spl bpl sil dil r8b r9b r10b r11b r12b
r13b r14b r15b))
(regsyms-gp16 (ax cx dx bx bp si di))
(regsyms-gp16-ext (r8w r9w r10w r11w r12w r13w
r14w r15w))
(defun parse-number (str &key (package *package*) (error nil))
(with-standard-io-syntax
(with-input-from-string (s str)
(let ((*read-eval* nil)
(*package* package))
(let ((val
(restart-case
(handler-bind
((condition (lambda (c)
(invoke-restart 'bad-read error))))
(defparameter *inst* nil)
(defun ast->3ac-helper (ast)
(if (atom ast)
(cond
((numberp ast)
ast)
((symbolp ast)
ast)
(t
(error "oops, don't know what this is")))
(defun probability-choice (lst)
"Expect LST to be ((prob item) (prob item) ...). It doesn't have to be
sorted but all PROB values must sum to 1. Return a random item based on these
probabilities."
(let ((tol 1d-10)
(prob-sum (reduce #'+ lst :key #'car)))
(assert (<= (- 1d0 (abs prob-sum)) tol)))
(format t "Probabilities are good.~%")