Context
context
Context
dataclass
Contains structures for operations/attributes registration.
Source code in xdsl/context.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
allow_unregistered: bool = field(default=False)
class-attribute
instance-attribute
loaded_ops: Iterable[type[Operation]]
property
Returns all the loaded operations. Not valid across mutations of this object.
loaded_attrs: Iterable[type[Attribute]]
property
Returns all the loaded attributes. Not valid across mutations of this object.
loaded_types: Iterable[type[TypeAttribute]]
property
Returns all the loaded types. Not valid across mutations of this object.
loaded_dialects: Iterable[Dialect]
property
Returns all the loaded attributes. Not valid across mutations of this object.
registered_dialect_names: Iterable[str]
property
Returns the names of all registered dialects. Not valid across mutations of this object.
__init__(allow_unregistered: bool = False, _loaded_dialects: dict[str, Dialect] = dict[str, Dialect](), _loaded_ops: dict[str, type[Operation]] = dict[str, type[Operation]](), _loaded_attrs: dict[str, type[Attribute]] = dict[str, type[Attribute]](), _loaded_types: dict[str, type[TypeAttribute]] = dict[str, type[TypeAttribute]](), _registered_dialects: dict[str, Callable[[], Dialect]] = dict[str, Callable[[], Dialect]]()) -> None
clone() -> Context
Source code in xdsl/context.py
35 36 37 38 39 40 41 42 43 | |
register_dialect(name: str, dialect_factory: Callable[[], Dialect]) -> None
Register a dialect without loading it. The dialect is only loaded in the context
when an operation or attribute of that dialect is parsed, or when explicitely
requested with load_registered_dialect.
Source code in xdsl/context.py
80 81 82 83 84 85 86 87 88 89 90 91 92 | |
load_registered_dialect(name: str) -> None
Load a dialect that is already registered in the context.
Source code in xdsl/context.py
94 95 96 97 98 99 100 101 102 103 104 105 | |
load_dialect(dialect: Dialect)
Load a dialect. Operation and Attribute names should be unique.
If the dialect is already registered in the context, use
load_registered_dialect instead.
Source code in xdsl/context.py
107 108 109 110 111 112 113 114 115 116 117 118 | |
load_op(op: type[Operation]) -> None
Load an operation definition. Operation names should be unique.
Source code in xdsl/context.py
120 121 122 123 124 125 126 | |
load_attr_or_type(attr: type[Attribute]) -> None
Load an attribute or type definition. Attribute or type names should be unique, but an attribute may have the same name as a type.
Source code in xdsl/context.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
get_optional_op(name: str, *, dialect_stack: Sequence[str] = ()) -> type[Operation] | None
Get an operation class from its name if it exists or is contained in one of the dialects in the dialect stack. If the operation is not registered, return None unless unregistered operations are allowed in the context, in which case return an UnregisteredOp.
Source code in xdsl/context.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
get_op(name: str, *, dialect_stack: Sequence[str] = ()) -> type[Operation]
Get an operation class from its name if it exists or is contained in one of the dialects in the dialect stack. If the operation is not registered, raise an exception unless unregistered operations are allowed in the context, in which case return an UnregisteredOp.
Source code in xdsl/context.py
186 187 188 189 190 191 192 193 194 195 196 197 | |
get_optional_type(name: str) -> type[TypeAttribute] | None
Get a type definition from its name if it exists. If the type is not registered, return None unless unregistered types are allowed in the context, in which case return an UnregisteredAttr.
Source code in xdsl/context.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
get_type(name: str) -> type[TypeAttribute]
Get a type definition from its name. If the type is not registered, raise an exception unless unregistered types are allowed in the context, in which case return an UnregisteredAttr.
Source code in xdsl/context.py
227 228 229 230 231 232 233 234 235 | |
get_optional_attr(name: str) -> type[Attribute] | None
Get an attribute class from its name if it exists. If the attribute is not registered, return None unless unregistered attributes are allowed in the context, in which case return an UnregisteredAttr.
Source code in xdsl/context.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
get_attr(name: str) -> type[Attribute]
Get an attribute class from its name. If the attribute is not registered, raise an exception unless unregistered attributes are allowed in the context, in which case return an UnregisteredAttr.
Source code in xdsl/context.py
270 271 272 273 274 275 276 277 278 279 280 281 | |
get_dialect(name: str) -> Dialect
Source code in xdsl/context.py
283 284 285 286 | |
get_optional_dialect(name: str) -> Dialect | None
Get a dialect from its name if it exists. If the dialect is not registered, return None.
Source code in xdsl/context.py
288 289 290 291 292 293 294 295 296 297 298 299 | |