mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-20 10:02:03 +03:00
1dc7b74e4e
* [RefC] Suppress code generation for unnecessary arglist wrappers. * [RefC] cleanup dead code of arglist. * Removed Value_Arglist to reduce Closure's allocation overhead. * fix linter error * [RefC] make trampoline() safety. * [RefC] cleanup cStatementsFromANF to keep code simple. * fix linter error * fix linter error * In another time, another galaxy. THE LINTER INVADORS conquaer the all humanity and make them slaves. Under 2024, a only leaved job for every humans is adjusting spaces of source code, or just type gg0vG$== in vim. * [ test ] update golden value * added supports 32 params on closure. * [RefC] [Cleanup] removing duplicate codes. * [RefC] Switch calling conventions based on the number of arguments to avoid limits on the number of arguments and to reduce stack usage. * [RefC] Argument that are too large are placed on the heap, as are closures. * [RefC] use idris2_malloc instead of malloc. * [RefC] [Cleanup] Keep pure things pure. * [RefC] Mapped some special constructors to NULL. This reduces malloc cost and generates simpler code in ConCase. But not work yet. * [RefC] fix merge failure. * [RefC] stringOps.c replace NULL for NIL. * [RefC] cleanup * [RefC] ConstCase now generate simple if-then statements instead of using helpers. This reduces malloc/free costs. * fix indentation * fix whitespaces * [RefC] The name field in Value_Constructor was restored for tycon. But changed to static const*. Hopefully the C compiler will remove the common string constants. The smartest thing to do would be to create a dummy global variable and use its address as a tag, but that would depend on the C compiler to resolve conflicts. * [refc] a big changes of the space * [RefC] Little tricks to reduce temporary variables * spaces * [RefC] fix compiler warnings * [RefC] [test] Perform memory leak analysis, if valgrind is installed. * [RefC] Fix invalid memory read. Fix C compiler warnings. * [RefC] Fix invalid memory read of strSubstr. [test] Perform memory leak analysis, if valgrind is installed. * [test] fix junk line * linter * linter * linter * linter * [RefC] merge with erase_trivial_constuctors * merge w/ erase_trivial_constructors * Revert "merge w/ erase_trivial_constructors" This reverts commitbe593a3715
. * Revert "[RefC] merge with erase_trivial_constuctors" This reverts commit3c21eb45d8
. * merge w/ upstream/main * fix merge failure * rename * fix renaming * [RefC] fix merge fail * [RefC] renamed C functions for safty. * [RefC] cleanup * [RefC] Fix constructor tag of UnconsResult.CHARACTER. --------- Co-authored-by: Mathew Polzin <matt.polzin@gmail.com> Co-authored-by: Guillaume Allais <guillaume.allais@ens-lyon.org>
67 lines
2.8 KiB
C
67 lines
2.8 KiB
C
#pragma once
|
|
|
|
#include "cBackend.h"
|
|
|
|
Value *idris2_newValue(size_t size);
|
|
Value *idris2_newReference(Value *source);
|
|
void idris2_removeReference(Value *source);
|
|
|
|
#define IDRIS2_NEW_VALUE(t) ((t *)idris2_newValue(sizeof(t)))
|
|
|
|
Value_Constructor *idris2_newConstructor(int total, int tag);
|
|
Value_Closure *idris2_mkClosure(Value *(*f)(), uint8_t arity, uint8_t filled);
|
|
|
|
Value *idris2_mkDouble(double d);
|
|
#define idris2_mkChar(x) \
|
|
((Value *)(((uintptr_t)(x) << idris2_vp_int_shift) + 1))
|
|
#define idris2_mkBits8(x) \
|
|
((Value *)(((uintptr_t)(x) << idris2_vp_int_shift) + 1))
|
|
#define idris2_mkBits16(x) \
|
|
((Value *)(((uintptr_t)(x) << idris2_vp_int_shift) + 1))
|
|
|
|
#if !defined(UINTPTR_WIDTH)
|
|
#define idris2_mkBits32(x) \
|
|
((idris2_vp_int_shift == 16) \
|
|
? (idris2_mkBits32_Boxed(x)) \
|
|
: ((Value *)(((uintptr_t)(x) << idris2_vp_int_shift) + 1)))
|
|
#define idris2_mkInt32(x) \
|
|
((idris2_vp_int_shift == 16) \
|
|
? (idris2_mkInt32_Boxed(x)) \
|
|
: ((Value *)(((uintptr_t)(x) << idris2_vp_int_shift) + 1)))
|
|
|
|
#elif UINTPTR_WIDTH >= 64
|
|
#define idris2_mkBits32(x) \
|
|
((Value *)(((uintptr_t)(x) << idris2_vp_int_shift) + 1))
|
|
#define idris2_mkInt32(x) \
|
|
((Value *)(((uintptr_t)(x) << idris2_vp_int_shift) + 1))
|
|
|
|
#elif UINTPTR_WIDTH >= 32
|
|
#define idris2_mkBits32(x) (idris2_mkBits32_Boxed(x))
|
|
#define idris2_mkInt32(x) (idris2_mkInt32_Boxed(x)))
|
|
|
|
#else
|
|
#error "unsupported uintptr_t width"
|
|
#endif
|
|
|
|
#define idris2_mkInt8(x) \
|
|
((Value *)(((uintptr_t)(x) << idris2_vp_int_shift) + 1))
|
|
#define idris2_mkInt16(x) \
|
|
((Value *)(((uintptr_t)(x) << idris2_vp_int_shift) + 1))
|
|
#define idris2_mkBool(x) (idris2_mkInt8(x))
|
|
|
|
Value *idris2_mkBits32_Boxed(uint32_t i);
|
|
Value *idris2_mkBits64(uint64_t i);
|
|
Value *idris2_mkInt32_Boxed(int32_t i);
|
|
Value *idris2_mkInt64(int64_t i);
|
|
|
|
Value_Integer *idris2_mkInteger();
|
|
Value_Integer *idris2_mkIntegerLiteral(char *i);
|
|
Value_String *idris2_mkEmptyString(size_t l);
|
|
Value_String *idris2_mkString(char *);
|
|
|
|
Value_Pointer *idris2_makePointer(void *);
|
|
Value_GCPointer *idris2_makeGCPointer(void *ptr_Raw,
|
|
Value_Closure *onCollectFct);
|
|
Value_Buffer *idris2_makeBuffer(void *buf);
|
|
Value_Array *idris2_makeArray(int length);
|