Skip to content

Commit

Permalink
Virtualize Set/Mapping math operators
Browse files Browse the repository at this point in the history
Also: implement map math operators for the first time
  • Loading branch information
GrieferAtWork committed Dec 6, 2024
1 parent 781046f commit e072c46
Show file tree
Hide file tree
Showing 30 changed files with 6,854 additions and 1,328 deletions.
6 changes: 4 additions & 2 deletions .vs/deemon-v141.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,10 @@
<ClInclude Include="..\src\deemon\objects\seq\default-enumerate.h" />
<ClInclude Include="..\src\deemon\objects\seq\default-iterators.h" />
<ClInclude Include="..\src\deemon\objects\seq\default-map-proxy.h" />
<ClInclude Include="..\src\deemon\objects\seq\default-maps.h" />
<ClInclude Include="..\src\deemon\objects\seq\default-reversed.h" />
<ClInclude Include="..\src\deemon\objects\seq\default-sequences.h" />
<ClInclude Include="..\src\deemon\objects\seq\default-sets.h" />
<ClInclude Include="..\src\deemon\objects\seq\each-fastpass.c.inl" />
<ClInclude Include="..\src\deemon\objects\seq\each.h" />
<ClInclude Include="..\src\deemon\objects\seq\filter.h" />
Expand All @@ -270,7 +272,6 @@
<ClInclude Include="..\src\deemon\objects\seq\range.h" />
<ClInclude Include="..\src\deemon\objects\seq\repeat.h" />
<ClInclude Include="..\src\deemon\objects\seq\segments.h" />
<ClInclude Include="..\src\deemon\objects\seq\set.h" />
<ClInclude Include="..\src\deemon\objects\seq\simpleproxy.h" />
<ClInclude Include="..\src\deemon\objects\seq\smap.h" />
<ClInclude Include="..\src\deemon\objects\seq\sort-impl.c.inl" />
Expand Down Expand Up @@ -448,8 +449,10 @@
<ClCompile Include="..\src\deemon\objects\seq\default-enumerate.c" />
<ClCompile Include="..\src\deemon\objects\seq\default-iterators.c" />
<ClCompile Include="..\src\deemon\objects\seq\default-map-proxy.c" />
<ClCompile Include="..\src\deemon\objects\seq\default-maps.c" />
<ClCompile Include="..\src\deemon\objects\seq\default-reversed.c" />
<ClCompile Include="..\src\deemon\objects\seq\default-sequences.c" />
<ClCompile Include="..\src\deemon\objects\seq\default-sets.c" />
<ClCompile Include="..\src\deemon\objects\seq\each.c" />
<ClCompile Include="..\src\deemon\objects\seq\fastseq.c" />
<ClCompile Include="..\src\deemon\objects\seq\filter.c" />
Expand All @@ -459,7 +462,6 @@
<ClCompile Include="..\src\deemon\objects\seq\range.c" />
<ClCompile Include="..\src\deemon\objects\seq\repeat.c" />
<ClCompile Include="..\src\deemon\objects\seq\segments.c" />
<ClCompile Include="..\src\deemon\objects\seq\set.c" />
<ClCompile Include="..\src\deemon\objects\seq\simpleproxy.c" />
<ClCompile Include="..\src\deemon\objects\seq\smap.c" />
<ClCompile Include="..\src\deemon\objects\seq\sort.c" />
Expand Down
18 changes: 12 additions & 6 deletions .vs/deemon-v141.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -750,12 +750,18 @@
<ClInclude Include="..\src\deemon\objects\seq\default-map-proxy.h">
<Filter>src\objects\seq</Filter>
</ClInclude>
<ClInclude Include="..\src\deemon\objects\seq\default-maps.h">
<Filter>src\objects\seq</Filter>
</ClInclude>
<ClInclude Include="..\src\deemon\objects\seq\default-reversed.h">
<Filter>src\objects\seq</Filter>
</ClInclude>
<ClInclude Include="..\src\deemon\objects\seq\default-sequences.h">
<Filter>src\objects\seq</Filter>
</ClInclude>
<ClInclude Include="..\src\deemon\objects\seq\default-sets.h">
<Filter>src\objects\seq</Filter>
</ClInclude>
<ClInclude Include="..\src\deemon\objects\seq\each-fastpass.c.inl">
<Filter>src\objects\seq</Filter>
</ClInclude>
Expand Down Expand Up @@ -783,9 +789,6 @@
<ClInclude Include="..\src\deemon\objects\seq\segments.h">
<Filter>src\objects\seq</Filter>
</ClInclude>
<ClInclude Include="..\src\deemon\objects\seq\set.h">
<Filter>src\objects\seq</Filter>
</ClInclude>
<ClInclude Include="..\src\deemon\objects\seq\simpleproxy.h">
<Filter>src\objects\seq</Filter>
</ClInclude>
Expand Down Expand Up @@ -1313,12 +1316,18 @@
<ClCompile Include="..\src\deemon\objects\seq\default-map-proxy.c">
<Filter>src\objects\seq</Filter>
</ClCompile>
<ClCompile Include="..\src\deemon\objects\seq\default-maps.c">
<Filter>src\objects\seq</Filter>
</ClCompile>
<ClCompile Include="..\src\deemon\objects\seq\default-reversed.c">
<Filter>src\objects\seq</Filter>
</ClCompile>
<ClCompile Include="..\src\deemon\objects\seq\default-sequences.c">
<Filter>src\objects\seq</Filter>
</ClCompile>
<ClCompile Include="..\src\deemon\objects\seq\default-sets.c">
<Filter>src\objects\seq</Filter>
</ClCompile>
<ClCompile Include="..\src\deemon\objects\seq\each.c">
<Filter>src\objects\seq</Filter>
</ClCompile>
Expand Down Expand Up @@ -1346,9 +1355,6 @@
<ClCompile Include="..\src\deemon\objects\seq\segments.c">
<Filter>src\objects\seq</Filter>
</ClCompile>
<ClCompile Include="..\src\deemon\objects\seq\set.c">
<Filter>src\objects\seq</Filter>
</ClCompile>
<ClCompile Include="..\src\deemon\objects\seq\simpleproxy.c">
<Filter>src\objects\seq</Filter>
</ClCompile>
Expand Down
6 changes: 4 additions & 2 deletions .vs/deemon-v142.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,10 @@
<ClInclude Include="..\src\deemon\objects\seq\default-enumerate.h" />
<ClInclude Include="..\src\deemon\objects\seq\default-iterators.h" />
<ClInclude Include="..\src\deemon\objects\seq\default-map-proxy.h" />
<ClInclude Include="..\src\deemon\objects\seq\default-maps.h" />
<ClInclude Include="..\src\deemon\objects\seq\default-reversed.h" />
<ClInclude Include="..\src\deemon\objects\seq\default-sequences.h" />
<ClInclude Include="..\src\deemon\objects\seq\default-sets.h" />
<ClInclude Include="..\src\deemon\objects\seq\each-fastpass.c.inl" />
<ClInclude Include="..\src\deemon\objects\seq\each.h" />
<ClInclude Include="..\src\deemon\objects\seq\filter.h" />
Expand All @@ -270,7 +272,6 @@
<ClInclude Include="..\src\deemon\objects\seq\range.h" />
<ClInclude Include="..\src\deemon\objects\seq\repeat.h" />
<ClInclude Include="..\src\deemon\objects\seq\segments.h" />
<ClInclude Include="..\src\deemon\objects\seq\set.h" />
<ClInclude Include="..\src\deemon\objects\seq\simpleproxy.h" />
<ClInclude Include="..\src\deemon\objects\seq\smap.h" />
<ClInclude Include="..\src\deemon\objects\seq\sort-impl.c.inl" />
Expand Down Expand Up @@ -448,8 +449,10 @@
<ClCompile Include="..\src\deemon\objects\seq\default-enumerate.c" />
<ClCompile Include="..\src\deemon\objects\seq\default-iterators.c" />
<ClCompile Include="..\src\deemon\objects\seq\default-map-proxy.c" />
<ClCompile Include="..\src\deemon\objects\seq\default-maps.c" />
<ClCompile Include="..\src\deemon\objects\seq\default-reversed.c" />
<ClCompile Include="..\src\deemon\objects\seq\default-sequences.c" />
<ClCompile Include="..\src\deemon\objects\seq\default-sets.c" />
<ClCompile Include="..\src\deemon\objects\seq\each.c" />
<ClCompile Include="..\src\deemon\objects\seq\fastseq.c" />
<ClCompile Include="..\src\deemon\objects\seq\filter.c" />
Expand All @@ -459,7 +462,6 @@
<ClCompile Include="..\src\deemon\objects\seq\range.c" />
<ClCompile Include="..\src\deemon\objects\seq\repeat.c" />
<ClCompile Include="..\src\deemon\objects\seq\segments.c" />
<ClCompile Include="..\src\deemon\objects\seq\set.c" />
<ClCompile Include="..\src\deemon\objects\seq\simpleproxy.c" />
<ClCompile Include="..\src\deemon\objects\seq\smap.c" />
<ClCompile Include="..\src\deemon\objects\seq\sort.c" />
Expand Down
18 changes: 12 additions & 6 deletions .vs/deemon-v142.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -750,12 +750,18 @@
<ClInclude Include="..\src\deemon\objects\seq\default-map-proxy.h">
<Filter>src\objects\seq</Filter>
</ClInclude>
<ClInclude Include="..\src\deemon\objects\seq\default-maps.h">
<Filter>src\objects\seq</Filter>
</ClInclude>
<ClInclude Include="..\src\deemon\objects\seq\default-reversed.h">
<Filter>src\objects\seq</Filter>
</ClInclude>
<ClInclude Include="..\src\deemon\objects\seq\default-sequences.h">
<Filter>src\objects\seq</Filter>
</ClInclude>
<ClInclude Include="..\src\deemon\objects\seq\default-sets.h">
<Filter>src\objects\seq</Filter>
</ClInclude>
<ClInclude Include="..\src\deemon\objects\seq\each-fastpass.c.inl">
<Filter>src\objects\seq</Filter>
</ClInclude>
Expand Down Expand Up @@ -783,9 +789,6 @@
<ClInclude Include="..\src\deemon\objects\seq\segments.h">
<Filter>src\objects\seq</Filter>
</ClInclude>
<ClInclude Include="..\src\deemon\objects\seq\set.h">
<Filter>src\objects\seq</Filter>
</ClInclude>
<ClInclude Include="..\src\deemon\objects\seq\simpleproxy.h">
<Filter>src\objects\seq</Filter>
</ClInclude>
Expand Down Expand Up @@ -1313,12 +1316,18 @@
<ClCompile Include="..\src\deemon\objects\seq\default-map-proxy.c">
<Filter>src\objects\seq</Filter>
</ClCompile>
<ClCompile Include="..\src\deemon\objects\seq\default-maps.c">
<Filter>src\objects\seq</Filter>
</ClCompile>
<ClCompile Include="..\src\deemon\objects\seq\default-reversed.c">
<Filter>src\objects\seq</Filter>
</ClCompile>
<ClCompile Include="..\src\deemon\objects\seq\default-sequences.c">
<Filter>src\objects\seq</Filter>
</ClCompile>
<ClCompile Include="..\src\deemon\objects\seq\default-sets.c">
<Filter>src\objects\seq</Filter>
</ClCompile>
<ClCompile Include="..\src\deemon\objects\seq\each.c">
<Filter>src\objects\seq</Filter>
</ClCompile>
Expand Down Expand Up @@ -1346,9 +1355,6 @@
<ClCompile Include="..\src\deemon\objects\seq\segments.c">
<Filter>src\objects\seq</Filter>
</ClCompile>
<ClCompile Include="..\src\deemon\objects\seq\set.c">
<Filter>src\objects\seq</Filter>
</ClCompile>
<ClCompile Include="..\src\deemon\objects\seq\simpleproxy.c">
<Filter>src\objects\seq</Filter>
</ClCompile>
Expand Down
1 change: 0 additions & 1 deletion cpp.hint
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,6 @@
#define rodict_object Dee_rodict_object
#define roset_item Dee_roset_item
#define roset_object Dee_roset_object
#define set_inversion_object Dee_set_inversion_object
#define string_object Dee_string_object
#define string_utf Dee_string_utf
#define super_object Dee_super_object
Expand Down
2 changes: 1 addition & 1 deletion include/deemon/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -4547,7 +4547,7 @@ DFUNDEF ATTR_COLD NONNULL((1, 2, 3)) int (DCALL DeeObject_TypeAssertFailed2)(Dee
#else /* __OPTIMIZE_SIZE__ */
#undef DeeObject_AssertTypeOrAbstract
#define DeeObject_AssertTypeOrAbstract(self, required_type) (DeeType_IsAbstract(required_type) ? 0 : DeeObject_AssertType(self, required_type))
#define DeeObject_AssertTypeExact(self, required_type) (unlikely(Dee_TYPE(self) == required_type ? 0 : DeeObject_TypeAssertFailed((DeeObject *)(self), required_type)))
#define DeeObject_AssertTypeExact(self, required_type) (unlikely(Dee_TYPE(self) == (required_type) ? 0 : DeeObject_TypeAssertFailed((DeeObject *)(self), required_type)))
#endif /* !__OPTIMIZE_SIZE__ */


Expand Down
45 changes: 13 additions & 32 deletions include/deemon/set.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,50 +108,31 @@ DDATDEF DeeTypeObject DeeSet_Type; /* `Set from deemon' */
* Though this statically allocated instance is used by most
* internal sequence functions.
* HINT: Any exact instance of `DeeSet_Type' should be considered stub/empty. */
DDATDEF DeeObject DeeSet_EmptyInstance;
DDATDEF DeeObject DeeSet_EmptyInstance;
#define Dee_EmptySet (&DeeSet_EmptyInstance)

/* Check for a symbolic, empty set.
* NOTE: This function isn't guarantied to capture any kind of empty set,
* only sets that are meant to symbolically represent any empty one. */
#define DeeSet_CheckEmpty(x) DeeObject_InstanceOfExact(x, &DeeSet_Type)
/* A universal instance of a generic set object (i.e. the set of everything in the universe).
* NOTE: This is _NOT_ a singleton. - Usercode may create more by calling `~Set()'. */
#ifndef GUARD_DEEMON_OBJECTS_SEQ_DEFAULT_SETS_C
DDATDEF DeeObject DeeSet_UniversalInstance;
#endif /* !GUARD_DEEMON_OBJECTS_SEQ_DEFAULT_SETS_C */
#define Dee_UniversalSet (&DeeSet_UniversalInstance)


#ifdef CONFIG_BUILDING_DEEMON
#ifndef CONFIG_EXPERIMENTAL_NEW_SEQUENCE_OPERATORS
INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeSet_Invert(DeeObject *__restrict self);
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSet_Union(DeeObject *lhs, DeeObject *rhs);
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSet_Difference(DeeObject *lhs, DeeObject *rhs);
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSet_Intersection(DeeObject *lhs, DeeObject *rhs);
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSet_SymmetricDifference(DeeObject *lhs, DeeObject *rhs);
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSet_OperatorAdd(DeeObject *lhs, DeeObject *rhs);
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSet_OperatorSub(DeeObject *lhs, DeeObject *rhs);
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSet_OperatorAnd(DeeObject *lhs, DeeObject *rhs);
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSet_OperatorXor(DeeObject *lhs, DeeObject *rhs);
INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSet_IsSubSet(DeeObject *lhs, DeeObject *rhs);
INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSet_IsTrueSubSet(DeeObject *lhs, DeeObject *rhs);
INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSet_IsSameSet(DeeObject *lhs, DeeObject *rhs);
#endif /* !CONFIG_EXPERIMENTAL_NEW_SEQUENCE_OPERATORS */
INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSet_IsDisjoint(DeeObject *lhs, DeeObject *rhs);
#endif /* CONFIG_BUILDING_DEEMON */


#ifdef DEE_SOURCE
#define Dee_set_inversion_object set_inversion_object
#endif /* DEE_SOURCE */

typedef struct Dee_set_inversion_object DeeSetInversionObject;
struct Dee_set_inversion_object {
/* An inverse set, that is the symbolic set containing all
* object, excluding those already contained within `si_set'
* Since such a set cannot be iterated, working with it
* requires some special operations, as well as special
* support in some places, which is why it is exposed here.
* In user-code, such a set is created through use of `operator ~()' */
Dee_OBJECT_HEAD
DREF DeeObject *si_set; /* [1..1][const] The underlying set. */
};
#define DeeSetInversion_GetSet(ob) (((DeeSetInversionObject *)Dee_REQUIRES_OBJECT(ob))->si_set)

DDATDEF DeeTypeObject DeeSetInversion_Type;
#define DeeSetInversion_Check(ob) DeeObject_InstanceOfExact(ob, &DeeSetInversion_Type) /* _InverseSet is final */
#define DeeSetInversion_CheckExact(ob) DeeObject_InstanceOfExact(ob, &DeeSetInversion_Type)


DECL_END

#endif /* !GUARD_DEEMON_SET_H */
1 change: 1 addition & 0 deletions src/deemon/linker-scripts/link-deemon-gcc-i386-cygwin.def
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@ EXPORTS
_DeeObject_TryGetItemIndex@8=DeeObject_TryGetItemIndex@8
_DeeObject_TryGetItemStringHash@12=DeeObject_TryGetItemStringHash@12
_DeeObject_TryGetItemStringLenHash@16=DeeObject_TryGetItemStringLenHash@16
_DeeObject_TypeAssertFailed2@12=DeeObject_TypeAssertFailed2@12
_DeeObject_TypeAssertFailed@8=DeeObject_TypeAssertFailed@8
_DeeObject_UndoConstruction@8=DeeObject_UndoConstruction@8
_DeeObject_Unpack@12=DeeObject_Unpack@12
Expand Down
1 change: 1 addition & 0 deletions src/deemon/linker-scripts/link-deemon-msvc-i386-win32.def
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@ EXPORTS
DeeObject_TryGetItemIndex@8=_DeeObject_TryGetItemIndex@8
DeeObject_TryGetItemStringHash@12=_DeeObject_TryGetItemStringHash@12
DeeObject_TryGetItemStringLenHash@16=_DeeObject_TryGetItemStringLenHash@16
DeeObject_TypeAssertFailed2@12=_DeeObject_TypeAssertFailed2@12
DeeObject_TypeAssertFailed@8=_DeeObject_TypeAssertFailed@8
DeeObject_UndoConstruction@8=_DeeObject_UndoConstruction@8
DeeObject_Unpack@12=_DeeObject_Unpack@12
Expand Down
1 change: 0 additions & 1 deletion src/deemon/objects/generic-proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ generic_proxy2_fini(ProxyObject2 *__restrict self) {
}



INTERN WUNUSED NONNULL((1)) int DCALL
generic_proxy_bool(ProxyObject *__restrict self) {
return DeeObject_Bool(self->po_obj);
Expand Down
1 change: 1 addition & 0 deletions src/deemon/objects/generic-proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ INTDEF WUNUSED NONNULL((1)) int DCALL generic_proxy2_init(ProxyObject2 *__restri
INTDEF NONNULL((1, 2)) void DCALL generic_proxy2_visit(ProxyObject2 *__restrict self, dvisit_t proc, void *arg);
INTDEF NONNULL((1)) void DCALL generic_proxy2_fini(ProxyObject2 *__restrict self);

INTDEF NONNULL((1)) int DCALL generic_proxy2_bool_1or2(ProxyObject2 *__restrict self);

STATIC_ASSERT_MSG(offsetof(ProxyObject2, po_obj1) == offsetof(ProxyObject, po_obj),
"You're allowed to use everything below with `ProxyObject2', "
Expand Down
Loading

0 comments on commit e072c46

Please sign in to comment.