initial try

This commit is contained in:
2026-01-27 19:17:44 -06:00
parent 2857581271
commit bcd6e641a5
4 changed files with 1173 additions and 144 deletions

View File

@@ -9,6 +9,8 @@
CELL_SHOP = $(HOME)/.cell
CELL_CORE_PACKAGE = $(CELL_SHOP)/packages/core
maker: install
makecell:
cell pack core -o cell
cp cell /opt/homebrew/bin/

View File

@@ -53,6 +53,7 @@ FMT(atom_u16)
FMT(atom_label_u8)
FMT(atom_label_u16)
FMT(label_u16)
FMT(key)
#undef FMT
#endif /* FMT */
@@ -122,14 +123,14 @@ DEF( put_ref_value, 1, 3, 0, none)
DEF( define_var, 6, 0, 0, atom_u8)
DEF(check_define_var, 6, 0, 0, atom_u8)
DEF( define_func, 6, 1, 0, atom_u8)
DEF( get_field, 5, 1, 1, atom)
DEF( get_field2, 5, 1, 2, atom)
DEF( put_field, 5, 2, 0, atom)
DEF( get_field, 5, 1, 1, key)
DEF( get_field2, 5, 1, 2, key)
DEF( put_field, 5, 2, 0, key)
DEF( get_array_el, 1, 2, 1, none)
DEF( get_array_el2, 1, 2, 2, none) /* obj prop -> obj value */
DEF( get_array_el3, 1, 2, 3, none) /* obj prop -> obj prop1 value */
DEF( put_array_el, 1, 3, 0, none)
DEF( define_field, 5, 2, 1, atom)
DEF( define_field, 5, 2, 1, key)
DEF( set_name, 5, 1, 1, atom)
DEF(set_name_computed, 1, 2, 2, none)
DEF(define_array_el, 1, 3, 2, none)

File diff suppressed because it is too large Load Diff

View File

@@ -67,6 +67,30 @@ typedef struct JSContext JSContext; // Each actor - has its own GC
typedef struct JSClass JSClass;
typedef uint32_t JSClassID;
typedef uint32_t JSAtom;
typedef uint32_t mist_key;
/* KeyId: property key encoding for the Misty object system.
High 3 bits encode the key kind, low 29 bits are the payload. */
typedef uint32_t KeyId;
enum {
K_EMPTY = 0, /* reserved: empty slot marker */
K_TOMB = 1, /* reserved: tombstone marker */
K_TEXT = 2, /* text key (payload = stone text intern id) */
K_SYM = 3, /* symbol key (payload = symbol id) */
K_REC = 4 /* record key (payload = rec_key_id) */
};
#define KEY_KIND_SHIFT 29u
#define KEY_KIND_MASK (7u << KEY_KIND_SHIFT)
#define KEY_PAYLOAD_MASK ((1u << KEY_KIND_SHIFT) - 1u)
static inline uint32_t key_kind(KeyId k) { return (k >> KEY_KIND_SHIFT); }
static inline uint32_t key_payload(KeyId k) { return (k & KEY_PAYLOAD_MASK); }
static inline int key_is_text(KeyId k) { return key_kind(k) == K_TEXT; }
static inline int key_is_rec(KeyId k) { return key_kind(k) == K_REC; }
static inline KeyId key_text(uint32_t payload) { return (K_TEXT << KEY_KIND_SHIFT) | payload; }
static inline KeyId key_rec(uint32_t payload) { return (K_REC << KEY_KIND_SHIFT) | payload; }
#if INTPTR_MAX >= INT64_MAX
#define JS_PTR64
@@ -303,6 +327,7 @@ static inline JS_BOOL JS_VALUE_IS_NAN(JSValue v)
typedef JSValue JSCFunction(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv);
typedef JSValue JSCFunctionMagic(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic);
typedef JSValue JSCFunctionData(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic, JSValue *data);
typedef struct JSMallocState {
size_t malloc_count;
@@ -674,12 +699,18 @@ JSValue JS_SetPropertyV(JSContext *js, JSValue obj, JSValue prop, JSValue val);
// For records
JSValue JS_GetPropertyStr(JSContext *ctx, JSValueConst this_obj, const char *prop);
int JS_SetPropertyStr(JSContext *ctx, JSValueConst this_obj, const char *prop, JSValue val);
int JS_SetProperty(JSContext *ctx, JSValueConst this_obj, JSAtom prop, JSValue val);
JSValue JS_GetPrototype(JSContext *ctx, JSValueConst val);
// Must be an array
JSValue JS_GetPropertyNumber(JSContext *ctx, JSValueConst this_obj, int idx);
JSValue JS_SetPropertyNumber(JSContext *ctx, JSValue obj, int idx, JSValue val);
// Indexed property access (works with arrays and objects)
JSValue JS_GetPropertyUint32(JSContext *ctx, JSValueConst this_obj, uint32_t idx);
int JS_SetPropertyUint32(JSContext *ctx, JSValueConst this_obj, uint32_t idx, JSValue val);
int JS_SetPropertyInt64(JSContext *ctx, JSValueConst this_obj, int64_t idx, JSValue val);
/* Get Own Property Names flags */
#define JS_GPN_STRING_MASK (1 << 0)
#define JS_GPN_SYMBOL_MASK (1 << 1)