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.
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.
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)
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.
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.
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.
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.
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.
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).
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.
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.
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.
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)
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
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
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
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
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
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
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