Skip to content

Commit bdaff40

Browse files
authored
Merge pull request #2824 from actonlang/new-unbox
New unbox
2 parents 75d0f67 + 8fd744d commit bdaff40

84 files changed

Lines changed: 2943 additions & 2276 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

base/builtin/bigint.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void zz_malloc_fit(zz_ptr res, len_t m) {
3434
res->alloc = m;
3535
}
3636

37-
B_bigint B_IntegralD_bigintD___lshift__(B_IntegralD_bigint wit, B_bigint a, B_int b);
37+
B_bigint B_IntegralD_bigintD___lshift__(B_IntegralD_bigint wit, B_bigint a, int64_t b);
3838

3939
B_bigint B_bigintG_new(B_atom a, B_int base) {
4040
if (base) {
@@ -123,7 +123,7 @@ B_bigint B_bigintG_new(B_atom a, B_int base) {
123123
double m = frexp(aval,&e);
124124
if (e>52) {
125125
B_bigint c = toB_bigint((long)(m*4503599627370496.0)); // (1<< 52);
126-
B_int d = toB_int(e-52);
126+
int64_t d = e-52;
127127
return B_IntegralD_bigintD___lshift__(NULL,c,d);
128128
} else {
129129
long al = (long)aval;
@@ -282,7 +282,7 @@ B_bigint B_IntegralD_bigintD_conjugate(B_IntegralD_bigint wit, B_bigint a) {
282282
return a;
283283
}
284284

285-
B_float B_IntegralD_bigintD___float__ (B_IntegralD_bigint wit, B_bigint n) {
285+
double B_IntegralD_bigintD___float__ (B_IntegralD_bigint wit, B_bigint n) {
286286
return B_floatG_new((B_atom)n);
287287
}
288288

@@ -327,26 +327,26 @@ B_bigint B_IntegralD_bigintD___round__ (B_IntegralD_bigint wit, B_bigint n, B_in
327327
return wit2->$class->__fromatom__(wit2,(B_atom)res);
328328
}
329329

330-
B_int B_IntegralD_bigintD___int__ (B_IntegralD_bigint wit, B_bigint n) {
330+
int64_t B_IntegralD_bigintD___int__ (B_IntegralD_bigint wit, B_bigint n) {
331331
unsigned long k = n->val.n[0];
332332
long sz = n->val.size;
333333
if (labs(sz) > 1 || (sz==1 && k > 0x7ffffffffffffffful) || sz == -1 && k > 0x8000000000000000ul) {
334334
char errmsg[1024];
335335
snprintf(errmsg, sizeof(errmsg), "bigint.__int__: value %s out of range for type int",get_str(&n->val));
336336
$RAISE((B_BaseException)$NEW(B_ValueError,to$str(errmsg)));
337337
}
338-
return toB_int(k*sz);
338+
return k*sz;
339339
}
340340

341-
B_int B_IntegralD_bigintD___index__ (B_IntegralD_bigint wit, B_bigint n) {
341+
int64_t B_IntegralD_bigintD___index__ (B_IntegralD_bigint wit, B_bigint n) {
342342
unsigned long k = n->val.n[0];
343343
long sz = n->val.size;
344344
if (labs(sz) > 1 || (sz==1 && k > 0x7ffffffffffffffful) || sz == -1 && k > 0x8000000000000000ul) {
345345
char errmsg[1024];
346346
snprintf(errmsg, sizeof(errmsg), "bigint.__index__: value %s out of range for type int",get_str(&n->val));
347347
$RAISE((B_BaseException)$NEW(B_ValueError,to$str(errmsg)));
348348
}
349-
return toB_int(k*sz);
349+
return k*sz;
350350
}
351351

352352
B_tuple B_IntegralD_bigintD___divmod__(B_IntegralD_bigint wit, B_bigint a, B_bigint b) {
@@ -377,10 +377,10 @@ B_bigint B_IntegralD_bigintD___mod__(B_IntegralD_bigint wit, B_bigint a, B_bigin
377377
return t->components[1];
378378
}
379379

380-
B_bigint B_IntegralD_bigintD___lshift__(B_IntegralD_bigint wit, B_bigint a, B_int b) {
380+
B_bigint B_IntegralD_bigintD___lshift__(B_IntegralD_bigint wit, B_bigint a, int64_t b) {
381381
zz_struct aval = a->val;
382382
long ma = aval.size;
383-
long bval = fromB_int(b);
383+
long bval = b;
384384
if (ma==0 || bval==0)
385385
return a;
386386
if (bval<0) {
@@ -408,10 +408,10 @@ B_bigint B_IntegralD_bigintD___lshift__(B_IntegralD_bigint wit, B_bigint a, B_i
408408
return res;
409409
}
410410

411-
B_bigint B_IntegralD_bigintD___rshift__(B_IntegralD_bigint wit, B_bigint a, B_int b) {
411+
B_bigint B_IntegralD_bigintD___rshift__(B_IntegralD_bigint wit, B_bigint a, int64_t b) {
412412
zz_struct aval = a->val;
413413
long ma = aval.size;
414-
long bval = fromB_int(b);
414+
long bval = b;
415415
if (ma==0 || bval==0)
416416
return a;
417417
if (bval<0) {
@@ -628,7 +628,7 @@ B_float B_DivD_bigintD___truediv__ (B_DivD_bigint wit, B_bigint a, B_bigint b) {
628628
zz_div(&ared->val,aval,&g->val);
629629
zz_div(&bred->val,bval,&g->val);
630630
zz_divrem(&q->val,&r->val,&ared->val,&bred->val);
631-
return to$float(B_floatG_new((B_atom)q)->val + B_floatG_new((B_atom)r)->val/ B_floatG_new((B_atom)bred)->val);
631+
return toB_float((B_floatG_new((B_atom)q) + B_floatG_new((B_atom)r)/ B_floatG_new((B_atom)bred)));
632632
}
633633

634634
// B_OrdD_bigint ////////////////////////////////////////////////////////////////////////////////////////

base/builtin/builtin_functions.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ struct $IdentityActorG_class $IdentityActorG_methods = {"$IdentityActor", UNASSI
503503

504504
// Various small functions //////////////////////////////////////////////////////////////
505505

506-
// Code generated by acton
506+
// Code generated by actonc
507507
/*
508508
$WORD B_abs (B_Number W_149, B_Real W_148, $WORD x) {
509509
return W_149->$class->__abs__(W_149, x, W_148);
@@ -540,7 +540,7 @@ B_tuple B_divmod (B_Integral W_225, $WORD a, $WORD b) {
540540
B_Iterator B_iter (B_Iterable W_278, $WORD x) {
541541
return W_278->$class->__iter__(W_278, x);
542542
}
543-
B_int B_len (B_Collection W_301, $WORD x) {
543+
int64_t B_len (B_Collection W_301, $WORD x) {
544544
return W_301->$class->__len__(W_301, x);
545545
}
546546

base/builtin/builtin_functions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ struct $IdentityActor {
178178
$WORD B_min_def(B_Ord wit, B_Iterable wit2, $WORD iter, $WORD deflt);
179179
$WORD B_max_def(B_Ord wit, B_Iterable wit2, $WORD iter, $WORD deflt);
180180

181-
// Signatures generated by acton
181+
// Signatures generated by actonc
182182

183183
/*
184184
$WORD B_abs (B_Real, B_Number, $WORD);
@@ -187,7 +187,7 @@ B_bool B_any (B_Iterable, $WORD);
187187
B_tuple B_divmod (B_Integral, $WORD, $WORD);
188188
B_u64 B_hash (B_Hashable, $WORD);
189189
B_Iterator B_iter (B_Iterable, $WORD);
190-
B_int B_len (B_Collection, $WORD);
190+
int64_t B_len (B_Collection, $WORD);
191191
$WORD $next (B_Iterator);
192192
$WORD B_pow (B_Number, $WORD, $WORD);
193193
B_str B_repr(B_value);

base/builtin/complex.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ B_complex B_complexG_new(B_Number wit, $WORD c) {
2424
}
2525

2626
B_complex B_complexD_from_real_imag (B_Real wit1, B_Real wit2, $WORD real, $WORD imag) {
27-
double re = wit1->$class->__float__(wit1, real)->val;
28-
double im = wit2->$class->__float__(wit2, imag)->val;
27+
double re = wit1->$class->__float__(wit1, real);
28+
double im = wit2->$class->__float__(wit2, imag);
2929
return toB_complex(re + im * _Complex_I);
3030
}
3131

base/builtin/dict.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static void build_indices(B_Hashable hashwit, $table oldtable, $table newtable,
4949
if (oldtable->tb_size > INIT_SIZE)
5050
hash = ep->hash;
5151
else {
52-
hash = fromB_u64(B_hash(hashwit, ep->key));
52+
hash = B_hash(hashwit, ep->key);
5353
ep->hash = hash;
5454
}
5555
unsigned long i = (unsigned long)hash & mask;
@@ -201,7 +201,7 @@ static void insertdict(B_dict dict, B_Hashable hashwit, uint64_t hash, $WORD key
201201
if (!dict->table || dict->table->tb_usable <= 0)
202202
dictresize(hashwit,dict);
203203
if (dict->table->tb_size == 2*INIT_SIZE)
204-
hash = fromB_u64(B_hash(hashwit, key));
204+
hash = B_hash(hashwit, key);
205205
int ix = $lookdict(dict,hashwit,hash,key,&old_value);
206206
if (ix == DKIX_EMPTY) {
207207
table = dict->table;
@@ -351,7 +351,7 @@ B_bool B_dictrel(bool directfalse,B_OrdD_dict w, B_dict a, B_dict b) {
351351
x = it->$class->__next__(it);
352352
long h = 0;
353353
if (a->table->tb_size > INIT_SIZE)
354-
h = fromB_u64(B_hash(wH, x));
354+
h = B_hash(wH, x);
355355
int ixa = $lookdict(a, wH, h, x, &resa);
356356
int ixb = $lookdict(b, wH, h, x ,&resb);
357357
if (ixb<0 || wB->$class->__ne__(wB,resa,resb)->val) {
@@ -469,8 +469,8 @@ B_dict B_MappingD_dictD___fromiter__ (B_MappingD_dict wit, B_Iterable wit2, $WOR
469469
*/
470470
}
471471

472-
B_int B_MappingD_dictD___len__ (B_MappingD_dict wit, B_dict dict) {
473-
return toB_int(dict->numelements);
472+
int64_t B_MappingD_dictD___len__ (B_MappingD_dict wit, B_dict dict) {
473+
return dict->numelements;
474474
}
475475

476476
B_bool B_MappingD_dictD___contains__ (B_MappingD_dict wit, B_dict dict, $WORD key) {
@@ -480,7 +480,7 @@ B_bool B_MappingD_dictD___contains__ (B_MappingD_dict wit, B_dict dict, $WORD ke
480480
$WORD res;
481481
long h = 0;
482482
if (dict->table->tb_size > INIT_SIZE)
483-
h = fromB_u64(B_hash(hashwit, key));
483+
h = B_hash(hashwit, key);
484484
return toB_bool($lookdict(dict,hashwit,h,key,&res) >= 0);
485485
}
486486

@@ -494,7 +494,7 @@ B_bool B_MappingD_dictD___containsnot__ (B_MappingD_dict wit, B_dict dict, $WORD
494494
uint64_t hash = 0;
495495
B_Hashable hashwit = wit->W_HashableD_AD_MappingD_dict;
496496
if (dict->table->tb_size > INIT_SIZE)
497-
hash = fromB_u64(B_hash(hashwit, key));
497+
hash = B_hash(hashwit, key);
498498
$WORD res;
499499
int ix = $lookdict(dict,hashwit,hash,key,&res);
500500
if (ix < 0)
@@ -509,7 +509,7 @@ B_bool B_MappingD_dictD___containsnot__ (B_MappingD_dict wit, B_dict dict, $WORD
509509
uint64_t hash = 0;
510510
B_Hashable hashwit = wit->W_HashableD_AD_MappingD_dict;
511511
if (dict->table->tb_size > INIT_SIZE)
512-
hash = fromB_u64(B_hash(hashwit, key));
512+
hash = B_hash(hashwit, key);
513513
$WORD res;
514514
int ix = $lookdict(dict,hashwit,hash,key,&res);
515515
if (ix < 0)
@@ -525,7 +525,7 @@ B_bool B_MappingD_dictD___containsnot__ (B_MappingD_dict wit, B_dict dict, $WORD
525525
uint64_t hash = 0;
526526
B_Hashable hashwit = wit->W_HashableD_AD_MappingD_dict;
527527
if (table->tb_size > INIT_SIZE) {
528-
hash = fromB_u64(B_hash(hashwit, key));
528+
hash = B_hash(hashwit, key);
529529
}
530530
$WORD res;
531531
int ix = $lookdict(dict,hashwit,hash,key,&res);
@@ -551,7 +551,7 @@ B_bool B_MappingD_dictD___containsnot__ (B_MappingD_dict wit, B_dict dict, $WORD
551551
uint64_t hash = 0;
552552
B_Hashable hashwit = wit->W_HashableD_AD_MappingD_dict;
553553
if (table->tb_size > INIT_SIZE) {
554-
hash = fromB_u64(B_hash(hashwit, key));
554+
hash = B_hash(hashwit, key);
555555
}
556556
$WORD res;
557557
int ix = $lookdict(dict,hashwit,hash,key,&res);
@@ -726,7 +726,7 @@ B_tuple B_MappingD_dictD_popitem (B_MappingD_dict wit, B_dict dict) {
726726
$entry_t entry = &TB_ENTRIES(table)[ix];
727727
if (entry->value != DELETED) {
728728
if (table->tb_size > INIT_SIZE) {
729-
uint64_t hash = fromB_u64(B_hash(hashwit, entry->key));
729+
uint64_t hash = B_hash(hashwit, entry->key);
730730
int i = $lookdict_index(table,hash,ix);
731731
table->tb_indices[i] = DKIX_DUMMY;
732732
}
@@ -742,7 +742,7 @@ B_tuple B_MappingD_dictD_popitem (B_MappingD_dict wit, B_dict dict) {
742742
$WORD B_MappingD_dictD_setdefault (B_MappingD_dict wit, B_dict dict, $WORD key, $WORD deflt) {
743743
if (!deflt) deflt = B_None;
744744
B_Hashable hashwit = wit->W_HashableD_AD_MappingD_dict;
745-
uint64_t hash = fromB_u64(B_hash(hashwit, key));
745+
uint64_t hash = B_hash(hashwit, key);
746746
$WORD value;
747747
int ix = $lookdict(dict,hashwit,hash,key,&value);
748748
if (ix >= 0)
@@ -760,7 +760,7 @@ B_tuple B_MappingD_dictD_popitem (B_MappingD_dict wit, B_dict dict) {
760760
B_Hashable hashwit = ((B_MappingD_dict)wit->W_Mapping)->W_HashableD_AD_MappingD_dict;
761761
uint64_t hash = 0;
762762
if (dict->table->tb_size > INIT_SIZE) {
763-
hash = fromB_u64(B_hash(hashwit, key));
763+
hash = B_hash(hashwit, key);
764764
}
765765
$WORD res;
766766
int ix = $lookdict(dict,hashwit,hash,key,&res);
@@ -774,7 +774,7 @@ B_NoneType B_IndexedD_MappingD_dictD___setitem__ (B_IndexedD_MappingD_dict wit,
774774
B_Hashable hashwit = ((B_MappingD_dict)wit->W_Mapping)->W_HashableD_AD_MappingD_dict;
775775
uint64_t hash = 0;
776776
if (dict->table && dict->table->tb_size > INIT_SIZE) {
777-
hash = fromB_u64(B_hash(hashwit, key));
777+
hash = B_hash(hashwit, key);
778778
}
779779
insertdict(dict, hashwit, hash, key, value);
780780
return B_None;
@@ -788,7 +788,7 @@ B_NoneType B_IndexedD_MappingD_dictD___delitem__ (B_IndexedD_MappingD_dict wit,
788788
uint64_t hash = 0;
789789
B_Hashable hashwit = ((B_MappingD_dict)wit->W_Mapping)->W_HashableD_AD_MappingD_dict;
790790
if (dict->table->tb_size > INIT_SIZE) {
791-
hash = fromB_u64(B_hash(hashwit, key));
791+
hash = B_hash(hashwit, key);
792792
}
793793
$WORD res;
794794
int ix = $lookdict(dict,hashwit,hash,key,&res);
@@ -813,7 +813,7 @@ B_NoneType B_IndexedD_MappingD_dictD___delitem__ (B_IndexedD_MappingD_dict wit,
813813
void B_dictD_setitem(B_dict dict, B_Hashable hashwit, $WORD key, $WORD value) {
814814
uint64_t hash = 0;
815815
if (dict->table && dict->table->tb_size > INIT_SIZE) {
816-
hash = fromB_u64(B_hash(hashwit, key));
816+
hash = B_hash(hashwit, key);
817817
}
818818
insertdict(dict, hashwit, hash, key, value);
819819
}
@@ -823,7 +823,7 @@ void B_dictD_setitem(B_dict dict, B_Hashable hashwit, $WORD key, $WORD value) {
823823
return deflt;
824824
uint64_t hash = 0;
825825
if (dict->table->tb_size > INIT_SIZE) {
826-
hash = fromB_u64(B_hash(hashwit, key));
826+
hash = B_hash(hashwit, key);
827827
}
828828
$WORD res;
829829
int ix = $lookdict(dict,hashwit,hash,key,&res);
@@ -839,7 +839,7 @@ void B_dictD_setitem(B_dict dict, B_Hashable hashwit, $WORD key, $WORD value) {
839839
$table table = dict->table;
840840
uint64_t hash = 0;
841841
if (table->tb_size > INIT_SIZE) {
842-
hash = fromB_u64(B_hash(hashwit, key));
842+
hash = B_hash(hashwit, key);
843843
}
844844
$WORD res;
845845
int ix = $lookdict(dict,hashwit,hash,key,&res);

base/builtin/env.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ void read_stdin(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) {
9595
return $R_CONT(c$cont, B_None);
9696
}
9797

98-
$R B_EnvD_exitG_local (B_Env self, $Cont c$cont, B_int n) {
99-
return_val = fromB_int(n);
98+
$R B_EnvD_exitG_local (B_Env self, $Cont c$cont, int64_t n) {
99+
return_val = n;
100100
rts_shutdown();
101101
return $R_CONT(c$cont, B_None);
102102
}

base/builtin/exceptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,4 @@ extern struct $RETG_class $RETG_methods;
177177
$RET $RETG_new(B_value);
178178

179179
$WORD $raiseValueError(B_str str);
180-
180+

0 commit comments

Comments
 (0)