当前位置: 首页>>代码示例>>Python>>正文


Python annlowlevel.hlstr函数代码示例

本文整理汇总了Python中pypy.rpython.annlowlevel.hlstr函数的典型用法代码示例。如果您正苦于以下问题:Python hlstr函数的具体用法?Python hlstr怎么用?Python hlstr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了hlstr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ll_float

    def ll_float(ll_str):
        from pypy.rpython.annlowlevel import hlstr
        from pypy.rlib.rarithmetic import break_up_float, parts_to_float
        s = hlstr(ll_str)
        assert s is not None

        n = len(s)
        beg = 0
        while beg < n:
            if s[beg] == ' ':
                beg += 1
            else:
                break
        if beg == n:
            raise ValueError
        end = n-1
        while end >= 0:
            if s[end] == ' ':
                end -= 1
            else:
                break
        assert end >= 0
        sign, before_point, after_point, exponent = break_up_float(s[beg:end+1])
    
        if not before_point and not after_point:
            raise ValueError

        return parts_to_float(sign, before_point, after_point, exponent)
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:28,代码来源:rstr.py

示例2: ll_splitlines

 def ll_splitlines(cls, LIST, ll_str, keep_newlines):
     from pypy.rpython.annlowlevel import hlstr
     s = hlstr(ll_str)
     STR = typeOf(ll_str)
     strlen = len(s)
     i = 0
     j = 0
     # The annotator makes sure this list is resizable.
     res = LIST.ll_newlist(0)
     while j < strlen:
         while i < strlen and s[i] != '\n' and s[i] != '\r':
             i += 1
         eol = i
         if i < strlen:
             if s[i] == '\r' and i + 1 < strlen and s[i + 1] == '\n':
                 i += 2
             else:
                 i += 1
             if keep_newlines:
                 eol = i
         list_length = res.ll_length()
         res._ll_resize_ge(list_length + 1)
         item = cls.ll_stringslice_startstop(ll_str, j, eol)
         res.ll_setitem_fast(list_length, item)
         j = i
     if j < strlen:
         list_length = res.ll_length()
         res._ll_resize_ge(list_length + 1)
         item = cls.ll_stringslice_startstop(ll_str, j, strlen)
         res.ll_setitem_fast(list_length, item)
     return res
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:31,代码来源:rstr.py

示例3: main

 def main():
     loop(1)
     op = jit_hooks.resop_new(rop.INT_ADD,
                              [jit_hooks.boxint_new(3),
                               jit_hooks.boxint_new(4)],
                              jit_hooks.boxint_new(1))
     assert hlstr(jit_hooks.resop_getopname(op)) == 'int_add'
     assert jit_hooks.resop_getopnum(op) == rop.INT_ADD
     box = jit_hooks.resop_getarg(op, 0)
     assert jit_hooks.box_getint(box) == 3
     box2 = jit_hooks.box_clone(box)
     assert box2 != box
     assert jit_hooks.box_getint(box2) == 3
     assert not jit_hooks.box_isconst(box2)
     box3 = jit_hooks.box_constbox(box)
     assert jit_hooks.box_getint(box) == 3
     assert jit_hooks.box_isconst(box3)
     box4 = jit_hooks.box_nonconstbox(box)
     assert not jit_hooks.box_isconst(box4)
     box5 = jit_hooks.boxint_new(18)
     jit_hooks.resop_setarg(op, 0, box5)
     assert jit_hooks.resop_getarg(op, 0) == box5
     box6 = jit_hooks.resop_getresult(op)
     assert jit_hooks.box_getint(box6) == 1
     jit_hooks.resop_setresult(op, box5)
     assert jit_hooks.resop_getresult(op) == box5
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:26,代码来源:test_jitiface.py

示例4: f

 def f(x, y):
     y = const(hlstr(y))
     if x > 0:
         l = [const('a'), const('b')]
     else:
         l = [const('a')]
     l += y
     return const('').join(l)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:8,代码来源:test_rstr.py

示例5: test_simple

 def test_simple(self):
     sb = StringBuilderRepr.ll_new(3)
     StringBuilderRepr.ll_append_char(sb, 'x')
     StringBuilderRepr.ll_append(sb, llstr("abc"))
     StringBuilderRepr.ll_append_slice(sb, llstr("foobar"), 2, 5)
     StringBuilderRepr.ll_append_multiple_char(sb, 'y', 3)
     s = StringBuilderRepr.ll_build(sb)
     assert hlstr(s) == "xabcobayyy"
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:8,代码来源:test_rbuilder.py

