Commit 1df1a441
1df1a441d577Merged
Richard Ramsden <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
Remove other dead helper code
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- 1df1a441d577
- Parent
- fc14feeef3db
spinel_codegen.rbmodifiedView file
@@ -168,7 +168,6 @@
168168
@needs_system = 0169169
@needs_int_array = 0170170
@needs_float_array = 0171-
@needs_ptr_array = 0172171
@tuple_types = "".split(",")173172
@needs_str_array = 0174173
@needs_str_int_hash = 0@@ -176,11 +175,8 @@
176175
@needs_int_str_hash = 0177176
@needs_sym_int_hash = 0178177
@needs_sym_str_hash = 0179-
@needs_str_poly_hash = 0180-
@needs_sym_poly_hash = 0181178
@needs_sym_intern = 0182179
@needs_setjmp = 0183-
@needs_file_io = 0184180
@needs_mutable_str = 0185181
@needs_rb_value = 0186182
@needs_regexp = 0@@ -197,7 +193,6 @@
197193
@parse_id_pool = [[0]]198194
199195
@needs_stringio = 0200-
@needs_proc = 0201196
@proc_counter = 0202197
@proc_funcs = ""203198
@@ -1379,7 +1374,6 @@
13791374
k = k + 113801375
end13811376
if all_same == 11382-
@needs_ptr_array = 113831377
@needs_gc = 113841378
return et + "_ptr_array"13851379
end@@ -1396,7 +1390,6 @@
13961390
k = k + 113971391
end13981392
if all_same == 11399-
@needs_ptr_array = 114001393
@needs_gc = 114011394
return et + "_ptr_array"14021395
end@@ -7047,9 +7040,6 @@
70477040
@needs_setjmp = 170487041
end70497042
end7050-
if t == "InterpolatedXStringNode"7051-
@needs_file_io = 17052-
end70537043
if t == "RegularExpressionNode"70547044
@needs_regexp = 170557045
# Collect pattern and flags@@ -7074,9 +7064,6 @@
70747064
@regexp_patterns.push(pat)70757065
@regexp_flags.push(flags)70767066
end7077-
if t == "XStringNode"7078-
@needs_file_io = 17079-
end70807067
if t == "ArrayNode"70817068
et = infer_array_elem_type(nid)70827069
if et == "str_array"@@ -7212,18 +7199,12 @@
72127199
if rn == "Hash"72137200
@needs_str_int_hash = 172147201
end7215-
if rn == "Proc"7216-
@needs_proc = 17217-
end72187202
if rn == "StringIO"72197203
@needs_stringio = 172207204
end72217205
end72227206
end72237207
end7224-
if mname == "proc"7225-
@needs_proc = 17226-
end72277208
if mname == "to_a"72287209
if @nd_receiver[nid] >= 072297210
rt = infer_type(@nd_receiver[nid])@@ -7286,18 +7267,8 @@
72867267
@needs_setjmp = 172877268
end72887269
if mname == "system"7289-
@needs_file_io = 172907270
@needs_system = 172917271
end7292-
if @nd_receiver[nid] >= 07293-
if @nd_type[@nd_receiver[nid]] == "ConstantReadNode"7294-
rn = @nd_name[@nd_receiver[nid]]7295-
if rn == "File"7296-
@needs_file_io = 17297-
7298-
end7299-
end7300-
end73017272
if mname == "keys"73027273
@needs_str_array = 173037274
@needs_gc = 1@@ -7329,9 +7300,6 @@
73297300
end73307301
end73317302
end7332-
if t == "BlockParameterNode"7333-
@needs_proc = 17334-
end73357303
# Recurse73367304
scan_features_children(nid)73377305
end@@ -8622,132 +8590,6 @@
86228590
changed86238591
end86248592
8625-
def emit_gc_runtime8626-
emit_raw("typedef struct sp_gc_hdr { struct sp_gc_hdr *next; void (*finalize)(void *); void (*scan)(void *); size_t size; unsigned marked : 1; } sp_gc_hdr;")8627-
emit_raw("static sp_gc_hdr *sp_gc_heap = NULL; static size_t sp_gc_bytes = 0; static size_t sp_gc_threshold = 256*1024;")8628-
emit_raw("#define SP_GC_STACK_MAX 65536")8629-
emit_raw("static void **sp_gc_roots[SP_GC_STACK_MAX]; static int sp_gc_nroots = 0;")8630-
emit_raw("#define SP_GC_SAVE() int __attribute__((cleanup(sp_gc_cleanup))) _gc_saved = sp_gc_nroots")8631-
emit_raw("#define SP_GC_ROOT(v) do{if(sp_gc_nroots<SP_GC_STACK_MAX)sp_gc_roots[sp_gc_nroots++]=(void**)&(v);}while(0)")8632-
emit_raw("#define SP_GC_RESTORE() sp_gc_nroots = _gc_saved")8633-
# stack_bottom removed (no conservative scan)8634-
emit_raw("#define SP_GC_MARK_STACK_MAX (1024*64)")8635-
emit_raw("static void**sp_gc_mark_stack=NULL;static int sp_gc_mark_top=0;")8636-
emit_raw("static void sp_gc_mark(void*obj){if(!obj)return;sp_gc_hdr*h=(sp_gc_hdr*)((char*)obj-sizeof(sp_gc_hdr));if(h->marked)return;h->marked=1;if(h->scan){if(sp_gc_mark_stack&&sp_gc_mark_top<SP_GC_MARK_STACK_MAX){sp_gc_mark_stack[sp_gc_mark_top++]=obj;}else{h->scan(obj);}}}")8637-
emit_raw("static void sp_gc_mark_all(void){if(!sp_gc_mark_stack)sp_gc_mark_stack=(void**)malloc(sizeof(void*)*SP_GC_MARK_STACK_MAX);sp_gc_mark_top=0;for(int i=0;i<sp_gc_nroots;i++){void*obj=*sp_gc_roots[i];if(obj)sp_gc_mark(obj);}while(sp_gc_mark_top>0){void*obj=sp_gc_mark_stack[--sp_gc_mark_top];sp_gc_hdr*h=(sp_gc_hdr*)((char*)obj-sizeof(sp_gc_hdr));if(h->scan)h->scan(obj);}}")8638-
emit_raw("static void sp_gc_cleanup(int*p){sp_gc_nroots=*p;}")8639-
# Size-segregated free lists (no arena overhead during sweep)8640-
emit_raw("#define SP_GC_NBUCKETS 32")8641-
emit_raw("static sp_gc_hdr*sp_gc_buckets[SP_GC_NBUCKETS];")8642-
emit_raw("static inline int sp_gc_bucket(size_t sz){int b=(int)(sz/16);return b<SP_GC_NBUCKETS?b:SP_GC_NBUCKETS-1;}")8643-
emit_raw("static int sp_gc_cycle=0;")8644-
emit_raw("static sp_gc_hdr*sp_gc_old_heap=NULL;static size_t sp_gc_old_bytes=0;")8645-
emit_raw("#define SP_GC_FULL_INTERVAL 8")8646-
emit_raw("static void sp_gc_collect(void){int full=(sp_gc_cycle%SP_GC_FULL_INTERVAL==0);sp_gc_cycle++;sp_gc_hdr*hh=sp_gc_old_heap;while(hh){hh->marked=0;hh=hh->next;}sp_gc_mark_all();if(full){sp_gc_hdr**pp=&sp_gc_old_heap;sp_gc_old_bytes=0;while(*pp){sp_gc_hdr*h=*pp;if(!h->marked){*pp=h->next;if(h->finalize)h->finalize((char*)h+sizeof(sp_gc_hdr));int b=sp_gc_bucket(h->size);h->next=sp_gc_buckets[b];sp_gc_buckets[b]=h;}else{h->marked=1;sp_gc_old_bytes+=h->size;pp=&h->next;}}}else{hh=sp_gc_old_heap;while(hh){hh->marked=1;hh=hh->next;}}sp_gc_hdr**pp=&sp_gc_heap;sp_gc_bytes=sp_gc_old_bytes;while(*pp){sp_gc_hdr*h=*pp;if(!h->marked){*pp=h->next;if(h->finalize)h->finalize((char*)h+sizeof(sp_gc_hdr));int b=sp_gc_bucket(h->size);h->next=sp_gc_buckets[b];sp_gc_buckets[b]=h;}else{h->marked=1;*pp=h->next;h->next=sp_gc_old_heap;sp_gc_old_heap=h;sp_gc_old_bytes+=h->size;sp_gc_bytes+=h->size;}}}")8647-
emit_raw("static size_t sp_gc_threshold_init=256*1024;")8648-
gc_linkage = @needs_bigint == 1 ? "" : "static "8649-
emit_raw(gc_linkage + "void*sp_gc_alloc(size_t sz,void(*fin)(void*),void(*scn)(void*)){if(sp_gc_bytes>sp_gc_threshold){size_t before=sp_gc_bytes;sp_gc_collect();size_t freed=before-sp_gc_bytes;if(freed<before/4){sp_gc_threshold=before*2;}else if(sp_gc_bytes>0){sp_gc_threshold=sp_gc_bytes*4;if(sp_gc_threshold<sp_gc_threshold_init)sp_gc_threshold=sp_gc_threshold_init;}else{sp_gc_threshold=sp_gc_threshold_init;}}size_t need=sizeof(sp_gc_hdr)+sz;int b=sp_gc_bucket(need);sp_gc_hdr*h=NULL;if(sp_gc_buckets[b]&&sp_gc_buckets[b]->size==need){h=sp_gc_buckets[b];sp_gc_buckets[b]=h->next;}if(!h){h=(sp_gc_hdr*)calloc(1,need);}h->finalize=fin;h->scan=scn;h->size=need;h->marked=0;h->next=sp_gc_heap;sp_gc_heap=h;sp_gc_bytes+=need;return(char*)h+sizeof(sp_gc_hdr);}")8650-
if @needs_bigint == 18651-
emit_raw("void*sp_gc_alloc_nogc(size_t sz,void(*fin)(void*),void(*scn)(void*)){size_t need=sizeof(sp_gc_hdr)+sz;sp_gc_hdr*h=(sp_gc_hdr*)calloc(1,need);h->finalize=fin;h->scan=scn;h->size=need;h->marked=0;h->next=sp_gc_heap;sp_gc_heap=h;sp_gc_bytes+=need;return(char*)h+sizeof(sp_gc_hdr);}")8652-
end8653-
emit_raw("")8654-
end8655-
8656-
def emit_int_array_runtime8657-
emit_raw("typedef struct{mrb_int*data;mrb_int start;mrb_int len;mrb_int cap;}sp_IntArray;")8658-
emit_raw("static void sp_IntArray_fin(void*p){free(((sp_IntArray*)p)->data);}")8659-
emit_raw("static sp_IntArray*sp_IntArray_new(void){sp_IntArray*a=(sp_IntArray*)sp_gc_alloc(sizeof(sp_IntArray),sp_IntArray_fin,NULL);a->cap=16;a->data=(mrb_int*)malloc(sizeof(mrb_int)*a->cap);a->start=0;a->len=0;{sp_gc_hdr*h=(sp_gc_hdr*)((char*)a-sizeof(sp_gc_hdr));h->size+=sizeof(mrb_int)*a->cap;sp_gc_bytes+=sizeof(mrb_int)*a->cap;}return a;}")8660-
emit_raw("static sp_IntArray*sp_IntArray_from_range(mrb_int s,mrb_int e){sp_IntArray*a=sp_IntArray_new();mrb_int n=e-s+1;if(n<0)n=0;if(n>a->cap){sp_gc_hdr*h=(sp_gc_hdr*)((char*)a-sizeof(sp_gc_hdr));sp_gc_bytes-=sizeof(mrb_int)*a->cap;h->size-=sizeof(mrb_int)*a->cap;a->cap=n;a->data=(mrb_int*)realloc(a->data,sizeof(mrb_int)*a->cap);h->size+=sizeof(mrb_int)*a->cap;sp_gc_bytes+=sizeof(mrb_int)*a->cap;}for(mrb_int i=0;i<n;i++)a->data[i]=s+i;a->len=n;return a;}")8661-
emit_raw("static sp_IntArray*sp_IntArray_dup(sp_IntArray*a){sp_IntArray*b=sp_IntArray_new();if(a->len>b->cap){sp_gc_hdr*h=(sp_gc_hdr*)((char*)b-sizeof(sp_gc_hdr));sp_gc_bytes-=sizeof(mrb_int)*b->cap;h->size-=sizeof(mrb_int)*b->cap;b->cap=a->len;b->data=(mrb_int*)realloc(b->data,sizeof(mrb_int)*b->cap);h->size+=sizeof(mrb_int)*b->cap;sp_gc_bytes+=sizeof(mrb_int)*b->cap;}memcpy(b->data,a->data+a->start,sizeof(mrb_int)*a->len);b->len=a->len;return b;}")8662-
emit_raw("static void __attribute__((noinline)) sp_IntArray_push_grow(sp_IntArray*a){if(a->start>0){memmove(a->data,a->data+a->start,sizeof(mrb_int)*a->len);a->start=0;if(a->len<a->cap)return;}a->cap=a->cap*2+1;a->data=(mrb_int*)realloc(a->data,sizeof(mrb_int)*a->cap);}")8663-
emit_raw("static inline void sp_IntArray_push(sp_IntArray*a,mrb_int v){if(a->start+a->len>=a->cap)sp_IntArray_push_grow(a);a->data[a->start+a->len]=v;a->len++;}")8664-
emit_raw("static inline mrb_int sp_IntArray_pop(sp_IntArray*a){return a->data[a->start+--a->len];}")8665-
emit_raw("static inline mrb_int sp_IntArray_shift(sp_IntArray*a){mrb_int v=a->data[a->start];a->start++;a->len--;return v;}")8666-
emit_raw("static inline mrb_int sp_IntArray_length(sp_IntArray*a){return a->len;}")8667-
emit_raw("static inline mrb_bool sp_IntArray_empty(sp_IntArray*a){return a->len==0;}")8668-
emit_raw("static inline mrb_int sp_IntArray_get(sp_IntArray*a,mrb_int i){if(i<0)i+=a->len;return a->data[a->start+i];}")8669-
emit_raw("static void sp_IntArray_set_slow(sp_IntArray*a,mrb_int i,mrb_int v){while(a->start+i>=a->cap){a->cap=a->cap*2+1;a->data=(mrb_int*)realloc(a->data,sizeof(mrb_int)*a->cap);}while(i>=a->len){a->data[a->start+a->len]=0;a->len++;}a->data[a->start+i]=v;}")8670-
emit_raw("static inline void sp_IntArray_set(sp_IntArray*a,mrb_int i,mrb_int v){if(i<0)i+=a->len;if(i>=0&&i<a->len){a->data[a->start+i]=v;return;}sp_IntArray_set_slow(a,i,v);}")8671-
emit_raw("static void sp_IntArray_reverse_bang(sp_IntArray*a){for(mrb_int i=0,j=a->len-1;i<j;i++,j--){mrb_int t=a->data[a->start+i];a->data[a->start+i]=a->data[a->start+j];a->data[a->start+j]=t;}}")8672-
emit_raw("static int _sp_int_cmp(const void*a,const void*b){mrb_int va=*(const mrb_int*)a,vb=*(const mrb_int*)b;return(va>vb)-(va<vb);}")8673-
emit_raw("static sp_IntArray*sp_IntArray_sort(sp_IntArray*a){sp_IntArray*b=sp_IntArray_dup(a);qsort(b->data+b->start,b->len,sizeof(mrb_int),_sp_int_cmp);return b;}")8674-
emit_raw("static void sp_IntArray_sort_bang(sp_IntArray*a){qsort(a->data+a->start,a->len,sizeof(mrb_int),_sp_int_cmp);}")8675-
emit_raw("static mrb_int sp_IntArray_min(sp_IntArray*a){mrb_int m=a->data[a->start];for(mrb_int i=1;i<a->len;i++)if(a->data[a->start+i]<m)m=a->data[a->start+i];return m;}")8676-
emit_raw("static mrb_int sp_IntArray_max(sp_IntArray*a){mrb_int m=a->data[a->start];for(mrb_int i=1;i<a->len;i++)if(a->data[a->start+i]>m)m=a->data[a->start+i];return m;}")8677-
emit_raw("static mrb_int sp_IntArray_sum(sp_IntArray*a){mrb_int s=0;for(mrb_int i=0;i<a->len;i++)s+=a->data[a->start+i];return s;}")8678-
emit_raw("static mrb_bool sp_IntArray_include(sp_IntArray*a,mrb_int v){for(mrb_int i=0;i<a->len;i++)if(a->data[a->start+i]==v)return TRUE;return FALSE;}")8679-
emit_raw("static sp_IntArray*sp_IntArray_uniq(sp_IntArray*a){sp_IntArray*b=sp_IntArray_new();for(mrb_int i=0;i<a->len;i++){int found=0;for(mrb_int j=0;j<b->len;j++){if(b->data[b->start+j]==a->data[a->start+i]){found=1;break;}}if(!found)sp_IntArray_push(b,a->data[a->start+i]);}return b;}")8680-
emit_raw("static void sp_IntArray_unshift(sp_IntArray*a,mrb_int v){if(a->start>0){a->start--;a->data[a->start]=v;a->len++;}else{mrb_int e=a->len+1;if(e>a->cap){a->cap=a->cap*2+1;a->data=(mrb_int*)realloc(a->data,sizeof(mrb_int)*a->cap);}memmove(a->data+1,a->data,sizeof(mrb_int)*a->len);a->data[0]=v;a->len++;}}")8681-
emit_raw("static const char*sp_IntArray_join(sp_IntArray*a,const char*sep){size_t sl=strlen(sep),cap=256;char*buf=(char*)malloc(cap);size_t len=0;for(mrb_int i=0;i<a->len;i++){if(i>0){if(len+sl>=cap){cap*=2;buf=(char*)realloc(buf,cap);}memcpy(buf+len,sep,sl);len+=sl;}char tmp[32];int n=snprintf(tmp,32,\"%lld\",(long long)a->data[a->start+i]);if(len+n>=cap){cap*=2;buf=(char*)realloc(buf,cap);}memcpy(buf+len,tmp,n);len+=n;}buf[len]=0;return buf;}")8682-
emit_raw("static mrb_bool sp_IntArray_eq(sp_IntArray*a,sp_IntArray*b){if(a->len!=b->len)return FALSE;for(mrb_int i=0;i<a->len;i++)if(a->data[a->start+i]!=b->data[b->start+i])return FALSE;return TRUE;}")8683-
emit_raw("")8684-
end8685-
8686-
def emit_ptr_array_runtime8687-
emit_raw("/* ---- PtrArray: array of void* pointers ---- */")8688-
emit_raw("typedef struct{void**data;mrb_int len;mrb_int cap;void(*scan_elem)(void*);}sp_PtrArray;")8689-
emit_raw("static void sp_PtrArray_fin(void*p){free(((sp_PtrArray*)p)->data);}")8690-
emit_raw("static void sp_PtrArray_gc_scan(void*p){sp_PtrArray*a=(sp_PtrArray*)p;if(!a->scan_elem)return;for(mrb_int i=0;i<a->len;i++){if(a->data[i])a->scan_elem(a->data[i]);}}")8691-
emit_raw("static sp_PtrArray*sp_PtrArray_new_scan(void(*scan_elem)(void*)){sp_PtrArray*a=(sp_PtrArray*)sp_gc_alloc(sizeof(sp_PtrArray),sp_PtrArray_fin,scan_elem?sp_PtrArray_gc_scan:NULL);a->cap=16;a->data=(void**)malloc(sizeof(void*)*a->cap);a->len=0;a->scan_elem=scan_elem;return a;}")8692-
emit_raw("static sp_PtrArray*sp_PtrArray_new(void){return sp_PtrArray_new_scan(sp_gc_mark);}")8693-
emit_raw("static inline void sp_PtrArray_push(sp_PtrArray*a,void*v){if(a->len>=a->cap){a->cap=a->cap*2+1;a->data=(void**)realloc(a->data,sizeof(void*)*a->cap);}a->data[a->len++]=v;}")8694-
emit_raw("static inline void*sp_PtrArray_get(sp_PtrArray*a,mrb_int i){if(i<0)i+=a->len;return a->data[i];}")8695-
emit_raw("static inline void sp_PtrArray_set(sp_PtrArray*a,mrb_int i,void*v){if(i<0)i+=a->len;a->data[i]=v;}")8696-
emit_raw("static inline mrb_int sp_PtrArray_length(sp_PtrArray*a){return a->len;}")8697-
emit_raw("static inline mrb_bool sp_PtrArray_empty(sp_PtrArray*a){return a->len==0;}")8698-
emit_raw("static sp_PtrArray*sp_PtrArray_dup(sp_PtrArray*a){sp_PtrArray*b=sp_PtrArray_new_scan(a->scan_elem);for(mrb_int i=0;i<a->len;i++)sp_PtrArray_push(b,a->data[i]);return b;}")8699-
emit_raw("static void sp_PtrArray_shuffle_bang(sp_PtrArray*a){for(mrb_int i=a->len-1;i>0;i--){mrb_int j=(mrb_int)(rand()%(i+1));void*t=a->data[i];a->data[i]=a->data[j];a->data[j]=t;}}")8700-
emit_raw("static sp_PtrArray*sp_PtrArray_shuffle(sp_PtrArray*a){sp_PtrArray*b=sp_PtrArray_dup(a);sp_PtrArray_shuffle_bang(b);return b;}")8701-
emit_raw("")8702-
end8703-
8704-
def emit_float_array_runtime8705-
emit_raw("typedef struct{mrb_float*data;mrb_int len;mrb_int cap;}sp_FloatArray;")8706-
emit_raw("static void sp_FloatArray_fin(void*p){free(((sp_FloatArray*)p)->data);}")8707-
emit_raw("static sp_FloatArray*sp_FloatArray_new(void){sp_FloatArray*a=(sp_FloatArray*)sp_gc_alloc(sizeof(sp_FloatArray),sp_FloatArray_fin,NULL);a->cap=16;a->data=(mrb_float*)malloc(sizeof(mrb_float)*a->cap);a->len=0;return a;}")8708-
emit_raw("static inline void sp_FloatArray_push(sp_FloatArray*a,mrb_float v){if(a->len>=a->cap){a->cap=a->cap*2+1;a->data=(mrb_float*)realloc(a->data,sizeof(mrb_float)*a->cap);}a->data[a->len++]=v;}")8709-
emit_raw("static inline mrb_float sp_FloatArray_pop(sp_FloatArray*a){return a->data[--a->len];}")8710-
emit_raw("static inline mrb_int sp_FloatArray_length(sp_FloatArray*a){return a->len;}")8711-
emit_raw("static inline mrb_bool sp_FloatArray_empty(sp_FloatArray*a){return a->len==0;}")8712-
emit_raw("static inline mrb_float sp_FloatArray_get(sp_FloatArray*a,mrb_int i){if(i<0)i+=a->len;return a->data[i];}")8713-
emit_raw("static inline void sp_FloatArray_set(sp_FloatArray*a,mrb_int i,mrb_float v){if(i<0)i+=a->len;while(i>=a->cap){a->cap=a->cap*2+1;a->data=(mrb_float*)realloc(a->data,sizeof(mrb_float)*a->cap);}while(i>=a->len){a->data[a->len]=0.0;a->len++;}a->data[i]=v;}")8714-
emit_raw("")8715-
end8716-
8717-
def emit_str_array_runtime8718-
emit_raw("typedef struct{const char**data;mrb_int len;mrb_int cap;}sp_StrArray;")8719-
emit_raw("static void sp_StrArray_fin(void*p){free(((sp_StrArray*)p)->data);}")8720-
emit_raw("static sp_StrArray*sp_StrArray_new(void){sp_StrArray*a=(sp_StrArray*)sp_gc_alloc(sizeof(sp_StrArray),sp_StrArray_fin,NULL);a->cap=16;a->data=(const char**)malloc(sizeof(const char*)*a->cap);a->len=0;return a;}")8721-
emit_raw("static inline void sp_StrArray_push(sp_StrArray*a,const char*v){if(a->len>=a->cap){a->cap=a->cap*2+1;a->data=(const char**)realloc(a->data,sizeof(const char*)*a->cap);}a->data[a->len++]=v;}")8722-
emit_raw("static const char*sp_StrArray_pop(sp_StrArray*a){return a->data[--a->len];}")8723-
emit_raw("static inline mrb_int sp_StrArray_length(sp_StrArray*a){return a->len;}")8724-
emit_raw("static inline mrb_bool sp_StrArray_empty(sp_StrArray*a){return a->len==0;}")8725-
emit_raw("static inline const char*sp_StrArray_get(sp_StrArray*a,mrb_int i){if(i<0)i+=a->len;return a->data[i];}")8726-
emit_raw("static inline void sp_StrArray_set(sp_StrArray*a,mrb_int i,const char*v){if(i<0)i+=a->len;while(i>=a->len)sp_StrArray_push(a,\"\");a->data[i]=v;}")8727-
emit_raw("static const char*sp_StrArray_join(sp_StrArray*a,const char*sep){size_t sl=strlen(sep),cap=256;char*buf=(char*)malloc(cap);size_t len=0;for(mrb_int i=0;i<a->len;i++){if(i>0){if(len+sl>=cap){cap*=2;buf=(char*)realloc(buf,cap);}memcpy(buf+len,sep,sl);len+=sl;}size_t el=strlen(a->data[i]);if(len+el>=cap){cap=(len+el)*2+1;buf=(char*)realloc(buf,cap);}memcpy(buf+len,a->data[i],el);len+=el;}buf[len]=0;return buf;}")8728-
emit_raw("static mrb_bool sp_StrArray_include(sp_StrArray*a,const char*v){for(mrb_int i=0;i<a->len;i++)if(strcmp(a->data[i],v)==0)return TRUE;return FALSE;}")8729-
emit_raw("")8730-
end8731-
8732-
def emit_str_hash_func8733-
emit_raw("static inline uint64_t sp_str_hash(const char*s){uint64_t h=14695981039346656037ULL;while(*s){h^=(unsigned char)*s++;h*=1099511628211ULL;}return h;}")8734-
end8735-
8736-
def emit_str_int_hash_runtime8737-
emit_raw("typedef struct{const char**keys;mrb_int*vals;const char**order;mrb_int len;mrb_int cap;mrb_int mask;}sp_StrIntHash;")8738-
emit_raw("static void sp_StrIntHash_fin(void*p){sp_StrIntHash*h=(sp_StrIntHash*)p;free(h->keys);free(h->vals);free(h->order);}")8739-
emit_raw("static sp_StrIntHash*sp_StrIntHash_new(void){sp_StrIntHash*h=(sp_StrIntHash*)sp_gc_alloc(sizeof(sp_StrIntHash),sp_StrIntHash_fin,NULL);h->cap=16;h->mask=15;h->keys=(const char**)calloc(h->cap,sizeof(const char*));h->vals=(mrb_int*)calloc(h->cap,sizeof(mrb_int));h->order=(const char**)malloc(sizeof(const char*)*h->cap);h->len=0;return h;}")8740-
emit_raw("static void sp_StrIntHash_grow(sp_StrIntHash*h){mrb_int oc=h->cap;const char**ok=h->keys;mrb_int*ov=h->vals;h->cap*=2;h->mask=h->cap-1;h->keys=(const char**)calloc(h->cap,sizeof(const char*));h->vals=(mrb_int*)calloc(h->cap,sizeof(mrb_int));h->order=(const char**)realloc(h->order,sizeof(const char*)*h->cap);mrb_int ol=h->len;h->len=0;for(mrb_int i=0;i<oc;i++){if(ok[i]){mrb_int idx=(mrb_int)(sp_str_hash(ok[i])&h->mask);while(h->keys[idx])idx=(idx+1)&h->mask;h->keys[idx]=ok[i];h->vals[idx]=ov[i];h->len++;}}free(ok);free(ov);}")8741-
emit_raw("static mrb_int sp_StrIntHash_get(sp_StrIntHash*h,const char*k){mrb_int idx=(mrb_int)(sp_str_hash(k)&h->mask);while(h->keys[idx]){if(strcmp(h->keys[idx],k)==0)return h->vals[idx];idx=(idx+1)&h->mask;}return 0;}")8742-
emit_raw("static void sp_StrIntHash_set(sp_StrIntHash*h,const char*k,mrb_int v){if(h->len*2>=h->cap)sp_StrIntHash_grow(h);mrb_int idx=(mrb_int)(sp_str_hash(k)&h->mask);while(h->keys[idx]){if(strcmp(h->keys[idx],k)==0){h->vals[idx]=v;return;}idx=(idx+1)&h->mask;}h->keys[idx]=k;h->vals[idx]=v;h->order[h->len]=k;h->len++;}")8743-
emit_raw("static mrb_bool sp_StrIntHash_has_key(sp_StrIntHash*h,const char*k){mrb_int idx=(mrb_int)(sp_str_hash(k)&h->mask);while(h->keys[idx]){if(strcmp(h->keys[idx],k)==0)return TRUE;idx=(idx+1)&h->mask;}return FALSE;}")8744-
emit_raw("static mrb_int sp_StrIntHash_length(sp_StrIntHash*h){return h->len;}")8745-
emit_raw("static void sp_StrIntHash_delete(sp_StrIntHash*h,const char*k){mrb_int idx=(mrb_int)(sp_str_hash(k)&h->mask);while(h->keys[idx]){if(strcmp(h->keys[idx],k)==0){h->keys[idx]=NULL;h->vals[idx]=0;h->len--;mrb_int j=(idx+1)&h->mask;while(h->keys[j]){mrb_int nj=(mrb_int)(sp_str_hash(h->keys[j])&h->mask);if((j>idx&&(nj<=idx||nj>j))||(j<idx&&nj<=idx&&nj>j)){h->keys[idx]=h->keys[j];h->vals[idx]=h->vals[j];h->keys[j]=NULL;h->vals[j]=0;idx=j;}j=(j+1)&h->mask;}return;}idx=(idx+1)&h->mask;}}")8746-
emit_raw("static sp_StrArray*sp_StrIntHash_keys(sp_StrIntHash*h){sp_StrArray*a=sp_StrArray_new();for(mrb_int i=0;i<h->len;i++)sp_StrArray_push(a,h->order[i]);return a;}")8747-
emit_raw("static sp_StrIntHash*sp_StrIntHash_merge(sp_StrIntHash*a,sp_StrIntHash*b){sp_StrIntHash*r=sp_StrIntHash_new();for(mrb_int i=0;i<a->len;i++)sp_StrIntHash_set(r,a->order[i],sp_StrIntHash_get(a,a->order[i]));for(mrb_int i=0;i<b->len;i++)sp_StrIntHash_set(r,b->order[i],sp_StrIntHash_get(b,b->order[i]));return r;}")8748-
emit_raw("")8749-
end8750-
87518593
# Symbol-keyed hash with integer values. Keys are sp_sym (mrb_int);87528594
# the empty-slot sentinel is -1 (= invalid sp_sym, same as default).87538595
def emit_sym_int_hash_runtime@@ -8763,23 +8605,6 @@
87638605
emit_raw("")87648606
end87658607
8766-
# Integer-keyed hash with string values.8767-
def emit_int_str_hash_runtime8768-
emit_raw("typedef struct{mrb_int*keys;const char**vals;mrb_int*order;mrb_bool*used;mrb_int len;mrb_int cap;mrb_int mask;}sp_IntStrHash;")8769-
emit_raw("static void sp_IntStrHash_fin(void*p){sp_IntStrHash*h=(sp_IntStrHash*)p;free(h->keys);free(h->vals);free(h->order);free(h->used);}")8770-
emit_raw("static void sp_IntStrHash_scan(void*p){sp_IntStrHash*h=(sp_IntStrHash*)p;for(mrb_int i=0;i<h->cap;i++)if(h->used[i])sp_mark_string(h->vals[i]);}")8771-
emit_raw("static sp_IntStrHash*sp_IntStrHash_new(void){sp_IntStrHash*h=(sp_IntStrHash*)sp_gc_alloc(sizeof(sp_IntStrHash),sp_IntStrHash_fin,sp_IntStrHash_scan);h->cap=16;h->mask=15;h->keys=(mrb_int*)calloc(h->cap,sizeof(mrb_int));h->vals=(const char**)calloc(h->cap,sizeof(const char*));h->order=(mrb_int*)malloc(sizeof(mrb_int)*h->cap);h->used=(mrb_bool*)calloc(h->cap,sizeof(mrb_bool));h->len=0;return h;}")8772-
emit_raw("static inline mrb_int _sp_istr_idx(mrb_int mask,mrb_int k){return(mrb_int)(((uint64_t)(unsigned long long)k*11400714819323198485ULL)&(uint64_t)mask);}")8773-
emit_raw("static void sp_IntStrHash_grow(sp_IntStrHash*h){mrb_int oc=h->cap,ol=h->len;mrb_int*ok=h->keys;const char**ov=h->vals;mrb_bool*ou=h->used;mrb_int*oo=h->order;h->cap*=2;h->mask=h->cap-1;h->keys=(mrb_int*)calloc(h->cap,sizeof(mrb_int));h->vals=(const char**)calloc(h->cap,sizeof(const char*));h->order=(mrb_int*)malloc(sizeof(mrb_int)*h->cap);h->used=(mrb_bool*)calloc(h->cap,sizeof(mrb_bool));h->len=0;for(mrb_int i=0;i<ol;i++){mrb_int k=oo[i];mrb_int si=_sp_istr_idx(oc-1,k);while(!ou[si]||ok[si]!=k)si=(si+1)&(oc-1);const char*v=ov[si];mrb_int di=_sp_istr_idx(h->mask,k);while(h->used[di])di=(di+1)&h->mask;h->used[di]=TRUE;h->keys[di]=k;h->vals[di]=v;h->order[h->len++]=k;}free(ok);free(ov);free(ou);free(oo);}")8774-
emit_raw("static void sp_IntStrHash_set(sp_IntStrHash*h,mrb_int k,const char*v){if(h->len*2>=h->cap)sp_IntStrHash_grow(h);mrb_int idx=_sp_istr_idx(h->mask,k);while(h->used[idx]){if(h->keys[idx]==k){h->vals[idx]=v;return;}idx=(idx+1)&h->mask;}h->used[idx]=TRUE;h->keys[idx]=k;h->vals[idx]=v;h->order[h->len++]=k;}")8775-
emit_raw("static const char*sp_IntStrHash_get(sp_IntStrHash*h,mrb_int k){mrb_int idx=_sp_istr_idx(h->mask,k);while(h->used[idx]){if(h->keys[idx]==k)return h->vals[idx];idx=(idx+1)&h->mask;}return\"\";}")8776-
emit_raw("static mrb_bool sp_IntStrHash_has_key(sp_IntStrHash*h,mrb_int k){mrb_int idx=_sp_istr_idx(h->mask,k);while(h->used[idx]){if(h->keys[idx]==k)return TRUE;idx=(idx+1)&h->mask;}return FALSE;}")8777-
emit_raw("static mrb_int sp_IntStrHash_length(sp_IntStrHash*h){return h->len;}")8778-
emit_raw("static sp_IntArray*sp_IntStrHash_keys(sp_IntStrHash*h){sp_IntArray*a=sp_IntArray_new();for(mrb_int i=0;i<h->len;i++)sp_IntArray_push(a,h->order[i]);return a;}")8779-
emit_raw("static sp_StrArray*sp_IntStrHash_values(sp_IntStrHash*h){sp_StrArray*a=sp_StrArray_new();for(mrb_int i=0;i<h->len;i++)sp_StrArray_push(a,sp_IntStrHash_get(h,h->order[i]));return a;}")8780-
emit_raw("")8781-
end8782-
87838608
# Symbol-keyed hash with string values.87848609
def emit_sym_str_hash_runtime87858610
emit_raw("typedef struct{sp_sym*keys;const char**vals;sp_sym*order;mrb_int len;mrb_int cap;mrb_int mask;}sp_SymStrHash;")@@ -8794,20 +8619,6 @@
87948619
emit_raw("")87958620
end87968621
8797-
def emit_str_str_hash_runtime8798-
emit_raw("typedef struct{const char**keys;const char**vals;const char**order;mrb_int len;mrb_int cap;mrb_int mask;}sp_StrStrHash;")8799-
emit_raw("static void sp_StrStrHash_fin(void*p){sp_StrStrHash*h=(sp_StrStrHash*)p;free(h->keys);free(h->vals);free(h->order);}")8800-
emit_raw("static sp_StrStrHash*sp_StrStrHash_new(void){sp_StrStrHash*h=(sp_StrStrHash*)sp_gc_alloc(sizeof(sp_StrStrHash),sp_StrStrHash_fin,NULL);h->cap=16;h->mask=15;h->keys=(const char**)calloc(h->cap,sizeof(const char*));h->vals=(const char**)calloc(h->cap,sizeof(const char*));h->order=(const char**)malloc(sizeof(const char*)*h->cap);h->len=0;return h;}")8801-
emit_raw("static void sp_StrStrHash_grow(sp_StrStrHash*h){mrb_int oc=h->cap;const char**ok=h->keys;const char**ov=h->vals;h->cap*=2;h->mask=h->cap-1;h->keys=(const char**)calloc(h->cap,sizeof(const char*));h->vals=(const char**)calloc(h->cap,sizeof(const char*));h->order=(const char**)realloc(h->order,sizeof(const char*)*h->cap);h->len=0;for(mrb_int i=0;i<oc;i++){if(ok[i]){mrb_int idx=(mrb_int)(sp_str_hash(ok[i])&h->mask);while(h->keys[idx])idx=(idx+1)&h->mask;h->keys[idx]=ok[i];h->vals[idx]=ov[i];h->len++;}}free(ok);free(ov);}")8802-
emit_raw("static const char*sp_StrStrHash_get(sp_StrStrHash*h,const char*k){mrb_int idx=(mrb_int)(sp_str_hash(k)&h->mask);while(h->keys[idx]){if(strcmp(h->keys[idx],k)==0)return h->vals[idx];idx=(idx+1)&h->mask;}return\"\";}")8803-
emit_raw("static void sp_StrStrHash_set(sp_StrStrHash*h,const char*k,const char*v){if(h->len*2>=h->cap)sp_StrStrHash_grow(h);mrb_int idx=(mrb_int)(sp_str_hash(k)&h->mask);while(h->keys[idx]){if(strcmp(h->keys[idx],k)==0){h->vals[idx]=v;return;}idx=(idx+1)&h->mask;}h->keys[idx]=k;h->vals[idx]=v;h->order[h->len]=k;h->len++;}")8804-
emit_raw("static mrb_bool sp_StrStrHash_has_key(sp_StrStrHash*h,const char*k){mrb_int idx=(mrb_int)(sp_str_hash(k)&h->mask);while(h->keys[idx]){if(strcmp(h->keys[idx],k)==0)return TRUE;idx=(idx+1)&h->mask;}return FALSE;}")8805-
emit_raw("static mrb_int sp_StrStrHash_length(sp_StrStrHash*h){return h->len;}")8806-
emit_raw("static void sp_StrStrHash_delete(sp_StrStrHash*h,const char*k){mrb_int idx=(mrb_int)(sp_str_hash(k)&h->mask);while(h->keys[idx]){if(strcmp(h->keys[idx],k)==0){h->keys[idx]=NULL;h->vals[idx]=NULL;h->len--;mrb_int j=(idx+1)&h->mask;while(h->keys[j]){mrb_int nj=(mrb_int)(sp_str_hash(h->keys[j])&h->mask);if((j>idx&&(nj<=idx||nj>j))||(j<idx&&nj<=idx&&nj>j)){h->keys[idx]=h->keys[j];h->vals[idx]=h->vals[j];h->keys[j]=NULL;h->vals[j]=NULL;idx=j;}j=(j+1)&h->mask;}return;}idx=(idx+1)&h->mask;}}")8807-
emit_raw("static sp_StrArray*sp_StrStrHash_keys(sp_StrStrHash*h){sp_StrArray*a=sp_StrArray_new();for(mrb_int i=0;i<h->len;i++)sp_StrArray_push(a,h->order[i]);return a;}")8808-
emit_raw("")8809-
end8810-
88118622
# Symbol type Phase 2, Step 1: collect all SymbolNode content strings88128623
# into @sym_names as a separate pass (dedup, stable order).88138624
def collect_sym_names@@ -8968,17 +8779,6 @@
89688779
189698780
end89708781
8971-
def emit_mutable_str_runtime8972-
emit_raw("typedef struct{char*data;int64_t len;int64_t cap;}sp_String;")8973-
emit_raw("static void sp_String_fin(void*p){free(((sp_String*)p)->data);}")8974-
emit_raw("static sp_String*sp_String_new(const char*s){sp_String*r=(sp_String*)sp_gc_alloc(sizeof(sp_String),sp_String_fin,NULL);r->len=(int64_t)strlen(s);r->cap=r->len*2+16;r->data=(char*)malloc(r->cap+1);memcpy(r->data,s,r->len+1);{sp_gc_hdr*h=(sp_gc_hdr*)((char*)r-sizeof(sp_gc_hdr));h->size+=r->cap+1;sp_gc_bytes+=r->cap+1;}return r;}")8975-
emit_raw("static inline void sp_String_append(sp_String*s,const char*t){int64_t tl=(int64_t)strlen(t);if(s->len+tl>=s->cap){sp_gc_hdr*h=(sp_gc_hdr*)((char*)s-sizeof(sp_gc_hdr));sp_gc_bytes-=s->cap+1;h->size-=s->cap+1;s->cap=(s->len+tl)*2+16;s->data=(char*)realloc(s->data,s->cap+1);h->size+=s->cap+1;sp_gc_bytes+=s->cap+1;}memcpy(s->data+s->len,t,tl+1);s->len+=tl;}")8976-
emit_raw("static inline const char*sp_String_cstr(sp_String*s){return s->data;}")8977-
emit_raw("static inline int64_t sp_String_length(sp_String*s){return s->len;}")8978-
emit_raw("static sp_String*sp_String_dup(sp_String*s){return sp_String_new(s->data);}")8979-
emit_raw("")8980-
end8981-
89828782
def emit_regexp_runtime89838783
# Common regexp types and helpers are in sp_runtime.h89848784
# Common regexp types and helpers are in sp_runtime.h@@ -9031,162 +8831,6 @@
90318831
emit_raw("")90328832
end90338833
9034-
def emit_rb_value_runtime9035-
emit_raw("/* NaN-boxed polymorphic value */")9036-
emit_raw("typedef uint64_t sp_RbValue;")9037-
emit_raw("#define SP_TAG_INT 0")9038-
emit_raw("#define SP_TAG_STR 1")9039-
emit_raw("#define SP_TAG_FLT 2")9040-
emit_raw("#define SP_TAG_BOOL 3")9041-
emit_raw("#define SP_TAG_NIL 4")9042-
emit_raw("#define SP_TAG_OBJ 5")9043-
emit_raw("typedef struct { int tag; int cls_id; union { mrb_int i; const char *s; mrb_float f; mrb_bool b; void *p; } v; } sp_RbVal;")9044-
emit_raw("static sp_RbVal sp_box_int(mrb_int v) { sp_RbVal r; r.tag = SP_TAG_INT; r.cls_id = 0; r.v.i = v; return r; }")9045-
emit_raw("static sp_RbVal sp_box_str(const char *v) { sp_RbVal r; r.tag = SP_TAG_STR; r.cls_id = 0; r.v.s = v; return r; }")9046-
emit_raw("static sp_RbVal sp_box_float(mrb_float v) { sp_RbVal r; r.tag = SP_TAG_FLT; r.cls_id = 0; r.v.f = v; return r; }")9047-
emit_raw("static sp_RbVal sp_box_bool(mrb_bool v) { sp_RbVal r; r.tag = SP_TAG_BOOL; r.cls_id = 0; r.v.b = v; return r; }")9048-
emit_raw("static sp_RbVal sp_box_nil(void) { sp_RbVal r; r.tag = SP_TAG_NIL; r.cls_id = 0; r.v.i = 0; return r; }")9049-
emit_raw("static sp_RbVal sp_box_obj(void *p, int cls_id) { sp_RbVal r; r.tag = SP_TAG_OBJ; r.cls_id = cls_id; r.v.p = p; return r; }")9050-
emit_raw("static void sp_poly_puts(sp_RbVal v) {")9051-
emit_raw(" switch (v.tag) {")9052-
emit_raw(" case SP_TAG_INT: printf(\"%lld" + bsl_n + "\", (long long)v.v.i); break;")9053-
emit_raw(" case SP_TAG_STR: if (v.v.s) { fputs(v.v.s, stdout); if (!*v.v.s || v.v.s[strlen(v.v.s)-1] != '" + bsl_n + "') putchar('" + bsl_n + "'); } else putchar('" + bsl_n + "'); break;")9054-
emit_raw(" case SP_TAG_FLT: { char _fb[64]; snprintf(_fb,64,\"%g\",v.v.f); if(!strchr(_fb,'.')&&!strchr(_fb,'e')&&!strchr(_fb,'i')&&!strchr(_fb,'n')){strcat(_fb,\".0\");} printf(\"%s" + bsl_n + "\",_fb); break; }")9055-
emit_raw(" case SP_TAG_BOOL: puts(v.v.b ? \"true\" : \"false\"); break;")9056-
emit_raw(" case SP_TAG_NIL: putchar('" + bsl_n + "'); break;")9057-
emit_raw(" default: printf(\"%lld" + bsl_n + "\", (long long)v.v.i); break;")9058-
emit_raw(" }")9059-
emit_raw("}")9060-
emit_raw("static mrb_bool sp_poly_nil_p(sp_RbVal v) { return v.tag == SP_TAG_NIL; }")9061-
emit_raw("static const char *sp_poly_to_s(sp_RbVal v) { switch (v.tag) { case SP_TAG_INT: return sp_int_to_s(v.v.i); case SP_TAG_STR: return v.v.s ? v.v.s : \"\"; case SP_TAG_FLT: return sp_float_to_s(v.v.f); case SP_TAG_BOOL: return v.v.b ? \"true\" : \"false\"; case SP_TAG_NIL: return \"\"; default: return \"\"; } }")9062-
emit_raw("static sp_RbVal sp_poly_add(sp_RbVal a, sp_RbVal b) { if (a.tag == SP_TAG_INT && b.tag == SP_TAG_INT) return sp_box_int(a.v.i + b.v.i); if (a.tag == SP_TAG_FLT && b.tag == SP_TAG_FLT) return sp_box_float(a.v.f + b.v.f); if (a.tag == SP_TAG_INT && b.tag == SP_TAG_FLT) return sp_box_float((mrb_float)a.v.i + b.v.f); if (a.tag == SP_TAG_FLT && b.tag == SP_TAG_INT) return sp_box_float(a.v.f + (mrb_float)b.v.i); if (a.tag == SP_TAG_STR && b.tag == SP_TAG_STR) return sp_box_str(sp_str_concat(a.v.s, b.v.s)); return sp_box_int(0); }")9063-
emit_raw("static sp_RbVal sp_poly_sub(sp_RbVal a, sp_RbVal b) { if (a.tag == SP_TAG_INT && b.tag == SP_TAG_INT) return sp_box_int(a.v.i - b.v.i); if (a.tag == SP_TAG_FLT && b.tag == SP_TAG_FLT) return sp_box_float(a.v.f - b.v.f); return sp_box_int(0); }")9064-
emit_raw("static sp_RbVal sp_poly_mul(sp_RbVal a, sp_RbVal b) { if (a.tag == SP_TAG_INT && b.tag == SP_TAG_INT) return sp_box_int(a.v.i * b.v.i); if (a.tag == SP_TAG_FLT && b.tag == SP_TAG_FLT) return sp_box_float(a.v.f * b.v.f); if (a.tag == SP_TAG_INT && b.tag == SP_TAG_FLT) return sp_box_float((mrb_float)a.v.i * b.v.f); if (a.tag == SP_TAG_FLT && b.tag == SP_TAG_INT) return sp_box_float(a.v.f * (mrb_float)b.v.i); return sp_box_int(0); }")9065-
emit_raw("static mrb_bool sp_poly_gt(sp_RbVal a, sp_RbVal b) { if (a.tag == SP_TAG_INT && b.tag == SP_TAG_INT) return a.v.i > b.v.i; if (a.tag == SP_TAG_FLT && b.tag == SP_TAG_FLT) return a.v.f > b.v.f; return FALSE; }")9066-
emit_raw("")9067-
emit_raw("/* PolyArray: array of sp_RbVal */")9068-
emit_raw("typedef struct { sp_RbVal *data; mrb_int len; mrb_int cap; } sp_PolyArray;")9069-
emit_raw("static sp_PolyArray *sp_PolyArray_new(void) { sp_PolyArray *a = (sp_PolyArray *)sp_gc_alloc(sizeof(sp_PolyArray), NULL, NULL); a->cap = 16; a->data = (sp_RbVal *)malloc(sizeof(sp_RbVal) * a->cap); a->len = 0; return a; }")9070-
emit_raw("static void sp_PolyArray_push(sp_PolyArray *a, sp_RbVal v) { if (a->len >= a->cap) { a->cap = a->cap * 2 + 1; a->data = (sp_RbVal *)realloc(a->data, sizeof(sp_RbVal) * a->cap); } a->data[a->len++] = v; }")9071-
emit_raw("static mrb_int sp_PolyArray_length(sp_PolyArray *a) { return a->len; }")9072-
emit_raw("static sp_RbVal sp_PolyArray_get(sp_PolyArray *a, mrb_int i) { if (i < 0) i += a->len; return a->data[i]; }")9073-
emit_raw("static sp_PolyArray *sp_PolyArray_dup(sp_PolyArray *a) { sp_PolyArray *b = sp_PolyArray_new(); for (mrb_int i = 0; i < a->len; i++) sp_PolyArray_push(b, a->data[i]); return b; }")9074-
emit_raw("static void sp_PolyArray_shuffle_bang(sp_PolyArray *a) { for (mrb_int i = a->len - 1; i > 0; i--) { mrb_int j = (mrb_int)(rand() % (i + 1)); sp_RbVal t = a->data[i]; a->data[i] = a->data[j]; a->data[j] = t; } }")9075-
emit_raw("static sp_PolyArray *sp_PolyArray_shuffle(sp_PolyArray *a) { sp_PolyArray *b = sp_PolyArray_dup(a); sp_PolyArray_shuffle_bang(b); return b; }")9076-
emit_raw("")9077-
end9078-
9079-
def emit_setjmp_runtime9080-
emit_raw("#include <setjmp.h>")9081-
emit_raw("#define SP_EXC_STACK_MAX 64")9082-
emit_raw("static jmp_buf sp_exc_stack[SP_EXC_STACK_MAX];")9083-
emit_raw("static const char *sp_exc_msg[SP_EXC_STACK_MAX];")9084-
emit_raw("static volatile int sp_exc_top = 0;")9085-
emit_raw("static const char *sp_exc_cls[SP_EXC_STACK_MAX];")9086-
emit_raw("static volatile const char *sp_last_exc_cls = \"\";")9087-
emit_raw("static void sp_raise_cls(const char *cls, const char *msg) { if (sp_exc_top > 0) { sp_exc_msg[sp_exc_top-1] = msg; sp_exc_cls[sp_exc_top-1] = cls; sp_last_exc_cls = cls; longjmp(sp_exc_stack[sp_exc_top-1], 1); } fprintf(stderr, \"unhandled exception: %s" + bsl_n + "\", msg); exit(1); }")9088-
emit_raw("static void sp_raise(const char *msg) { sp_raise_cls(\"RuntimeError\", msg); }")9089-
emit_raw("static mrb_bool sp_exc_is_a(const char *cls, const char *target) { return strcmp(cls, target) == 0; }")9090-
emit_raw("")9091-
# catch/throw support9092-
emit_raw("#define SP_CATCH_STACK_MAX 64")9093-
emit_raw("static jmp_buf sp_catch_stack[SP_CATCH_STACK_MAX];")9094-
emit_raw("static const char *sp_catch_tag[SP_CATCH_STACK_MAX];")9095-
emit_raw("static mrb_int sp_catch_val[SP_CATCH_STACK_MAX];")9096-
emit_raw("static volatile int sp_catch_top = 0;")9097-
emit_raw("static void sp_throw(const char *tag, mrb_int val) { int i = sp_catch_top - 1; while (i >= 0) { if (strcmp(sp_catch_tag[i], tag) == 0) { sp_catch_val[i] = val; sp_catch_top = i + 1; longjmp(sp_catch_stack[i], 1); } i--; } fprintf(stderr, \"uncaught throw: %s" + bsl_n + "\", tag); exit(1); }")9098-
emit_raw("")9099-
end9100-
9101-
def emit_file_io_runtime9102-
emit_raw("static const char *sp_file_read(const char *path) { FILE *f = fopen(path, \"rb\"); if (!f) return \"\"; fseek(f, 0, SEEK_END); long sz = ftell(f); fseek(f, 0, SEEK_SET); char *buf = (char *)malloc(sz + 1); if (sz > 0) { size_t r = fread(buf, 1, sz, f); (void)r; } buf[sz] = 0; fclose(f); return buf; }")9103-
emit_raw("static void sp_file_write(const char *path, const char *data) { FILE *f = fopen(path, \"w\"); if (f) { fputs(data, f); fclose(f); } }")9104-
emit_raw("static mrb_bool sp_file_exist(const char *path) { FILE *f = fopen(path, \"r\"); if (f) { fclose(f); return TRUE; } return FALSE; }")9105-
emit_raw("static void sp_file_delete(const char *path) { remove(path); }")9106-
emit_raw("static const char *sp_backtick(const char *cmd) { FILE *p = popen(cmd, \"r\"); if (!p) return \"\"; char *buf = (char *)malloc(4096); size_t n = fread(buf, 1, 4095, p); buf[n] = 0; pclose(p); return buf; }")9107-
emit_raw("static const char *sp_file_basename(const char *path) { const char *s = strrchr(path, '/'); if (s) return s + 1; return path; }")9108-
emit_raw("")9109-
end9110-
9111-
def emit_proc_runtime9112-
emit_raw("typedef mrb_int (*sp_proc_fn_t)(void *, mrb_int);")9113-
emit_raw("typedef struct sp_Proc { sp_proc_fn_t fn; void *cap; void (*cap_scan)(void *); } sp_Proc;")9114-
emit_raw("static void sp_Proc_scan(void *p) { sp_Proc *pr = (sp_Proc *)p; if (pr->cap && pr->cap_scan) pr->cap_scan(pr->cap); }")9115-
emit_raw("static sp_Proc *sp_proc_new(sp_proc_fn_t fn, void *cap, void (*cap_scan)(void *)) { sp_Proc *p = (sp_Proc *)sp_gc_alloc(sizeof(sp_Proc), NULL, sp_Proc_scan); p->fn = fn; p->cap = cap; p->cap_scan = cap_scan; return p; }")9116-
emit_raw("static mrb_int sp_proc_call(sp_Proc *p, mrb_int arg) { return (p && p->fn) ? p->fn(p->cap, arg) : 0; }")9117-
emit_raw("")9118-
end9119-
9120-
def emit_lambda_runtime9121-
emit_raw("/* ---- Lambda/closure runtime (sp_Val) ---- */")9122-
emit_raw("#include <sys/mman.h>")9123-
emit_raw("typedef struct sp_Val sp_Val;")9124-
emit_raw("typedef sp_Val *(*sp_fn_t)(sp_Val *self, sp_Val *arg);")9125-
emit_raw("struct sp_Val { enum { SP_PROC2, SP_INT2, SP_BOOL2, SP_NIL2 } tag; union { struct { sp_fn_t fn; int ncaptures; } proc; mrb_int ival; mrb_bool bval; } u; sp_Val *captures[]; };")9126-
emit_raw("#define SP_ARENA_SIZE ((size_t)16ULL * 1024 * 1024 * 1024)")9127-
emit_raw("static char *sp_arena = NULL; static size_t sp_arena_pos = 0;")9128-
emit_raw("static void *sp_lam_alloc(size_t sz) { sz = (sz + 7) & ~(size_t)7; if (!sp_arena) { sp_arena = (char *)mmap(NULL, SP_ARENA_SIZE, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0); if (sp_arena == MAP_FAILED) { perror(\"mmap\"); exit(1); } sp_arena_pos = 0; } if (sp_arena_pos + sz > SP_ARENA_SIZE) { fprintf(stderr, \"arena exhausted" + bsl_n + "\"); exit(1); } void *p = sp_arena + sp_arena_pos; sp_arena_pos += sz; return p; }")9129-
emit_raw("static sp_Val *sp_lam_proc(sp_fn_t fn, int ncap) { sp_Val *v = (sp_Val *)sp_lam_alloc(sizeof(sp_Val) + sizeof(sp_Val *) * ncap); v->tag = SP_PROC2; v->u.proc.fn = fn; v->u.proc.ncaptures = ncap; return v; }")9130-
emit_raw("static sp_Val *sp_lam_int(mrb_int n) { sp_Val *v = (sp_Val *)sp_lam_alloc(sizeof(sp_Val)); v->tag = SP_INT2; v->u.ival = n; return v; }")9131-
emit_raw("static sp_Val *sp_lam_bool(mrb_bool b) { sp_Val *v = (sp_Val *)sp_lam_alloc(sizeof(sp_Val)); v->tag = SP_BOOL2; v->u.bval = b; return v; }")9132-
emit_raw("static sp_Val sp_lam_nil_val = { .tag = SP_NIL2 };")9133-
emit_raw("static sp_Val *sp_lam_call(sp_Val *f, sp_Val *arg) { return f->u.proc.fn(f, arg); }")9134-
emit_raw("static mrb_int sp_lam_to_int(sp_Val *v) { return v->u.ival; }")9135-
emit_raw("")9136-
end9137-
9138-
def emit_fiber_runtime9139-
emit_raw("/* ---- Fiber runtime (ucontext) ---- */")9140-
emit_raw("#include <ucontext.h>")9141-
emit_raw("#include <sys/mman.h>")9142-
emit_raw("#define SP_FIBER_STACK_SIZE (64*1024)")9143-
emit_raw("typedef struct sp_Fiber{ucontext_t ctx;ucontext_t caller_ctx;char*stack;int state;int transferred;sp_RbVal yielded_value;sp_RbVal resumed_value;void(*body)(struct sp_Fiber*);void*user_data;int saved_exc_top;int saved_catch_top;}sp_Fiber;")9144-
emit_raw("static sp_Fiber sp_fiber_root;")9145-
emit_raw("static sp_Fiber*sp_fiber_current=&sp_fiber_root;")9146-
emit_raw("static void sp_Fiber_fin(void*p){sp_Fiber*f=(sp_Fiber*)p;if(f->stack)munmap(f->stack,SP_FIBER_STACK_SIZE);}")9147-
emit_raw("static void sp_Fiber_scan(void*p){sp_Fiber*f=(sp_Fiber*)p;if(f->user_data)sp_gc_mark(f->user_data);}")9148-
emit_raw("static sp_Fiber*sp_Fiber_new(void(*body)(sp_Fiber*)){sp_Fiber*f=(sp_Fiber*)sp_gc_alloc(sizeof(sp_Fiber),sp_Fiber_fin,sp_Fiber_scan);f->stack=(char*)mmap(NULL,SP_FIBER_STACK_SIZE,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0);f->state=0;f->transferred=0;f->body=body;f->yielded_value=sp_box_nil();f->resumed_value=sp_box_nil();f->user_data=NULL;f->saved_exc_top=0;f->saved_catch_top=0;return f;}")9149-
emit_raw("static void sp_fiber_trampoline(void){sp_Fiber*f=sp_fiber_current;f->body(f);f->state=3;if(f->transferred){sp_fiber_current=&sp_fiber_root;setcontext(&sp_fiber_root.ctx);}else{swapcontext(&f->ctx,&f->caller_ctx);}}")9150-
emit_raw("static sp_RbVal sp_Fiber_resume(sp_Fiber*f,sp_RbVal val){if(f->state==3){sp_raise_cls(\"FiberError\",\"attempt to resume a terminated fiber\");}f->resumed_value=val;sp_Fiber*prev=sp_fiber_current;sp_fiber_current=f;if(f->state==0){f->state=1;getcontext(&f->ctx);f->ctx.uc_stack.ss_sp=f->stack;f->ctx.uc_stack.ss_size=SP_FIBER_STACK_SIZE;f->ctx.uc_link=&f->caller_ctx;makecontext(&f->ctx,(void(*)(void))sp_fiber_trampoline,0);swapcontext(&f->caller_ctx,&f->ctx);}else{f->state=1;swapcontext(&f->caller_ctx,&f->ctx);}sp_fiber_current=prev;return f->yielded_value;}")9151-
emit_raw("static sp_RbVal sp_Fiber_yield(sp_RbVal val){sp_Fiber*f=sp_fiber_current;f->yielded_value=val;f->state=2;swapcontext(&f->ctx,&f->caller_ctx);return f->resumed_value;}")9152-
emit_raw("static mrb_bool sp_Fiber_alive(sp_Fiber*f){return f->state!=3;}")9153-
emit_raw("static sp_RbVal sp_Fiber_transfer(sp_Fiber*f,sp_RbVal val){f->resumed_value=val;sp_Fiber*prev=sp_fiber_current;sp_fiber_current=f;if(f->state==0){f->state=1;f->transferred=1;getcontext(&f->ctx);f->ctx.uc_stack.ss_sp=f->stack;f->ctx.uc_stack.ss_size=SP_FIBER_STACK_SIZE;f->ctx.uc_link=&prev->ctx;makecontext(&f->ctx,(void(*)(void))sp_fiber_trampoline,0);swapcontext(&prev->ctx,&f->ctx);}else{f->state=1;swapcontext(&prev->ctx,&f->ctx);}sp_fiber_current=prev;return prev->resumed_value;}")9154-
emit_raw("")9155-
end9156-
9157-
def emit_stringio_runtime9158-
emit_raw("/* ---- StringIO runtime ---- */")9159-
emit_raw("typedef struct { char *buf; int64_t len; int64_t cap; int64_t pos; int64_t lineno; int closed; } sp_StringIO;")9160-
emit_raw("static void sio_grow(sp_StringIO *sio, int64_t need) { int64_t req = sio->pos + need; if (req <= sio->cap) return; int64_t nc = sio->cap ? sio->cap : 64; while (nc < req) nc *= 2; sio->buf = (char *)realloc(sio->buf, nc + 1); sio->cap = nc; }")9161-
emit_raw("static int64_t sio_write(sp_StringIO *sio, const char *d, int64_t dl) { sio_grow(sio, dl); if (sio->pos > sio->len) memset(sio->buf + sio->len, 0, sio->pos - sio->len); memcpy(sio->buf + sio->pos, d, dl); sio->pos += dl; if (sio->pos > sio->len) sio->len = sio->pos; sio->buf[sio->len] = '" + bsl + "0'; return dl; }")9162-
emit_raw("static sp_StringIO *sp_StringIO_new(void) { sp_StringIO *s = (sp_StringIO *)calloc(1, sizeof(sp_StringIO)); s->buf = (char *)calloc(1, 64); s->cap = 63; return s; }")9163-
emit_raw("static sp_StringIO *sp_StringIO_new_s(const char *init) { sp_StringIO *s = (sp_StringIO *)calloc(1, sizeof(sp_StringIO)); int64_t l = (int64_t)strlen(init); int64_t c = l < 63 ? 63 : l; s->buf = (char *)malloc(c+1); memcpy(s->buf, init, l); s->buf[l]='" + bsl + "0'; s->len = l; s->cap = c; return s; }")9164-
emit_raw("static const char *sp_StringIO_string(sp_StringIO *s) { return s->buf ? s->buf : \"\"; }")9165-
emit_raw("static int64_t sp_StringIO_pos(sp_StringIO *s) { return s->pos; }")9166-
emit_raw("static int64_t sp_StringIO_size(sp_StringIO *s) { return s->len; }")9167-
emit_raw("static int64_t sp_StringIO_write(sp_StringIO *s, const char *str) { return sio_write(s, str, (int64_t)strlen(str)); }")9168-
emit_raw("static int64_t sp_StringIO_puts(sp_StringIO *s, const char *str) { int64_t l = (int64_t)strlen(str); sio_write(s, str, l); if (l == 0 || str[l-1] != '" + bsl_n + "') sio_write(s, \"" + bsl_n + "\", 1); return 0; }")9169-
emit_raw("static int64_t sp_StringIO_puts_empty(sp_StringIO *s) { sio_write(s, \"" + bsl_n + "\", 1); return 0; }")9170-
emit_raw("static int64_t sp_StringIO_print(sp_StringIO *s, const char *str) { return sio_write(s, str, (int64_t)strlen(str)); }")9171-
emit_raw("static int64_t sp_StringIO_putc(sp_StringIO *s, int64_t ch) { char c = (char)(ch & 0xFF); sio_write(s, &c, 1); return ch; }")9172-
emit_raw("static const char *sp_StringIO_read(sp_StringIO *s) { if (s->pos >= s->len) return \"\"; const char *r = s->buf + s->pos; s->pos = s->len; return r; }")9173-
emit_raw("static const char *sp_StringIO_read_n(sp_StringIO *s, int64_t n) { if (s->pos >= s->len) return \"\"; int64_t rem = s->len - s->pos; if (n > rem) n = rem; char *r = (char *)malloc(n+1); memcpy(r, s->buf + s->pos, n); r[n] = '" + bsl + "0'; s->pos += n; return r; }")9174-
emit_raw("static const char *sp_StringIO_gets(sp_StringIO *s) { if (s->pos >= s->len) return NULL; const char *st = s->buf + s->pos; const char *nl = memchr(st, '" + bsl_n + "', s->len - s->pos); int64_t ll = nl ? (nl - st) + 1 : s->len - s->pos; char *r = (char *)malloc(ll+1); memcpy(r, st, ll); r[ll] = '" + bsl + "0'; s->pos += ll; s->lineno++; return r; }")9175-
emit_raw("static const char *sp_StringIO_getc(sp_StringIO *s) { if (s->pos >= s->len) return NULL; char *gc = (char *)malloc(2); gc[0] = s->buf[s->pos++]; gc[1] = '" + bsl + "0'; return gc; }")9176-
emit_raw("static int64_t sp_StringIO_getbyte(sp_StringIO *s) { if (s->pos >= s->len) return -1; return (int64_t)(unsigned char)s->buf[s->pos++]; }")9177-
emit_raw("static int64_t sp_StringIO_rewind(sp_StringIO *s) { s->pos = 0; s->lineno = 0; return 0; }")9178-
emit_raw("static int64_t sp_StringIO_seek(sp_StringIO *s, int64_t off) { if (off < 0) off = 0; s->pos = off; return 0; }")9179-
emit_raw("static int64_t sp_StringIO_tell(sp_StringIO *s) { return s->pos; }")9180-
emit_raw("static mrb_bool sp_StringIO_eof_p(sp_StringIO *s) { return s->pos >= s->len; }")9181-
emit_raw("static int64_t sp_StringIO_truncate(sp_StringIO *s, int64_t l) { if (l < 0) l = 0; if (l < s->len) { s->len = l; s->buf[l] = '" + bsl + "0'; } return 0; }")9182-
emit_raw("static int64_t sp_StringIO_close(sp_StringIO *s) { s->closed = 1; return 0; }")9183-
emit_raw("static mrb_bool sp_StringIO_closed_p(sp_StringIO *s) { return s->closed; }")9184-
emit_raw("static sp_StringIO *sp_StringIO_flush(sp_StringIO *s) { return s; }")9185-
emit_raw("static mrb_bool sp_StringIO_sync(sp_StringIO *s) { (void)s; return 1; }")9186-
emit_raw("static mrb_bool sp_StringIO_isatty(sp_StringIO *s) { (void)s; return 0; }")9187-
emit_raw("")9188-
end9189-
91908834
# ---- Struct emission ----91918835
def emit_global_constants91928836
# Emit file-scope constant declarations (initialized in main)@@ -11276,7 +10920,6 @@
1127610920
end1127710921
if is_obj_type(arg_type) == 11127810922
target_type = arg_type + "_ptr_array"11279-
@needs_ptr_array = 11128010923
@needs_gc = 11128110924
ki = 01128210925
while ki < names.length@@ -12392,11 +12035,9 @@
1239212035
return tmp1239312036
end1239412037
if t == "XStringNode"12395-
@needs_file_io = 11239612038
return "sp_backtick(" + c_string_literal(@nd_content[nid]) + ")"1239712039
end1239812040
if t == "InterpolatedXStringNode"12399-
@needs_file_io = 11240012041
interp = compile_interpolated(nid)1240112042
return "sp_backtick(" + interp + ")"1240212043
end@@ -13546,7 +13187,6 @@
1354613187
return "0"1354713188
end1354813189
if mname == "system"13549-
@needs_file_io = 11355013190
@needs_system = 11355113191
return "({ fflush(stdout); sp_last_status = system(" + compile_arg0(nid) + "); sp_last_status == 0; })"1355213192
end@@ -13593,7 +13233,6 @@
1359313233
end1359413234
if mname == "proc"1359513235
if @nd_block[nid] >= 013596-
@needs_proc = 11359713236
return compile_proc_literal(nid)1359813237
end1359913238
end@@ -13701,7 +13340,6 @@
1370113340
end1370213341
if has_block_param == 11370313342
if @nd_block[nid] >= 013704-
@needs_proc = 11370513343
block_proc = compile_proc_literal(nid)1370613344
return "sp_" + sanitize_name(mname) + "(" + compile_call_args(nid) + ", " + block_proc + ")"1370713345
end@@ -14355,7 +13993,6 @@
1435513993
if cname != ""1435613994
if cname == "Proc"1435713995
if @nd_block[nid] >= 014358-
@needs_proc = 11435913996
return compile_proc_literal(nid)1436013997
end1436113998
end@@ -15244,7 +14881,6 @@
1524414881
end1524514882
# zip without block: return array of pairs/tuples1524614883
if mname == "zip" && @nd_block[nid] < 015247-
@needs_ptr_array = 11524814884
@needs_gc = 11524914885
pfx_recv = array_c_prefix(recv_type)1525014886
args_id = @nd_arguments[nid]@@ -16093,7 +15729,6 @@
1609315729
if mname == "to_a"1609415730
tt = "tuple:string,int"1609515731
register_tuple_type(tt)16096-
@needs_ptr_array = 11609715732
@needs_gc = 11609815733
tname = tuple_c_name(tt)1609915734
tmp = new_temp@@ -16199,7 +15834,6 @@
1619915834
if mname == "to_a"1620015835
tt = "tuple:string,string"1620115836
register_tuple_type(tt)16202-
@needs_ptr_array = 11620315837
@needs_gc = 11620415838
tname = tuple_c_name(tt)1620515839
tmp = new_temp@@ -16369,15 +16003,12 @@
1636916003
# File operations1637016004
if rcname == "File"1637116005
if mname == "read"16372-
@needs_file_io = 11637316006
return "sp_file_read(" + compile_arg0(nid) + ")"1637416007
end1637516008
if mname == "exist?"16376-
@needs_file_io = 11637716009
return "sp_file_exist(" + compile_arg0(nid) + ")"1637816010
end1637916011
if mname == "delete"16380-
@needs_file_io = 11638116012
return "(sp_file_delete(" + compile_arg0(nid) + "), 0)"1638216013
end1638316014
if mname == "join"@@ -17575,7 +17206,6 @@
1757517206
return tmp1757617207
end1757717208
if is_ptr_array_type(arr_type) == 117578-
@needs_ptr_array = 11757917209
tmp = new_temp1758017210
emit(" sp_PtrArray *" + tmp + " = sp_PtrArray_new();")1758117211
k = 0@@ -17662,7 +17292,6 @@
1766217292
return tmp1766317293
end1766417294
if ht == "sym_poly_hash"17665-
@needs_sym_poly_hash = 11766617295
@needs_rb_value = 11766717296
tmp = new_temp1766817297
emit(" sp_SymPolyHash *" + tmp + " = sp_SymPolyHash_new();")@@ -17674,7 +17303,6 @@
1767417303
return tmp1767517304
end1767617305
if ht == "str_poly_hash"17677-
@needs_str_poly_hash = 11767817306
@needs_rb_value = 11767917307
tmp = new_temp1768017308
emit(" sp_StrPolyHash *" + tmp + " = sp_StrPolyHash_new();")@@ -17764,7 +17392,6 @@
1776417392
@needs_gc = 11776517393
emit(" " + vref + " = sp_IntArray_new();")1776617394
else17767-
@needs_ptr_array = 11776817395
@needs_gc = 11776917396
emit(" " + vref + " = sp_PtrArray_new();")1777017397
end@@ -18819,7 +18446,6 @@
1881918446
if @nd_type[recv] == "ConstantReadNode"1882018447
if @nd_name[recv] == "File"1882118448
if @nd_block[nid] >= 018822-
@needs_file_io = 11882318449
args_id = @nd_arguments[nid]1882418450
path_expr = "\"\""1882518451
mode_expr = "\"r\""@@ -19612,7 +19238,6 @@
1961219238
# system1961319239
if mname == "system"1961419240
if recv < 019615-
@needs_file_io = 11961619241
emit(" fflush(stdout);")1961719242
emit(" sp_last_status = system(" + compile_arg0(nid) + ");")1961819243
return 1@@ -19648,7 +19273,6 @@
1964819273
rcname = @nd_name[recv]1964919274
if rcname == "File"1965019275
if mname == "write"19651-
@needs_file_io = 11965219276
args_id = @nd_arguments[nid]1965319277
arg_ids = []1965419278
if args_id >= 0@@ -19666,7 +19290,6 @@
1966619290
return 11966719291
end1966819292
if mname == "delete"19669-
@needs_file_io = 11967019293
emit(" sp_file_delete(" + compile_arg0(nid) + ");")1967119294
return 11967219295
end@@ -23631,7 +23254,6 @@
2363123254
end2363223255
if lmname == "proc"2363323256
if return_type != "void"23634-
@needs_proc = 12363523257
val = compile_proc_literal(last)2363623258
emit(" return " + val + ";")2363723259
return