Carp/core/Core.carp

69 lines
1.7 KiB
Plaintext
Raw Permalink Normal View History

(system-include "assert.h")
(system-include "stddef.h")
(system-include "stdlib.h")
(system-include "stdint.h")
(system-include "inttypes.h")
(system-include "float.h")
(system-include "limits.h")
(system-include "string.h")
(system-include "math.h")
(system-include "ctype.h")
(system-include "stdarg.h")
(system-include "stdio.h")
(system-include "time.h")
(system-include "carp_stdbool.h")
(system-include "core.h")
(system-include "carp_memory.h")
2020-05-05 16:00:57 +03:00
(load-once "Interfaces.carp")
(load-once "Blitable.carp")
2020-05-05 16:00:57 +03:00
(load-once "Bool.carp")
feat: add box type (#1358) * feat: add box templates and box type This commit adds an implementation of Boxes, memory manged heap allocated values. Boxes are implemented as C pointers, with no additional structure but are treated as structs in Carp. To facilitate this, we need to add them as a clause to our special type emissions (TypesToC) as they'd otherwise be emitted like other struct types. Co-authored-by: Veit Heller <veit@veitheller.de> * fix: slight memory management fix for Box Make sure we free the box! * test: add tests for box (including memory checks) * Revert "fix: Ignore clang nitpick" This reverts commit 70ec6d46d4c636c39dc4d47dc7732421a30a0b3f. * fix: update example/functor.carp Now that a builtin type named Box exists, the definitions in this file cause a conflict. I've renamed the "Box" type in the functor example to remove the conflict. * feat: add Box.peek Box.peek allows users to transform a reference to a box into a a reference to the box's contained value. The returned reference will have the same lifetime as the box. This function allows callers to manipulate the value in a box without re-allocation, for example: ```clojure (deftype Num [val Int]) (let-do [box (Box.init (Num.init 0))] (Num.set-val! (Box.peek &box) 1) @(Num.val (Box.peek &box))) ``` This commit also includes tests for Box.peek. Co-authored-by: TimDeve <TimDeve@users.noreply.github.com> Co-authored-by: Veit Heller <veit@veitheller.de> Co-authored-by: Erik Svedäng <erik@coherence.io> Co-authored-by: TimDeve <TimDeve@users.noreply.github.com>
2021-11-30 12:35:22 +03:00
(load-once "Box.carp")
2020-05-05 16:00:57 +03:00
(load-once "Macros.carp")
2021-07-05 15:48:35 +03:00
(load-once "BoolExtras.carp")
(load-once "List.carp")
(load-once "Derive.carp")
(load-once "Gensym.carp")
(load-once "ControlMacros.carp")
(load-once "Project.carp")
(load-once "Platform.carp")
(load-once "Introspect.carp")
(load-once "Quasiquote.carp")
2020-05-12 22:58:40 +03:00
(load-once "Pointer.carp")
(load-once "Unsafe.carp")
(load-once "Function.carp")
2020-05-05 16:00:57 +03:00
(load-once "Generics.carp")
(load-once "Maybe.carp")
(load-once "Result.carp")
(load-once "Dynamic.carp")
(load-once "Format.carp")
(load-once "Byte.carp")
(load-once "Int.carp")
(load-once "Long.carp")
(load-once "Double.carp")
(load-once "Float.carp")
(load-once "Tuples.carp")
(load-once "Array.carp")
(load-once "StaticArray.carp")
(load-once "StdInt.carp")
2020-05-05 16:00:57 +03:00
(load-once "Char.carp")
(load-once "String.carp")
(load-once "ArrayExt.carp")
2020-05-05 16:00:57 +03:00
(load-once "System.carp")
(load-once "IO.carp")
(load-once "Pattern.carp")
(load-once "Debug.carp")
(load-once "Random.carp")
(load-once "Map.carp")
(load-once "Heap.carp")
(load-once "Sort.carp")
(load-once "Binary.carp")
(load-once "Control.carp")
2020-06-18 01:16:58 +03:00
(load-once "Opaque.carp")
More Unit type member enhancements (#986) * Emit/Deftype: Add a few more special cases for Unit members There were a few gaps remaining in our handling of Unit types as members of user defined types, most notably, generic setters weren't handling Units appropriately. This commit adds special checks for Unit types in generic setters, and also accounts for a Unit refs: - Specialize generic setter functions against Unit members - Specialize calls to str/prn against Unit members in StructUtils (rather than accessing the struct member, which doesn't exist in the Unit case, we simple call Unit's prn function (added in the next commit). - Don't bind references to Unit values to variables. This fixes an error whereby a reference to a Unit would generate invalid C such as: `void* _9 = &;` Likewise, we omit references to Units from function arguments just as we omit Unit values. * Unit: Add Unit type implementations for common interfaces. Now that Unit can be used as a member type it is subject to several interfaces, such as prn, that it previously hadn't implemented. This commit adds Unit.carp to core which implements `prn`, `copy`, and `zero` for the Unit type. * Deftype: Return null pointers for Unit getters This is *hopefully* one of the final updates needed to fully support Unit's as member types. Getters for fields of such types have no struct member to read, but are expected to return a void pointer; so we return a NULL void pointer instead. This commit also updates our emissions for function calls to prevent assigning the results of functions with Unit and (Ref Unit) return types to variables. * Emit: Filter void args from lambda calls Just as we filter void argument types from other function calls, we now filter them from calls to lambdas.
2020-11-21 07:57:03 +03:00
(load-once "Unit.carp")
2020-05-01 13:50:31 +03:00
2020-05-12 21:24:40 +03:00
(posix-only
(system-include "sys/wait.h")
(system-include "unistd.h")
(system-include "signal.h"))