示例6: _normalize

def _normalize(x):
    if not isinstance(x, str):
        TYPE = lltype.typeOf(x)
        if (isinstance(TYPE, lltype.Ptr) and TYPE.TO._name == 'rpy_string'
            or getattr(TYPE, '_name', '') == 'String'):    # ootype
            from pypy.rpython.annlowlevel import hlstr
            return hlstr(x)
    return x
开发者ID:alkorzt,项目名称:pypy,代码行数:8,代码来源:opimpl.py

示例7: entrypoint1

def entrypoint1(r, string, repeat):
    r = array2list(r)
    string = hlstr(string)
    match = None
    for i in range(repeat):
        match = rsre_core.match(r, string)
    if match is None:
        return -1
    else:
        return match.match_end
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:10,代码来源:test_zjit.py

示例8: posix_fakeimpl

 def posix_fakeimpl(arg):
     if s_arg == str:
         arg = hlstr(arg)
     st = getattr(os, name)(arg)
     fields = [TYPE for fieldname, TYPE in STAT_FIELDS]
     TP = TUPLE_TYPE(fields)
     ll_tup = lltype.malloc(TP.TO)
     for i, (fieldname, TYPE) in enumerate(STAT_FIELDS):
         val = getattr(st, fieldname)
         if isinstance(TYPE, lltype.Number):
             rffi.setintfield(ll_tup, 'item%d' % i, int(val))
         elif TYPE is lltype.Float:
             setattr(ll_tup, 'item%d' % i, float(val))
         else:
             setattr(ll_tup, 'item%d' % i, val)
     return ll_tup
开发者ID:alkorzt,项目名称:pypy,代码行数:16,代码来源:ll_os_stat.py

示例9: test_recursive_call_to_portal_from_blackhole

    def test_recursive_call_to_portal_from_blackhole(self):
        from pypy.rpython.annlowlevel import hlstr
        
        myjitdriver = JitDriver(greens = ['k'], reds = ['n'])
        def f(n, k):
            while n >= 0:
                myjitdriver.can_enter_jit(n=n, k=k)
                myjitdriver.jit_merge_point(n=n, k=k)
                if n == 3 and k == 0:
                    return f(10, 1)
                n -= 1
            if k == 1:
                return "string"
            return "xyz"

        res = self.meta_interp(f, [20, 0])
        assert hlstr(res) == "string"
开发者ID:craigkerstiens,项目名称:pypy,代码行数:17,代码来源:test_send.py

示例10: test_context_manager

def test_context_manager():
    state = []
    class C:
        def __enter__(self):
            state.append('acquire')
            return self
        def __exit__(self, *args):
            if args[1] is not None:
                state.append('raised')
            state.append('release')
    def f():
        try:
            with C() as c:
                state.append('use')
                raise ValueError
        except ValueError:
            pass
        return ', '.join(state)
    res = interpret(f, [])
    assert hlstr(res) == 'acquire, use, raised, release'
开发者ID:ieure,项目名称:pypy,代码行数:20,代码来源:test_llinterp.py

示例11: ll_float

    def ll_float(ll_str):
        from pypy.rpython.annlowlevel import hlstr
        from pypy.rlib.rfloat import rstring_to_float
        s = hlstr(ll_str)
        assert s is not None

        n = len(s)
        beg = 0
        while beg < n:
            if s[beg] == ' ':
                beg += 1
            else:
                break
        if beg == n:
            raise ValueError
        end = n-1
        while end >= 0:
            if s[end] == ' ':
                end -= 1
            else:
                break
        assert end >= 0
        return rstring_to_float(s[beg:end+1])
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:23,代码来源:rstr.py

示例12: f

 def f(fn):
     fn = hlstr(fn)
     return os.path.exists(fn)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:3,代码来源:test_rbuiltin.py

示例13: f

 def f(n, enable_opts):
     set_param(None, 'enable_opts', hlstr(enable_opts))
     return g(n)
开发者ID:craigkerstiens,项目名称:pypy,代码行数:3,代码来源:test_warmspot.py

示例14: p

 def p(pc, code):
     code = hlstr(code)
     return "%s %d %s" % (code, pc, code[pc])
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:3,代码来源:test_recursive.py

示例15: f

 def f(arg):
     s = llstr(hlstr(arg))
     return len(s.chars)
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:3,代码来源:test_annlowlevel.py


注:本文中的pypy.rpython.annlowlevel.hlstr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。