File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed
src/bloqade/squin/analysis/shape Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ from typing import final
2+ from dataclasses import dataclass
3+
4+ from kirin .lattice import (
5+ SingletonMeta ,
6+ BoundedLattice ,
7+ SimpleJoinMixin ,
8+ SimpleMeetMixin ,
9+ )
10+
11+
12+ @dataclass
13+ class Shape (
14+ SimpleJoinMixin ["Shape" ], SimpleMeetMixin ["Shape" ], BoundedLattice ["Shape" ]
15+ ):
16+ @classmethod
17+ def bottom (cls ) -> "Shape" :
18+ return NoShape ()
19+
20+ @classmethod
21+ def top (cls ) -> "Shape" :
22+ return AnyShape ()
23+
24+
25+ @final
26+ @dataclass
27+ class NoShape (Shape , metaclass = SingletonMeta ):
28+
29+ def is_subseteq (self , other : Shape ) -> bool :
30+ return True
31+
32+
33+ @final
34+ @dataclass
35+ class AnyShape (Shape , metaclass = SingletonMeta ):
36+
37+ def is_subseteq (self , other : Shape ) -> bool :
38+ return isinstance (other , Shape )
39+
40+
41+ @final
42+ @dataclass
43+ class OpShape (Shape ):
44+ size : int
45+
46+ def is_subseteq (self , other : Shape ) -> bool :
47+ if isinstance (other , OpShape ):
48+ return self .size == other .size
49+ return False
You can’t perform that action at this time.
0 commit comments