# Path: cmd_ir/instructions/_core.py
# class PreambleInsn(Insn, metaclass=abc.ABCMeta):
# 
#     is_preamble_insn = True
#     top_preamble_only = False
#     func_preamble_only = False
# 
#     def apply(self, out, func):
#         assert False, "This is a preamble insn, %s" % self
# 
#     def run(self, ev):
#         assert False, "Not a compile time instruction, %s" % self
# 
#     def activate(self, seq):
#         assert isinstance(seq, Preamble), self
#         if self.top_preamble_only:
#             assert seq.is_top, self
#         if self.func_preamble_only:
#             assert not seq.is_top, self
#         return self.preapply(seq)
# 
#     @abc.abstractmethod
#     def preapply(self, preamble):
#         pass
# 
#     def postapply(self, out, func):
#         pass
# 
# Path: cmd_ir/instructions/control_flow.py
# class RunDeferredCallback(RuntimeInsn):
#     """(Internal) Copies the callback function from the stackframe
#     into the zero tick block. See deferred_invoke."""
# 
#     args = []
#     argnames = ''
#     insn_name = 'run_deferred_callback'
# 
#     def apply(self, out, func):
#         storage = c.GlobalNBT(func.namespace)
#         out.write(_zt.cmd_set_from(c.StackFrameHead(-1), storage))
# 
# Path: cmd_ir/core_types.py
# class VirtualString(NativeType):
# 
#     def __init__(self, val):
#         assert type(val) == str, val
#         self.val = val
# 
#     def __str__(self):
#         return self.val
# 
#     def clone(self):
#         return self
# 
#     def serialize(self):
#         return '"%s"' % self.val.replace('\\', '\\\\').replace('"', '\\"')


from ._core import PreambleInsn
from .control_flow import RunDeferredCallback
from ..core_types import VirtualString
    argnames = ''
    func_preamble_only = True
    insn_name = 'pure_func'

    def preapply(self, seq):
        seq.holder.set_pure()

class InlineInsn(PreambleInsn):
    """Marks the function as inline-able. invoke calls to this function will
    result in the body of the function being inserted at the call site"""

    args = []
    argnames = ''
    func_preamble_only = True
    insn_name = 'inline'

    def preapply(self, seq):
        seq.holder.set_inline()

class RunCallbackOnExit(PreambleInsn):
    """Converts this function into an async function - one that
    does not return immediately, but instead invokes a callback
    when it eventually exits. Call this function with deferred_invoke."""

    args = []
    argnames = ''
    func_preamble_only = True
    insn_name = 'run_callback_on_exit'

    def preapply(self, seq):

# Path: cmd_ir/instructions/_core.py
# class PreambleInsn(Insn, metaclass=abc.ABCMeta):
# 
#     is_preamble_insn = True
#     top_preamble_only = False
#     func_preamble_only = False
# 
#     def apply(self, out, func):
#         assert False, "This is a preamble insn, %s" % self
# 
#     def run(self, ev):
#         assert False, "Not a compile time instruction, %s" % self
# 
#     def activate(self, seq):
#         assert isinstance(seq, Preamble), self
#         if self.top_preamble_only:
#             assert seq.is_top, self
#         if self.func_preamble_only:
#             assert not seq.is_top, self
#         return self.preapply(seq)
# 
#     @abc.abstractmethod
#     def preapply(self, preamble):
#         pass
# 
#     def postapply(self, out, func):
#         pass
# 
# Path: cmd_ir/instructions/control_flow.py
# class RunDeferredCallback(RuntimeInsn):
#     """(Internal) Copies the callback function from the stackframe
#     into the zero tick block. See deferred_invoke."""
# 
#     args = []
#     argnames = ''
#     insn_name = 'run_deferred_callback'
# 
#     def apply(self, out, func):
#         storage = c.GlobalNBT(func.namespace)
#         out.write(_zt.cmd_set_from(c.StackFrameHead(-1), storage))
# 
# Path: cmd_ir/core_types.py
# class VirtualString(NativeType):
# 
#     def __init__(self, val):
#         assert type(val) == str, val
#         self.val = val
# 
#     def __str__(self):
#         return self.val
# 
#     def clone(self):
#         return self
# 
#     def serialize(self):
#         return '"%s"' % self.val.replace('\\', '\\\\').replace('"', '\\"')


# Path: cmd_ir/instructions/func_prop.py
from ._core import PreambleInsn
from .control_flow import RunDeferredCallback
from ..core_types import VirtualString

    argnames = ''
    func_preamble_only = True
    insn_name = 'pure_func'

    def preapply(self, seq):
        seq.holder.set_pure()

class InlineInsn(PreambleInsn):
    """Marks the function as inline-able. invoke calls to this function will
    result in the body of the function being inserted at the call site"""

    args = []
    argnames = ''
    func_preamble_only = True
    insn_name = 'inline'

    def preapply(self, seq):
        seq.holder.set_inline()

class RunCallbackOnExit(PreambleInsn):
    """Converts this function into an async function - one that
    does not return immediately, but instead invokes a callback
    when it eventually exits. Call this function with deferred_invoke."""

    args = []
    argnames = ''
    func_preamble_only = True
    insn_name = 'run_callback_on_exit'

    def preapply(self, seq):

        seq.holder.post_exit_insns.append(RunDeferredCallback())