def Space(*args, **kwds): space = ReflectiveObjSpace(*args, **kwds) patch_space_in_place(space, "reflective", proxymaker) w___pypy__ = space.getbuiltinmodule("__pypy__") space.setattr(w___pypy__, space.wrap("set_reflectivespace"), space.wrap(app_set_reflectivespace)) W_SpaceAccess.typedef = typedef.TypeDef("ObjSpace", **W_SpaceAccess_dict) return space
def Space(*args, **kwds): space = ReflectiveObjSpace(*args, **kwds) patch_space_in_place(space, 'reflective', proxymaker) w___pypy__ = space.getbuiltinmodule("__pypy__") space.setattr(w___pypy__, space.wrap('set_reflectivespace'), space.wrap(app_set_reflectivespace)) W_SpaceAccess.typedef = typedef.TypeDef("ObjSpace", **W_SpaceAccess_dict) return space
def Space(*args, **kwds): # for now, always make up a wrapped StdObjSpace from pypy.objspace import std space = std.Space(*args, **kwds) patch_space_in_place(space, 'thunk', proxymaker) w___pypy__ = space.getbuiltinmodule("__pypy__") space.w_fn_thunk = space.wrap(app_thunk) space.setattr(w___pypy__, space.wrap('thunk'), space.w_fn_thunk) space.setattr(w___pypy__, space.wrap('is_thunk'), space.wrap(app_is_thunk)) space.setattr(w___pypy__, space.wrap('become'), space.wrap(app_become)) space.setattr(w___pypy__, space.wrap('lazy'), space.wrap(app_lazy)) return space
def Space(*args, **kwds): # for now, always make up a wrapped StdObjSpace from pypy.objspace import std space = std.Space(*args, **kwds) patch_space_in_place(space, "thunk", proxymaker) space.resolve_target = lambda w_arg: _force(space, w_arg) w___pypy__ = space.getbuiltinmodule("__pypy__") space.w_fn_thunk = space.wrap(app_thunk) space.setattr(w___pypy__, space.wrap("thunk"), space.w_fn_thunk) space.setattr(w___pypy__, space.wrap("is_thunk"), space.wrap(app_is_thunk)) space.setattr(w___pypy__, space.wrap("become"), space.wrap(app_become)) space.setattr(w___pypy__, space.wrap("lazy"), space.wrap(app_lazy)) return space
def __init__(self, *args, **kwds): StdObjSpace.__init__(self, *args, **kwds) w_dict = self.newdict() self.setitem(w_dict, self.wrap("__doc__"), self.wrap("""\ Exception that is raised when an operation revealing information on a tainted object is performed.""")) self.w_TaintError = self.call_function( self.w_type, self.wrap("TaintError"), self.newtuple([self.w_Exception]), w_dict ) w___pypy__ = self.getbuiltinmodule("__pypy__") self.setattr(w___pypy__, self.wrap('taint'), self.wrap(app_taint)) self.setattr(w___pypy__, self.wrap('is_tainted'), self.wrap(app_is_tainted)) self.setattr(w___pypy__, self.wrap('untaint'), self.wrap(app_untaint)) self.w_fn_taint_atomic_function = self.wrap(app_taint_atomic_function) self.setattr(w___pypy__, self.wrap('taint_atomic'), self.wrap(app_taint_atomic)) self.setattr(w___pypy__, self.wrap('TaintError'), self.w_TaintError) self.setattr(w___pypy__, self.wrap('_taint_debug'), self.wrap(app_taint_debug)) self.setattr(w___pypy__, self.wrap('_taint_look'), self.wrap(app_taint_look)) patch_space_in_place(self, 'taint', proxymaker) # XXX may leak info, perfomance hit, what about taint bombs? from pypy.objspace.std.typeobject import W_TypeObject def taint_lookup(w_obj, name): if isinstance(w_obj, W_Tainted): w_obj = w_obj.w_obj w_type = self.type(w_obj) assert isinstance(w_type, W_TypeObject) return w_type.lookup(name) def taint_lookup_in_type_where(w_obj, name): if isinstance(w_obj, W_Tainted): w_type = w_obj.w_obj else: w_type = w_obj assert isinstance(w_type, W_TypeObject) return w_type.lookup_where(name) self.lookup = taint_lookup self.lookup_in_type_where = taint_lookup_in_type_where
def __init__(self, *args, **kwds): StdObjSpace.__init__(self, *args, **kwds) w_dict = self.newdict() self.setitem( w_dict, self.wrap("__doc__"), self.wrap("""\ Exception that is raised when an operation revealing information on a tainted object is performed.""")) self.w_TaintError = self.call_function( self.w_type, self.wrap("TaintError"), self.newtuple([self.w_Exception]), w_dict) w___pypy__ = self.getbuiltinmodule("__pypy__") self.setattr(w___pypy__, self.wrap('taint'), self.wrap(app_taint)) self.setattr(w___pypy__, self.wrap('is_tainted'), self.wrap(app_is_tainted)) self.setattr(w___pypy__, self.wrap('untaint'), self.wrap(app_untaint)) self.w_fn_taint_atomic_function = self.wrap(app_taint_atomic_function) self.setattr(w___pypy__, self.wrap('taint_atomic'), self.wrap(app_taint_atomic)) self.setattr(w___pypy__, self.wrap('TaintError'), self.w_TaintError) self.setattr(w___pypy__, self.wrap('_taint_debug'), self.wrap(app_taint_debug)) self.setattr(w___pypy__, self.wrap('_taint_look'), self.wrap(app_taint_look)) patch_space_in_place(self, 'taint', proxymaker) # XXX may leak info, perfomance hit, what about taint bombs? from pypy.objspace.std.typeobject import W_TypeObject def taint_lookup(w_obj, name): if isinstance(w_obj, W_Tainted): w_obj = w_obj.w_obj w_type = self.type(w_obj) assert isinstance(w_type, W_TypeObject) return w_type.lookup(name) def taint_lookup_in_type_where(w_obj, name): if isinstance(w_obj, W_Tainted): w_type = w_obj.w_obj else: w_type = w_obj assert isinstance(w_type, W_TypeObject) return w_type.lookup_where(name) self.lookup = taint_lookup self.lookup_in_type_where = taint_lookup_in_type_where
def __init__(self, *args, **kwds): self.dumper = Dumper(self) StdObjSpace.__init__(self, *args, **kwds) patch_space_in_place(self, 'dump', proxymaker)
def Space(*args, **kwds): try: # for now, always make up a wrapped StdObjSpace from pypy.objspace import std space = std.Space(*args, **kwds) # multimethods hack space.model.typeorder[W_Var] = [(W_Var, None), (W_Root, None)] # None means no conversion space.model.typeorder[W_Future] = [(W_Future, None), (W_Var, None), (W_Root, None)] space.model.typeorder[W_CVar] = [(W_CVar, None), (W_Var, None), (W_Root, None)] for name in all_mms.keys(): exprargs, expr, miniglobals, fallback = ( all_mms[name].install_not_sliced(space.model.typeorder, baked_perform_call=False)) func = stdtypedef.make_perform_trampoline('__mm_' + name, exprargs, expr, miniglobals, all_mms[name]) # e.g. add(space, w_x, w_y) def make_boundmethod(func=func): def boundmethod(*args): return func(space, *args) return func_with_new_name(boundmethod, 'boundmethod_'+name) boundmethod = make_boundmethod() setattr(space, name, boundmethod) # store into 'space' instance # /multimethods hack #-- BUILTINS #-- variable ------- space.setitem(space.builtin.w_dict, space.wrap('newvar'), space.wrap(app_newvar)) space.setitem(space.builtin.w_dict, space.wrap('domain'), space.wrap(app_domain)) space.setitem(space.builtin.w_dict, space.wrap('domain_of'), space.wrap(app_domain_of)) space.setitem(space.builtin.w_dict, space.wrap('name_of'), space.wrap(app_name_of)) space.setitem(space.builtin.w_dict, space.wrap('is_free'), space.wrap(app_is_free)) space.setitem(space.builtin.w_dict, space.wrap('is_bound'), space.wrap(app_is_bound)) space.setitem(space.builtin.w_dict, space.wrap('alias_of'), space.wrap(app_alias_of)) space.setitem(space.builtin.w_dict, space.wrap('is_aliased'), space.wrap(app_is_aliased)) space.setitem(space.builtin.w_dict, space.wrap('bind'), space.wrap(app_bind)) space.setitem(space.builtin.w_dict, space.wrap('entail'), space.wrap(app_entail)) space.setitem(space.builtin.w_dict, space.wrap('unify'), space.wrap(app_unify)) #-- variables & threading -- space.setitem(space.builtin.w_dict, space.wrap('wait'), space.wrap(app_wait)) space.setitem(space.builtin.w_dict, space.wrap('wait_needed'), space.wrap(app_wait_needed)) #-- misc ----- space.setitem(space.builtin.w_dict, space.wrap('interp_id'), space.wrap(app_interp_id)) # make sure that _stackless is imported w_modules = space.getbuiltinmodule('_stackless') # cleanup func called from space.finish() def exitfunc(): pass app_exitfunc = gateway.interp2app(exitfunc, unwrap_spec=[]) space.setitem(space.sys.w_dict, space.wrap("exitfunc"), space.wrap(app_exitfunc)) # capture one non-blocking op space.is_nb_ = space.is_ # do the magic patch_space_in_place(space, 'logic', proxymaker) # instantiate singleton scheduler sched.main_thread = AppCoroutine.w_getcurrent(space) tg = W_ThreadGroupScheduler(space) sched.uler = TopLevelScheduler(space, tg) tg._init_head(sched.main_thread) except: import traceback traceback.print_exc() raise return space