Пример #1
0
def generateThrowException(context, exception):
    return (
        #as a short-term hack, use a runtime function to stash this where the callsite can pick it up.
        runtime_functions.stash_exception_ptr.call(
            native_ast.const_utf8_cstr(str(exception))) >>
        native_ast.Expression.Throw(expr=native_ast.Expression.Constant(
            val=native_ast.Constant.NullPointer(
                value_type=native_ast.UInt8.pointer()))))
Пример #2
0
 def pushException(self, type, value):
     self.pushEffect(
         # as a short-term hack, use a runtime function to stash this where the callsite can pick it up.
         runtime_functions.stash_exception_ptr.call(
             native_ast.const_utf8_cstr(str(value))) >>
         native_ast.Expression.Throw(expr=native_ast.Expression.Constant(
             val=native_ast.Constant.NullPointer(
                 value_type=native_ast.UInt8.pointer()))))
 def constant(self, context, s):
     return context.push(
         str,
         lambda strRef: strRef.expr.store(
             runtime_functions.string_from_utf8_and_len.call(
                 native_ast.const_utf8_cstr(s),
                 native_ast.const_int_expr(len(s))
             ).cast(self.layoutType)
         )
     )
 def convert_attribute(self, context, instance, attr):
     assert isinstance(attr, str)
     return context.push(
         self, lambda targetSlot: targetSlot.expr.store(
             runtime_functions.getattr_pyobj.call(
                 instance.nonref_expr, native_ast.const_utf8_cstr(attr))))