def get_imports_from_w_importss_sexp(w_importss): from pycket.interpreter import Gensym importss_acc, importss_len = to_rpython_list(w_importss) importss_list = [None] * importss_len for index, importss_current in enumerate(importss_acc): importss_group_ls, group_len = to_rpython_list(importss_current) inner_acc = [None] * group_len for i, c in enumerate(importss_group_ls): if isinstance(c, values.W_Symbol): w_imp_sym = Gensym.gensym(c.tostring()) inner_acc[i] = Import(values.W_Fixnum(index), w_imp_sym, c, c) elif isinstance(c, values.W_List): if c.cdr().cdr() is not values.w_null: raise SchemeException( "Unhandled renamed import form : %s" % c.tostring()) external_id = c.car().get_obj() if isinstance( c.car(), W_Correlated) else c.car() internal_id = c.cdr().car().get_obj() if isinstance( c.cdr().car(), W_Correlated) else c.cdr().car() w_internal_id = Gensym.gensym(internal_id.tostring()) inner_acc[i] = Import(values.W_Fixnum(index), w_internal_id, internal_id, external_id) elif isinstance(c, W_Correlated): cc = c.get_obj() w_cc = Gensym.gensym(cc.tostring()) inner_acc[i] = Import(values.W_Fixnum(index), w_cc, cc, cc) else: raise SchemeException("uncrecognized import : %s" % c.tostring()) importss_list[index] = inner_acc return importss_list
def get_imports_from_w_importss_sexp(w_importss): from pycket.interpreter import Gensym importss_acc, importss_len = to_rpython_list(w_importss) importss_list = [None]*importss_len for index, importss_current in enumerate(importss_acc): importss_group_ls, group_len = to_rpython_list(importss_current) inner_acc = [None]*group_len for i, c in enumerate(importss_group_ls): if isinstance(c, values.W_Symbol): w_imp_sym = Gensym.gensym(c.tostring()) inner_acc[i] = Import(values.W_Fixnum(index), w_imp_sym, c, c) elif isinstance(c, values.W_List): if c.cdr().cdr() is not values.w_null: raise SchemeException("Unhandled renamed import form : %s" % c.tostring()) external_id = c.car().get_obj() if isinstance(c.car(), W_Correlated) else c.car() internal_id = c.cdr().car().get_obj() if isinstance(c.cdr().car(), W_Correlated) else c.cdr().car() w_internal_id = Gensym.gensym(internal_id.tostring()) inner_acc[i] = Import(values.W_Fixnum(index), w_internal_id, internal_id, external_id) elif isinstance(c, W_Correlated): cc = c.get_obj() w_cc = Gensym.gensym(cc.tostring()) inner_acc[i] = Import(values.W_Fixnum(index), w_cc, cc, cc) else: raise SchemeException("uncrecognized import : %s" % c.tostring()) importss_list[index] = inner_acc return importss_list
def get_exports_from_w_exports_sexp(w_exports): from pycket.interpreter import Gensym r_exports, exports_len = to_rpython_list(w_exports) exports = {} for i, exp in enumerate(r_exports): if isinstance(exp, values.W_WrappedConsProper): car = exp.car() internal_name = car.get_obj() if isinstance(car, W_Correlated) else car cadr = exp.cdr().car() external_name = cadr.get_obj() if isinstance(cadr, W_Correlated) else cadr w_internal_name = Gensym.gensym(internal_name.tostring()) # don't gensym the external_id exports[internal_name] = Export(w_internal_name, external_name) else: c_exp = exp.get_obj() if isinstance(exp, W_Correlated) else exp w_c_exp = Gensym.gensym(c_exp.tostring()) exports[c_exp] = Export(w_c_exp, c_exp) return exports
def mk_cmk(s): from pycket.interpreter import Gensym s = Gensym.gensym("cm") if s is None else s return values.W_ContinuationMarkKey(s)
def gensym(init): from pycket.interpreter import Gensym return Gensym.gensym(init.value)
def mcpt(s): from pycket.interpreter import Gensym s = Gensym.gensym("cm") if s is None else s return values.W_ContinuationPromptTag(s)
def gensym(init): from pycket.interpreter import Gensym return Gensym.gensym(init.utf8value)