[pypy-svn] r20366 - in pypy/branch/somepbc-refactoring/pypy: annotation rpython rpython/ootypesystem rpython/ootypesystem/test
pedronis at codespeak.net
pedronis at codespeak.net
Mon Nov 28 18:46:17 CET 2005
Author: pedronis
Date: Mon Nov 28 18:46:13 2005
New Revision: 20366
Modified:
pypy/branch/somepbc-refactoring/pypy/annotation/builtin.py
pypy/branch/somepbc-refactoring/pypy/annotation/model.py
pypy/branch/somepbc-refactoring/pypy/rpython/llinterp.py
pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/ootype.py
pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/rclass.py
pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/rpbc.py
pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/test/test_ooann.py
pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/test/test_oortype.py
pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/test/test_ootype.py
pypy/branch/somepbc-refactoring/pypy/rpython/rpbc.py
pypy/branch/somepbc-refactoring/pypy/rpython/rtyper.py
pypy/branch/somepbc-refactoring/pypy/rpython/typesystem.py
Log:
(arre, pedronis)
Added support for StaticMethods for ootype.null with test.
Introduced type_system.null_callable.
Fixed ootype callable equality (with test)
Repaired ootypesystem/rclass for the branch graph-centered world
(introducing an helper class MethodImplementations in ootypesystem/rpbc.py
to compute lowleveltype and implemention of methods)
Fixes in tests and llinterp.
Modified: pypy/branch/somepbc-refactoring/pypy/annotation/builtin.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/annotation/builtin.py (original)
+++ pypy/branch/somepbc-refactoring/pypy/annotation/builtin.py Mon Nov 28 18:46:13 2005
@@ -385,10 +385,10 @@
r = SomeOOInstance(ootype.typeOf(i))
return r
-def null(I):
- assert I.is_constant()
- i = ootype.null(I.const)
- r = SomeOOInstance(ootype.typeOf(i))
+def null(I_OR_SM):
+ assert I_OR_SM.is_constant()
+ null = ootype.null(I_OR_SM.const)
+ r = lltype_to_annotation(ootype.typeOf(null))
return r
def instanceof(i, I):
Modified: pypy/branch/somepbc-refactoring/pypy/annotation/model.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/annotation/model.py (original)
+++ pypy/branch/somepbc-refactoring/pypy/annotation/model.py Mon Nov 28 18:46:13 2005
@@ -480,6 +480,8 @@
def annotation_to_lltype(s_val, info=None):
if isinstance(s_val, SomeOOInstance):
return s_val.ootype
+ if isinstance(s_val, SomeOOStaticMeth):
+ return s_val.method
if isinstance(s_val, SomePtr):
return s_val.ll_ptrtype
for witness, lltype in annotation_to_ll_map:
@@ -499,6 +501,8 @@
if s is None:
if isinstance(T, ootype.Instance):
return SomeOOInstance(T)
+ elif isinstance(T, ootype.StaticMethod):
+ return SomeOOStaticMeth(T)
else:
return SomePtr(T)
else:
Modified: pypy/branch/somepbc-refactoring/pypy/rpython/llinterp.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/llinterp.py (original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/llinterp.py Mon Nov 28 18:46:13 2005
@@ -1,4 +1,4 @@
-from pypy.objspace.flow.model import Constant, Variable, last_exception
+from pypy.objspace.flow.model import FunctionGraph, Constant, Variable, last_exception
from pypy.rpython.rarithmetic import intmask, r_uint, ovfcheck
from pypy.rpython.lltypesystem import lltype
from pypy.rpython.memory import lladdress
@@ -90,6 +90,7 @@
class LLFrame(object):
def __init__(self, graph, args, llinterpreter, f_back=None):
+ assert isinstance(graph, FunctionGraph)
self.graph = graph
self.args = args
self.llinterpreter = llinterpreter
@@ -633,7 +634,7 @@
assert isinstance(message, str)
bm = getattr(inst, message)
m = bm.meth
- m._checkargs(args)
+ m._checkargs(args, check_callable=False)
if getattr(m, 'abstract', False):
raise RuntimeError("calling abstract method %r" % (m,))
return self.op_direct_call(m, inst, *args)
Modified: pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/ootype.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/ootype.py (original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/ootype.py Mon Nov 28 18:46:13 2005
@@ -71,7 +71,7 @@
if self._has_field(name):
raise TypeError("Can't add method %r: field already exists" % name)
if not isinstance(typeOf(method), Meth):
- raise TypeError("added methods must be _meths, not %s" % type(defn))
+ raise TypeError("added methods must be _meths, not %s" % type(method))
self._methods.update(methods)
def _init_instance(self, instance):
@@ -119,10 +119,12 @@
return all
class StaticMethod(OOType):
+ __slots__ = ['_null']
def __init__(self, args, result):
self.ARGS = tuple(args)
self.RESULT = result
+ self._null = _static_meth(self, _callable=None)
def _example(self):
_retval = self.RESULT._example()
@@ -136,8 +138,10 @@
class _class(object):
_TYPE = Class
+
def __init__(self, INSTANCE):
self._INSTANCE = INSTANCE
+
nullruntimeclass = _class(None)
class _instance(object):
@@ -208,18 +212,31 @@
self._callable = None
self.__dict__.update(attrs)
- def _checkargs(self, args):
+ def _checkargs(self, args, check_callable=True):
if len(args) != len(self._TYPE.ARGS):
raise TypeError,"calling %r with wrong argument number: %r" % (self._TYPE, args)
for a, ARG in zip(args, self._TYPE.ARGS):
if not isCompatibleType(typeOf(a), ARG):
raise TypeError,"calling %r with wrong argument types: %r" % (self._TYPE, args)
+ if not check_callable:
+ return None
callb = self._callable
if callb is None:
- raise RuntimeError,"calling undefined function"
+ raise RuntimeError,"calling undefined or null function"
return callb
+ def __eq__(self, other):
+ return (self.__class__ is other.__class__ and
+ self.__dict__ == other.__dict__)
+
+ def __ne__(self, other):
+ return not (self == other)
+
+ def __hash__(self):
+ return hash(frozendict(self.__dict__))
+
+
class _static_meth(_callable):
def __init__(self, STATICMETHOD, **attrs):
@@ -260,8 +277,8 @@
def meth(METHOD, **attrs):
return _meth(METHOD, **attrs)
-def null(INSTANCE):
- return INSTANCE._null
+def null(INSTANCE_OR_FUNCTION):
+ return INSTANCE_OR_FUNCTION._null
def instanceof(inst, INSTANCE):
# this version of instanceof() accepts a NULL instance and always
@@ -295,7 +312,7 @@
def isSubclass(C1, C2):
c = C1
while c is not None:
- if c is C2:
+ if c == C2:
return True
c = c._superclass
return False
Modified: pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/rclass.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/rclass.py (original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/rclass.py Mon Nov 28 18:46:13 2005
@@ -1,4 +1,6 @@
import types
+from pypy.annotation import model as annmodel
+from pypy.annotation import description
from pypy.rpython.rmodel import inputconst, TyperError
from pypy.rpython.rclass import AbstractClassRepr, AbstractInstanceRepr, \
getinstancerepr, getclassrepr, get_type_repr
@@ -17,19 +19,8 @@
def _setup_repr(self):
pass # not actually needed?
- def convert_const(self, value):
- if not isinstance(value, (type, types.ClassType)):
- raise TyperError("not a class: %r" % (value,))
- try:
- subclassdef = self.rtyper.annotator.getuserclasses()[value]
- except KeyError:
- raise TyperError("no classdef: %r" % (value,))
- if self.classdef is not None:
- if self.classdef.commonbase(subclassdef) != self.classdef:
- raise TyperError("not a subclass of %r: %r" % (
- self.classdef.cls, value))
- #
- return getinstancerepr(self.rtyper, subclassdef).lowleveltype._class
+ def getruntime(self):
+ return getinstancerepr(self.rtyper, self.classdef).lowleveltype._class
def rtype_issubtype(self, hop):
class_repr = get_type_repr(self.rtyper)
@@ -73,7 +64,7 @@
self.baserepr = getinstancerepr(rtyper, b)
b = self.baserepr.lowleveltype
- self.lowleveltype = ootype.Instance(classdef.cls.__name__, b, {}, {})
+ self.lowleveltype = ootype.Instance(classdef.shortname, b, {}, {})
self.prebuiltinstances = {} # { id(x): (x, _ptr) }
self.object_type = self.lowleveltype
@@ -89,22 +80,38 @@
fields = {}
fielddefaults = {}
- attrs = self.classdef.attrs.items()
+
+ selfattrs = self.classdef.attrs
- for name, attrdef in attrs:
+ for name, attrdef in selfattrs.iteritems():
+ mangled = mangle(name)
if not attrdef.readonly:
- mangled = mangle(name)
repr = self.rtyper.getrepr(attrdef.s_value)
allfields[mangled] = repr
oot = repr.lowleveltype
fields[mangled] = oot
try:
- fielddefaults[mangled] = getattr(self.classdef.cls, name)
+ value = self.classdef.classdesc.read_attribute(name)
+ fielddefaults[mangled] = repr.convert_desc_or_const(value)
except AttributeError:
pass
+ else:
+ s_value = attrdef.s_value
+ if isinstance(s_value, annmodel.SomePBC):
+ if s_value.getKind() == description.MethodDesc:
+ # attrdef is for a method
+ if mangled in allclassattributes:
+ raise TyperError("method overrides class attribute")
+ allmethods[mangled] = name, s_value
+ continue
+ # class attribute
+ if mangled in allmethods:
+ raise TyperError("class attribute overrides method")
+ allclassattributes[mangled] = name, s_value
+
#
# hash() support
- if self.rtyper.needs_hash_support(self.classdef.cls):
+ if self.rtyper.needs_hash_support(self.classdef):
from pypy.rpython import rint
allfields['_hash_cache_'] = rint.signed_repr
fields['_hash_cache_'] = ootype.Signed
@@ -116,57 +123,61 @@
baseInstance = self.lowleveltype._superclass
classrepr = getclassrepr(self.rtyper, self.classdef)
+ for mangled, (name, s_value) in allmethods.iteritems():
+ methdescs = s_value.descriptions
+ origin = dict([(methdesc.originclassdef, methdesc) for
+ methdesc in methdescs])
+ if self.classdef in origin:
+ methdesc = origin[self.classdef]
+ else:
+ if name in selfattrs:
+ for superdef in self.classdef.getmro():
+ if superdef in origin:
+ # put in methods
+ methdesc = origin[superdef]
+ break
+ else:
+ # abstract method
+ methdesc = None
+ else:
+ continue
+
+ # get method implementation
+ from pypy.rpython.ootypesystem.rpbc import MethodImplementations
+ methimpls = MethodImplementations.get(self.rtyper, s_value)
+ m = methimpls.get_impl(mangled, methdesc)
+
+ methods[mangled] = m
+
+
for classdef in self.classdef.getmro():
- attrs = classdef.attrs.items()
- for name, attrdef in attrs:
+ for name, attrdef in classdef.attrs.iteritems():
if not attrdef.readonly:
continue
mangled = mangle(name)
- is_method = (classrepr.prepare_method(attrdef.s_value)
- is not None)
- if mangled in allmethods or mangled in allclassattributes:
- # if the method/attr was already found in a parent class,
- # we register it again only if it is overridden.
- if is_method and mangled in allclassattributes:
- raise TyperError("method overrides class attribute")
- if not is_method and mangled in allmethods:
- raise TyperError("class attribute overrides method")
- if name not in self.classdef.cls.__dict__:
- continue
- impl = self.classdef.cls.__dict__[name]
- else:
- # otherwise, for new method/attrs, we look in all parent
- # classes to see if it's defined in a parent but only
- # actually first used in self.classdef.
- for clsdef in self.classdef.getmro():
- if name in clsdef.cls.__dict__:
- impl = clsdef.cls.__dict__[name]
- break
+ if mangled in allclassattributes:
+ selfdesc = self.classdef.classdesc
+ if name not in selfattrs:
+ # if the attr was already found in a parent class,
+ # we register it again only if it is overridden.
+ if selfdesc.find_source_for(name) is None:
+ continue
+ value = selfdesc.read_attribute(name)
else:
- if is_method:
- impl = None # abstract base method
- else:
+ # otherwise, for new attrs, we look in all parent
+ # classes to see if it's defined in a parent but only
+ # actually first used in self.classdef.
+ value = selfdesc.read_attribute(name, None)
+ if value is None:
raise TyperError("class %r has no attribute %r" % (
- self.classdef.cls, name))
- if is_method:
- # a regular method
- exmpl = impl or attrdef.s_value.prebuiltinstances.keys()[0]
- f, inputs, ret = getsignature(self.rtyper, exmpl)
- M = ootype.Meth([r.lowleveltype for r in inputs[1:]], ret.lowleveltype)
- if impl:
- m = ootype.meth(M, _name=mangled, _callable=impl,
- graph=f.graph)
- else:
- m = ootype.meth(M, _name=mangled, abstract=True)
- methods[mangled] = m
- allmethods[mangled] = True
- else:
+ self.classdef.name, name))
+
# a non-method class attribute
- allclassattributes[mangled] = True
if not attrdef.s_value.is_constant():
- classattributes[mangled] = attrdef.s_value, impl
+ classattributes[mangled] = attrdef.s_value, value
ootype.addMethods(self.lowleveltype, methods)
+
self.allfields = allfields
self.allmethods = allmethods
self.allclassattributes = allclassattributes
@@ -183,9 +194,9 @@
# step 3: provide accessor methods for class attributes that are
# really overridden in subclasses
- for mangled, (s_value, impl) in classattributes.items():
+ for mangled, (s_value, value) in classattributes.items():
r = self.rtyper.getrepr(s_value)
- oovalue = r.convert_const(impl)
+ oovalue = r.convert_desc_or_const(value)
m = self.attach_class_attr_accessor(mangled, oovalue,
r.lowleveltype)
@@ -194,10 +205,10 @@
return oovalue
ll_getclassattr = func_with_new_name(ll_getclassattr,
'll_get_' + mangled)
- sm = self.rtyper.annotate_helper(ll_getclassattr, [self.lowleveltype])
+ graph = self.rtyper.annotate_helper(ll_getclassattr, [self.lowleveltype])
M = ootype.Meth([], oovaluetype)
m = ootype.meth(M, _name=mangled, _callable=ll_getclassattr,
- graph=sm.graph)
+ graph=graph)
ootype.addMethods(self.lowleveltype, {mangled: m})
def rtype_getattr(self, hop):
@@ -250,7 +261,7 @@
def rtype_hash(self, hop):
if self.classdef is None:
raise TyperError, "hash() not supported for this class"
- if self.rtyper.needs_hash_support(self.classdef.cls):
+ if self.rtyper.needs_hash_support(self.classdef):
vinst, = hop.inputargs(self)
return hop.gendirectcall(ll_inst_hash, vinst)
else:
@@ -263,8 +274,9 @@
def convert_const(self, value):
if value is None:
return ootype.null(self.lowleveltype)
+ bk = self.rtyper.annotator.bookkeeper
try:
- classdef = self.rtyper.annotator.getuserclasses()[value.__class__]
+ classdef = bk.getuniqueclassdef(value.__class__)
except KeyError:
raise TyperError("no classdef: %r" % (value.__class__,))
if classdef != self.classdef:
@@ -274,7 +286,7 @@
raise TyperError("not implemented: object() instance")
if classdef.commonbase(self.classdef) != self.classdef:
raise TyperError("not an instance of %r: %r" % (
- self.classdef.cls, value))
+ self.classdef.name, value))
rinstance = getinstancerepr(self.rtyper, classdef)
result = rinstance.convert_const(value)
return ootype.ooupcast(self.lowleveltype, result)
Modified: pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/rpbc.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/rpbc.py (original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/rpbc.py Mon Nov 28 18:46:13 2005
@@ -1,4 +1,5 @@
from pypy.rpython.rpbc import AbstractClassesPBCRepr, AbstractMethodsPBCRepr
+from pypy.rpython.rpbc import get_concrete_calltable
from pypy.rpython.rclass import rtype_new_instance
from pypy.rpython.ootypesystem import ootype
from pypy.rpython.ootypesystem.rclass import ClassRepr, InstanceRepr, mangle
@@ -10,13 +11,52 @@
if self.lowleveltype is not ootype.Void:
raise NotImplementedError()
- klass = self.s_pbc.const
- v_instance = rtype_new_instance(hop.rtyper, klass, hop.llops)
+ classdef = hop.s_result.classdef
+ v_instance = rtype_new_instance(hop.rtyper, classdef, hop.llops)
return v_instance
+class MethodImplementations(object):
+
+ def __init__(self, rtyper, methdescs):
+ samplemdesc = methdescs.iterkeys().next()
+ concretetable, uniquerows = get_concrete_calltable(rtyper,
+ samplemdesc.funcdesc.getcallfamily())
+ self._uniquerows = uniquerows
+ if len(uniquerows) == 1:
+ row = uniquerows[0]
+ sample_as_static_meth = row.itervalues().next()
+ SM = ootype.typeOf(sample_as_static_meth)
+ M = ootype.Meth(SM.ARGS[1:], SM.RESULT) # cut self
+ self.lowleveltype = M
+ else:
+ XXX_later
+
+ def get(rtyper, s_pbc):
+ lst = list(s_pbc.descriptions)
+ lst.sort()
+ key = tuple(lst)
+ try:
+ return rtyper.oo_meth_impls[key]
+ except KeyError:
+ methodsimpl = MethodImplementations(rtyper, s_pbc.descriptions)
+ rtyper.oo_meth_impls[key] = methodsimpl
+ return methodsimpl
+ get = staticmethod(get)
+
+ def get_impl(self, name, methdesc):
+ M = self.lowleveltype
+ if methdesc is None:
+ return ootype.meth(M, _name=name, abstract=True)
+ else:
+ impl_graph = self._uniquerows[0][methdesc.funcdesc].graph
+ return ootype.meth(M, _name=name, graph=impl_graph)
+
class MethodsPBCRepr(AbstractMethodsPBCRepr):
+ def __init__(self, rtyper, s_pbc):
+ AbstractMethodsPBCRepr.__init__(self, rtyper, s_pbc)
+
def rtype_simple_call(self, hop):
vlist = hop.inputargs(self, *hop.args_r[1:])
mangled = mangle(self.methodname)
Modified: pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/test/test_ooann.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/test/test_ooann.py (original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/test/test_ooann.py Mon Nov 28 18:46:13 2005
@@ -146,6 +146,17 @@
assert s.knowntype == int
+def test_null_static_method():
+ F = StaticMethod([Signed, Signed], Signed)
+
+ def oof():
+ return null(F)
+
+ a = RPythonAnnotator()
+ s = a.build_types(oof, [])
+
+ assert s == annmodel.SomeOOStaticMeth(F)
+
def test_truth_value():
C = Instance("C", None)
def oof(f):
Modified: pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/test/test_oortype.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/test/test_oortype.py (original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/test/test_oortype.py Mon Nov 28 18:46:13 2005
@@ -2,7 +2,7 @@
from pypy.rpython.ootypesystem.ootype import *
from pypy.annotation import model as annmodel
from pypy.objspace.flow import FlowObjSpace
-from pypy.translator.translator import Translator
+from pypy.translator.translator import Translator, graphof
from pypy.rpython.test.test_llinterp import interpret
def gengraph(f, args=[], viewBefore=False, viewAfter=False):
@@ -13,7 +13,7 @@
t.specialize(type_system="ootype")
if viewAfter:
t.view()
- return t.flowgraphs[f]
+ return graphof(t, f)
def test_simple_class():
C = Instance("test", None, {'a': Signed})
Modified: pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/test/test_ootype.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/test/test_ootype.py (original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/ootypesystem/test/test_ootype.py Mon Nov 28 18:46:13 2005
@@ -122,6 +122,9 @@
py.test.raises(TypeError, "f()")
py.test.raises(TypeError, "f(1, 2, 3)")
+ null_F = null(F)
+ py.test.raises(RuntimeError, "null_F(1,2)")
+
def test_class_method():
M = Meth([Signed], Signed)
def m_(self, b):
@@ -288,3 +291,12 @@
1, 1, 0,
1, 1, 1,
]
+
+def test_static_method_equality():
+ SM = StaticMethod([], Signed)
+ SM1 = StaticMethod([], Signed)
+ assert SM == SM1
+
+ sm = static_meth(SM, 'f', graph='graph')
+ sm1 = static_meth(SM1, 'f', graph='graph')
+ assert sm == sm1
Modified: pypy/branch/somepbc-refactoring/pypy/rpython/rpbc.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/rpbc.py (original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/rpbc.py Mon Nov 28 18:46:13 2005
@@ -224,7 +224,7 @@
value = value.im_func # unbound method -> bare function
if self.lowleveltype is Void:
return value
- null = nullptr(self.lowleveltype.TO)
+ null = self.rtyper.type_system.null_callable(self.lowleveltype)
if value is None:
return null
funcdesc = self.rtyper.annotator.bookkeeper.getdesc(value)
Modified: pypy/branch/somepbc-refactoring/pypy/rpython/rtyper.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/rtyper.py (original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/rtyper.py Mon Nov 28 18:46:13 2005
@@ -57,6 +57,7 @@
self.pbc_reprs = {}
self.concrete_calltables = {}
self.class_pbc_attributes = {}
+ self.oo_meth_impls = {}
self.typererrors = []
self.typererror_count = 0
# make the primitive_to_repr constant mapping
@@ -542,14 +543,9 @@
and return it as a function pointer object.
"""
args_s = [annmodel.lltype_to_annotation(T) for T in arglltypes]
- was_frozen = self.annotator.translator.frozen
- self.annotator.translator.frozen = False # oh well
- try:
- ignored, spec_function = annotate_lowlevel_helper(self.annotator,
- ll_function, args_s)
- finally:
- self.annotator.translator.frozen = was_frozen
- return self.getfunctionptr(spec_function)
+ helper_graph = annotate_lowlevel_helper(self.annotator,
+ ll_function, args_s)
+ return helper_graph
def attachRuntimeTypeInfoFunc(self, GCSTRUCT, func, ARG_GCSTRUCT=None):
self.call_all_setups() # compute ForwardReferences now
Modified: pypy/branch/somepbc-refactoring/pypy/rpython/typesystem.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/typesystem.py (original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/typesystem.py Mon Nov 28 18:46:13 2005
@@ -34,6 +34,10 @@
"""
raise NotImplementedError()
+ def null_callable(self, T):
+ """null callable object of type T"""
+ raise NotImplementedError()
+
def getcallable(self, graph, getconcretetype=None):
"""Return callable given a Python function."""
if getconcretetype is None:
@@ -70,6 +74,9 @@
def getconcretetype(self, v):
return getattr(v, 'concretetype', lltype.Ptr(lltype.PyObject))
+ def null_callable(self, T):
+ return lltype.nullptr(T.TO)
+
def isCompatibleType(self, t1, t2):
return lltype.isCompatibleType(t1, t2)
@@ -80,6 +87,9 @@
def deref(self, obj):
assert isinstance(ootype.typeOf(obj), ootype.OOType)
return obj
+
+ def null_callable(self, T):
+ return ootype.null(T)
def isCompatibleType(self, t1, t2):
return ootype.isCompatibleType(t1, t2)
More information about the Pypy-commit
mailing list