Commit graph

90 commits

Author SHA1 Message Date
Daniel Kochmański
f0046250f8 reader: store separately macro and a dispatch table
This improves code readibility, because dispatch macro characters are built on
top of "normal" macro characters.
2026-03-11 08:42:05 +01:00
Daniel Kochmański
c1092b4728 reader: add a new object to the system ecl_token
It represents unparsed token constructed by the reader.
2026-03-11 08:42:05 +01:00
Daniel Kochmański
ad2e7a6e4b core: move defacto constants from cl_core structure to global space 2026-03-11 08:42:04 +01:00
Marius Gerbershagen
d4994b33f0 cmp: fix incorrect coercion of base strings to extended strings
The compiler was coercing base strings to extended strings when
encountering them as literal objects in compiled files. According to
CLHS 3.2.4.2.2, we need to preserve the actual element type (after
upgrading) of arrays during compilation. For ECL, the actual array
element type of a base-string is base-char and therefore we can't
change this to an extended string.

Actually fixing this requires some work since we use the reader to
store a printed representation of the string in the compiled file. The
reader string syntax always returns an extended string (There is a
comment in the code which claims that this is implied by CLHS 2.4.5. I
am not quite sure if that is really true but for backwards
compatibility I don't want to change this). We thus introduce a new
syntax #"..." for base strings which is used when reading objects from
compiled files. To prevent the new syntax from leaking outside of this
context, we also introduce a new readtable.
2026-02-14 20:36:49 +01:00
Daniel Kochmański
600901da05 bytecodes: add a new slot nlcl denoting the maximal number of locals
Currently it is initialized to NIL, the next commit will assign to it a correct
value.
2025-05-09 13:55:59 +02:00
Daniel Kochmański
92772b1afd bytecmp: implement flat closures
This commit replaces capturing whole LEX with an explicit vector of closed
variables. We introduce a set of additional opcodes that deal with closed
entities. Locals are referred as lcl and closed variables as lex.
2025-03-27 22:45:34 +01:00
Daniel Kochmański
1102e58e0e bignum: replace numerous references to mpz with _ecl_big trampolines 2025-01-20 12:39:59 +01:00
Daniel Kochmański
295dfc0cd8 printer: fix the write_ugly method for bclosure
We've made an implicit cast from bclosure to bytecodes, so instead of a name
we've printed bytecodes itself.

Except from thsi fix we also write the closure address to make it possible to
distinguish two different closures over the same function.
2024-12-18 10:47:17 +01:00
Daniel Kochmański
3e37843a33 cleanup: update license to lgpl-2.1+ in both headers and text 2024-01-14 12:22:27 +01:00
Marius Gerbershagen
d437bd0779 speed up looking up and setting values of dynamic variables
Introduce ecl_cmp_symbol_value and ecl_cmp_setq which do the minimal
amount of work needed to implement symbol-value and setq for dynamic
variables which we have checked to be non-null and of type symbol in
the compiler.

Also introduce a type check in ecl_symbol_value to be consistent with
ecl_setq which also checks the type. These two functions are mainly
used for the embedding interface now, so for that reason it is also
useful to have a type check in there.
2023-10-30 12:01:18 +01:00
Marius Gerbershagen
3a0d818c0e printer: print zero after decimal point in exponential notation if there are no other trailing digits
Previously for example (prin1 1.0e-8) would result in 1.e-8. However,
the ANSI standard (see CLHS section 22.1.3.1.3) specifies that there
has to be at least one digit after the decimal point therefore we now
print 1.0e-8.
2023-01-21 17:43:48 +01:00
Marius Gerbershagen
763369ee84 float_to_digits.d: add some comments 2022-09-18 16:02:47 +02:00
Daniel Kochmański
4e9fab94eb ecl_bignum: access the internal object with a macro ecl_bignum
This provides a better data encapsulation and is more portable. Moreover it is
consistent with how we handle other boxed values like ecl_doublefloat.
2022-05-06 10:13:08 +02:00
Marius Gerbershagen
8f51683516 printer: don't pretty print stuff in _ecl_write_list
The pretty printer should handle this and we should not pretty print
objects if *pretty-print* is false.

Closes #673.
2022-01-31 21:05:27 +01:00
Marius Gerbershagen
e72ef09e78 printer: fix printing of symbols with non-ascii names
Bug was introduced in commit c6b4296bb8
in converting buffer_write_char from a macro to an inline
function. Problem reported by Vladimir Sedach on the ecl-devel mailing
list.
2020-05-06 21:04:28 +02:00
Marius Gerbershagen
c6b4296bb8 cosmetic: fix some compiler warnings 2020-04-29 20:35:37 +02:00
Marius Gerbershagen
693ce14130 printer: remove redundancies between pretty and ordinary printer 2019-08-18 19:31:58 +02:00
Daniel Kochmański
6e5016dcb8 hash-table: add extension for generic predicates
Added:
- implementation
- test
- documentaiton entries

Additionally:
- remove #if 0 code branches (unused clutter)
- bring up-to-date help.lsp file for hints in slime
- wrap synchronized access in unwind protect
- write_ugly did not carry extensions in the printer
2019-05-25 09:56:08 +02:00
Daniel Kochmański
ea87100a06 long-float: remove conditionalization
Many parts of the source code were bent backward to support builds
without long floats which are always present given we depend expect
c99 compiler.

The corresponding C macros (ECL_LONG_FLOAT) and the *feature*
entry (:long-float) are marked as deprecated in the documentation.
2019-05-24 21:04:59 +00:00
Daniel Kochmański
51594b8037 complex-float: print like any other complex number
During printing we cons new floats for imag and real part. We could
opencode that but that would add a lot of code for a little gain. If
this proves to be a real bottleneck we will refactor float printing.
2019-05-15 16:35:16 +02:00
Daniel Kochmański
e1adfd2794 numeric tower: merge <complex float> with <complex>
cl_type_of: give better results for (type-of <complex>)

Instead of simply returning complex we return:

  (complex real)

when code is built without complex float support, and otherwise

  (complex rational)
  (complex single-float)
  (complex double-float)
  (complex long-float)

New functions:
- ecl_to_csfloat
- ecl_to_cdfloat
- ecl_to_clfloat
2019-05-15 16:35:16 +02:00
Daniel Kochmański
a0a92dc2af complex float: add a new types and builtin classes
What has changed:

- new types si:complex-float, si:complex-single-float,
  si:complex-double-float and si:complex-long-float
- new builtin classes long-float (for completness) and
  si:complex-float
- new internal function si:complex-float and si:complex-float-p for
  constructing complex floats (both arguments must be of the same
  float type) and a type predicate
- printer for new types (right now it conses, see below)
- a new feature :complex-float
- a new type is recognized as a type disjoint of complex and real

- cleanup: +built-in-type-list+: remove some redundancy
  For instance instread of saying
    (real (or integer single-float double-float ratio))
  We say
    (real (or integer float ratio))
  etc.

Flaws which will be fixed in upcoming commits:

- complex-float hierarchy is independent of the complex hierarchy
- ecl_make_complex_float could be replaced by _ecl_make_complex_*float
- write_complex_float allocates new objects for printing
- write_complex_float does print unreadable object
- math dispatchers doesn't recognize the object

Testing things out:

> (si:complex-float 0.0d0 0.0d0)
; #<CF(0.0d0 0.0d0)>
> (si:complex-float 0.0d0 0.0s0)       ; signals type error
> (+ (si:complex-float 0.0d0 0.0d0) 1) ; signals type error

lisp runtime: make si_complex-float a subtype of a number.
2019-05-13 19:48:54 +02:00
Daniel Kochmański
f78cb49def complex float: rename cl_lispunion member complex to gencomplex
Complex is a macro specified in complex.h for c99 to simplify using
_Complex type. This file also contains functions to work on complex
floats. To avoid conflicts we rename internal name complex to
gencomplex and update all references to it.
2019-05-06 08:17:33 +02:00
Daniel Kochmański
6ecd2473c4 complex float: add types and structures to core runtime
t_csfloat - ecl_csfloat,
t_cdfloat - ecl_cdfloat,
t_clfloat - ecl_clfloat.
2019-05-06 08:17:33 +02:00
Marius Gerbershagen
aa5ed8bc7b printer: ensure that we generate enough digits for floats
When the number of digits was not specified, we were sometimes
outputting a number that was exactly halfway between the exact value
and the next higher float. When reading that number in again, one
would get a different value due to rounding issues. Therefore, we now
always output enough digits, so that the number can be reconstructed
unambigously. Fixes #500.
2019-05-05 16:58:17 +02:00
Daniel Kochmański
3766821b25 cosmetic: indent, line breaks 2019-04-20 22:31:21 +02:00
Daniel Kochmanski
2575218ccb printer: fix wrong string printed in write_condition_variable
it printed #<semaphore> while it should be #<condition-variable>.
2018-12-28 10:08:38 +01:00
Marius Gerbershagen
741a01da09 reader: fix reading of bclosures
The syntax had been changed in commit
    991bc3ab78, but the reader macro
    became broken in the process and commit
    835e85bc99 removed the broken
    parts. Since the reason for the change in the syntax is unclear,
    go back to the old syntax.
2018-09-01 17:31:19 +02:00
Marius Gerbershagen
4d3df3766b printer: fix printing of string input streams
Currently ECL crashes because we did not set the array element
    type for the stack allocated tag. Use the string pool instead.
    This should be plenty fast enough, since the performance of
    printing of string input streams is not important anyway.
2018-06-16 13:04:49 +02:00
Marius Gerbershagen
706847293d printer: use si_do_write_sequence in recently optimized printing routines
We don't need cl_write_string, since the CLOS stuff inside there
    is just for optimization. Improves performance for ANSI streams.
2018-06-05 21:30:29 +02:00
Marius Gerbershagen
2c135e798b printer: fix the recently optimized printing routines
Overflows of the string buffer were not correctly handled.
2018-05-23 22:13:15 +02:00
Marius Gerbershagen
5f621c6e96 printer: use the string pool to optimize more printing routines 2018-05-14 22:20:44 +02:00
Daniel Kochmański
ca0962cdb3 Printer addresses 2018-05-04 08:38:33 +00:00
Marius Gerbershagen
82dbd0ea1f make potential_number_p thread-safe. Closes #406 2017-09-24 19:03:38 +02:00
Fabrizio Fabbri
cc442ac9cd
Compiled assoc does not check arguments 2017-07-04 04:59:37 +02:00
Daniel Kochmański
915b40ce03 cleanup: move C/CXX part of CLOS to src/c/clos/ directory
instance.d and gfun.d were in the top C source directory.
2017-05-06 18:27:34 +02:00
Kris Katterjohn
892a3e92f3 Remove some unused variables 2017-03-14 15:51:13 -05:00
Daniel Kochmański
c80b7762d6 buildsystem: fix sse build 2016-12-19 12:31:51 +01:00
Daniel Kochmański
c1067620a7 Improve rwlock built-in class recognition
Fixes #303.
2016-11-10 19:42:52 +01:00
Daniel Kochmański
5e8ec11bdd cosmetic: fix indent (rest of C) 2016-05-06 08:41:52 +02:00
Fabrizio Fabbri
52de2ceea6 Fix compilation for AIX and xlc compiler. 2016-03-02 12:08:48 -05:00
Daniel Kochmański
c80e3cad11 Merge branch 'style' into 'develop'
"style" temporary branch

The ECL code no longer uses tabulator characters, they were replaced
by spaces.

A custom script was used to insert/replace Emacs and ViM per-file editor
settings according to their type and the new ECL coding style.

See merge request !8
2015-09-03 18:07:04 +00:00
Matthew Mondor
8f07cd58d8 The ECL code no longer uses tabulator characters, they were replaced
by spaces.

A custom script was used to insert/replace Emacs and ViM per-file editor
settings according to their type and the new ECL coding style.
2015-09-03 07:35:47 -04:00
Daniel Kochmański
527be2a017 printer: coerce float infinity more roboustly
Basically use C function instead of a generic Lisp one.

Signed-off-by: Daniel Kochmański <daniel@turtleware.eu>
2015-09-03 08:47:00 +02:00
Daniel Kochmański
de22539146 cosmetic: short-float: fix inconsistencies with short-float
Altough short-float is now implemented as single-float, there are
clear signs that there were attempts / was separate implementation of
that type with partly-abandoned efforts. This patch shapes a bit code
in predlib.lsp and adds comments in appropriate places, that this
files needs to be modified, if such separate implementation occurs.

Signed-off-by: Daniel Kochmański <daniel@turtleware.eu>
2015-07-26 12:54:10 +02:00
Daniel Kochmański
7a29be4337 CLOS: remove dead code and conditionals for non-clos builds
Builds without CLOS weren't possible for long time, yet a lot of dead
code for non-clos builds was spread across sources. This commit
removes all ifdefs and dead blocks from codebase.

Signed-off-by: Daniel Kochmański <dkochmanski@turtle-solutions.eu>
2015-07-01 16:56:17 +02:00
Daniel Kochmański
4d19a27424 cosmetic: untabify
Signed-off-by: Daniel Kochmański <dkochmanski@turtle-solutions.eu>
2015-06-21 14:38:20 +02:00
Philipp Marek
2929636a14 #276 [PATCH]: printing hashtables readably is broken
https://sourceforge.net/p/ecls/bugs/276/
Thanks, Stas.
2014-02-22 12:27:26 +01:00
Juan Jose Garcia Ripoll
f7afeb4c34 Print integers using upcase letters for radix > 10 (P. Salvi) 2013-01-12 09:37:54 +01:00
Juan Jose Garcia Ripoll
04bcc1414d potential_number_p() did not use the fact that potential numbers must contain one digit 2012-11-27 22:03:47 +01:00