本文整理汇总了Python中pycket.interpreter.return_value函数的典型用法代码示例。如果您正苦于以下问题:Python return_value函数的具体用法?Python return_value怎么用?Python return_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了return_value函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: do_is_struct
def do_is_struct(v, env, cont):
from pycket.interpreter import return_value
current_inspector = values_struct.current_inspector_param.get(cont)
if isinstance(v, values_struct.W_RootStruct):
if current_inspector.has_control(v.struct_type()):
return return_value(values.w_true, env, cont)
return return_value(values.w_false, env, cont)
开发者ID:magnusmorton,项目名称:pycket,代码行数:7,代码来源:struct_structinfo.py
示例2: read_bytes_avail_bang
def read_bytes_avail_bang(w_bstr, w_port, w_start, w_end, env, cont):
# FIXME: discern the available from the non-available form
from pycket.interpreter import return_value
# FIXME: custom ports
if w_bstr.immutable():
raise SchemeException("read-bytes-avail!: given immutable byte string")
if w_port is None:
w_port = current_in_param.get(cont)
start = w_start.value
stop = len(w_bstr.value) if w_end is None else w_end.value
if stop == start:
return return_value(values.W_Fixnum(0), env, cont)
# FIXME: assert something on indices
assert start >= 0 and stop <= len(w_bstr.value)
n = stop - start
res = w_port.read(n)
reslen = len(res)
# shortcut without allocation when complete replace
if start == 0 and stop == len(w_bstr.value) and reslen == n:
w_bstr.value = list(res)
return return_value(values.W_Fixnum(reslen), env, cont)
if reslen == 0:
return return_value(values.eof_object, env, cont)
for i in range(0, reslen):
w_bstr.value[start + i] = res[i]
return return_value(values.W_Fixnum(reslen), env, cont)
开发者ID:krono,项目名称:pycket,代码行数:33,代码来源:input_output.py
示例3: proc_arity_cont
def proc_arity_cont(arity, env, cont, _vals):
from pycket.interpreter import check_one_val, return_value
val = check_one_val(_vals)
if not arity.arity_list:
return return_value(val, env, cont)
result = make_arity_list(arity, val)
return return_value(result, env, cont)
开发者ID:vishesh,项目名称:pycket,代码行数:7,代码来源:general.py
示例4: do_read_one
def do_read_one(w_port, as_bytes, peek, env, cont):
from pycket.interpreter import return_value
if peek:
c = w_port.peek()
else:
c = w_port.read(1)
if len(c) == 0:
return return_value(values.eof_object, env, cont)
i = ord(c[0])
if as_bytes:
return return_value(values.W_Fixnum(i), env, cont)
else:
# hmpf, poking around in internals
needed = runicode.utf8_code_length[i]
if peek:
old = w_port.tell()
c = w_port.read(needed)
w_port.seek(old)
elif needed > 1:
c += w_port.read(needed - 1)
c = c.decode("utf-8")
assert len(c) == 1
return return_value(values.W_Character(c[0]), env, cont)
开发者ID:rjnw,项目名称:pycket,代码行数:25,代码来源:input_output.py
示例5: datum_to_correlated
def datum_to_correlated(ignored, datum, _srcloc, env, cont):
if isinstance(datum, W_Correlated):
return return_value(datum, env, cont)
else:
from pycket.prims.general import srcloc
srcloc_const = srcloc.constructor
if isinstance(_srcloc, W_Vector):
#unerase = _srcloc.get_strategy().unerase
#vector_contents = unerase(_srcloc.storage)
v_ref = _srcloc.get_strategy().ref
return srcloc_const.call([v_ref(_srcloc, 0),
v_ref(_srcloc, 1),
v_ref(_srcloc, 2),
v_ref(_srcloc, 3),
v_ref(_srcloc, 4)],
env, datum_to_corr_cont(datum, env, cont))
elif isinstance(_srcloc, W_List):
return srcloc_const.call([_srcloc.car(),
_srcloc.cdr().car(),
_srcloc.cdr().cdr().car(),
_srcloc.cdr().cdr().cdr().car(),
_srcloc.cdr().cdr().cdr().cdr().car()],
env, datum_to_corr_cont(datum, env, cont))
elif isinstance(_srcloc, W_Correlated):
raise Exception("FIXME NYI datum->syntax _srcloc is a correlated")
else:
if _srcloc is not w_false:
raise Exception("FIXME, unhandled srcloc type %s" % _srcloc.tostring())
srcloc = _srcloc
return return_value(W_Correlated(datum, srcloc, {}), env, cont)
开发者ID:pycket,项目名称:pycket,代码行数:31,代码来源:correlated.py
示例6: write_bytes_avail
def write_bytes_avail(w_bstr, w_port, w_start, w_end, env, cont):
# FIXME: discern the available from the non-available form
from pycket.interpreter import return_value
# FIXME: custom ports
if w_port is None:
w_port = current_out_param.get(cont)
start = w_start.value
stop = len(w_bstr.value) if w_end is None else w_end.value
if start == stop:
w_port.flush()
return return_value(values.W_Fixnum(0), env, cont)
if start == 0 and stop == len(w_bstr.value):
to_write = w_bstr.value
else:
slice_stop = stop - 1
assert start >= 0 and slice_stop < len(w_bstr.value)
assert slice_stop >= 0
to_write = w_bstr.value[start:slice_stop]
# FIXME: we fake here
w_port.write("".join(to_write))
return return_value(values.W_Fixnum(stop - start), env, cont)
开发者ID:antongulenko,项目名称:pycket,代码行数:25,代码来源:input_output.py
示例7: hash_copy
def hash_copy(src, env, cont):
from pycket.interpreter import return_value
new = src.make_empty()
if isinstance(src, W_ImmutableHashTable):
return return_value(new, env, cont)
if src.length() == 0:
return return_value(new, env, cont)
return hash_copy_loop(src.hash_items(), 0, src, new, env, cont)
开发者ID:magnusmorton,项目名称:pycket,代码行数:8,代码来源:hash.py
示例8: hash_ref_cont
def hash_ref_cont(default, env, cont, _vals):
from pycket.interpreter import return_value, check_one_val
val = check_one_val(_vals)
if val is not w_missing:
return return_value(val, env, cont)
if default is None:
raise SchemeException("key not found")
if default.iscallable():
return default.call([], env, cont)
return return_value(default, env, cont)
开发者ID:uternet,项目名称:pycket,代码行数:10,代码来源:hash.py
示例9: arity_to_value
def arity_to_value(arity, env, cont):
from pycket.interpreter import return_value
if arity.at_least != -1:
val = [values.W_Fixnum(arity.at_least)]
constructor = arity_at_least.constructor
return constructor.call(val, env, proc_arity_cont(arity, env, cont))
if len(arity.arity_list) == 1:
item = values.W_Fixnum(arity.arity_list[0])
return return_value(item, env, cont)
result = make_arity_list(arity)
return return_value(result, env, cont)
开发者ID:vishesh,项目名称:pycket,代码行数:11,代码来源:general.py
示例10: hash_for_each_cont
def hash_for_each_cont(f, ht, index, env, cont, _vals):
from pycket.interpreter import return_value
nextindex = index + 1
try:
w_key, w_value = ht.get_item(index)
except KeyError:
return return_value(values.w_void, env,
hash_for_each_cont(f, ht, nextindex, env, cont))
except IndexError:
return return_value(values.w_void, env, cont)
after = hash_for_each_cont(f, ht, nextindex, env, cont)
return f.call([w_key, w_value], env, after)
开发者ID:krono,项目名称:pycket,代码行数:12,代码来源:hash.py
示例11: do_procedure_arity
def do_procedure_arity(proc, env, cont):
from pycket.interpreter import return_value
result = []
arity = proc.get_arity()
for item in arity.arity_list:
result.append(values.W_Fixnum(item))
if arity.at_least != -1:
val = [values.W_Fixnum(arity.at_least)]
return arity_at_least.constr.call(val, env, proc_arity_cont(result, env, cont))
if len(result) == 1:
return return_value(result[0], env, cont)
return return_value(values.to_list(result[:]), env, cont)
开发者ID:rrnewton,项目名称:pycket,代码行数:12,代码来源:general.py
示例12: ormap_cont
def ormap_cont(f, ls, env, cont, vals):
# XXX this is currently not properly jitted
from pycket.interpreter import return_value, check_one_val
val = check_one_val(vals)
if val is values.w_true:
return return_value(val, env, cont)
for l in ls:
if l is values.w_null:
return return_value(values.w_false, env, cont)
cars = [l.car() for l in ls]
cdrs = [l.cdr() for l in ls]
return f.call(cars, env, ormap_cont(f, cdrs, env, cont))
开发者ID:vishesh,项目名称:pycket,代码行数:12,代码来源:general.py
示例13: do_extract_struct_info
def do_extract_struct_info(v, env, cont):
assert is_struct_info(v)
from pycket.interpreter import return_value
if isinstance(v, values.W_Cons):
return return_value(v, env, cont)
elif isinstance(v, values.W_Prim):
return v.call([], env, cont)
else:
# TODO: it can be also:
# 1. a structure with the prop:struct-info property
# 2. a structure type derived from struct:struct-info or
# with prop:struct-info and wrapped with make-set!-transformer
return return_value(values.w_void, env, cont)
开发者ID:rrnewton,项目名称:pycket,代码行数:13,代码来源:struct_structinfo.py
示例14: call
def call(self, args, env, cont):
from pycket.interpreter import return_value
if len(args) == 0:
return return_value(self.get(cont), env, cont)
elif len(args) == 1:
cell = find_param_cell(cont, self)
assert isinstance(cell, values.W_ThreadCell)
if self.guard:
return self.guard.call([args[0]], env, param_set_cont(cell, env, cont))
else:
cell.set(args[0])
return return_value(values.w_void, env, cont)
else:
raise SchemeException("wrong number of arguments to parameter")
开发者ID:uternet,项目名称:pycket,代码行数:14,代码来源:values_parameter.py
示例15: call_with_extra_info
def call_with_extra_info(self, arg, fail, env, cont, app):
from pycket.interpreter import return_value
if isinstance(arg, W_StructType):
w_val = arg.read_prop_precise(self.property)
if w_val is not None:
return return_value(w_val, env, cont)
elif arg.struct_type() is not None:
return arg.get_prop(self.property, env, cont)
elif fail is not None:
if fail.iscallable():
return fail.call_with_extra_info([], env, cont, app)
return return_value(fail, env, cont)
raise SchemeException("%s-accessor: expected %s? but got %s" %
(self.property.name, self.property.name, arg.tostring()))
开发者ID:rjnw,项目名称:pycket,代码行数:14,代码来源:values_struct.py
示例16: do_read_one
def do_read_one(port, as_bytes, env, cont):
from pycket.interpreter import return_value
if port is None:
port = current_in_param.get(cont)
assert isinstance(port, values.W_InputPort)
# FIXME: UTF-8
c = port.read(1)
if len(c) == 0:
return return_value(values.eof_object, env, cont)
i = ord(c[0])
if as_bytes:
return return_value(values.W_Fixnum(i), env, cont)
else:
return return_value(values.W_Character(unichr(i)), env, cont)
开发者ID:antongulenko,项目名称:pycket,代码行数:15,代码来源:input_output.py
示例17: hash_map_cont
def hash_map_cont(f, ht, index, w_acc, env, cont, vals):
from pycket.interpreter import return_value, check_one_val
w_val = check_one_val(vals)
if w_val is not w_missing:
w_acc = values.W_Cons.make(w_val, w_acc)
nextindex = index + 1
try:
w_key, w_value = ht.get_item(index)
except KeyError:
return return_value(w_missing, env,
hash_map_cont(f, ht, nextindex, w_acc, env, cont))
except IndexError:
return return_value(w_acc, env, cont)
after = hash_map_cont(f, ht, nextindex, w_acc, env, cont)
return f.call([w_key, w_value], env, after)
开发者ID:krono,项目名称:pycket,代码行数:15,代码来源:hash.py
示例18: hash_iter_ref
def hash_iter_ref(ht, n, env, cont, returns=_KEY_AND_VALUE):
from pycket.interpreter import return_value, return_multi_vals
try:
w_key, w_val = ht.get_item(n)
if returns == _KEY:
return return_value(w_key, env, cont)
if returns == _VALUE:
return return_value(w_val, env, cont)
if returns == _KEY_AND_VALUE:
vals = values.Values._make2(w_key, w_val)
return return_multi_vals(vals, env, cont)
except KeyError:
raise SchemeException("hash-iterate-key: invalid position")
except IndexError:
raise SchemeException("hash-iterate-key: invalid position")
开发者ID:rjnw,项目名称:pycket,代码行数:15,代码来源:hash.py
示例19: unsafe_vector_set
def unsafe_vector_set(v, i, new, env, cont):
from pycket.interpreter import return_value
if isinstance(v, imp.W_ImpVector) or isinstance(v, imp.W_ChpVector):
return v.vector_set(i, new, env, cont)
else:
assert type(v) is values_vector.W_Vector
return return_value(v.unsafe_set(i.value, new), env, cont)
开发者ID:antongulenko,项目名称:pycket,代码行数:7,代码来源:vector.py
示例20: get_input_port
def get_input_port(port, env, cont):
from pycket.interpreter import return_value
if port is None:
port = current_in_param.get(cont)
return return_value(port, env, cont)
else:
return get_port(port, values_struct.w_prop_input_port, values.W_InputPort, env, cont)
开发者ID:rjnw,项目名称:pycket,代码行数:7,代码来源:input_output.py
注:本文中的pycket.interpreter.return_value函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论