Commit graph

34 commits

Author SHA1 Message Date
Alexander Motzkau
fb691fa2ea Implement LPC Type objects
Add a new type 'lpctype' to contain a type object, describing a compile-time
type, together with a decltype() operator and to_lpctype() and check_type()
efuns.
2022-09-25 22:20:32 +02:00
Alexander Motzkau
9acced71ca Changed svalue_eq() and rvalue_eq() to return bool
Both functions returned 0 for equality and -1 for inequality which is
counter-intuitive and led to mistakes. Changed them to return true
for equality and false otherwise.
2022-08-21 12:59:42 +02:00
Alexander Motzkau
3c4ebfacd5 Renamed is_lambda to is_closure in callback structure
Use the name lambda only for those closures with their own code.
2022-08-21 12:40:31 +02:00
Alexander Motzkau
8365fa5ebe Implement usage of Python objects in LPC
Python can register certain types for LPC. Objects of those types
can then be passed between Python and LPC code.
2022-05-25 23:16:58 +02:00
Alexander Motzkau
9a89c72a92 Implement range index operator for wide mappings
Introduce a mapping index operation m[key, index1 .. index2].
(Implements #753)
2021-06-09 16:32:21 +02:00
Alexander Motzkau
8556262748 Implement coroutines
Add a new type and several statements to LPC to implement coroutines.
Coroutines allow a function to suspend its execution and resume it
later.
2022-01-09 21:22:34 +01:00
Alexander Motzkau
0659a4124d Implement lightweight objects
Add a new type and data structure to LPC. Lightweight objects combine
properties from structs (small memory footprint, automatic lifetime
management) and objects (capsulation, functions).
(Implements #688)
2022-01-09 01:13:21 +01:00
Alexander Motzkau
6eb9064c3b Removed the preliminary closure type and ownership transfers
The closure type CLOSURE_PRELIMINARY was used for static initialization of
a blueprint's variables in LDMud 3.2 and before. Those closures needed
adaption to the real object after the object was finalized. Also the .user
field of every array and mapping in the blueprint's variables were corrected
in that step.

Since LDMud 3.3 variables are initialized after the object is created
and was given a uid, so there is no need for that mechanism anymore.
2022-01-09 01:13:21 +01:00
Fuchur
7365f66fe2 fix a crash in implode()
implode() on bytes would crash whenever the result is empty, for example

  implode(({b""}), b"");

We have to make sure that arr_implode_string returns an empty string of
the right type in this case.
2021-04-17 00:16:44 +02:00
Alexander Motzkau
b5207f9589 Put callback structures on the heap
Callback structures for efuns like filter() and map() were put on the
stack with the risk of being overwritten during error handling after
a longjmp. This patch puts them all on the heap, the T_CALLBACK svalue
handling will now free the block.
2019-11-23 22:52:34 +01:00
Alexander Motzkau
5e3c6145b8 Use C99 variable length arrays
Replace the array hacks by variable length arrays from C99.
2019-08-22 18:43:10 +02:00
Alexander Motzkau
f0c1c3a3e6 Added runtime type for byte sequences.
Introduces T_BYTES as a runtime type for byte sequences
similar to T_STRING.
2019-04-28 16:43:50 +02:00
Alexander Motzkau
81abe1be2d Implemented Unicode support for operators and efuns.
Added a 'bytes' type for the func_spec file and efun argument checks.
Added type checks to differentiate between text strings and byte sequences.
Implemented support for UTF8 in a lot of operators and functions.
2019-04-28 16:43:49 +02:00
Alexander Motzkau
e90cd834bb Implemented unicode support for strings.
Differentiate between unicode and byte strings
and provide efuns to convert between each other.
2019-04-27 13:30:11 +02:00
Richard James Salts
ccf5a221ca Correcting spelling mistakes in documentation and output strings 2018-02-07 22:42:05 +11:00
Alexander Motzkau
4f03a768b1 Handle lvalue references within arrays/mappings/structs
Updated several efuns to handle lvalues within data structures.
Unless direct arguments that are dereferenced upon pushing them
on the stack, lvalues within arrays, mappings or structs stay
so when passed to an array. So they must be dereferenced when
accessed.
2017-09-27 00:45:42 +02:00
Alexander Motzkau
9cdbcc774a Implemented support for references in arrays for transpose_array().
transpose_array() refused any array that had references as elements.
Implemented support for them, also renamed the local variables to
more meaningful names. Also when creating the new array copy the
entries as rvalues (unraveling any lvalue entries).
2017-09-27 00:45:42 +02:00
Alexander Motzkau
d84ec25a7b Compare rvalues when sorting arrays
Normalization is forbidden for mapping keys,
so only do it for array sorting. Therefore differentiate
between rvalue_eq and svalue_eq.
2017-09-27 00:45:42 +02:00
Alexander Motzkau
40eba97910 Remove lvalue references from array copies.
When shallow copying arrays remove any lvalue references.
2017-09-27 00:45:41 +02:00
Alexander Motzkau
ac06ee0b50 Implemented support for references in arrays for implode().
implode() ignored any lvalue references in arrays, even if they
reference a string. But lvalue references will now also be created
covertly as a part of string index operations, implode() must not
ignore them anymore.
2017-09-27 00:45:41 +02:00
Alexander Motzkau
3b26ccce7c Overhauled the lvalue handling.
Moved all the svalue types for lvalues into a single T_LVALUE.
Differentiate them via .x.lvalue_type. Give protected lvalues
("lvalue references") their own refcounted object, so they have
an umlimited lifespan. Reorganized the bytecodes, so protected lvalues
are generated from unprotected ones now (via F_MAKE_PROTECTED).
Fixed several smaller bugs while looking at every lvalue handling code.
2017-09-27 00:45:40 +02:00
Alexander Motzkau
9b97b73bd8 Fixed memory leak in allocate() in out of memory situations.
allocate() with non-trivial init values leaks the copies of that
init value that were already made in the event of an out-of-memory error.
Because freeing of complex structures requires memory itself (for the
serialization of these structures), instead of freeing the (partly)
array at once added a cleanup handler that reverses the allocate()
algorithm freeing each element seperately.
2017-04-13 14:38:58 +02:00
Zesstra
835949fed9 Removes alist support
The package pkg-alists.c was removed.
The alists were deprecated for some time now.
A patch for re-introducing them will be archived to
ldmud-extensions for people really needing it.
(fixes bug #776)
2015-05-09 16:27:33 +02:00
Zesstra
30721ff690 Removed check_map_for_destr() during array initialization.
allocate() checked mappings for destructed keys, because later on
a copy_mapping() was done. Since some time, copy_mapping() deals with keys
referencing destructed objects in the mappings, so the check shouldn't be
necessary any more. (bug #701)
(array.c)

git-svn-id: svn://svn.bearnip.com/ldmud/trunk@3049 56160b6e-f8f8-0310-bd54-bccebfe6a2f2
2011-11-22 21:58:21 +00:00
Zesstra
4d5bff37af Use shrink_array() only for alists.
Intersecting empty arrays or mappings references the null_vector instead
of creating a new empty array with shrink_array(vec,0). shrink_array is
only used in intersect_ordered_arr().
(array.c, mapping.c)

git-svn-id: svn://svn.bearnip.com/ldmud/trunk@2792 56160b6e-f8f8-0310-bd54-bccebfe6a2f2
2009-11-02 20:25:44 +00:00
Zesstra
a437ef046c sort_array(): sort in place if array is given as reference.
Accept a lvalue as first argument for sort_array(). Always sort in place
(irrespective of the refcount) if the array was given as lvalue. (#224)
(array.c, func_spec)

git-svn-id: svn://svn.bearnip.com/ldmud/trunk@2777 56160b6e-f8f8-0310-bd54-bccebfe6a2f2
2009-10-22 20:33:50 +00:00
Zesstra
88bdb005f9 Raise an error in implode() if given an empty array.
explode() now returns always a non-empty array. For the sake of
consistency, implode() raises an error upon empty arrays. (#180)

git-svn-id: svn://svn.bearnip.com/ldmud/trunk@2764 56160b6e-f8f8-0310-bd54-bccebfe6a2f2
2009-10-06 22:10:06 +00:00
Zesstra
e1baff746a Guarantee to return a non-empty array in explode().
explode("","") returned an empty array, while explode("","anything")
returned ({""}). Changed behaviour that explode will always return
({""}) if the explode string is empty. (#180)

git-svn-id: svn://svn.bearnip.com/ldmud/trunk@2763 56160b6e-f8f8-0310-bd54-bccebfe6a2f2
2009-10-06 21:28:21 +00:00
Gnomi
e998b385ef - Made T_ERROR_HANDLER a standalone type (without T_LVALUE)
(svalue.h, interpret.c, and a lot of other files)


git-svn-id: svn://svn.bearnip.com/ldmud/trunk@2630 56160b6e-f8f8-0310-bd54-bccebfe6a2f2
2009-06-06 11:03:22 +00:00
Fuchur
9f0f41c32a - (array.c, strfuns.c, structs.c, efuns.c, doc/efun[.de]/map[.de])
Implement map(*, mapping, idx) (#367)



git-svn-id: svn://svn.bearnip.com/ldmud/trunk@2532 56160b6e-f8f8-0310-bd54-bccebfe6a2f2
2009-03-15 13:01:38 +00:00
Zesstra
c08ad022e5 - (array.c, backend.c, comm.c, dumpstat.c, interpret.c, mapping.c, lex.c)
Changed format specifiers for mp_int to PRI*MPINT and some for p_int to
    PRI*PINT.


git-svn-id: svn://svn.bearnip.com/ldmud/trunk@2394 56160b6e-f8f8-0310-bd54-bccebfe6a2f2
2008-07-18 23:15:21 +00:00
Lars
f3db3ba4c5 - (i-eval_cost.h, efuns.c, lots of files) Replaced the eval-cost
increment macro with an inline function which does more checks
       to prevent an overflow. Also, to allow proper catch() handling,
       the eval_cost is capped at max_eval_cost+1 (suggested by Gnomi).
  - (efuns.c) Having md5()/sha1() cost 10 ticks per iteration makes too
       long evaluations more unlikely (suggested by Gnomi).



git-svn-id: svn://svn.bearnip.com/ldmud/trunk@2363 56160b6e-f8f8-0310-bd54-bccebfe6a2f2
2007-12-27 23:15:23 +00:00
Lars
9fbd3afdd9 - (array.c) Removed a memory leak when array intersection or subtraction
failed.
  - (mapping, array, interpret.c, prolang.y) Implemented the array/mapping
       intersection.



git-svn-id: svn://svn.bearnip.com/ldmud/trunk@2306 56160b6e-f8f8-0310-bd54-bccebfe6a2f2
2006-06-15 05:35:13 +00:00
Lars
f84a2fc7a0 Initial import from PRCS.
git-svn-id: svn://svn.bearnip.com/ldmud/trunk@4 56160b6e-f8f8-0310-bd54-bccebfe6a2f2
2005-06-21 01:46:13 +00:00