File tree Expand file tree Collapse file tree 3 files changed +16
-14
lines changed
Expand file tree Collapse file tree 3 files changed +16
-14
lines changed Original file line number Diff line number Diff line change 22from .aff import Aff
33from .aff_list import AffList
44from .ast_build import ASTBuild
5- from .ast_expr import ASTExpr
5+ from .ast_expr import expr , ASTExpr
66from .ast_node import ASTNode , ASTUserNode
77from .ast_node_list import AstNodeList
88from .ast_print_options import ASTPrintOptions
9999 "ScheduleConstraints" ,
100100 "ScheduleNode" ,
101101 "ASTBuild" ,
102+ "expr" ,
102103 "ASTExpr" ,
103104 "ASTNode" ,
104105 "StrideInfo" ,
132133 "ASTPrintOptions" ,
133134 "AstNodeList" ,
134135 "ASTUserNode" ,
135- ]
136+ ]
Original file line number Diff line number Diff line change 2020
2121_lib = load_libisl ()
2222
23+ # handle is an integer, to prevent the confusion vs val, use I.expr instead of I.ASTExpr
24+ def expr (id_or_val : Any ) -> "ASTExpr" :
25+ if isinstance (id_or_val , int ):
26+ from .val import Val
27+ return ASTExpr .from_val (Val .int_from_si (id_or_val ))
28+ elif isinstance (id_or_val , str ):
29+ from .id import Id
30+ return ASTExpr .from_id (Id (id_or_val ))
31+ else :
32+ raise TypeError ("I.expr can only accept int or str" )
33+
2334class ASTExpr (ISLObject , ISLObjectMixin ):
2435 __slots__ = ()
2536
2637 def __init__ (self , handle_or_spec : Any ) -> None :
27- if isinstance (handle_or_spec , str ):
28- handle = _isl_ast_expr_read_from_str (handle_or_spec , return_raw_pointer = True )
29- super ().__init__ (handle )
30- else :
31- super ().__init__ (handle_or_spec )
38+ super ().__init__ (handle_or_spec )
3239
3340 def get_type_name (self ) -> str :
3441 """Helper to get the string name of the expr type."""
Original file line number Diff line number Diff line change @@ -20,13 +20,7 @@ class Val(ISLObject, ISLObjectMixin):
2020 __slots__ = ()
2121
2222 def __init__ (self , handle_or_spec : Any ) -> None :
23- if isinstance (handle_or_spec , str ):
24- handle = _isl_val_read_from_str (handle_or_spec , return_raw_pointer = True )
25- super ().__init__ (handle )
26- if isinstance (handle_or_spec , int ):
27- handle = _isl_val_int_from_si (handle_or_spec , return_raw_pointer = True )
28- else :
29- super ().__init__ (handle_or_spec )
23+ super ().__init__ (handle_or_spec )
3024
3125 @classmethod
3226 def from_str (cls , spec : str ) -> Any :
You can’t perform that action at this time.
0 commit comments