#include #include #include "assert.h" #include "cstring.h" #include "errors/report.h" #include "files/files.h" #include "files/writetext.h" #include "object.h" #include "types/boolean.h" #include "types/composites/composites.h" #include "types/numbers/integer.h" #include "types/typestrings.h" void dumpobject(const cstring message, const object thing) { static_assert(sizeof thing >= 8, ""); uint8_t *bytes = (union {object thing; uint8_t bytes[sizeof thing];}){.thing = thing}.bytes; textmessage( message, "%.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x ", bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7] ); if (sizeof thing == 16) { textmessage( "", "%.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x", bytes[9], bytes[10], bytes[11], bytes[12], bytes[13], bytes[14], bytes[15] ); } } void reportobject(object thing, const cstring function, const int line, const cstring file) { (void)function;(void)line;(void)file; writestring(string("%%[ "), stderr); writestring(string(function), stderr); writestring(string("() '"), stderr); writestring(string(file), stderr); writestring(string(" +"), stderr); writetext(integer(line), stderr); writestring(string("': (object){.type = "), stderr); writetext(thing.type < alltypes ? typestring(thing) : integer(thing.type), stderr); if (thing.type == filetype) thing.type = arraytype; const object access = accessattributestring(thing.access); thing.access = readonly; writestring(string(", .value = "), stderr); writesyntactictext(thing, stderr); writestring(string(", .length = "), stderr); writetext(integer(thing.length <= largestinteger ? (integer)thing.length : -1), stderr); writestring(string(", .access = "), stderr); writetext(access, stderr); writestring(string(", .isexecutable = "), stderr); writetext(boolean(thing.isexecutable), stderr); writestring(string("};"), stderr); writestring(string(" ]%%\n"), stderr); }