from rpython.rlib import rsocket from spyvm import model, error from spyvm.plugins.plugin import Plugin SocketPlugin = Plugin() def is_squeak_socket(w_socket_handle): return not isinstance(w_socket_handle, W_SocketHandle) @SocketPlugin.expose_primitive(unwrap_spec=[object, object]) def primitiveSocketConnectionStatus(interp, s_frame, w_rcvr, w_socket_handle): """ "Socket Status Values" InvalidSocket := -1. Unconnected := 0. WaitingForConnection := 1. Connected := 2. OtherEndClosed := 3. ThisEndClosed := 4. """ if is_squeak_socket(w_socket_handle): return interp.space.wrap_int(-1) else: return interp.space.wrap_int(-1) # for now ... @SocketPlugin.expose_primitive(unwrap_spec=[object]) def primitiveResolverStatus(interp, s_frame, w_rcvr): """ "Resolver Status Values" ResolverUninitialized := 0. "network is not initialized"
from spyvm import model, error from spyvm.plugins.plugin import Plugin DebuggingPlugin = Plugin() DebuggingPlugin.userdata['stop_ui'] = False def stop_ui_process(): DebuggingPlugin.userdata['stop_ui'] = True # @DebuggingPlugin.expose_primitive(unwrap_spec=[object]) # def trace(interp, s_frame, w_rcvr): # interp.trace = True # return w_rcvr # @DebuggingPlugin.expose_primitive(unwrap_spec=[object]) # def untrace(interp, s_frame, w_rcvr): # interp.trace = False # return w_rcvr @DebuggingPlugin.expose_primitive(unwrap_spec=[object]) def trace_proxy(interp, s_frame, w_rcvr): interp.trace_proxy.activate() return w_rcvr @DebuggingPlugin.expose_primitive(unwrap_spec=[object]) def untrace_proxy(interp, s_frame, w_rcvr):
from spyvm import model from spyvm.primitives import prim_table, \ BIT_AND, BIT_OR, BIT_XOR, BIT_SHIFT, ADD, SUBTRACT, DIVIDE, MULTIPLY from spyvm.error import PrimitiveFailedError from spyvm.plugins.plugin import Plugin LargeIntegerPlugin = Plugin() ops = { 'primDigitBitAnd': BIT_AND, 'primDigitBitOr': BIT_OR, 'primDigitBitXor': BIT_XOR, 'primDigitBitShiftMagnitude': BIT_SHIFT, 'primDigitAdd': ADD, 'primDigitSubtract': SUBTRACT, } for (name, primitive) in ops.items(): def make_func(primitive): primfunc = prim_table[primitive] def func(interp, s_frame, argcount): return primfunc(interp, s_frame, argcount) func.func_name = name LargeIntegerPlugin.expose_primitive(clean_stack=False, no_result=True)(func) make_func(primitive) negOps = {
from spyvm import model, error from spyvm.plugins.plugin import Plugin DebuggingPlugin = Plugin() DebuggingPlugin.userdata['stop_ui'] = False def stop_ui_process(): DebuggingPlugin.userdata['stop_ui'] = True # @DebuggingPlugin.expose_primitive(unwrap_spec=[object]) # def trace(interp, s_frame, w_rcvr): # interp.trace = True # return w_rcvr # @DebuggingPlugin.expose_primitive(unwrap_spec=[object]) # def untrace(interp, s_frame, w_rcvr): # interp.trace = False # return w_rcvr @DebuggingPlugin.expose_primitive(unwrap_spec=[object]) def trace_proxy(interp, s_frame, w_rcvr): interp.trace_proxy.activate() return w_rcvr @DebuggingPlugin.expose_primitive(unwrap_spec=[object]) def untrace_proxy(interp, s_frame, w_rcvr): interp.trace_proxy.deactivate() return w_rcvr @DebuggingPlugin.expose_primitive(unwrap_spec=[object])
from spyvm import model_display, model from spyvm.error import PrimitiveFailedError from spyvm.storage import AbstractCachingShadow from spyvm.plugins.plugin import Plugin from rpython.rlib import jit, objectmodel from rpython.rlib.rarithmetic import r_uint, intmask BitBltPlugin = Plugin() @BitBltPlugin.expose_primitive(unwrap_spec=[object], clean_stack=True) def primitiveCopyBits(interp, s_frame, w_rcvr): from spyvm.interpreter import Return if not isinstance(w_rcvr, model.W_PointersObject) or w_rcvr.size() < 15: raise PrimitiveFailedError( "BitBlt primitive not called in BitBlt object!") # only allow combinationRules 0-41 combinationRule = interp.space.unwrap_positive_32bit_int( w_rcvr.fetch(interp.space, 3)) if combinationRule > 41: raise PrimitiveFailedError("Missing combinationRule %d" % combinationRule) space = interp.space s_bitblt = w_rcvr.as_special_get_shadow(space, BitBltShadow) s_bitblt.loadBitBlt() s_bitblt.copyBits() w_dest_form = w_rcvr.fetch(space, 0)
import os, stat, sys from rpython.rlib import jit, rarithmetic from rpython.rlib.listsort import TimSort from spyvm import model, error from spyvm.plugins.plugin import Plugin from spyvm.primitives import PrimitiveFailedError, index1_0 FilePlugin = Plugin() os.stat_float_times(False) try: std_fds = [sys.stdin.fileno(), sys.stdout.fileno(), sys.stderr.fileno()] except ValueError: std_fds = [0, 1, 2] @FilePlugin.expose_primitive(unwrap_spec=[object]) def primitiveDirectoryDelimitor(interp, s_frame, w_rcvr): return interp.space.wrap_char(os.path.sep) @FilePlugin.expose_primitive(unwrap_spec=[object, str, index1_0]) def primitiveDirectoryLookup(interp, s_frame, w_file_directory, full_path, index): if full_path == '': contents = os.listdir(os.path.sep) else: if not os.path.isdir(full_path): raise PrimitiveFailedError