chiark / gitweb /
Merge branches 'mdw/kwargs' and 'mdw/c11'
authorMark Wooding <mdw@distorted.org.uk>
Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 29 May 2016 14:33:27 +0000 (15:33 +0100)
* mdw/kwargs: (29 commits)
  New feature: initialization keyword arguments.
  src/method-{proto,impl}.lisp: New `method-keyword-argument-lists' protocol.
  New feature: proper object lifecycle protocol; init and teardown fragments.
  src/builtin.lisp: Bind `me' around slot initializers, and define the order.
  Replace the `init' class-slot function with an `init' message.
  Compatibility: the `init' function no longer calls `imprint' for you.
  src/method-{proto,impl}.lisp: Introduce `effective-method-live-p' protocol.
  doc/runtime.tex, lib/sod.3: Restructure the runtime library reference.
  doc/concepts.tex: Reorganize the instance lifecycle material.
  doc/: Miscellaneous clarifications and rewordings.
  doc/concepts.tex: Don't highlight `primary' as literal, because it's not.
  src/: Abolish the distinction between different kinds of initializers.
  src/method-{proto,impl}.lisp: Abolish `sod-message-no-varargs-tail'.
  New feature: messages with keyword arguments!
  lib/: Pure C machinery for handling `keyword arguments' to functions.
  doc/runtime.tex: Demote the object-system support stuff to a section.
  src/c-types-*.lisp: New type for functions which take keyword arguments.
  src/c-types-parse.lisp (parse-declarator): Refactor argument list parsing.
  src/c-types-parse.lisp (parse-declarator): Explain how it works.
  src/: New function `reify-variable-argument-tail'.
  ...

* mdw/c11:
  src/c-types-impl.lisp, src/c-types-parse.lisp: Support C11 `_Alignas'.
  src/c-types-{proto,impl,parse}.lisp: Add `storage specifiers' to the model.
  src/c-types-{impl,parse}.lisp: Support C11 `_Atomic'.
  src/c-types-{impl,parse}.tex: Support `_Atomic' types.
  src/c-types-parse.lisp: Introduce a pluggable parser for declspecs.
  src/c-types-parse.lisp: Hoist up the `ds-FOO' methods for raw types.
  src/c-types-parse.lisp: Improve handling of compatibility keywords.
  src/final.lisp: Add function for interactively testing type parsing.
  src/c-types-proto.lisp, src/c-types-impl.lisp: Qualifier name protocol.
  src/module-parse.lisp (parse-raw-class-item): Commit after declarator.
  Add a new class slot `align', holding the instance layout alignment.
  src/c-types-impl.lisp (make-or-intern-c-type): Pull out useful function.
  src/c-types-parse.lisp, src/c-types-proto.lisp: Some minor cleanups.
  src/parser/parser-proto.lisp: Add functions returning standard parsers.
  src/parser/: Allow parsers to commit to a parse while peeking.
  doc/clang.tex: Improve documentation of C type spec expansion.

Conflicts:
doc/SYMBOLS (regenerated)
doc/syntax.tex (hand-merge; extra parameter to <declarator>)
lib/sod.h (simple hand-merge)
src/sod-module.5 (extra parameter to <declarator>, added by hand)

12 files changed:
1  2 
doc/SYMBOLS
doc/clang.tex
doc/structures.tex
doc/syntax.tex
lib/sod-structs.3
lib/sod.h
src/builtin.lisp
src/c-types-impl.lisp
src/c-types-parse.lisp
src/c-types-proto.lisp
src/module-parse.lisp
src/sod-module.5

diff --cc doc/SYMBOLS
index 00bfb3b7ae0fdb6acaf8d549efe58df807a81fba,20e2eef1918dc97e4d4dc9e6b7c0c347badc514b..cec9fa3023e8782bb238ed69a510df5101d9e8c2
@@@ -20,11 -23,10 +23,12 @@@ c-types-impl.lis
    bool                                          c-type
    c-array-dimensions                            generic
    c-array-type                                  class
+   c-atomic-type                                 class
    c-enum-type                                   class
    c-function-arguments                          generic
 +  c-function-keywords                           generic
    c-function-type                               class
 +  c-keyword-function-type                       class
    c-pointer-type                                class
    c-struct-type                                 class
    c-tagged-type-kind                            generic
@@@ -624,8 -600,9 +642,10 @@@ cl:
        c-type
          c-array-type
          c-function-type
 +          c-keyword-function-type
+         c-storage-specifiers-type
          qualifiable-c-type
+           c-atomic-type
            c-pointer-type
            simple-c-type
              c-class-type
@@@ -730,8 -701,9 +750,11 @@@ c-fragment-tex
    c-fragment
  c-function-arguments
    c-function-type
 +c-function-keywords
 +  c-keyword-function-type
+ c-qualifier-keyword
+   (eql :atomic)
+   cl:symbol
  c-tagged-type-kind
    c-enum-type
    c-struct-type
@@@ -743,10 -715,12 +766,13 @@@ c-type-clas
  c-type-equal-p
    t t
    c-array-type c-array-type
+   c-atomic-type c-atomic-type
    c-class-type c-class-type
    c-function-type c-function-type
 +  c-keyword-function-type c-keyword-function-type
    c-pointer-type c-pointer-type
+   c-storage-specifiers-type c-type
+   c-type c-storage-specifiers-type
    qualifiable-c-type qualifiable-c-type
    simple-c-type simple-c-type
    tagged-c-type tagged-c-type
@@@ -862,8 -839,7 +892,7 @@@ compute-islot
    sod-class sod-class
  compute-method-entry-functions
    basic-effective-method
 -  simple-effective-method
 +  effective-method
-   simple-effective-method
  compute-sod-effective-method
    sod-message sod-class
  compute-vtable
@@@ -1261,9 -1207,10 +1301,11 @@@ pprint-c-storage-specifie
  pprint-c-type
    t t t
    c-array-type t t
+   c-atomic-type t t
    c-function-type t t
 +  c-keyword-function-type t t
    c-pointer-type t t
+   c-storage-specifiers-type t t
    simple-c-type t t
    tagged-c-type t t
  primary-method-class
diff --cc doc/clang.tex
index 6f7e218d2abb09478fe0291ebf82c9b0065d4cd3,ce342653fdcc0b09fccf7975535880a3fafb6bcb..0c6c4bb6c7a9cfe8852c4555d3e4dd3915091650
@@@ -46,10 -46,10 +46,11 @@@ The class hierarchy is shown in~\xref{f
            @|c-struct-type| \\
            @|c-union-type| \\
            @|c-enum-type| \- \\
+         @|c-atomic-type| \\
          @|c-pointer-type| \- \\
        @|c-array-type| \\
 -      @|c-function-type|
 +      @|c-function-type| \\ \ind
 +        @|c-keyword-function-type| \-
    \end{tabbing}}
    \caption{Classes representing C types}
  \label{fig:codegen.c-types.classes}
index 42739efea5e63d254473afddbdda26b99fa1c80f,b63a3362aa28e42a7567ba4cbde9a384e141bd16..3826bdc8572e37923d3e6d25935379cd8d9f7135
@@@ -204,7 -139,9 +204,8 @@@ recommended
         const char *name; \\
         const char *nick; \\
         size_t initsz; \\
+        size_t align; \\
         void *(*imprint)(void *@<p>); \\
 -       void *(*init)(void *@<p>); \\
         size_t n_supers; \\
         const SodClass *const *supers; \\
         size_t n_cpl; \\
diff --cc doc/syntax.tex
index 3034b1e9caf393c9bca91e80361ef28e89f63af8,b8ae7977792376c4751e0ef297901076e734b124..21f835e618ebe801a398ecd3700f42fbeff93627
@@@ -509,11 -522,13 +522,14 @@@ All of these have their usual C meaning
  
  <argument> ::= @<declaration-specifier>^+ <argument-declarator>
  
 -<abstract-declarator> ::= <declarator>$[\epsilon]$
++<abstract-declarator> ::= <declarator>$[\epsilon, \mbox{@<argument-list>}]$
+ <argument-declarator> ::= <declarator>$[\mbox{@<identifier> @! $\epsilon$}]$
 +<argument-declarator> ::=
 +  <declarator>$[\mbox{@<identifier> @! $\epsilon$}, \mbox{@<argument-list>}]$
  
 -<simple-declarator> ::= <declarator>$[\mbox{@<identifier>}]$
 -
 -<dotted-name> ::= <identifier> "." <identifier>
 +<simple-declarator> ::=
 +  <declarator>$[\mbox{@<identifier>}, \mbox{@<argument-list>}]$
  \end{grammar}
  
  The declarator syntax is taken from C, but with some differences.
index 029cabde8be5ec4b0a9e9c481cbe5816e79609ce,5624d337fe1967276408207565010a958e49b7f2..35f668f471e6024f060b57d12b324ddedfd29567
@@@ -105,7 -95,9 +105,8 @@@ struct SodObject__ilayout 
  \h'8n'const char *name;
  \h'8n'const char *nick;
  \h'8n'size_t initsz;
+ \h'8n'size_t align;
  \h'8n'void *(*imprint)(void *\fIp\fB);
 -\h'8n'void *(*init)(void *\fIp\fB);
  \h'8n'size_t n_supers;
  \h'8n'const SodClass *const *supers;
  \h'8n'size_t n_cpl;
diff --cc lib/sod.h
index 894581034835f267486aa2c085a203db6a749f3c,943ed4b2434f43e449a5d3e1708c14195e4540bb..45886261949e4f9eb1984fa1c97b57832d1e5895
+++ b/lib/sod.h
  /* We're going to want to make use of this ourselves. */
  SOD__VARARGS_MACROS_PREAMBLE
  
+ /* --- @SOD__ALIGNOF@ --- *
+  *
+  * Arguments: @type@ = a C type name, consisting of declaration specifiers
+  *                    and `*[QUALIFIERS]' declarator operators
+  *
+  * Returns:   A sufficient alignment for objects of the given @type@, as a
+  *            @size_t@.
+  */
+ #if __STDC_VERSION__ >= 201112
+ #  define SOD__ALIGNOF(type) _Alignof(type)
+ #elif SOD__GCC_P(4, 7)
+ #  define SOD__ALIGNOF(type) __extension__ _Alignof(type)
+ #elif defined(__GNUC__)
+ #  define SOD__ALIGNOF(type) __alignof__(type)
+ #else
+ #  define SOD__ALIGNOF(type)                                          \
+ offsetof(struct { char sod__x; type sod__y; }, sod__y)
+ #endif
 +/* --- @SOD__IGNORE@ --- *
 + *
 + * Arguments: @var@ = some variable name
 + *
 + * Use:               Suppress any warning that @var@ isn't used.
 + */
 +
 +#define SOD__IGNORE(var) ((void)(var))
 +
  /* --- @SOD__CAR@ --- *
   *
   * Arguments: @...@ = a nonempty list of arguments
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 66937dacc910d4b0b96c1d2f34e9dd47156ed949,18375246943fa78275580323691a2b5c76af1c05..949e781593dfb0d4f93f654a131b179dc17f4e1c
@@@ -877,9 -890,13 +913,13 @@@ and one of the following, up to reorder
  .IR declaration-specifier \*+
  .I argument-declarator
  .br
 -.IR declarator [\*e]
+ .I abstract-declarator
+ ::=
++.IR declarator "[\*e, " argument-list ]
+ .br
  .I argument-declarator
  ::=
 -.IR declarator [ identifier " | \*e]"
 +.IR declarator [ identifier " | \*e, " argument-list ]
  .br
  .I simple-declarator
  ::=