Commit graph

8083 commits

Author SHA1 Message Date
Daniel Kochmański
5c02111bfc clos: finalize-inheritance: don't always change the class-slots identity
Specification of M-I-O explicitly says that instances are not made
when "local slots" are compatible. This change is necessary to prevent
infinite recursion as reported in #568 without breaking the
finalization protocol, because currently class-slots are used as a
signature for its instances (and that's how being obsolete is
determined).
2020-04-19 14:34:23 +02:00
Daniel Kochmański
bee9e8db55 clos: finalize-inheritance: revert a non-conforming change
finalize-inheritance is expected to run regardless of the fact that
class has been already finalized. I suppose that it is in case when
compute-slot-* methods are specialized to return something else.
2020-04-19 14:34:23 +02:00
Daniel Kochmański
5feb42dfa3 clos: reinitialize-instance: don't remove generic functions
Local function REMOVE-OPTIONAL-SLOT-ACCESSORS removed generic
functions after removing methods while redefining the class if said
generic functions have no other methods. There is nothing in the spec
what would justify it, so we don't fmakunbound these functions
anymore.
2020-04-19 14:34:23 +02:00
Daniel Kochmański
681caade84 clos: allocate-instance: add a comment in allocate-instance
As pointed out by Dr. Robert Strandth initargs argument may be passed
to allocate-instance only after the class has been already finalized,
and indeed we finalize it in make-instance. To be on a safe side,
unlike CLASP, we still check whether the class is already finalized in
case of someone calling allocate-instance outside the make-instance
method.
2020-04-19 14:34:23 +02:00
Daniel Kochmański
3ec02d6daf clos: finalize-unless-forward: check for the class itself first
That was probably a typo, because finalize-unless-forward checked only
the class parents if they were forward-referenced classes, not the
class itself.
2020-04-19 14:34:23 +02:00
Daniel Kochmański
d45f079c3c clos: cleanup: remove unused file, use when-let
File macros.lsp was used for bootstrapping in the past, but it is not
loaded anymore.
2020-04-19 14:34:23 +02:00
Daniel Kochmański
735d49bfd1 tests: improve some tests
- extend tests for make-instances-obsolete
- add a metastability test for the standard-method finalization
- fix tests which assume that metaclasses are finalized eagerly
2020-04-19 14:34:23 +02:00
Daniel Kochmański
34cd3dc221 Merge branch 'getaddrinfo-fixes' into 'develop'
Minor fixes for get-host-by-name from sockets

See merge request embeddable-common-lisp/ecl!199
2020-04-19 12:33:48 +00:00
Marius Gerbershagen
beadd585ce sockets: don't return the same address multiple times in get-host-by-name 2020-04-19 10:46:03 +02:00
Marius Gerbershagen
5451f73bb8 sockets: don't call getaddrinfo with AI_ADDRCONFIG
On linux, using AI_ADDRCONFIG causes getaddrinfo to return no ip
address for localhost when only the loopback connection is
active. Also, we only get ipv4 addresses anyway due to specifying
ai_family = AF_INET, therefore the AI_ADDRCONFIG flag in not necessary
anyway.
2020-04-19 10:46:03 +02:00
Daniel Kochmański
1fe88da7f1 Merge branch 'close-with-input-from-string-stream' into 'develop'
Always close stream in with-input-from-string

See merge request embeddable-common-lisp/ecl!197
2020-04-18 15:59:26 +00:00
Moritz Petersen
17f183873d Add a regression test for the bug described in !197 2020-04-18 17:49:46 +02:00
Moritz Petersen
72560efa5a Always close stream in with-input-from-string & Cosmetic changes
The Common Lisp Standard defines that with-input-from-string always closes the
input stream that it creates. But with the current definition it would only be
closed in the case of an index variable being provided.

This change wraps the code for both cases (index given or not) in a unified
unwind-protect form, updates the index if present, and always closes the
stream. It also unifies the processing of declarations.

Downcase code & fix indentation:

Set the uppercased code in lower case to harmonise appearance and increase
readability. Differentiated indentation for the first forms in unwind-protect
and multiple-value-prog1 helps to understand their special meaning.
2020-04-18 17:44:41 +02:00
Marius Gerbershagen
3e4c253a7d Merge branch 'fix-572' into 'develop'
Fix 572

Closes #572

See merge request embeddable-common-lisp/ecl!196
2020-04-12 08:29:55 +00:00
Daniel Kochmański
958a1c9f38 tests: add a regression test for #572 2020-04-11 20:02:00 +02:00
Daniel Kochmański
322eaddfa2 finalize-inheritance: guard against treating class as its own parent
Fix 49b244db78 assumed, that the class
itself is first in the CPL list, and this assumption while correct in
light of MOP specification may be broken by a non-conforming code.

