Add method add_conversion_points into a ConvRepo

This commit is contained in:
2025-08-20 03:11:17 +03:00
parent 9142cb05fc
commit 5ac6ff102f
2 changed files with 5 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
[project]
name = "breakshaft"
version = "0.1.6.post1"
version = "0.1.6.post2"
description = "Library for in-time codegen for type conversion"
authors = [
{ name = "nikto_b", email = "niktob560@yandex.ru" }

View File

@@ -79,11 +79,14 @@ class ConvRepo:
def convertor_set(self):
return self._convertor_set
def add_conversion_points(self, conversion_points: Iterable[ConversionPoint]):
self._convertor_set |= set(conversion_points)
def add_injector(self,
func: Callable,
rettype: Optional[type] = None,
type_remap: Optional[dict[str, type]] = None):
self._convertor_set |= set(ConversionPoint.from_fn(func, rettype=rettype, type_remap=type_remap))
self.add_conversion_points(ConversionPoint.from_fn(func, rettype=rettype, type_remap=type_remap))
def _callseq_from_callgraph(self, cg: Callgraph) -> list[ConversionPoint]:
if len(cg.variants) == 0: