File tree Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -35,8 +35,15 @@ structure CtorLayout where
35
35
numUSize : Nat
36
36
scalarSize : Nat
37
37
38
- @[extern "lean_ir_get_ctor_layout"]
39
38
opaque getCtorLayout (env : @& Environment) (ctorName : @& Name) : Except String CtorLayout
40
39
41
40
end IR
41
+
42
+ -- Expose `getCtorLayout` in the `Lean` namespace to make it available for the benefit of
43
+ -- the test `lean/ctor_layout.lean`
44
+ -- Can be removed once we no longer have to limit the number of exported symbols and
45
+ -- can use `Lean.IR` from the interpreter.
46
+ @[extern "lean_ir_get_ctor_layout"]
47
+ def getCtorLayout := IR.getCtorLayout
48
+
42
49
end Lean
Original file line number Diff line number Diff line change
1
+ import Lean.Compiler.IR
2
+
3
+ open Lean
4
+
5
+ unsafe def main : IO Unit :=
6
+ withImportModules #[{module := `Lean.Compiler.IR.Basic}] {} 0 fun env => do
7
+ let ctorLayout ← IO.ofExcept $ getCtorLayout env `Lean.IR.Expr.reuse;
8
+ ctorLayout.fieldInfo.forM $ fun finfo => IO.println (format finfo);
9
+ IO.println "---" ;
10
+ let ctorLayout ← IO.ofExcept $ getCtorLayout env `Lean.EnvironmentHeader.mk;
11
+ ctorLayout.fieldInfo.forM $ fun finfo => IO.println (format finfo);
12
+ IO.println "---" ;
13
+ let ctorLayout ← IO.ofExcept $ getCtorLayout env `Subtype.mk;
14
+ ctorLayout.fieldInfo.forM $ fun finfo => IO.println (format finfo);
15
+ pure ()
16
+
17
+ #eval main
Original file line number Diff line number Diff line change
1
+ obj@0
2
+ obj@1
3
+ scalar#1@0:u8
4
+ obj@2
5
+ ---
6
+ scalar#4@0:u32
7
+ scalar#1@4:u8
8
+ obj@0
9
+ obj@1
10
+ obj@2
11
+ obj@3
12
+ obj@4
13
+ ---
14
+ obj@0
15
+ ◾
You can’t perform that action at this time.
0 commit comments