Read about our upcoming Code of Conduct on this issue

Commit b124af37 authored by Armin Rigo's avatar Armin Rigo
Browse files

Backed out changeset 8faa5a81be74

Forgot to add rnone.py, making imports break.
parent 8faa5a81be74
......@@ -160,6 +160,8 @@ class Bookkeeper(object):
def consider_call_site_for_pbc(self, s_callable, args, s_result,
call_op):
descs = list(s_callable.descriptions)
if not descs:
return
family = descs[0].getcallfamily()
s_callable.getKind().consider_call_site(self, family, descs, args,
s_result, call_op)
......
......@@ -486,7 +486,7 @@ class CastObjectToPtrEntry(extregistry.ExtRegistryEntry):
assert False
def specialize_call(self, hop):
from rpython.rtyper.rnone import NoneRepr
from rpython.rtyper import rpbc
PTR = hop.r_result.lowleveltype
if isinstance(PTR, lltype.Ptr):
T = lltype.Ptr
......@@ -496,7 +496,7 @@ class CastObjectToPtrEntry(extregistry.ExtRegistryEntry):
assert False
hop.exception_cannot_occur()
if isinstance(hop.args_r[1], NoneRepr):
if isinstance(hop.args_r[1], rpbc.NoneFrozenPBCRepr):
return hop.inputconst(PTR, null)
v_arg = hop.inputarg(hop.args_r[1], arg=1)
assert isinstance(v_arg.concretetype, T)
......
......@@ -7,15 +7,39 @@ from rpython.rtyper import callparse
from rpython.rtyper.lltypesystem import rclass, llmemory
from rpython.rtyper.lltypesystem.lltype import (typeOf, Void, ForwardReference,
Struct, Bool, Char, Ptr, malloc, nullptr, Array, Signed)
from rpython.rtyper.rmodel import Repr, inputconst
from rpython.rtyper.rmodel import Repr, TyperError, inputconst
from rpython.rtyper.rpbc import (AbstractClassesPBCRepr, AbstractMethodsPBCRepr,
OverriddenFunctionPBCRepr, AbstractMultipleFrozenPBCRepr,
AbstractFunctionsPBCRepr, AbstractMultipleUnrelatedFrozenPBCRepr,
SingleFrozenPBCRepr, get_concrete_calltable)
SingleFrozenPBCRepr, MethodOfFrozenPBCRepr, none_frozen_pbc_repr,
get_concrete_calltable)
from rpython.rtyper.typesystem import getfunctionptr
from rpython.tool.pairtype import pairtype
def rtype_is_None(robj1, rnone2, hop, pos=0):
if isinstance(robj1.lowleveltype, Ptr):
v1 = hop.inputarg(robj1, pos)
return hop.genop('ptr_iszero', [v1], resulttype=Bool)
elif robj1.lowleveltype == llmemory.Address:
v1 = hop.inputarg(robj1, pos)
cnull = hop.inputconst(llmemory.Address, robj1.null_instance())
return hop.genop('adr_eq', [v1, cnull], resulttype=Bool)
elif robj1 == none_frozen_pbc_repr:
return hop.inputconst(Bool, True)
elif isinstance(robj1, SmallFunctionSetPBCRepr):
if robj1.s_pbc.can_be_None:
v1 = hop.inputarg(robj1, pos)
return hop.genop('char_eq', [v1, inputconst(Char, '\000')],
resulttype=Bool)
else:
return inputconst(Bool, False)
else:
raise TyperError('rtype_is_None of %r' % (robj1))
# ____________________________________________________________
class MultipleFrozenPBCRepr(AbstractMultipleFrozenPBCRepr):
"""Representation selected for multiple non-callable pre-built constants."""
def __init__(self, rtyper, access_set):
......
......@@ -4,8 +4,9 @@ from rpython.annotator import model as annmodel, description
from rpython.flowspace.model import Constant
from rpython.annotator.argument import simple_args
from rpython.rtyper import rclass, callparse
from rpython.rtyper.annlowlevel import llstr
from rpython.rtyper.error import TyperError
from rpython.rtyper.lltypesystem.lltype import typeOf, Void
from rpython.rtyper.lltypesystem.lltype import typeOf, Void, Bool
from rpython.rtyper.rmodel import (Repr, inputconst, CanBeNull, mangle,
inputdesc, warning, impossible_repr)
from rpython.tool.pairtype import pair, pairtype
......@@ -22,7 +23,8 @@ def small_cand(rtyper, s_pbc):
class __extend__(annmodel.SomePBC):
def rtyper_makerepr(self, rtyper):
from rpython.rtyper.lltypesystem.rpbc import (FunctionsPBCRepr,
SmallFunctionSetPBCRepr, ClassesPBCRepr, MethodsPBCRepr)
SmallFunctionSetPBCRepr, ClassesPBCRepr, MethodsPBCRepr,
MethodOfFrozenPBCRepr)
kind = self.getKind()
if issubclass(kind, description.FunctionDesc):
sample = self.any_description()
......@@ -59,6 +61,13 @@ class __extend__(annmodel.SomePBC):
t = ()
return tuple([self.__class__, self.can_be_None]+lst)+t
class __extend__(annmodel.SomeNone):
def rtyper_makerepr(self, rtyper):
return none_frozen_pbc_repr
def rtyper_makekey(self):
return self.__class__,
# ____________________________________________________________
class ConcreteCallTableRow(dict):
......@@ -580,6 +589,56 @@ class __extend__(pairtype(MethodOfFrozenPBCRepr, MethodOfFrozenPBCRepr)):
def convert_from_to((r_from, r_to), v, llops):
return pair(r_from.r_im_self, r_to.r_im_self).convert_from_to(v, llops)
# __ None ____________________________________________________
class NoneFrozenPBCRepr(Repr):
lowleveltype = Void
def rtype_bool(self, hop):
return Constant(False, Bool)
def none_call(self, hop):
raise TyperError("attempt to call constant None")
def ll_str(self, none):
return llstr("None")
def get_ll_eq_function(self):
return None
def get_ll_hash_function(self):
return ll_none_hash
rtype_simple_call = none_call
rtype_call_args = none_call
none_frozen_pbc_repr = NoneFrozenPBCRepr()
def ll_none_hash(_):
return 0
class __extend__(pairtype(Repr, NoneFrozenPBCRepr)):
def convert_from_to((r_from, _), v, llops):
return inputconst(Void, None)
def rtype_is_((robj1, rnone2), hop):
from rpython.rtyper.lltypesystem.rpbc import rtype_is_None
if hop.s_result.is_constant():
return hop.inputconst(Bool, hop.s_result.const)
return rtype_is_None(robj1, rnone2, hop)
class __extend__(pairtype(NoneFrozenPBCRepr, Repr)):
def convert_from_to((_, r_to), v, llops):
return inputconst(r_to, None)
def rtype_is_((rnone1, robj2), hop):
from rpython.rtyper.lltypesystem.rpbc import rtype_is_None
if hop.s_result.is_constant():
return hop.inputconst(Bool, hop.s_result.const)
return rtype_is_None(robj2, rnone1, hop, pos=1)
# ____________________________________________________________
class AbstractClassesPBCRepr(Repr):
......
......@@ -936,7 +936,7 @@ class LowLevelOpList(list):
# _______________________________________________________________________
# this has the side-effect of registering the unary and binary operations
# and the rtyper_chooserepr() methods
from rpython.rtyper import rint, rbool, rfloat, rnone
from rpython.rtyper import rint, rbool, rfloat
from rpython.rtyper import rrange
from rpython.rtyper import rstr, rdict, rlist, rbytearray
from rpython.rtyper import rclass, rbuiltin, rpbc
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment