Skip to content

Commit 82022bf

Browse files
committed
Enable and generate computed operators
1 parent 324ca83 commit 82022bf

Some content is hidden

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

73 files changed

+5403
-3174
lines changed

include/deemon/computed-operators.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,61 @@ DECL_BEGIN
9090

9191
/* Reusable default operators (and operator callbacks that get inherited) */
9292
/*[[[begin::computer-operator-decls]]]*/
93+
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_Concat(DeeObject *lhs, DeeObject *rhs);
94+
INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL default_seq_printrepr(DeeObject *__restrict self, Dee_formatprinter_t printer, void *arg);
95+
INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL default_set_printrepr(DeeObject *__restrict self, Dee_formatprinter_t printer, void *arg);
96+
INTDEF WUNUSED NONNULL((1, 2)) int DCALL generic_object_compare_eq(DeeObject *lhs, DeeObject *rhs);
97+
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL generic_object_eq(DeeObject *lhs, DeeObject *rhs);
98+
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL generic_object_ne(DeeObject *lhs, DeeObject *rhs);
99+
INTDEF WUNUSED NONNULL((1, 2)) int DCALL generic_object_trycompare_eq(DeeObject *lhs, DeeObject *rhs);
100+
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL iterator_add(DeeObject *lhs, DeeObject *rhs);
101+
INTDEF WUNUSED NONNULL((1)) int DCALL iterator_bool(DeeObject *__restrict self);
102+
INTDEF WUNUSED NONNULL((1, 2)) int DCALL iterator_compare(DeeObject *lhs, DeeObject *rhs);
103+
INTDEF WUNUSED NONNULL((1)) int DCALL iterator_dec(DREF DeeObject **__restrict p_self);
104+
INTDEF WUNUSED NONNULL((1)) int DCALL iterator_inc(DREF DeeObject **__restrict p_self);
105+
INTDEF WUNUSED NONNULL((1, 2)) int DCALL iterator_inplace_add(DREF DeeObject **__restrict p_lhs, DeeObject *rhs);
106+
INTDEF WUNUSED NONNULL((1, 2)) int DCALL iterator_inplace_sub(DREF DeeObject **__restrict p_lhs, DeeObject *rhs);
107+
INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL iterator_next(DeeObject *self, size_t argc, DeeObject *const *argv);
108+
INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL iterator_printrepr(DeeObject *__restrict self, Dee_formatprinter_t printer, void *arg);
109+
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL iterator_sub(DeeObject *lhs, DeeObject *rhs);
110+
INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL map_printrepr(DeeObject *__restrict self, Dee_formatprinter_t printer, void *arg);
111+
INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL module_printrepr(DeeObject *__restrict self, Dee_formatprinter_t printer, void *arg);
112+
INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL module_str(DeeObject *__restrict self);
113+
INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL object_repr(DeeObject *__restrict self);
114+
INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL object_str(DeeObject *__restrict self);
115+
INTDEF WUNUSED NONNULL((1, 2)) int DCALL type_compare_eq(DeeObject *lhs, DeeObject *rhs);
116+
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL type_eq(DeeObject *lhs, DeeObject *rhs);
117+
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL type_ne(DeeObject *lhs, DeeObject *rhs);
118+
INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL type_print(DeeObject *__restrict self, Dee_formatprinter_t printer, void *arg);
119+
INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL type_printrepr(DeeObject *__restrict self, Dee_formatprinter_t printer, void *arg);
120+
INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL type_repr(DeeObject *__restrict self);
121+
INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL type_str(DeeObject *__restrict self);
122+
INTDEF struct type_cmp default__tp_cmp__247219960F1E745D;
123+
INTDEF struct type_cmp default__tp_cmp__26B2EC529683DE3C;
124+
INTDEF struct type_cmp default__tp_cmp__287C06B7236F06BE;
125+
INTDEF struct type_cmp default__tp_cmp__2B5761B4075B51D3;
126+
INTDEF struct type_cmp default__tp_cmp__3C4D336761465F8A;
127+
INTDEF struct type_cmp default__tp_cmp__40D3D60A1F18CAE2;
128+
INTDEF struct type_cmp default__tp_cmp__50A436E90E5A2AF0;
129+
INTDEF struct type_cmp default__tp_cmp__5819FE7E0C5EF426;
130+
INTDEF struct type_cmp default__tp_cmp__6F3C9C45873AB01F;
131+
INTDEF struct type_cmp default__tp_cmp__7188129899C2A8D6;
132+
INTDEF struct type_cmp default__tp_cmp__7EA181D4706D1525;
133+
INTDEF struct type_cmp default__tp_cmp__ABC6920EC80A6EC1;
134+
INTDEF struct type_cmp default__tp_cmp__B8EC3298B952DF3A;
135+
INTDEF struct type_cmp default__tp_cmp__C2B62E6BCA44673D;
136+
INTDEF struct type_cmp default__tp_cmp__C6AA9DC8372C283F;
137+
INTDEF struct type_cmp default__tp_cmp__CE2E4B8E19554701;
138+
INTDEF struct type_cmp default__tp_cmp__DC202CECA797EF15;
139+
INTDEF struct type_iterator default__tp_iterator__863AC70046E4B6B0;
140+
INTDEF struct type_math default__tp_math__385A9235483A0324;
141+
INTDEF struct type_math default__tp_math__3959C0D1502AC76A;
142+
INTDEF struct type_math default__tp_math__56685E2B01B76756;
143+
INTDEF struct type_math default__tp_math__667432E5904B49F8;
144+
INTDEF struct type_math default__tp_math__7C9B3D263E47878C;
145+
INTDEF struct type_math default__tp_math__9211580AA9433079;
146+
INTDEF struct type_math default__tp_math__AFC6A8FA89E9F0A6;
147+
INTDEF struct type_math default__tp_math__BA555DDFFD44D1A5;
93148
/*[[[end::computer-operator-decls]]]*/
94149

