本文整理汇总了Python中pypy.rpython.annlowlevel.llstr函数的典型用法代码示例。如果您正苦于以下问题:Python llstr函数的具体用法?Python llstr怎么用?Python llstr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了llstr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_streq_checknull_char
def test_streq_checknull_char():
func = LLtypeHelpers._ll_2_str_eq_checknull_char.im_func
assert func(llstr("wor"), "x") == False
assert func(llstr("w"), "x") == False
assert func(llstr(""), "x") == False
assert func(llstr("x"), "x") == True
assert func(llstr(None), "x") == False
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:7,代码来源:test_support.py
示例2: test_streq_nonnull_char
def test_streq_nonnull_char():
func = LLtypeHelpers._ll_2_str_eq_nonnull_char.im_func
assert func(llstr("wor"), "x") == False
assert func(llstr("w"), "x") == False
assert func(llstr(""), "x") == False
assert func(llstr("x"), "x") == True
py.test.raises(AttributeError, func, llstr(None), "x")
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:7,代码来源:test_support.py
示例3: test_set_param_enable_opts
def test_set_param_enable_opts(self):
from pypy.rpython.annlowlevel import llstr, hlstr
myjitdriver = JitDriver(greens = [], reds = ['n'])
class A(object):
def m(self, n):
return n-1
def g(n):
while n > 0:
myjitdriver.can_enter_jit(n=n)
myjitdriver.jit_merge_point(n=n)
n = A().m(n)
return n
def f(n, enable_opts):
myjitdriver.set_param('enable_opts', hlstr(enable_opts))
return g(n)
# check that the set_param will override the default
res = self.meta_interp(f, [10, llstr('')])
assert res == 0
self.check_loops(new_with_vtable=1)
res = self.meta_interp(f, [10, llstr(ALL_OPTS_NAMES)],
enable_opts='')
assert res == 0
self.check_loops(new_with_vtable=0)
开发者ID:ieure,项目名称:pypy,代码行数:27,代码来源:test_warmspot.py
示例4: 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
示例5: test_streq_slice_nonnull
def test_streq_slice_nonnull():
p1 = llstr("hello world")
p2 = llstr("wor")
func = LLtypeHelpers._ll_4_str_eq_slice_nonnull.im_func
assert func(p1, 6, 3, p2) == True
assert func(p1, 6, 2, p2) == False
assert func(p1, 5, 3, p2) == False
py.test.raises(AttributeError, func, p1, 2, 1, llstr(None))
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:8,代码来源:test_support.py
示例6: test_streq_slice_checknull
def test_streq_slice_checknull():
p1 = llstr("hello world")
p2 = llstr("wor")
func = LLtypeHelpers._ll_4_str_eq_slice_checknull.im_func
assert func(p1, 6, 3, p2) == True
assert func(p1, 6, 2, p2) == False
assert func(p1, 5, 3, p2) == False
assert func(p1, 2, 1, llstr(None)) == False
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:8,代码来源:test_support.py
示例7: getvar
def getvar(self, arg):
if not arg:
return ConstInt(0)
try:
return ConstInt(int(arg))
except ValueError:
if self.is_float(arg):
return ConstFloat(float(arg))
if arg.startswith('"') or arg.startswith("'"):
# XXX ootype
info = arg.strip("'\"")
return ConstPtr(lltype.cast_opaque_ptr(llmemory.GCREF,
llstr(info)))
if arg.startswith('ConstClass('):
name = arg[len('ConstClass('):-1]
return self.get_const(name, 'class')
elif arg == 'None':
return None
elif arg == 'NULL':
if self.type_system == 'lltype':
return ConstPtr(ConstPtr.value)
else:
return ConstObj(ConstObj.value)
elif arg.startswith('ConstPtr('):
name = arg[len('ConstPtr('):-1]
return self.get_const(name, 'ptr')
return self.vars[arg]
开发者ID:enyst,项目名称:plexnet,代码行数:27,代码来源:oparser.py
示例8: test_streq_slice_char
def test_streq_slice_char():
p1 = llstr("hello world")
func = LLtypeHelpers._ll_4_str_eq_slice_char.im_func
assert func(p1, 6, 3, "w") == False
assert func(p1, 6, 0, "w") == False
assert func(p1, 6, 1, "w") == True
assert func(p1, 6, 1, "x") == False
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:7,代码来源:test_support.py
示例9: read_code
def read_code():
from pypy.module.marshal.interp_marshal import dumps
filename = 'pypyjit_demo.py'
source = readfile(filename)
ec = space.getexecutioncontext()
code = ec.compiler.compile(source, filename, 'exec', 0)
return llstr(space.str_w(dumps(space, code, space.wrap(2))))
开发者ID:enyst,项目名称:plexnet,代码行数:8,代码来源:pypyjit.py
示例10: apply_jit
def apply_jit(policy, interp, graph, CPUClass):
print 'warmspot.jittify_and_run() started...'
option.view = True
LIST = graph.getargs()[0].concretetype
lst = LIST.TO.ll_newlist(len(ARGS))
for i, arg in enumerate(ARGS):
lst.ll_setitem_fast(i, llstr(arg))
warmspot.jittify_and_run(interp, graph, [lst], policy=policy,
listops=True, CPUClass=CPUClass,
backendopt=True, inline=True,
optimizer=OPTIMIZER_FULL)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:11,代码来源:jittest.py
示例11: test_streq_nonnull
def test_streq_nonnull():
p1 = llstr("wor")
p2 = llstr("wor")
assert p1 != p2
func = LLtypeHelpers._ll_2_str_eq_nonnull.im_func
assert func(p1, p1) == True
assert func(p1, p2) == True
assert func(p1, llstr("wrl")) == False
assert func(p1, llstr("world")) == False
assert func(p1, llstr("w")) == False
py.test.raises(AttributeError, func, p1, llstr(None))
py.test.raises(AttributeError, func, llstr(None), p2)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:12,代码来源:test_support.py
示例12: ll_float_str
def ll_float_str(repr, f):
from pypy.rlib.rfloat import formatd
return llstr(formatd(f, 'f', 6))
开发者ID:gorakhargosh,项目名称:pypy,代码行数:3,代码来源:ll_str.py
示例13: f
def f(arg):
s = llstr(hlstr(arg))
return len(s.chars)
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:3,代码来源:test_annlowlevel.py
示例14: ll_float_str
def ll_float_str(repr, f):
return llstr(formatd("%f", f))
开发者ID:alkorzt,项目名称:pypy,代码行数:2,代码来源:ll_str.py
示例15: test_llstr
def test_llstr(self):
s = llstr("abc")
assert len(s.chars) == 3
assert s.chars[0] == "a"
assert s.chars[1] == "b"
assert s.chars[2] == "c"
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:6,代码来源:test_annlowlevel.py
示例16: conststr
def conststr(self, str):
ll = llstr(str)
return history.ConstPtr(lltype.cast_opaque_ptr(llmemory.GCREF, ll))
开发者ID:enyst,项目名称:plexnet,代码行数:3,代码来源:typesystem.py
示例17: meta_interp_search
def meta_interp_search(self, pattern, string, repeat=1):
r = get_code(pattern)
return self.meta_interp(entrypoint2, [list2array(r), llstr(string),
repeat],
listcomp=True, backendopt=True)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:5,代码来源:test_zjit.py
示例18: test_nooveralloc
def test_nooveralloc(self):
sb = StringBuilderRepr.ll_new(3)
StringBuilderRepr.ll_append(sb, llstr("abc"))
assert StringBuilderRepr.ll_build(sb) == sb.buf
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:4,代码来源:test_rbuilder.py
示例19: ll_str
def ll_str(self, none):
return llstr("None")
开发者ID:enyst,项目名称:plexnet,代码行数:2,代码来源:rpbc.py
示例20: f
def f():
a = llstr("xyz")
b = (llmemory.cast_ptr_to_adr(a) + llmemory.offsetof(STR, 'chars')
+ llmemory.itemoffsetof(STR.chars, 0))
buf = rffi.cast(rffi.VOIDP, b)
return buf[2]
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:6,代码来源:test_lltyped.py
注:本文中的pypy.rpython.annlowlevel.llstr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论