aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-03-08 13:50:49 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-03-08 13:50:49 -0500
commit6293d3dd914965872376350814f8e37e6d9b96ca (patch)
tree9f3dac612680dbf5c5f6030a2bb2ac8cffe28ec6
parent55b4528da67403e3909398dc08446244c07eee3e (diff)
Tweaks to memory printing and constness
-rw-r--r--builtins/memory.c2
-rw-r--r--builtins/table.c7
-rw-r--r--builtins/table.h2
3 files changed, 6 insertions, 5 deletions
diff --git a/builtins/memory.c b/builtins/memory.c
index 41b1a841..d4af4cc2 100644
--- a/builtins/memory.c
+++ b/builtins/memory.c
@@ -17,7 +17,7 @@ public CORD Memory__as_text(const void *p, bool colorize, const TypeInfo *type)
(void)type;
if (!p) return "Memory";
CORD cord;
- CORD_sprintf(&cord, colorize ? "\x1b[0;34;1mMemory<%p>\x1b[m" : "Memory<%p>", *(const void**)p);
+ CORD_sprintf(&cord, colorize ? "\x1b[0;34;1mMemory<%p>\x1b[m" : "Memory<%p>", p);
return cord;
}
diff --git a/builtins/table.c b/builtins/table.c
index 521b78ba..b6ab9a40 100644
--- a/builtins/table.c
+++ b/builtins/table.c
@@ -21,6 +21,7 @@
#include "../util.h"
#include "array.h"
#include "datatypes.h"
+#include "memory.h"
#include "text.h"
#include "table.h"
#include "types.h"
@@ -41,17 +42,17 @@
#define GET_ENTRY(t, i) ((t)->entries.data + (t)->entries.stride*(i))
#define ENTRIES_TYPE(type) (&(TypeInfo){.size=sizeof(array_t), .align=__alignof__(array_t), .tag=ArrayInfo, .ArrayInfo.item=(&(TypeInfo){.size=entry_size(type), .align=entry_align(type), .tag=OpaqueInfo})})
-TypeInfo MemoryPointer = {
+const TypeInfo MemoryPointer = {
.size=sizeof(void*),
.align=__alignof__(void*),
.tag=PointerInfo,
.PointerInfo={
.sigil="@",
- .pointed=NULL,
+ .pointed=&Memory,
},
};
-TypeInfo StrToVoidStarTable = {
+const TypeInfo StrToVoidStarTable = {
.size=sizeof(table_t),
.align=__alignof__(table_t),
.tag=TableInfo,
diff --git a/builtins/table.h b/builtins/table.h
index 7439ee03..ea2f98a7 100644
--- a/builtins/table.h
+++ b/builtins/table.h
@@ -60,6 +60,6 @@ void Table_str_remove(table_t *t, const char *key);
#define Table_length(t) ((t)->entries.length)
-extern TypeInfo StrToVoidStarTable;
+extern const TypeInfo StrToVoidStarTable;
// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1