def catch_set_is_equal_cont(data, idx, key, val, env, cont, _vals): from pycket.interpreter import check_one_val, return_value cmp = check_one_val(_vals) if cmp is not values.w_false: data[idx] = (key, val) return return_value(values.w_void, env, cont) return equal_hash_set_loop(data, idx + 1, key, val, env, cont)
def vector_cas_bang_cont(vec, pos_idx, old_val, new_val, env, cont, _vals): from pycket.interpreter import check_one_val, return_value current_vec_val = check_one_val(_vals) if equal.eqp_logic(current_vec_val, old_val): #eq? return vec.vector_set(pos_idx, new_val, env, vector_cas_success(env, cont)) return return_value(values.w_false, env, cont)
def get_port_cont(prop, typ, env, cont, _vals): from pycket.interpreter import return_value, check_one_val val = check_one_val(_vals) if isinstance(val, values_struct.W_RootStruct): return get_port(val, prop, typ, env, cont) else: return return_value(val, env, cont)
def catch_equal_cont(vals, args, idx, env, cont, _vals): from pycket.interpreter import check_one_val val = check_one_val(_vals) if val is values.w_false: raise SchemeException("Expecting original value or chaperone") return check_chaperone_results_loop(vals, args, idx + 1, env, 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)
def imp_struct_set_cont(orig_struct, setter, field, app, env, cont, _vals): from pycket.interpreter import check_one_val val = check_one_val(_vals) if setter is values.w_false: return orig_struct.set_with_extra_info(field, val, app, env, cont) return setter.call_with_extra_info([orig_struct, val], env, cont, app)
def hash_keys_subset_huh_cont(keys_vals, hash_2, idx, env, cont, _vals): from pycket.interpreter import return_value, check_one_val val = check_one_val(_vals) if val is values.w_false: return return_value(values.w_false, env, cont) else: return hash_keys_subset_huh_loop(keys_vals, hash_2, idx + 1, env, cont)
def equal_ht_done_cont(hash_1_items, hash_2, idx, info, env, cont, _vals): from pycket.interpreter import check_one_val, return_value eq = check_one_val(_vals) if eq is values.w_false: return return_value(values.w_false, env, cont) inc = idx + 1 return equal_ht_func(hash_1_items, hash_2, inc, info, env, cont)
def equal_vec_done_cont(a, b, idx, info, env, cont, _vals): from pycket.interpreter import check_one_val, return_value eq = check_one_val(_vals) if eq is values.w_false: return return_value(values.w_false, env, cont) inc = idx + 1 return equal_vec_func(a, b, inc, info, env, 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(s+n+1, env, vec2val_cont(vals, vec, n+1, s, l, env, cont))
def equal_ht_cont(hash_1_items, hash_2, idx, info, env, cont, _vals): from pycket.interpreter import return_value, check_one_val hash_2_val = check_one_val(_vals) if hash_2_val is values.w_false: return return_value(values.w_false, env, cont) else: return equal_func(hash_1_items[idx][1], hash_2_val, info, env, equal_ht_done_cont(hash_1_items, hash_2, idx, info, env, cont))
def vector_copy_cont_get(src, src_start, src_end, dest, dest_start, i, env, cont, _vals): from pycket.interpreter import check_one_val val = check_one_val(_vals) idx = i + dest_start next = i + 1 return dest.vector_set(idx, val, env, goto_vector_copy_loop(src, src_start, src_end, dest, dest_start, next, env, 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)
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))
def vector_copy_cont_get(src, src_start, src_end, dest, dest_start, i, env, cont, _vals): from pycket.interpreter import check_one_val val = check_one_val(_vals) idx = values.W_Fixnum(i.value + dest_start) next = values.W_Fixnum(i.value + 1) return dest.vector_set(idx, val, env, goto_vector_copy_loop(src, src_start, src_end, dest, dest_start, next, env, cont))
def read_stream_cont(env, cont, _vals): from pycket.interpreter import check_one_val, return_value port = check_one_val(_vals) rt = current_readtable_param.get(cont) if rt is values.w_false: rt = None else: assert isinstance(rt, values.W_ReadTable) return read_stream_rt(port, rt, env, cont)
def display_escape_cont(exn, env, cont, _vals): from pycket.interpreter import check_one_val message = check_one_val(_vals) display_handler = error_display_handler_param.get(cont) # parameterize this to default first escape_handler = error_escape_handler_param.get(cont) # this one too # display, then escape return display_handler.call([message, exn], env, call_handler_cont(escape_handler, [], env, cont))
def extend_cont(paramz, i, eventual_vals, vals, params, env, cont, _vals): from pycket.interpreter import check_one_val, return_value new_val = check_one_val(_vals) eventual_vals[i] = new_val i += 1 if i == len(vals): new_paramz = paramz._extend(params, vals) return return_value(new_paramz, env, cont) else: return step_extend(paramz, i, eventual_vals, vals, params, env, cont)
def hash_ref_cont(default, k, 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 %s not found"%k.tostring()) if default.iscallable(): return default.call([], env, cont) return return_value(default, env, 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)
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))
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)
def do_read_line(mode, as_bytes, env, cont, _vals): # FIXME: respect mode from pycket.interpreter import return_value, check_one_val port = check_one_val(_vals) line = port.readline() stop = len(line) - 1 if stop >= 0: # chomp if line[stop] == "\n": line = line[:stop] if as_bytes: return return_value(values.W_Bytes.from_string(line), env, cont) else: return return_value(values_string.W_String.fromstr_utf8(line), env, cont) else: return return_value(values.eof_object, env, cont)
def save_prop_value(self, props, idx, is_checked, env, cont, _vals): from pycket.interpreter import check_one_val prop = props[idx][0] prop_val = check_one_val(_vals) props[idx] = (prop, prop_val, None) return self.attach_prop(props, idx, is_checked, env, cont)
def imp_cmk_post_set_cont(body, inner, env, cont, _vals): from pycket.interpreter import check_one_val val = check_one_val(_vals) return inner.set_cmk(body, val, cont, env, cont)
def hash_set_cont(key, val, env, cont, _vals): from pycket.interpreter import check_one_val table = check_one_val(_vals) return table.hash_set(key, val, env, return_table_cont(table, env, cont))
def imp_cmk_post_get_cont(key, env, cont, _vals): from pycket.interpreter import check_one_val val = check_one_val(_vals) return key.get_cmk(val, env, cont)
def datum_to_corr_cont(datum, env, cont, _vals): srcloc_object = check_one_val(_vals) return return_value(W_Correlated(datum, srcloc_object, {}), env, cont)
def post_build_exception(env, cont, _vals): from pycket.interpreter import check_one_val barrier = values.w_true val = check_one_val(_vals) return raise_exception(val, barrier, env, cont)
def imp_vec_set_cont(v, i, env, cont, vals): from pycket.interpreter import check_one_val return v.vector_set(i.value, check_one_val(vals), env, cont)
def hash_copy_ref_cont(keys, idx, src, new, env, cont, _vals): from pycket.interpreter import check_one_val val = check_one_val(_vals) return new.hash_set(keys[idx][0], val, env, hash_copy_set_cont(keys, idx, src, new, env, cont))
def catch_ref_is_equal_cont(data, idx, key, v, env, cont, _vals): from pycket.interpreter import check_one_val, return_value val = check_one_val(_vals) if val is not values.w_false: return return_value(v, env, cont) return equal_hash_ref_loop(data, idx + 1, key, env, cont)
def map_cons_cont(f, lists, val, env, cont, _vals): from pycket.interpreter import check_one_val, return_value rest = check_one_val(_vals) return return_value(values.W_Cons.make(val, rest), env, cont)
def map_first_cont(f, lists, env, cont, _vals): from pycket.interpreter import check_one_val val = check_one_val(_vals) return map_loop(f, lists, env, map_cons_cont(f, lists, val, env, cont))
def receive_first_field(proc, v, v1, v2, env, cont, _vals): from pycket.interpreter import check_one_val first_field = check_one_val(_vals) return first_field.call([v1, v2], env, check_cont(proc, v, v1, v2, env, cont))
def check_cont(proc, v, v1, v2, env, cont, _vals): from pycket.interpreter import check_one_val, return_value val = check_one_val(_vals) if val is not values.w_false: return return_value(v._ref(1), env, cont) return proc.call([v, v1, v2], env, cont)
def call_with_paramz_cont(f, args, env, cont, _vals): from pycket.interpreter import check_one_val paramz = check_one_val(_vals) return call_with_parameterization(f, args, paramz, env, cont)
def hash_map_cont(f, ht, index, w_acc, env, cont, _vals): from pycket.interpreter import check_one_val w_val = check_one_val(_vals) w_acc = values.W_Cons.make(w_val, w_acc) return hash_map_loop(f, ht, index + 1, w_acc, env, cont)
def arity_error_cont(self, env, cont, _vals): from pycket.interpreter import check_one_val msg = check_one_val(_vals) raise SchemeException("expected: " + msg.tostring())
def receive_proc_cont(self, args, app, env, cont, _vals): from pycket.interpreter import check_one_val proc = check_one_val(_vals) return self.checked_call(proc, args, env, cont, app)
def param_set_cont(cell, env, cont, vals): from pycket.interpreter import check_one_val, return_value v = check_one_val(vals) cell.set(v) return return_value(values.w_void, env, cont)
def imp_box_set_cont(b, env, cont, vals): from pycket.interpreter import check_one_val return b.set_box(check_one_val(vals), env, cont)
def copy_vector_ref_cont(v, data, len, idx, env, cont, _vals): from pycket.interpreter import check_one_val val = check_one_val(_vals) data.set(idx, val) return copy_vector_loop(v, data, len, idx + 1, env, cont)