95150
INTDEF Dee_hash_t DCALL default__hash__unsupported(DeeObject *__restrict self);

src/deemon/compiler/compiler.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,14 @@ PUBLIC DeeTypeObject DeeCompiler_Type = {
354354
},
355355
/* .tp_dtor = */ (void (DCALL *)(DeeObject *__restrict))&compiler_fini,
356356
/* .tp_assign = */ NULL,
357-
/* .tp_move_assign = */ NULL
357+
/* .tp_move_assign = */ NULL,
358358
},
359359
/* .tp_cast = */ {
360-
/* .tp_str = */ NULL,
361-
/* .tp_repr = */ NULL,
362-
/* .tp_bool = */ NULL
360+
/* .tp_str = */ DEFIMPL(&object_str),
361+
/* .tp_repr = */ DEFIMPL(&object_repr),
362+
/* .tp_bool = */ NULL,
363+
/* .tp_print = */ DEFIMPL(&default__print__with__str),
364+
/* .tp_printrepr = */ DEFIMPL(&default__printrepr__with__repr),
363365
},
364366
/* .tp_call = */ NULL,
365367
/* .tp_visit = */ (void (DCALL *)(DeeObject *__restrict, dvisit_t, void *))&compiler_visit,
@@ -377,7 +379,7 @@ PUBLIC DeeTypeObject DeeCompiler_Type = {
377379
/* .tp_members = */ NULL,
378380
/* .tp_class_methods = */ NULL,
379381
/* .tp_class_getsets = */ NULL,
380-
/* .tp_class_members = */ compiler_class_members
382+
/* .tp_class_members = */ compiler_class_members,
381383
};
382384

383385
DECL_END

src/deemon/execute/code.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,6 +1717,8 @@ PRIVATE struct type_cmp code_cmp = {
17171717
/* .tp_compare_eq = */ (int (DCALL *)(DeeObject *, DeeObject *))&code_compare_eq,
17181718
/* .tp_compare = */ NULL,
17191719
/* .tp_trycompare_eq = */ (int (DCALL *)(DeeObject *, DeeObject *))&code_trycompare_eq,
1720+
/* .tp_eq = */ DEFIMPL(&default__eq__with__compare_eq),
1721+
/* .tp_ne = */ DEFIMPL(&default__ne__with__compare_eq),
17201722
};
17211723

17221724
PRIVATE WUNUSED DREF DeeObject *DCALL code_ctor(void) {
@@ -2526,14 +2528,14 @@ PUBLIC DeeTypeObject DeeCode_Type = {
25262528
},
25272529
/* .tp_dtor = */ (void (DCALL *)(DeeObject *__restrict))&code_fini,
25282530
/* .tp_assign = */ NULL,
2529-
/* .tp_move_assign = */ NULL
2531+
/* .tp_move_assign = */ NULL,
25302532
},
25312533
/* .tp_cast = */ {
2532-
/* .tp_str = */ NULL,
2533-
/* .tp_repr = */ NULL,
2534+
/* .tp_str = */ DEFIMPL(&default__str__with__print),
2535+
/* .tp_repr = */ DEFIMPL(&default__repr__with__printrepr),
25342536
/* .tp_bool = */ NULL,
25352537
/* .tp_print = */ (dssize_t (DCALL *)(DeeObject *__restrict, dformatprinter, void *))&code_print,
2536-
/* .tp_printrepr = */ (dssize_t (DCALL *)(DeeObject *__restrict, dformatprinter, void *))&code_printrepr
2538+
/* .tp_printrepr = */ (dssize_t (DCALL *)(DeeObject *__restrict, dformatprinter, void *))&code_printrepr,
25372539
},
25382540
/* .tp_call = */ NULL,
25392541
/* .tp_visit = */ (void (DCALL *)(DeeObject *__restrict, dvisit_t, void *))&code_visit,
@@ -2551,7 +2553,7 @@ PUBLIC DeeTypeObject DeeCode_Type = {
25512553
/* .tp_members = */ code_members,
25522554
/* .tp_class_methods = */ NULL,
25532555
/* .tp_class_getsets = */ NULL,
2554-
/* .tp_class_members = */ NULL
2556+
/* .tp_class_members = */ NULL,
25552557
};
25562558

