Skip to content

Commit 507d49b

Browse files
committed
add annotation codegen for stim
1 parent da6def7 commit 507d49b

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

src/bloqade/stim/emit/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
from . import impls as impls
12
from .stim_str import FuncEmit as FuncEmit, EmitStimMain as EmitStimMain

src/bloqade/stim/emit/impls.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from kirin.emit import EmitStrFrame
2+
from kirin.interp import MethodTable, impl
3+
from kirin.dialects.debug import Info, dialect
4+
5+
from bloqade.stim.emit.stim_str import EmitStimMain
6+
7+
8+
@dialect.register(key="emit.stim")
9+
class EmitStimDebugMethods(MethodTable):
10+
11+
@impl(Info)
12+
def info(self, emit: EmitStimMain, frame: EmitStrFrame, stmt: Info):
13+
14+
msg: str = frame.get(stmt.msg)
15+
emit.writeln(frame, f"#{msg}")
16+
17+
return ()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from kirin.dialects import debug
2+
3+
from bloqade import stim
4+
5+
from .base import codegen
6+
7+
8+
def test_debug():
9+
10+
@stim.main
11+
def test_debug_main():
12+
debug.info("debug message")
13+
14+
test_debug_main.print()
15+
out = codegen(test_debug_main)
16+
assert out.strip() == "#debug message"

0 commit comments

Comments
 (0)