Bringing back the check whether (eq x class) when we try to finalize
the "top-most class which is not yet finalized" does not break
conforming code whiel still enabling slihgtly broken code to work.

Fixes #572.
2020-04-11 20:01:01 +02:00
Marius Gerbershagen
abe2a2811f Merge branch 'fix-571' into 'develop'
Fix 571

Closes #571

See merge request embeddable-common-lisp/ecl!195
2020-04-09 16:51:47 +00:00
Marius Gerbershagen
0e6016559e Merge branch 'improve-congruency' into 'develop'
congruent-lambda-p: be more permissive with the congruency test

See merge request embeddable-common-lisp/ecl!194
2020-04-09 16:47:35 +00:00
Daniel Kochmański
b64da63efd tests: add a test for the change in congruent-lambda-p 2020-04-08 22:19:25 +02:00
Daniel Kochmański
896e7c5895 congruent-lambda-p: be more permissive with the congruency test
Lambda list congruency is described here:

- 7.6.4 Congruent Lambda-lists for all Methods of a Generic Function
- 7.6.5 Keyword Arguments in Generic Functions and Methods

Previously we have tested conformingly for the fourth point:

  4. If the generic function lambda list mentions &key, each method
  must accept all of the keyword names mentioned after &key, either by
  accepting them explicitly, by specifying &allow-other-keys, or by
  specifying &rest but not &key. Each method can accept additional
  keyword arguments of its own. The checking of the validity of
  keyword names is done in the generic function, not in each method. A
  method is invoked as if the keyword argument pair whose name is
  :allow-other-keys and whose value is true were supplied, though no
  such argument pair will be passed.

The fifth point mentions that if either the generic function or any
applicable method has &allow-other-keys, then function may be called
with extra keyword arguments:

  5. The use of &allow-other-keys need not be consistent across lambda
  lists. If &allow-other-keys is mentioned in the lambda list of any
  applicable method or of the generic function, any keyword arguments
  may be mentioned in the call to the generic function.

This change makes the fourth point more consistent with the fifth,
however it is *not* conformant when it is read literally. Reasons for
this change:

- this behavior is exhibited at least by SBCL and CCL, so we'll be
  more compatible with a non-conformant code tested on them

- the change won't impact results of a correct program unless it
  depends on the defmethod signaling an error condition
2020-04-08 22:18:44 +02:00
Daniel Kochmański
b41b60e7bf tests: add a regression test for #571 2020-04-08 22:02:25 +02:00
Daniel Kochmański
d769494674 defmethod: do not evaluate the method at the compilation time
Fixes #571.
2020-04-08 22:01:21 +02:00
Daniel Kochmański
aa34ab7119 compiler: rewrite clos::need-to-make-load-form-p
Function is rewritten in C in compiler.d to remove a dependency
between the bytecodes compiler and the clos module. It may be more
performant thanks to more precise type handing, however we use a list
instead of a hashtable, so it may be slower with lookup. To assess
that we should run some benchmarks against real code -- rewriting C
code to work with a hash table should be trivial.

clos::need-to-make-load-form-p is now si::need-to-make-load-form-p and
may be called from C code as si_need_to_make_load_form_p.
2020-04-08 22:01:16 +02:00
Marius Gerbershagen
8fc3b4a56e Merge branch 'fix-568' into 'develop'
Fix 568

Closes #568

See merge request embeddable-common-lisp/ecl!193
2020-04-06 18:08:59 +00:00
Daniel Kochmański
cdf55007a4 tests: add a regression test for the issue #568
- also fix test which assumed constant unreadable representation of
  the object of class compiler-test-class
2020-04-05 15:13:59 +02:00
Daniel Kochmański
49b244db78 finalize-inheritance: do not refinalize when already finalized
We've reinitialized the class even when it was already finalized and
none of its parents has changed with the recomputed information.

That leads to replacing the class slots with a result of COMPUTE-SLOTS
and in effect changing the INSTANCE-SIG (see src/clos/change.lsp).
Next time when ENSURE-UP-TO-DATE-INSTANCE is called (i.e from the
STANDARD-INSTANCE-ACCESS), then the instance is reinitalized.

Behavior was the most notable when we had tried to re-finalize the
STANDARD-EFFECTIVE-SLOT-DEFINITION class, because then /its new/ slots
were by definition obsolete after calling setf on this class and
unbound, what leads to an infinite recursion when we try to signal
unbound-slot condition.

Fixes #568.
2020-04-05 15:06:55 +02:00
Daniel Kochmański
f532057a83 print-object: when printing the standard object print its address
Now instead of a default printer #<a foo> we have the identity
information #<a foo 0x56123571d240>. That is certainly useful for
printing when we have lists of instances of the same class.
2020-04-05 14:15:34 +02:00
Daniel Kochmański
3891bcc76b dpp: ensure null terminating character
putting \0 at the end of the string does not cut it.
2020-03-28 18:16:09 +01:00
Daniel Kochmański
fa24f95f7b Merge branch 'fix-562' into 'develop'
Compiler improvements