25572559

src/deemon/execute/ddi.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@ PRIVATE struct type_cmp ddi_cmp = {
731731
/* .tp_compare_eq = */ (int (DCALL *)(DeeObject *, DeeObject *))&ddi_compare_eq,
732732
/* .tp_compare = */ NULL,
733733
/* .tp_trycompare_eq = */ (int (DCALL *)(DeeObject *, DeeObject *))&ddi_trycompare_eq,
734+
/* .tp_eq = */ DEFIMPL(&default__eq__with__compare_eq),
735+
/* .tp_ne = */ DEFIMPL(&default__ne__with__compare_eq),
734736
};
735737

736738

@@ -761,14 +763,14 @@ PUBLIC DeeTypeObject DeeDDI_Type = {
761763
},
762764
/* .tp_dtor = */ (void (DCALL *)(DeeObject *__restrict))&ddi_fini,
763765
/* .tp_assign = */ NULL,
764-
/* .tp_move_assign = */ NULL
766+
/* .tp_move_assign = */ NULL,
765767
},
766768
/* .tp_cast = */ {
767-
/* .tp_str = */ NULL,
768-
/* .tp_repr = */ NULL,
769+
/* .tp_str = */ DEFIMPL(&object_str),
770+
/* .tp_repr = */ DEFIMPL(&default__repr__with__printrepr),
769771
/* .tp_bool = */ NULL,
770-
/* .tp_print = */ NULL,
771-
/* .tp_printrepr = */ (dssize_t (DCALL *)(DeeObject *__restrict, dformatprinter, void *))&ddi_printrepr
772+
/* .tp_print = */ DEFIMPL(&default__print__with__str),
773+
/* .tp_printrepr = */ (dssize_t (DCALL *)(DeeObject *__restrict, dformatprinter, void *))&ddi_printrepr,
772774
},
773775
/* .tp_call = */ NULL,
774776
/* .tp_visit = */ (void (DCALL *)(DeeObject *__restrict, dvisit_t, void *))&ddi_visit,
@@ -786,7 +788,7 @@ PUBLIC DeeTypeObject DeeDDI_Type = {
786788
/* .tp_members = */ ddi_members,
787789
/* .tp_class_methods = */ NULL,
788790
/* .tp_class_getsets = */ NULL,
789-
/* .tp_class_members = */ NULL
791+
/* .tp_class_members = */ NULL,
790792
};
791793

792794
DECL_END

src/deemon/execute/dex.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -549,18 +549,20 @@ PUBLIC DeeTypeObject DeeDex_Type = {
549549
},
550550
/* .tp_dtor = */ (void (DCALL *)(DeeObject *__restrict))&dex_fini,
551551
/* .tp_assign = */ NULL,
552-
/* .tp_move_assign = */ NULL
552+
/* .tp_move_assign = */ NULL,
553553
},
554554
/* .tp_cast = */ {
555-
/* .tp_str = */ NULL,
556-
/* .tp_repr = */ NULL,
557-
/* .tp_bool = */ NULL
555+
/* .tp_str = */ DEFIMPL(&module_str),
556+
/* .tp_repr = */ DEFIMPL(&default__repr__with__printrepr),
557+
/* .tp_bool = */ NULL,
558+
/* .tp_print = */ DEFIMPL(&default__print__with__str),
559+
/* .tp_printrepr = */ DEFIMPL(&module_printrepr),
558560
},
559561
/* .tp_call = */ NULL,
560562
/* .tp_visit = */ NULL, // (void (DCALL *)(DeeObject *__restrict, dvisit_t, void *))&dex_visit,
561563
/* .tp_gc = */ NULL,
562564
/* .tp_math = */ NULL,
563-
/* .tp_cmp = */ NULL,
565+
/* .tp_cmp = */ DEFIMPL(&default__tp_cmp__6F3C9C45873AB01F),
564566
/* .tp_seq = */ NULL,
565567
/* .tp_iter_next = */ NULL,
566568
/* .tp_iterator = */ NULL,
@@ -572,7 +574,7 @@ PUBLIC DeeTypeObject DeeDex_Type = {
572574
/* .tp_members = */ NULL,
573575
/* .tp_class_methods = */ NULL,
574576
/* .tp_class_getsets = */ NULL,
575-
/* .tp_class_members = */ NULL
577+
/* .tp_class_members = */ NULL,
576578
};
577579

578580
DECL_END

0 commit comments

Comments
 (0)