Const typeinfos
This commit is contained in:
parent
805c26e65a
commit
a7bbbe9584
@ -23,7 +23,7 @@ public CORD Bool__as_str(const bool *b, bool colorize, const TypeInfo *type)
|
||||
return *b ? "yes" : "no";
|
||||
}
|
||||
|
||||
public TypeInfo Bool = {
|
||||
public const TypeInfo Bool = {
|
||||
.size=sizeof(bool),
|
||||
.align=__alignof__(bool),
|
||||
.tag=CustomInfo,
|
||||
|
@ -11,6 +11,6 @@
|
||||
|
||||
CORD Bool__as_str(const bool *b, bool colorize, const TypeInfo *type);
|
||||
|
||||
extern TypeInfo Bool;
|
||||
extern const TypeInfo Bool;
|
||||
|
||||
// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0
|
||||
|
@ -48,7 +48,7 @@
|
||||
} \
|
||||
public const c_type KindOfInt##__min = min_val; \
|
||||
public const c_type KindOfInt##__max = max_val; \
|
||||
public TypeInfo KindOfInt = { \
|
||||
public const TypeInfo KindOfInt = { \
|
||||
.size=sizeof(c_type), \
|
||||
.align=__alignof__(c_type), \
|
||||
.tag=CustomInfo, \
|
||||
|
@ -23,7 +23,7 @@
|
||||
CORD type_name ## __octal(c_type i, int64_t digits, bool prefix); \
|
||||
c_type type_name ## __random(int64_t min, int64_t max); \
|
||||
extern const c_type type_name ## __min, type_name##__max; \
|
||||
extern TypeInfo type_name;
|
||||
extern const TypeInfo type_name;
|
||||
|
||||
DEFINE_INT_TYPE(int64_t, Int64);
|
||||
DEFINE_INT_TYPE(int32_t, Int32);
|
||||
|
@ -21,7 +21,7 @@ public CORD Memory__as_str(const void *p, bool colorize, const TypeInfo *type) {
|
||||
return cord;
|
||||
}
|
||||
|
||||
public TypeInfo Memory = {
|
||||
public const TypeInfo Memory = {
|
||||
.size=0,
|
||||
.align=0,
|
||||
.tag=CustomInfo,
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
extern TypeInfo Memory;
|
||||
extern const TypeInfo Memory;
|
||||
CORD Memory__as_str(const void *p, bool colorize, const TypeInfo *type);
|
||||
|
||||
// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0
|
||||
|
@ -54,7 +54,7 @@ public bool Num64__isinf(double n) { return isinf(n); }
|
||||
public bool Num64__finite(double n) { return finite(n); }
|
||||
public bool Num64__isnan(double n) { return isnan(n); }
|
||||
|
||||
public TypeInfo Num64 = {
|
||||
public const TypeInfo Num64 = {
|
||||
.size=sizeof(double),
|
||||
.align=__alignof__(double),
|
||||
.tag=CustomInfo,
|
||||
@ -109,7 +109,7 @@ public bool Num32__isinf(float n) { return isinf(n); }
|
||||
public bool Num32__finite(float n) { return finite(n); }
|
||||
public bool Num32__isnan(float n) { return isnan(n); }
|
||||
|
||||
public TypeInfo Num32 = {
|
||||
public const TypeInfo Num32 = {
|
||||
.size=sizeof(float),
|
||||
.align=__alignof__(float),
|
||||
.tag=CustomInfo,
|
||||
|
@ -39,7 +39,7 @@ F(tan) F(tanh) F(tgamma) F(trunc) F(y0) F(y1)
|
||||
#define F(name) double (*Num64__##name)(double x, double y) = name;
|
||||
F(atan2) F(copysign) F(fdim) F(hypot) F(nextafter) F(pow) F(remainder)
|
||||
#undef F
|
||||
extern TypeInfo Num64;
|
||||
extern const TypeInfo Num64;
|
||||
|
||||
CORD Num32__as_str(const float *f, bool colorize, const TypeInfo *type);
|
||||
int32_t Num32__compare(const float *x, const float *y, const TypeInfo *type);
|
||||
@ -70,6 +70,6 @@ F(tan) F(tanh) F(tgamma) F(trunc) F(y0) F(y1)
|
||||
#define F(name) float (*Num32__##name)(float x, float y) = name##f;
|
||||
F(atan2) F(copysign) F(fdim) F(hypot) F(nextafter) F(pow) F(remainder)
|
||||
#undef F
|
||||
extern TypeInfo Num32;
|
||||
extern const TypeInfo Num32;
|
||||
|
||||
// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0
|
||||
|
@ -254,7 +254,7 @@ public CORD Str__join(CORD glue, Str_Array_t pieces)
|
||||
return ret;
|
||||
}
|
||||
|
||||
public TypeInfo Str = {
|
||||
public const TypeInfo Str = {
|
||||
.size=sizeof(CORD),
|
||||
.align=__alignof__(CORD),
|
||||
.tag=CustomInfo,
|
||||
|
@ -39,6 +39,6 @@ CORD Str__replace(CORD text, CORD pat, CORD replacement, int64_t limit);
|
||||
Str_Array_t Str__split(CORD str, CORD split);
|
||||
CORD Str__join(CORD glue, Str_Array_t pieces);
|
||||
|
||||
extern TypeInfo Str;
|
||||
extern const TypeInfo Str;
|
||||
|
||||
// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0
|
||||
|
@ -23,19 +23,15 @@ public CORD Type__as_str(const void *typeinfo, bool colorize, const TypeInfo *ty
|
||||
return c;
|
||||
}
|
||||
|
||||
public TypeInfo TypeInfo_info = {
|
||||
public const TypeInfo TypeInfo_info = {
|
||||
.size=sizeof(TypeInfo),
|
||||
.align=__alignof__(TypeInfo),
|
||||
.tag=CustomInfo,
|
||||
.TypeInfoInfo.type_str="TypeInfo",
|
||||
};
|
||||
|
||||
public struct {
|
||||
TypeInfo type;
|
||||
} Void = {.type={.size=0, .align=0}};
|
||||
public struct {
|
||||
TypeInfo type;
|
||||
} Abort = {.type={.size=0, .align=0}};
|
||||
public const TypeInfo Void = {.size=0, .align=0};
|
||||
public const TypeInfo Abort = {.size=0, .align=0};
|
||||
|
||||
public CORD Func__as_str(const void *fn, bool colorize, const TypeInfo *type)
|
||||
{
|
||||
|
@ -55,7 +55,9 @@ typedef struct TypeInfo {
|
||||
#define $TypeInfoInfo(typestr) &((TypeInfo){.size=sizeof(TypeInfo), .align=__alignof__(TypeInfo), \
|
||||
.tag=TypeInfoInfo, .TypeInfoInfo.type_str=typestr})
|
||||
|
||||
extern TypeInfo TypeInfo_info;
|
||||
extern const TypeInfo TypeInfo_info;
|
||||
extern const TypeInfo Void;
|
||||
extern const TypeInfo Abort;
|
||||
|
||||
CORD Type__as_str(const void *typeinfo, bool colorize, const TypeInfo *type);
|
||||
CORD Func__as_str(const void *fn, bool colorize, const TypeInfo *type);
|
||||
|
Loading…
Reference in New Issue
Block a user