44
55import cirq
66from kirin import ir , types , interp
7- from kirin .emit import EmitABC , EmitError , EmitFrame
7+ from kirin .emit import EmitABC , EmitFrame
88from kirin .interp import MethodTable , impl
99from kirin .dialects import py , func
1010from typing_extensions import Self
@@ -102,7 +102,7 @@ def main():
102102 and isinstance (mt .code , func .Function )
103103 and not mt .code .signature .output .is_subseteq (types .NoneType )
104104 ):
105- raise EmitError (
105+ raise interp . exceptions . InterpreterError (
106106 "The method you are trying to convert to a circuit has a return value, but returning from a circuit is not supported."
107107 " Set `ignore_returns = True` in order to simply ignore the return values and emit a circuit."
108108 )
@@ -116,12 +116,12 @@ def main():
116116
117117 symbol_op_trait = mt .code .get_trait (ir .SymbolOpInterface )
118118 if (symbol_op_trait := mt .code .get_trait (ir .SymbolOpInterface )) is None :
119- raise EmitError ("The method is not a symbol, cannot emit circuit!" )
119+ raise interp . exceptions . InterpreterError ("The method is not a symbol, cannot emit circuit!" )
120120
121121 sym_name = symbol_op_trait .get_sym_name (mt .code ).unwrap ()
122122
123123 if (signature_trait := mt .code .get_trait (ir .HasSignature )) is None :
124- raise EmitError (
124+ raise interp . exceptions . InterpreterError (
125125 f"The method { sym_name } does not have a signature, cannot emit circuit!"
126126 )
127127
@@ -135,7 +135,7 @@ def main():
135135
136136 assert first_stmt is not None , "Method has no statements!"
137137 if len (args_ssa ) - 1 != len (args ):
138- raise EmitError (
138+ raise interp . exceptions . InterpreterError (
139139 f"The method { sym_name } takes { len (args_ssa ) - 1 } arguments, but you passed in { len (args )} via the `args` keyword!"
140140 )
141141
@@ -166,7 +166,7 @@ def _default_kernel():
166166
167167@dataclass
168168class EmitCirq (EmitABC [EmitCirqFrame , cirq .Circuit ]):
169- keys = [ "emit.cirq" , "main" ]
169+ keys = ( "emit.cirq" , "emit. main" )
170170 dialects : ir .DialectGroup = field (default_factory = _default_kernel )
171171 void = cirq .Circuit ()
172172 qubits : Sequence [cirq .Qid ] | None = None
@@ -226,7 +226,7 @@ def emit_func(self, emit: EmitCirq, frame: EmitCirqFrame, stmt: func.Function):
226226
227227 @impl (func .Invoke )
228228 def emit_invoke (self , emit : EmitCirq , frame : EmitCirqFrame , stmt : func .Invoke ):
229- raise EmitError (
229+ raise interp . exceptions . InterpreterError (
230230 "Function invokes should need to be inlined! "
231231 "If you called the emit_circuit method, that should have happened, please report this issue."
232232 )
0 commit comments