<commit_before>(in-package :varjo)
(in-readtable :fn.reader)

;;------------------------------------------------------------

(defclass v-function ()
  ((versions :initform nil :initarg :versions :accessor v-versions)
   (argument-spec :initform nil :initarg :arg-spec :accessor v-argument-spec)
   (glsl-string :initform "" :initarg :glsl-string :reader v-glsl-string)
   (glsl-name :initarg :glsl-name :accessor v-glsl-name)
   (return-spec :initform nil :initarg :return-spec :accessor v-return-spec)
   (v-place-index :initform nil :initarg :v-place-index :reader v-place-index)
   (name :initform nil :initarg :name :reader name)
   (implicit-args :initform nil :initarg :implicit-args :reader implicit-args)
   (in-out-args :initform nil :initarg :in-out-args :reader in-out-args)
   (in-arg-flow-ids :initform (error 'flow-ids-mandatory :for :v-function
                                     :code-type :v-function)
                    :initarg :in-arg-flow-ids :reader in-arg-flow-ids)
   (flow-ids :initform (error 'flow-ids-mandatory :for :v-function
                              :code-type :v-function)
             :initarg :flow-ids :reader flow-ids)))

(defmethod functions ((fn v-function))
  (list fn))

;;------------------------------------------------------------

(def-v-type-class v-user-function (v-function)
  ((code :initform nil :initarg :code :reader v-code)))

(defmethod functions ((fn v-user-function))
  (list fn))

;;------------------------------------------------------------

(defclass v-function-set ()
  ((functions :initform nil :initarg :functions :reader functions)))

(defmethod initialize-instance :after ((set v-function-set)
                                       &key functions &allow-other-keys)
  (assert (every λ(or (typep _ 'v-function) (typep _ 'external-function))
                 functions)
          (functions)
          "Failed to initialize v-function-set:~% functions: ~s" functions))

;;------------------------------------------------------------

(defmethod v-type-of ((func v-function))
  (with-slots (argument-spec return-spec) func
    (assert (listp return-spec))
    (make-instance 'v-function-type
                   :ctv func ;; make the func the compile-time-val in this type
                   :arg-spec argument-spec
                   :return-spec return-spec)))

(defmethod v-type-of ((func-set v-function-set))
  (make-instance 'v-any-one-of
                 :types (mapcar #'v-type-of (functions func-set))
                 :ctv func-set))

(defmethod v-place-function-p ((f v-function))
  (not (null (v-place-index f))))

(defmethod print-object ((object v-function) stream)
  (with-slots (name argument-spec return-spec) object
    (format stream "#<V-FUNCTION ~s ~s -> ~s>"<commit_msg>print-object showing when function-set is empty<commit_after>(in-package :varjo)
(in-readtable :fn.reader)

;;------------------------------------------------------------

(defclass v-function ()
  ((versions :initform nil :initarg :versions :accessor v-versions)
   (argument-spec :initform nil :initarg :arg-spec :accessor v-argument-spec)
   (glsl-string :initform "" :initarg :glsl-string :reader v-glsl-string)
   (glsl-name :initarg :glsl-name :accessor v-glsl-name)
   (return-spec :initform nil :initarg :return-spec :accessor v-return-spec)
   (v-place-index :initform nil :initarg :v-place-index :reader v-place-index)
   (name :initform nil :initarg :name :reader name)
   (implicit-args :initform nil :initarg :implicit-args :reader implicit-args)
   (in-out-args :initform nil :initarg :in-out-args :reader in-out-args)
   (in-arg-flow-ids :initform (error 'flow-ids-mandatory :for :v-function
                                     :code-type :v-function)
                    :initarg :in-arg-flow-ids :reader in-arg-flow-ids)
   (flow-ids :initform (error 'flow-ids-mandatory :for :v-function
                              :code-type :v-function)
             :initarg :flow-ids :reader flow-ids)))

(defmethod functions ((fn v-function))
  (list fn))

;;------------------------------------------------------------

(def-v-type-class v-user-function (v-function)
  ((code :initform nil :initarg :code :reader v-code)))

(defmethod functions ((fn v-user-function))
  (list fn))

;;------------------------------------------------------------

(defclass v-function-set ()
  ((functions :initform nil :initarg :functions :reader functions)))

(defmethod initialize-instance :after ((set v-function-set)
                                       &key functions &allow-other-keys)
  (assert (every λ(or (typep _ 'v-function) (typep _ 'external-function))
                 functions)
          (functions)
          "Failed to initialize v-function-set:~% functions: ~s" functions))

(defmethod print-object ((fs v-function-set) stream)
  (if (null (functions fs))
      (format stream "#<EMPTY-FUNCTION-SET>")
      (call-next-method)))

;;------------------------------------------------------------

(defmethod v-type-of ((func v-function))
  (with-slots (argument-spec return-spec) func
    (assert (listp return-spec))
    (make-instance 'v-function-type
                   :ctv func ;; make the func the compile-time-val in this type
                   :arg-spec argument-spec
                   :return-spec return-spec)))

(defmethod v-type-of ((func-set v-function-set))
  (make-instance 'v-any-one-of
                 :types (mapcar #'v-type-of (functions func-set))
                 :ctv func-set))

(defmethod v-place-function-p ((f v-function))
  (not (null (v-place-index f))))

(defmethod print-object ((object v-function) stream)
  (with-slots (name argument-spec return-spec) object
    (format stream "#<V-FUNCTION ~s ~s -> ~s>"
{'fraction_non_alphanumeric': 0.21669875722037457, 'fraction_numerical': 0.0, 'mean_word_length': 2.0248808893594497, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2197048', 'n_tokens_mistral': 1720, 'n_tokens_neox': 1705, 'n_words': 435}