@expose("hash-ref", [W_HashTable, values.W_Object, default(values.W_Object, None)], simple=False) def hash_ref(ht, k, default, env, cont): return ht.hash_ref(k, env, hash_ref_cont(default, env, cont)) @expose("hash-remove!", [W_HashTable, values.W_Object], simple=False) def hash_remove_bang(ht, k, env, cont): return ht.hash_remove_inplace(k, env, cont) @expose("hash-remove", [W_HashTable, values.W_Object], simple=False) def hash_remove(ht, k, env, cont): if not ht.immutable(): raise SchemeException("hash-remove: expected immutable hash table") return ht.hash_remove(k, env, cont) define_nyi("hash-clear!", [W_HashTable]) define_nyi("hash-clear", [W_HashTable]) @expose("hash-count", [W_HashTable]) def hash_count(hash): return values.W_Fixnum(hash.length()) @continuation 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)) @continuation
("file-exists?",), ("directory-exists?",), ("link-exists?",), ("relative-path?",), ("absolute-path?",), ("internal-definition-context?",), ("set!-transformer?",), ("rename-transformer?",), ("identifier?",), ("port?",), ("sequence?",), ("namespace-anchor?",), ("chaperone-channel",), ("impersonate-channel",), ]: define_nyi(*args) @expose("object-name", [values.W_Object]) def object_name(v): return values_string.W_String.fromstr_utf8(v.tostring()) # XXX really? @expose("namespace-variable-value", [values.W_Symbol, default(values.W_Object, values.w_true), default(values.W_Object, values.w_true), default(values.W_Object, None)]) def namespace_variable_value(sym, use_mapping, failure_thunk, namespace): return values.w_void @expose("find-main-config", [])
def procedurep(n): return values.W_Bool.make(n.iscallable()) @expose("syntax-original?", [values.W_Syntax]) def syntax_original(v): return values.w_false @expose("syntax-tainted?", [values.W_Syntax]) def syntax_tainted(v): return values.w_false @expose("syntax->datum", [values.W_Syntax]) def syntax_to_datum(stx): return stx.val define_nyi("datum->syntax") # @expose("datum->syntax", [values.W_Object, values.W_Object, # default(values.W_Object, None), default(values.W_Object, None), # default(values.W_Object, None)]) # def datum_to_syntax(ctxt, v, srcloc, prop, ignored): # raise NotImplementedError() # assert isinstance(ctxt, values.W_Syntax) or ctxt is values.w_false # return values.W_Syntax(v) @expose("compiled-module-expression?", [values.W_Object]) def compiled_module_expression(v): return values.w_false expose_val("null", values.w_null) expose_val("true", values.w_true) expose_val("false", values.w_false)
pass else: raise SchemeException("regexp-match: unknown kind of regexp") if isinstance(w_str, values_string.W_String): s = w_str.as_str_ascii() # XXX for now result = w_re.match_string(s) return result if isinstance(w_str, values.W_Bytes): result = w_re.match_string(w_str.as_str()) return result if isinstance(w_str, values.W_InputPort): result = w_re.match_port(w_str) return result raise SchemeException("regexp-match: can't deal with this type") @expose("regexp-match?", [values.W_Object, values.W_Object]) def regexp_matchp(w_r, w_o): result = match(w_r, w_o) if result: return values.w_true else: return values.w_false # FIXME: implementation define_nyi("regexp-replace", [values.W_Object, values.W_Object, values.W_Object, default(values.W_Bytes, None)]) # def regexp_replace(pattern, input, insert, input_prefix): # raise NotImplementedError() # return input
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) @expose("hash-ref", [W_HashTable, values.W_Object, default(values.W_Object, None)], simple=False) def hash_ref(ht, k, default, env, cont): return ht.hash_ref(k, env, hash_ref_cont(default, env, cont)) @expose("hash-remove!", [W_HashTable, values.W_Object], simple=False) def hash_remove_bang(ht, k, env, cont): return ht.hash_remove_inplace(k, env, cont) define_nyi("hash-remove", [W_HashTable, values.W_Object]) define_nyi("hash-clear!", [W_HashTable]) define_nyi("hash-clear", [W_HashTable]) @expose("hash-count", [W_HashTable]) def hash_count(hash): return values.W_Fixnum(hash.length()) @continuation 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 make_hasheqv(pairs): lsts = values.from_list(pairs) keys = [] vals = [] for lst in lsts: if not isinstance(lst, values.W_Cons): raise SchemeException("make-hash: expected list of pairs") keys.append(lst.car()) vals.append(lst.cdr()) return W_EqvHashTable(keys, vals) @expose("hash-set!", [W_HashTable, values.W_Object, values.W_Object], simple=False) def hash_set_bang(ht, k, v, env, cont): return ht.hash_set(k, v, env, cont) define_nyi("hash-set", [W_HashTable, values.W_Object, values.W_Object], simple=False) # def hash_set(ht, k, v, env, cont): # raise NotImplementedError() # return ht.hash_set(k, v, env, cont) # #return ht @continuation 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 None: return return_value(val, env, cont) if default is None: raise SchemeException("key not found") if default.iscallable(): return default.call([], env, cont)
futures_str + \ place_str + \ flfxnum_str + \ extfl_str + \ pycket_extra_str + \ schemify_hooks + \ network_str if DEBUG: print( "\n\nPriming all primitives in : linklet + kernel + paramz + unsafe + foreign + futures + place + flfxnum + extfl + network\n" ) for prim_name_str in all_prims: if W_Symbol.make(prim_name_str) not in prim_env: define_nyi(prim_name_str) def report_undefined_prims(): linklets = get_undef_prims_in(linklet_str) kernel = get_undef_prims_in(kernel_str) paramz = get_undef_prims_in(paramz_str) unsafe = get_undef_prims_in(unsafe_str) foreign = get_undef_prims_in(foreign_str) futures = get_undef_prims_in(futures_str) places = get_undef_prims_in(place_str) flfxnum = get_undef_prims_in(flfxnum_str) extfl = get_undef_prims_in(extfl_str) network = get_undef_prims_in(network_str) total = linklets + kernel + paramz + unsafe + foreign + futures + places + flfxnum + extfl + network
xs.append(values.W_Cons.make(s, e)) return values.to_list(xs) @expose("regexp-match?", [values.W_Object, values.W_Object]) def regexp_matchp(w_r, w_o): result = match(w_r, w_o) if result: return values.w_true else: return values.w_false @expose("regexp-max-lookbehind", [values.W_Object]) def regexp_max_lookbehind(obj): if not isinstance(obj, values_regex.W_Regexp) and not isinstance( obj, values_regex.W_ByteRegexp): raise SchemeException( "regexp-max-lookbehind: expected regexp or bytes-regexp") return values.W_Fixnum(1000) # FIXME: implementation define_nyi("regexp-replace", [ values.W_Object, values.W_Object, values.W_Object, default(values.W_Bytes, None) ]) # def regexp_replace(pattern, input, insert, input_prefix): # raise NotImplementedError() # return input
w_k, w_v = ht.get_item(0) return ht.hash_remove_inplace(w_k, env, hash_clear_cont(ht, env, cont)) @expose("hash-clear!", [W_HashTable], simple=False) def hash_clear_bang(ht, env, cont): from pycket.interpreter import return_value if ht.is_impersonator(): ht.hash_clear_proc(env, cont) return hash_clear_loop(ht, env, cont) else: ht.hash_empty() return return_value(values.w_void, env, cont) define_nyi("hash-clear", [W_HashTable]) @expose("hash-count", [W_HashTable]) def hash_count(hash): return values.W_Fixnum(hash.length()) @continuation 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) @loop_label
def make_hasheqv(pairs): lsts = values.from_list(pairs) keys = [] vals = [] for lst in lsts: if not isinstance(lst, values.W_Cons): raise SchemeException("make-hash: expected list of pairs") keys.append(lst.car()) vals.append(lst.cdr()) return W_EqvHashTable(keys, vals) @expose("hash-set!", [W_HashTable, values.W_Object, values.W_Object], simple=False) def hash_set_bang(ht, k, v, env, cont): return ht.hash_set(k, v, env, cont) define_nyi("hash-set", [W_HashTable, values.W_Object, values.W_Object], simple=False) @continuation 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) @expose("hash-ref", [W_HashTable, values.W_Object, default(values.W_Object, None)], simple=False) def hash_ref(ht, k, default, env, cont):
("thread-dead?",), ("will-executor?",), ("evt?",), ("semaphore-try-wait?",), ("channel?",), ("readtable?",), ("link-exists?",), ("rename-transformer?",), ("identifier?",), ("port?",), ("sequence?",), ("namespace-anchor?",), ("chaperone-channel",), ("impersonate-channel",), ]: define_nyi(*args) @expose("set!-transformer?", [values.W_Object]) def set_bang_transformer(v): if isinstance(v, values.W_AssignmentTransformer): return values.w_true elif isinstance(v, values_struct.W_RootStruct): w_prop = v.struct_type().read_prop(values_struct.w_prop_set_bang_transformer) return values.W_Bool.make(w_prop is not None) else: return values.w_false @expose("object-name", [values.W_Object]) def object_name(v):
("path-for-some-system?", ), ("file-exists?", ), ("directory-exists?", ), ("link-exists?", ), ("relative-path?", ), ("absolute-path?", ), ("internal-definition-context?", ), ("rename-transformer?", ), ("identifier?", ), ("port?", ), ("sequence?", ), ("namespace-anchor?", ), ("chaperone-channel", ), ("impersonate-channel", ), ]: define_nyi(*args) @expose("set!-transformer?", [values.W_Object]) def set_bang_transformer(v): if isinstance(v, values.W_AssignmentTransformer): return values.w_true elif isinstance(v, values_struct.W_RootStruct): w_prop = v.struct_type().read_prop( values_struct.w_prop_set_bang_transformer) return values.W_Bool.make(w_prop is not None) else: return values.w_false @expose("object-name", [values.W_Object])
unsafe_str + \ foreign_str + \ futures_str + \ place_str + \ flfxnum_str + \ extfl_str + \ pycket_extra_str + \ schemify_hooks + \ network_str if DEBUG: print("\n\nPriming all primitives in : linklet + kernel + paramz + unsafe + foreign + futures + place + flfxnum + extfl + network\n") for prim_name_str in all_prims: if W_Symbol.make(prim_name_str) not in prim_env: define_nyi(prim_name_str) def report_undefined_prims(): linklets = get_undef_prims_in(linklet_str) kernel = get_undef_prims_in(kernel_str) paramz = get_undef_prims_in(paramz_str) unsafe = get_undef_prims_in(unsafe_str) foreign = get_undef_prims_in(foreign_str) futures = get_undef_prims_in(futures_str) places = get_undef_prims_in(place_str) flfxnum = get_undef_prims_in(flfxnum_str) extfl = get_undef_prims_in(extfl_str) network = get_undef_prims_in(network_str) total = linklets + kernel + paramz + unsafe + foreign + futures + places + flfxnum + extfl + network
@expose("hash-ref", [W_HashTable, values.W_Object, default(values.W_Object, None)], simple=False) def hash_ref(ht, k, default, env, cont): return ht.hash_ref(k, env, hash_ref_cont(default, env, cont)) @expose("hash-remove!", [W_HashTable, values.W_Object], simple=False) def hash_remove_bang(ht, k, env, cont): return ht.hash_remove(k, env, cont) define_nyi("hash-remove", [W_HashTable, values.W_Object]) define_nyi("hash-clear!", [W_HashTable]) define_nyi("hash-clear", [W_HashTable]) @expose("hash-count", [W_HashTable]) def hash_count(hash): return values.W_Fixnum(hash.length()) @continuation def hash_copy_ref_cont(keys, idx, src, new, env, cont, _vals): from pycket.interpreter import check_one_val val = check_one_val(_vals)