本文整理汇总了Python中pycket.interpreter.return_multi_vals函数的典型用法代码示例。如果您正苦于以下问题:Python return_multi_vals函数的具体用法?Python return_multi_vals怎么用?Python return_multi_vals使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了return_multi_vals函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rmpe
def rmpe(pat, input, inp_start, inp_end, output_port, prefix, count, env, cont):
from pycket.interpreter import return_multi_vals
start = inp_start.value
if inp_end is values.w_false:
end = sys.maxint
elif isinstance(inp_end, values.W_Fixnum):
end = inp_end.value
else:
raise SchemeException("regexp-match-positions/end: expected fixnum or #f for argument 3")
assert output_port is values.w_false, "output port not supported yet"
matches = match_positions(pat, input, start, end)
if matches is None:
return return_multi_vals(NO_MATCH, env, cont)
acc, end = make_match_list(matches)
length = count.value
start = max(0, end - length)
assert start >= 0 and end >= 0
matched = input.getslice(start, end)
bytestring = ['\0'] * (end - start)
for i in range(end - start):
bytestring[i] = chr(ord(matched.getitem(i)) % 256)
bytes = values.W_Bytes(bytestring)
result = values.Values._make2(acc, bytes)
return return_multi_vals(result, env, cont)
示例2: rmpe
def rmpe(pat, input, inp_start, inp_end, output_port, prefix, count, env, cont):
from pycket.interpreter import return_multi_vals
start = inp_start.value
if inp_end is values.w_false:
end = sys.maxint
elif isinstance(inp_end, values.W_Fixnum):
end = inp_end.value
else:
raise SchemeException("regexp-match-positions/end: expected fixnum or #f for argument 3")
assert output_port is values.w_false, "output port not supported yet"
matches = match_positions(pat, input, start, end)
if matches is None:
return return_multi_vals(NO_MATCH, env, cont)
acc, end = make_match_list(matches)
length = count.value
input_str = input.as_str_ascii()
start = max(0, end - length)
assert start >= 0 and end >= 0
bytes = values.W_Bytes.from_string(input_str[start:end], immutable=False)
result = values.Values.make([acc, bytes])
return return_multi_vals(result, env, cont)
示例3: constr_proc_wrapper_cont
def constr_proc_wrapper_cont(self, field_values, struct_type_name, issuper,
app, env, cont, _vals):
from pycket.interpreter import return_multi_vals, jump
guard_values = _vals.get_all_values()
type = jit.promote(self.type)
if guard_values:
field_values = guard_values
super_type = jit.promote(type.super)
if isinstance(super_type, W_StructType):
split_position = len(field_values) - type.init_field_cnt
super_auto = super_type.constr.type.auto_values
assert split_position >= 0
field_values = self._splice(field_values, len(field_values),\
split_position, super_auto, len(super_auto))
if issuper:
return super_type.constr.code(field_values[:split_position],
struct_type_name, True, env, cont, app)
else:
return super_type.constr.code(field_values[:split_position],
struct_type_name, True,
env, self.constr_proc_cont(field_values, env, cont), app)
else:
if issuper:
return return_multi_vals(values.Values.make(field_values), env, cont)
else:
return jump(env, self.constr_proc_cont(field_values, env, cont))
示例4: attach_prop
def attach_prop(self, props, idx, is_checked, env, cont):
from pycket.interpreter import return_multi_vals
if idx < len(props):
(prop, prop_val, sub_prop) = props[idx]
if sub_prop is not None:
for p in props:
if p[0] is sub_prop:
return prop_val.call([p[1]], env,
self.save_prop_value(props, idx, False, env, cont))
assert isinstance(prop, W_StructProperty)
if not is_checked and prop.guard.iscallable():
return prop.guard.call([prop_val, values.to_list(self.struct_type_info())],
env, self.save_prop_value(props, idx, True, env, cont))
if prop.isinstance(w_prop_procedure):
self.prop_procedure = prop_val
self.props.append((prop, prop_val))
return self.attach_prop(props, idx + 1, False, env, cont)
# at this point all properties are saved, next step is to copy
# propertyes from super types
struct_type = self.super
while isinstance(struct_type, W_StructType):
self.props = self.props + struct_type.props
if not self.prop_procedure and struct_type.prop_procedure:
self.prop_procedure = struct_type.prop_procedure
self.procedure_source = struct_type.procedure_source
struct_type = struct_type.super
struct_tuple = self.make_struct_tuple()
return return_multi_vals(values.Values.make(struct_tuple), env, cont)
示例5: split_path
def split_path(w_path, env, cont):
from pycket.interpreter import return_multi_vals
path = extract_path(w_path)
base, name, must_be_dir = _split_path(path)
result = values.Values.make([base, name, must_be_dir])
return return_multi_vals(result, env, cont)
示例6: make_imp_prop
def make_imp_prop(sym, env, cont):
from pycket.interpreter import return_multi_vals
name = sym.utf8value
prop = imp.W_ImpPropertyDescriptor(name)
pred = imp.W_ImpPropertyPredicate(prop)
accs = imp.W_ImpPropertyAccessor(prop)
return return_multi_vals(values.Values.make([prop, pred, accs]), env, cont)
示例7: do_struct_info
def do_struct_info(v, env, cont):
from pycket.interpreter import return_multi_vals
if (isinstance(v, values_struct.W_RootStruct) and
values_struct.current_inspector.has_control(v.struct_type())):
return v.get_struct_info(env, cont)
return return_multi_vals(
values.Values.make([values.w_false, values.w_true]), env, cont)
示例8: time_apply_cont
def time_apply_cont(initial, env, cont, vals):
from pycket.interpreter import return_multi_vals
final = time.clock()
ms = values.W_Fixnum(int((final - initial) * 1000))
vals_l = vals._get_full_list()
results = values.Values.make([values.to_list(vals_l),
ms, ms, values.W_Fixnum(0)])
return return_multi_vals(results, env, cont)
示例9: imp_hash_table_post_ref_cont
def imp_hash_table_post_ref_cont(post, ht, old, env, cont, _vals):
from pycket.interpreter import check_one_val, return_multi_vals
val = check_one_val(_vals)
if val is None:
# XXX this looks wrong, check_one_val raises if there are multiple
# values
return return_multi_vals(_vals, env, cont)
return post.call([ht, old, val], env, cont)
示例10: vec2val_cont
def vec2val_cont(vals, vec, n, s, l, env, cont, new_vals):
from pycket.interpreter import return_multi_vals, check_one_val
new = check_one_val(new_vals)
vals[n] = new
if s+n+1 == l:
return return_multi_vals(values.Values.make(vals), env, cont)
else:
return vec.vector_ref(values.W_Fixnum.make(s+n+1), env, vec2val_cont(vals, vec, n+1, s, l, env, cont))
示例11: vector_to_values
def vector_to_values(v, start, end, env, cont):
from pycket.interpreter import return_multi_vals
l = end.value if end else v.length()
s = start.value
if s == l:
return return_multi_vals(values.Values.make([]), env, cont)
else:
vals = [None] * (l - s)
return v.vector_ref(values.W_Fixnum.make(s), env, vec2val_cont(vals, v, 0, s, l, env, cont))
示例12: check_chaperone_results_loop
def check_chaperone_results_loop(vals, args, idx, env, cont):
from pycket.interpreter import return_multi_vals
from pycket.prims.equal import equal_func, EqualInfo
while idx < len(args) and vals._get_list(idx) is None and args[idx] is None:
idx += 1
if idx >= len(args):
return return_multi_vals(vals, env, cont)
info = EqualInfo.CHAPERONE_SINGLETON
return equal_func(vals._get_list(idx), args[idx], info, env,
catch_equal_cont(vals, args, idx, env, cont))
示例13: install_continuation_fast_path
def install_continuation_fast_path(current_cont, args, has_handlers, env, cont):
from pycket.interpreter import return_multi_vals, return_void
if not has_handlers:
args = values.Values.make(args)
return return_multi_vals(args, env, cont)
unwind = find_handlers(current_cont, cont)
cont = return_args_cont(args, env, cont)
unwind = [x for x in reversed(unwind)]
cont = do_unwind_cont(unwind, env, cont)
return return_void(env, cont)
示例14: check_chaperone_results_loop
def check_chaperone_results_loop(vals, args, idx, env, cont):
from pycket.interpreter import return_multi_vals
from pycket.prims.equal import equal_func_unroll_n, EqualInfo
while idx < len(args) and vals.get_value(idx) is None and args[idx] is None:
idx += 1
if idx >= len(args):
return return_multi_vals(vals, env, cont)
info = EqualInfo.CHAPERONE_SINGLETON
# XXX it would be best to store the parameter on the toplevel env and make
# it changeable via a cmdline parameter to pycket-c
unroll_n_times = 2 # XXX needs tuning
return equal_func_unroll_n(vals.get_value(idx), args[idx], info, env,
catch_equal_cont(vals, args, idx, env, cont), unroll_n_times)
示例15: func_result_handling
def func_result_handling(*args):
from pycket.interpreter import (return_multi_vals,
return_value_direct)
from pycket import values
env = args[-2]
cont = args[-1]
args = args[:-2]
result = func_arg_unwrap(*args)
if result is None:
result = values.w_void
if isinstance(result, values.Values):
return return_multi_vals(result, env, cont)
else:
return return_value_direct(result, env, cont)