Bases: InterpreterFunctions
Source code in xdsl/frontend/listlang/marimo.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 | @register_impls
class PrintfFunctions(InterpreterFunctions):
def _format_arg(self, fmt_val: Any, arg: Any) -> str:
if isa(fmt_val.type, builtin.I1):
return "true" if arg else "false"
return str(arg)
@impl(PrintFormatOp)
def run_println(
self, interpreter: Interpreter, op: PrintFormatOp, args: tuple[Any, ...]
):
pretty_args = tuple(
self._format_arg(fmt_val, arg)
for fmt_val, arg in zip(op.format_vals, args, strict=True)
)
print(
op.format_str.data.format(*pretty_args),
file=interpreter.file,
end="",
)
return ()
|
run_println(interpreter: Interpreter, op: PrintFormatOp, args: tuple[Any, ...])
Source code in xdsl/frontend/listlang/marimo.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 | @impl(PrintFormatOp)
def run_println(
self, interpreter: Interpreter, op: PrintFormatOp, args: tuple[Any, ...]
):
pretty_args = tuple(
self._format_arg(fmt_val, arg)
for fmt_val, arg in zip(op.format_vals, args, strict=True)
)
print(
op.format_str.data.format(*pretty_args),
file=interpreter.file,
end="",
)
return ()
|