<commit_before>(in-package :cl-js)

(defvar *env*)

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter *std-types*
    #(:object :function :array :string :arguments :regexp #+js-dates :date :error :type-error
      :reference-error :syntax-error :uri-error :range-error :eval-error :boolean :number))
  (defun type-offset (id)
    (declare (optimize speed (safety 0)))
    (loop :for off :of-type fixnum :below (length (the simple-vector *std-types*)) :do
       (when (eq id (svref *std-types* off)) (return off)))))

(defmacro find-proto (id)
  (let ((std (and (keywordp id) (position id *std-types* :test #'eq))))
    (if std
        `(svref (gobj-proto-vec *env*) ,std)
        `(lookup-prototype ,id))))
(defmacro find-cls (id)
  (let ((std (and (keywordp id) (position id *std-types* :test #'eq))))
    (if std
        `(svref (gobj-class-vec *env*) ,std)
        `(lookup-class ,id))))
(defun lookup-prototype (id)
  (let ((std (position id *std-types* :test #'eq)))
    (or (and std (svref (gobj-proto-vec *env*) std))
        (second (assoc id (gobj-proto-list *env*) :test #'eq))
        (error "No prototype ~a defined." id))))
(defun lookup-class (id)
  (let ((std (position id *std-types* :test #'eq)))
    (or (and std (svref (gobj-class-vec *env*) std))
        (cddr (assoc id (gobj-proto-list *env*) :test #'eq))
        (error "No prototype ~a defined." id))))


;; (Some of this code is *really* unorthogonal, repeating itself a
;; lot. This is mostly due to the fact that we are using different
;; code paths, some of which can assume previously-checked conditions,
;; to optimize.)

(eval-when (:compile-toplevel)
  (declaim (optimize speed (safety 0))))

(defstruct cls prototype)
(defstruct (scls (:constructor make-scls (props prototype)) (:include cls))
  props children)
(defstruct (hcls (:constructor make-hcls (prototype)) (:include cls)))

(defstruct (obj (:constructor make-obj (cls &optional vals)))
  cls (vals (make-array 4)))
(defstruct (vobj (:constructor make-vobj (cls value)) (:include obj))
  value)
(defstruct (fobj (:constructor make-fobj (cls proc new-cls &optional vals)) (:include obj))
  proc new-cls)
(defstruct (cfobj (:constructor make-cfobj (cls proc new-cls make-new &optional vals)) (:include fobj))
  make-new)
(defstruct (gobj (:constructor make-gobj (cls vals proto-vec class-vec)) (:include obj))
  proto-vec class-vec proto-list required)
(defstruct (aobj (:constructor make-aobj (cls arr)) (:include obj))
  arr)
(defstruct (reobj (:constructor make-reobj (cls proc scanner global)) (:include fobj))
  scanner global)
#+js-dates
(defstruct (dobj (:constructor make-dobj (cls time zone)) (:include obj))
  time zone)
(defstruct (argobj (:constructor make-argobj (cls list length callee)) (:include obj))
  list length callee)

(defmethod print-object ((obj obj) stream) (format stream "#<js obj>"))

;; Slots are (offset . flags) conses for scls objects, (value . flags) conses for hcls
(defconstant +slot-ro+ 1)<commit_msg>fix non-optional arg in struct constructor<commit_after>(in-package :cl-js)

(defvar *env*)

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter *std-types*
    #(:object :function :array :string :arguments :regexp #+js-dates :date :error :type-error
      :reference-error :syntax-error :uri-error :range-error :eval-error :boolean :number))
  (defun type-offset (id)
    (declare (optimize speed (safety 0)))
    (loop :for off :of-type fixnum :below (length (the simple-vector *std-types*)) :do
       (when (eq id (svref *std-types* off)) (return off)))))

(defmacro find-proto (id)
  (let ((std (and (keywordp id) (position id *std-types* :test #'eq))))
    (if std
        `(svref (gobj-proto-vec *env*) ,std)
        `(lookup-prototype ,id))))
(defmacro find-cls (id)
  (let ((std (and (keywordp id) (position id *std-types* :test #'eq))))
    (if std
        `(svref (gobj-class-vec *env*) ,std)
        `(lookup-class ,id))))
(defun lookup-prototype (id)
  (let ((std (position id *std-types* :test #'eq)))
    (or (and std (svref (gobj-proto-vec *env*) std))
        (second (assoc id (gobj-proto-list *env*) :test #'eq))
        (error "No prototype ~a defined." id))))
(defun lookup-class (id)
  (let ((std (position id *std-types* :test #'eq)))
    (or (and std (svref (gobj-class-vec *env*) std))
        (cddr (assoc id (gobj-proto-list *env*) :test #'eq))
        (error "No prototype ~a defined." id))))


;; (Some of this code is *really* unorthogonal, repeating itself a
;; lot. This is mostly due to the fact that we are using different
;; code paths, some of which can assume previously-checked conditions,
;; to optimize.)

(eval-when (:compile-toplevel)
  (declaim (optimize speed (safety 0))))

(defstruct cls prototype)
(defstruct (scls (:constructor make-scls (props prototype)) (:include cls))
  props children)
(defstruct (hcls (:constructor make-hcls (prototype)) (:include cls)))

(defstruct (obj (:constructor make-obj (cls &optional vals)))
  cls (vals (make-array 4)))
(defstruct (vobj (:constructor make-vobj (cls &optional value)) (:include obj))
  value)
(defstruct (fobj (:constructor make-fobj (cls proc new-cls &optional vals)) (:include obj))
  proc new-cls)
(defstruct (cfobj (:constructor make-cfobj (cls proc new-cls make-new &optional vals)) (:include fobj))
  make-new)
(defstruct (gobj (:constructor make-gobj (cls vals proto-vec class-vec)) (:include obj))
  proto-vec class-vec proto-list required)
(defstruct (aobj (:constructor make-aobj (cls arr)) (:include obj))
  arr)
(defstruct (reobj (:constructor make-reobj (cls proc scanner global)) (:include fobj))
  scanner global)
#+js-dates
(defstruct (dobj (:constructor make-dobj (cls time zone)) (:include obj))
  time zone)
(defstruct (argobj (:constructor make-argobj (cls list length callee)) (:include obj))
  list length callee)

(defmethod print-object ((obj obj) stream) (format stream "#<js obj>"))

;; Slots are (offset . flags) conses for scls objects, (value . flags) conses for hcls
(defconstant +slot-ro+ 1)
{'fraction_non_alphanumeric': 0.16393442622950818, 'fraction_numerical': 0.001324722636198046, 'mean_word_length': 4.197934595524957, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7672347', 'n_tokens_mistral': 2082, 'n_tokens_neox': 2006, 'n_words': 701}