Skip to content

Commit 1f09ded

Browse files
committed
Lkt lowering: add AnalysisUnit type handling
This is needed for the test in the next commit to work. TN: RA22-015
1 parent 16ee730 commit 1f09ded

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

contrib/lkt/language/parser.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,18 @@ def get_builtin_gen_decl(entity_name=T.Symbol):
227227
doc="Unit method. Return the Iterator builtin trait."
228228
)
229229

230+
analysis_unit_gen_trait = Property(
231+
Self.get_builtin_gen_decl('AnalysisUnit'),
232+
public=True,
233+
doc="Unit method. Return the ``AnalysisUnit`` builtin generic trait."
234+
)
235+
236+
analysis_unit_trait = Property(
237+
Self.analysis_unit_gen_trait.decl.cast(T.TraitDecl),
238+
public=True,
239+
doc="Unit method. Return the ``AnalysisUnit`` builtin trait."
240+
)
241+
230242
@langkit_property(external=True,
231243
uses_entity_info=False,
232244
uses_envs=True,

langkit/lkt_lowering.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,7 @@ def get_field(decl: L.TraitDecl, name: str) -> L.Decl:
11611161
self.astlist_type = root.p_astlist_type
11621162
self.iterator_trait = root.p_iterator_trait
11631163
self.map_method = get_field(self.iterator_trait, 'map')
1164+
self.analysis_unit_trait = root.p_analysis_unit_trait
11641165

11651166
# Map Lkt nodes for the declarations of builtin types to the
11661167
# corresponding CompiledType instances.
@@ -1234,6 +1235,9 @@ def resolve_type_decl(self, decl: L.TypeDecl) -> CompiledTypeOrDefer:
12341235
assert isinstance(node, (ASTNodeType, TypeRepo.Defer))
12351236
result = node.list
12361237

1238+
elif inner_type == self.analysis_unit_trait:
1239+
result = T.AnalysisUnit
1240+
12371241
else:
12381242
assert False, (
12391243
'Unknown generic type: {} (from {})'

0 commit comments

Comments
 (0)