X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/e45a106df3272c787444bc6f7b8920016b7fc677..refs/heads/mdw/progfmt:/src/builtin.lisp diff --git a/src/builtin.lisp b/src/builtin.lisp index 4d5b5cd..6310741 100644 --- a/src/builtin.lisp +++ b/src/builtin.lisp @@ -278,8 +278,18 @@ static const SodClass *const ~A__cpl[] = { list)) (definst suppliedp-struct (stream) (flags var) + "Declare a `suppliedp' structure VAR containing a bit for each named FLAG. + + The output looks like this: + + struct { + unsigned FLAG: 1; + /* ... */ + } VAR; + + Note that this will not be valid C unless there is at least one flag." (format stream - "~@" + "~@" flags var)) ;; Initialization. @@ -294,18 +304,30 @@ static const SodClass *const ~A__cpl[] = { ((message initialization-message)) 'initialization-effective-method) -(defmethod method-keyword-argument-lists - ((method initialization-effective-method) direct-methods) +(defmethod sod-message-keyword-argument-lists + ((message initialization-message) (class sod-class) direct-methods state) (append (call-next-method) (mapcan (lambda (class) - (let ((initargs (sod-class-initargs class))) + (let* ((initargs (sod-class-initargs class)) + (map (make-hash-table)) + (arglist (mapcar + (lambda (initarg) + (let ((arg (sod-initarg-argument + initarg))) + (setf (gethash arg map) initarg) + arg)) + initargs))) (and initargs - (list (cons (mapcar #'sod-initarg-argument - initargs) - (format nil "initargs for ~A" - class)))))) - (sod-class-precedence-list - (effective-method-class method))))) + (list (cons (lambda (arg) + (info-with-location + (gethash arg map) + "Type `~A' from initarg ~ + in class `~A' (here)" + (argument-type arg) class) + (report-inheritance-path + state class)) + arglist))))) + (sod-class-precedence-list class)))) (defmethod lifecycle-method-kernel ((method initialization-effective-method) codegen target) @@ -410,19 +432,20 @@ static const SodClass *const ~A__cpl[] = { (when (or init initargs) (focus-this-class) (let* ((slot-type (sod-slot-type dslot)) - (slot-default (sod-initializer-value init)) (target (format nil "~A.~A" isl (sod-slot-name dslot))) - (initinst (set-from-initializer target - slot-type - slot-default))) + (initinst (and init + (set-from-initializer + target slot-type + (sod-initializer-value init))))) ;; If there are applicable initialization arguments, ;; check to see whether they were supplied. (dolist (initarg (reverse (remove-duplicates initargs :key #'sod-initarg-name - :test #'string=))) + :test #'string= + :from-end t))) (let ((arg-name (sod-initarg-name initarg))) (setf initinst (make-if-inst (format nil "suppliedp.~A" arg-name) @@ -504,9 +527,11 @@ static const SodClass *const ~A__cpl[] = { instance of `SodClass', and `SodClass' is a subclass of `SodObject' (and an instance of itself)." (let* ((sod-object (make-sod-class "SodObject" nil - (make-property-set :nick 'obj))) + (make-property-set :nick 'obj + :%bootstrapping t))) (sod-class (make-sod-class "SodClass" (list sod-object) - (make-property-set :nick 'cls))) + (make-property-set :nick 'cls + :%bootstrapping t))) (classes (list sod-object sod-class))) ;; Attach the built-in messages.