See merge request embeddable-common-lisp/ecl!190
2020-03-28 08:16:53 +00:00
Marius Gerbershagen
b94d07a072 Merge branch 'fix-logical-pathname' into 'develop'
fix logical-pathname.3 regression

See merge request embeddable-common-lisp/ecl!192
2020-03-27 20:12:16 +00:00
Marius Gerbershagen
320d3acdfd tests: don't pollute commonly used variables in the global environment in cmp.0030.make-load-form 2020-03-27 20:54:32 +01:00
Daniel Kochmański
6473d70ff3 fix logical-pathname.3 regression
We've abandoned original filename in favour of the coerced path. That
is not correct.
2020-03-27 13:57:23 +01:00
Daniel Kochmański
554855c8a4 compiler.d: add a static function push to a safe list handling
- the function push complements the function pop
- rename the local macro push from c_labels_flet to push_back to
  better reflect its purpose
2020-03-27 11:48:34 +01:00
Daniel Kochmański
b86a067788 dpp: add a syntax for parsing strings
@"foo" will expand to ecl_make_constant_base_string("foo", -1) now.
That saves some typing during testing when we want to feed a string to
the cl_format and other CL functions opearting on strings.

Now:

cl_format(3, @"~a: ~s", obj1, obj2);

Then:

cl_object str = ecl_make_constant_base_string("~a: ~s", -1);
cl_format(3, str, obj1, obj2);
2020-03-27 11:48:00 +01:00
Daniel Kochmański
379254456e cmp: make-load-form: detect circular dependencies
Init forms are deferred when possible. This change solves two problems:

- init forms using uninitialized constant boxes
- make forms not signaling an error when circular

Partial fix for #562 (we need to fix bytecodes compiler too).
2020-03-27 11:33:53 +01:00
Daniel Kochmański
3b6dd501e6 make-load-form: cons: initialize car in init form
This way we do not need to worry about cons recursion in make forms.
2020-03-27 11:33:53 +01:00
Daniel Kochmański
dcdb53f29e tests: add tests for #562 and #565 2020-03-27 11:33:53 +01:00
Daniel Kochmański
dade0b4688 cosmetic: cmp: refactor function add-object
Function is hopefully more readable now.
2020-03-27 11:33:51 +01:00
Daniel Kochmański
2b5b2374b6 util: add binding macros from alexandria for convenience
if-let, when-let, when-let* are well known utilities and we have
plenty of places where we could use these idioms.
2020-03-26 13:42:37 +01:00
Daniel Kochmański
4c7658a6fe Merge branch 'minor-compiler-fixes' into 'develop'
Fix some minor compiler bugs

Closes #545

See merge request embeddable-common-lisp/ecl!191
2020-03-26 12:41:06 +00:00
Marius Gerbershagen
91d251a7ba cmp: correctly handle unused special &rest variables
Even when the variable is not used, we still have to do the binding.
2020-03-21 13:05:23 +01:00
Marius Gerbershagen
14d46da134 cmp: fix evaluation order bugs in compiler macros 2020-03-21 11:44:01 +01:00
Marius Gerbershagen
dda466dd0e cmp: allow :allow-other-keys for functions with &key but zero keywords
Functions such as
(defun f (&key) ...)
would give an error when called like (f :allow-other-keys ...).
2020-03-20 21:29:18 +01:00
Marius Gerbershagen
a9065d1d8e cmp: fix closure type for local functions calling closures
When a local function calls a closure it has to be a closure too. Thus
when updating the closure type for a function f, we have to possibly
update also all functions referencing f.

Fixes #545.
2020-03-18 22:00:57 +01:00
Marius Gerbershagen
1d7551c773 doc: document ECLDIR and ecl_import/release_current_thread
Also reorganize the embedding reference into two subsubsections.
2020-03-14 19:56:51 +01:00
Marius Gerbershagen
d7529988f0 numbers: add workaround for log1p
log1pl is not present on NetBSD.
2020-03-12 21:29:12 +01:00
Marius Gerbershagen
1aeb7823e8 cmp: add explicit type suffixes for emitted integer constants in C code
According to the C99 standard, compilers are supposed to automatically
choose the correct type. However, for the C89 standard explicit suffixes
are needed for long longs. Guess what standard msvc follows...
2020-03-07 22:26:44 +01:00
Marius Gerbershagen
f776bd8615 fix daylight savings time detection for win64 2020-03-07 22:26:43 +01:00
Marius Gerbershagen
f76bd95786 fix array dimension limit for msvc win64 2020-03-07 22:26:43 +01:00
Marius Gerbershagen
f936415c0d process.d: add missing include 2020-03-02 22:07:29 +01:00