[pypy-svn] r10310 - pypy/dist/pypy/translator/llvm
cfbolz at codespeak.net
cfbolz at codespeak.net
Tue Apr 5 02:58:46 CEST 2005
Author: cfbolz
Date: Tue Apr 5 02:58:46 2005
New Revision: 10310
Modified:
pypy/dist/pypy/translator/llvm/classrepr.py
pypy/dist/pypy/translator/llvm/funcrepr.py
pypy/dist/pypy/translator/llvm/genllvm.py
pypy/dist/pypy/translator/llvm/list.c
pypy/dist/pypy/translator/llvm/list_template.ll
pypy/dist/pypy/translator/llvm/llvmbc.py
pypy/dist/pypy/translator/llvm/representation.py
pypy/dist/pypy/translator/llvm/seqrepr.py
pypy/dist/pypy/translator/llvm/typerepr.py
Log:
Changed the type representations to distinguish better between LLVM
types and type objects. Also added further pieces of exception support.
Modified: pypy/dist/pypy/translator/llvm/classrepr.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/classrepr.py (original)
+++ pypy/dist/pypy/translator/llvm/classrepr.py Tue Apr 5 02:58:46 2005
@@ -13,6 +13,8 @@
from pypy.translator.llvm.funcrepr import FunctionRepr, BoundMethodRepr
from pypy.translator.llvm.funcrepr import VirtualMethodRepr
+debug = True
+
class ClassRepr(TypeRepr):
l_classes = {}
def get(obj, gen):
@@ -87,9 +89,12 @@
print "--> value"
self.l_attrs_types = [gen.get_repr(attr.s_value) for attr in attribs]
self.dependencies = sets.Set(self.l_attrs_types)
- attributes = ", ".join([at.llvmname() for at in self.l_attrs_types])
- self.definition = "%s = type {%%std.class*, %s}" % (self.name,
- attributes)
+ attributes = ", ".join([at.typename() for at in self.l_attrs_types])
+ if attributes != "":
+ self.definition = "%s = type {%%std.class*, %s}" % (self.name,
+ attributes)
+ else:
+ self.definition = "%s = type {%%std.class*}" % self.name
self.attributes = attribs
self.attr_num = {}
for i, attr in enumerate(attribs):
@@ -112,14 +117,10 @@
(self.l_base.objectname, l_tmp.llvmname()))
def llvmtype(self):
- return "%std.class* "
+ return "%std.class*"
- def typed_name(self):
- #XXXX: Ouch. I get bitten by the fact that
- # in LLVM typedef != class object
- # This will work, as long as class objects are only passed to functions
- # (as opposed to used in LLVM instructions)
- return "%%std.class* %s" % self.objectname
+ def llvmname(self):
+ return self.objectname
def op_simple_call(self, l_target, args, lblock, l_func):
lblock.malloc(l_target, self)
@@ -240,7 +241,7 @@
else:
self.l_base = None
- def llvmname(self):
+ def typename(self):
return "%std.exception* "
def llvmtype(self):
Modified: pypy/dist/pypy/translator/llvm/funcrepr.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/funcrepr.py (original)
+++ pypy/dist/pypy/translator/llvm/funcrepr.py Tue Apr 5 02:58:46 2005
@@ -10,18 +10,20 @@
from pypy.translator.llvm import llvmbc
from pypy.translator.unsimplify import remove_double_links
-from pypy.translator.llvm.representation import debug, LLVMRepr
+from pypy.translator.llvm.representation import debug, LLVMRepr, CompileError
from pypy.translator.llvm.typerepr import TypeRepr, PointerTypeRepr
+debug = True
-INTRINSIC_OPS = ["lt", "le", "eq", "ne", "gt", "ge", "is", "is_true", "len",
+INTRINSIC_OPS = ["lt", "le", "eq", "ne", "gt", "ge", "is_", "is_true", "len",
"neg", "pos", "invert", "add", "sub", "mul", "truediv",
"floordiv", "div", "mod", "pow", "lshift", "rshift", "and_",
"or", "xor", "inplace_add", "inplace_sub", "inplace_mul",
"inplace_truediv", "inplace_floordiv", "inplace_div",
"inplace_mod", "inplace_pow", "inplace_lshift",
"inplace_rshift", "inplace_and", "inplace_or", "inplace_xor",
- "contains", "newlist", "newtuple", "alloc_and_set"]
+ "contains", "newlist", "newtuple", "alloc_and_set",
+ "issubtype"]
C_SIMPLE_TYPES = {annmodel.SomeChar: "char",
annmodel.SomeString: "char*",
@@ -124,6 +126,8 @@
checkgraph(self.graph)
a = self.annotator
for number, pyblock in enumerate(self.allblocks):
+ if debug:
+ print "#" * 20, self.graph.name, number, pyblock
pyblock = self.allblocks[number]
is_tryblock = isinstance(pyblock.exitswitch, Constant) and \
pyblock.exitswitch.value == last_exception
@@ -147,12 +151,15 @@
if isinstance(node, Link) and node.target == pyblock:
incoming_links.append(node)
traverse(visit, self.graph)
+ print "***** phi nodes *****"
if len(incoming_links) != 0:
for i, arg in enumerate(pyblock.inputargs):
+ print "___", i, arg, "___",
l_arg = self.gen.get_repr(arg)
l_values = [self.gen.get_repr(l.args[i])
for l in incoming_links]
for j in range(len(l_values)):
+ print j, l_values[j].llvmtype(), l_arg.llvmtype()
if l_values[j].llvmtype() != l_arg.llvmtype():
try:
l_values[j] = \
@@ -193,26 +200,56 @@
# type there, we have to make the cast in this block since the phi
# instructions in the next block cannot be preceded by any other
# instruction
+ print "******Casts:******"
for link in pyblock.exits:
+ print "____________block:", link.target
for i, arg in enumerate(link.args):
- localtype = self.annotator.binding(arg)
- targettype = self.annotator.binding(
- link.target.inputargs[i])
- l_targettype = self.gen.get_repr(targettype)
- l_localtype = self.gen.get_repr(localtype)
+ print arg,
+ l_target = self.gen.get_repr(link.target.inputargs[i])
l_local = self.gen.get_repr(arg)
- self.dependencies.update([l_targettype, l_localtype,
- l_local])
- if l_targettype.llvmname() != l_localtype.llvmname():
- l_tmp = self.gen.get_local_tmp(l_targettype, self)
+ self.dependencies.update([l_target, l_local])
+ print "local", l_local.typed_name()
+ print "target", l_target.typed_name()
+ print "from ", l_local.llvmtype(),
+ print "to", l_target.llvmtype(),
+ if l_target.llvmtype() != l_local.llvmtype():
+ print "change: ",
+ l_tmp = self.gen.get_local_tmp(l_target.type, self)
lblock.cast(l_tmp, l_local)
- l_local.alt_types = {l_targettype.llvmname(): l_tmp}
+ try:
+ print l_local.alt_types
+ l_local.alt_types[l_target.llvmtype()] = l_tmp
+ except (AttributeError, TypeError):
+ l_local.alt_types = {l_target.llvmtype(): l_tmp}
+ print l_local.alt_types
+ else:
+ print
#Create branches
if pyblock.exitswitch is None:
if pyblock == self.graph.returnblock:
l_returnvalue = self.gen.get_repr(pyblock.inputargs[0])
self.dependencies.add(l_returnvalue)
lblock.ret(l_returnvalue)
+ elif pyblock == self.graph.exceptblock:
+ l_exc = self.gen.get_repr(pyblock.inputargs[0])
+ l_val = self.gen.get_repr(pyblock.inputargs[1])
+ l_last_exception = self.gen.get_repr(last_exception)
+ l_last_exc_value = self.gen.get_repr(last_exc_value)
+ self.dependencies.update([l_exc, l_val, l_last_exception,
+ l_last_exc_value])
+ if "%std.class" != l_exc.llvmtype():
+ l_tmp = self.gen.get_local_tmp(
+ PointerTypeRepr("%std.class", self.gen), self)
+ lblock.cast(l_tmp, l_exc)
+ l_exc = l_tmp
+ if "%std.exception" != l_val.llvmtype():
+ l_tmp = self.gen.get_local_tmp(
+ PointerTypeRepr("%std.exception", self.gen), self)
+ lblock.cast(l_tmp, l_val)
+ l_val = l_tmp
+ lblock.store(l_exc, l_last_exception)
+ lblock.store(l_val, l_last_exc_value)
+ lblock.unwind()
else:
lblock.uncond_branch(
"%%block%i" % self.blocknum[pyblock.exits[0].target])
Modified: pypy/dist/pypy/translator/llvm/genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/genllvm.py (original)
+++ pypy/dist/pypy/translator/llvm/genllvm.py Tue Apr 5 02:58:46 2005
@@ -22,7 +22,7 @@
from pypy.translator.llvm.representation import CompileError
from pypy.translator.llvm.funcrepr import EntryFunctionRepr
-debug = True
+debug = False
def llvmcompile(transl, optimize=False):
@@ -175,4 +175,3 @@
yield l_dep1
yield l_repr
-
Modified: pypy/dist/pypy/translator/llvm/list.c
==============================================================================
--- pypy/dist/pypy/translator/llvm/list.c (original)
+++ pypy/dist/pypy/translator/llvm/list.c Tue Apr 5 02:58:46 2005
@@ -123,6 +123,17 @@
l->data[index] = value;
}
+void setitem_EXCEPTION(struct list* l, int index, struct item* value) {
+ if (index < 0)
+ index = l->length + index;
+ if (valid_index(index, l) == 0) {
+ LAST_EXCEPTION_TYPE = &INDEX_ERROR;
+ unwind();
+ return;
+ }
+ l->data[index] = value;
+}
+
struct list* add(struct list* a, struct list* b) {
struct list* nlist = malloc(sizeof(struct list));
unsigned int newlength = a->length + b->length;
@@ -177,6 +188,24 @@
return ret;
}
+struct item* pop_EXCEPTION(struct list* a, int index) {
+ if (index < 0)
+ index = a->length + index;
+ if (valid_index(index, a) == 0) {
+ LAST_EXCEPTION_TYPE = &INDEX_ERROR;
+ return unwind();
+ }
+ struct item* ret = a->data[index];
+ struct item** newdata = malloc(sizeof(struct item*) * (a->length - 1));
+ copy(a->data, newdata, index);
+ copy(a->data + index + 1, newdata + index, a->length - 1 - index);
+ a->length -= 1;
+ free(a->data);
+ a->data = newdata;
+ return ret;
+}
+
+
struct item* pop_ALTERNATIVE1(struct list* a) {
return pop(a, a->length - 1);
}
@@ -194,5 +223,4 @@
hi -= 1;
}
}
-
-
+
Modified: pypy/dist/pypy/translator/llvm/list_template.ll
==============================================================================
--- pypy/dist/pypy/translator/llvm/list_template.ll (original)
+++ pypy/dist/pypy/translator/llvm/list_template.ll Tue Apr 5 02:58:46 2005
@@ -221,6 +221,38 @@
ret void
}
+internal void %std.setitem.exc(%std.list.%(name)s* %l, int %index.1, %(item)s %value) {
+entry:
+ %tmp.1 = setlt int %index.1, 0
+ br bool %tmp.1, label %then.0, label %endif.0.i
+
+then.0:
+ %tmp.4 = getelementptr %std.list.%(name)s* %l, int 0, uint 0
+ %tmp.5 = load uint* %tmp.4
+ %tmp.5 = cast uint %tmp.5 to int
+ %tmp.9 = add int %tmp.5, %index.1
+ %tmp.1.i5 = setlt int %tmp.9, 0
+ br bool %tmp.1.i5, label %then.1, label %endif.0.i
+
+endif.0.i:
+ %index_addr.0.0 = phi int [ %tmp.9, %then.0 ], [ %index.1, %entry ]
+ %tmp.1.i.i = getelementptr %std.list.%(name)s* %l, int 0, uint 0
+ %tmp.2.i.i = load uint* %tmp.1.i.i
+ %tmp.3.i.i = cast uint %tmp.2.i.i to int
+ %tmp.6.i = setgt int %tmp.3.i.i, %index_addr.0.0
+ br bool %tmp.6.i, label %endif.1, label %then.1
+
+then.1:
+ store %std.class* %glb.class.IndexError.object, %std.class** %std.last_exception.type
+ unwind
+endif.1:
+ %tmp.17 = getelementptr %std.list.%(name)s* %l, int 0, uint 1
+ %tmp.18 = load %(item)s** %tmp.17
+ %tmp.20 = getelementptr %(item)s* %tmp.18, int %index_addr.0.0
+ store %(item)s %value, %(item)s* %tmp.20
+ ret void
+}
+
internal %std.list.%(name)s* %std.add(%std.list.%(name)s* %a, %std.list.%(name)s* %b) {
entry:
%tmp.0 = malloc %std.list.%(name)s
@@ -461,6 +493,78 @@
ret %(item)s %tmp.15
}
+internal %(item)s %std.pop.exc(%std.list.%(name)s* %a, int %index.1) {
+entry:
+ %tmp.1 = setlt int %index.1, 0
+ br bool %tmp.1, label %then.0, label %endif.0.i
+
+then.0:
+ %tmp.4 = getelementptr %std.list.%(name)s* %a, int 0, uint 0
+ %tmp.5 = load uint* %tmp.4
+ %tmp.5 = cast uint %tmp.5 to int
+ %tmp.9 = add int %tmp.5, %index.1
+ %tmp.1.i20 = setlt int %tmp.9, 0
+ br bool %tmp.1.i20, label %then.1, label %endif.0.i
+
+endif.0.i:
+ %index_addr.0.0 = phi int [ %tmp.9, %then.0 ], [ %index.1, %entry ]
+ %tmp.1.i.i = getelementptr %std.list.%(name)s* %a, int 0, uint 0
+ %tmp.2.i.i = load uint* %tmp.1.i.i
+ %tmp.3.i.i = cast uint %tmp.2.i.i to int
+ %tmp.6.i = setgt int %tmp.3.i.i, %index_addr.0.0
+ br bool %tmp.6.i, label %endif.1, label %then.1
+
+then.1:
+ store %std.class* %glb.class.IndexError.object, %std.class** %std.last_exception.type
+ unwind
+endif.1:
+ %tmp.19 = getelementptr %std.list.%(name)s* %a, int 0, uint 1
+ %tmp.20 = load %(item)s** %tmp.19
+ %tmp.22 = getelementptr %(item)s* %tmp.20, int %index_addr.0.0
+ %tmp.23 = load %(item)s* %tmp.22
+ %tmp.27-off = add uint %tmp.2.i.i, 1073741823
+ %tmp.24 = malloc %(item)s, uint %tmp.27-off
+ %tmp.36 = cast int %index_addr.0.0 to uint
+ %tmp.2.i526 = seteq int %index_addr.0.0, 0
+ br bool %tmp.2.i526, label %copy.entry12, label %no_exit.i6
+
+no_exit.i6:
+ %i.0.i4.0 = phi uint [ %tmp.14.i10, %no_exit.i6 ], [ 0, %endif.1 ]
+ %tmp.7.i7 = getelementptr %(item)s* %tmp.24, uint %i.0.i4.0
+ %tmp.11.i8 = getelementptr %(item)s* %tmp.20, uint %i.0.i4.0
+ %tmp.12.i9 = load %(item)s* %tmp.11.i8
+ store %(item)s %tmp.12.i9, %(item)s* %tmp.7.i7
+ %tmp.14.i10 = add uint %i.0.i4.0, 1
+ %tmp.2.i5 = setlt uint %tmp.14.i10, %tmp.36
+ br bool %tmp.2.i5, label %no_exit.i6, label %copy.entry12
+
+copy.entry12:
+ %tmp.43.sum = add int %index_addr.0.0, 1
+ %tmp.56 = add uint %tmp.2.i.i, 4294967295
+ %tmp.57 = sub uint %tmp.56, %tmp.36
+ %tmp.2.i31 = seteq uint %tmp.56, %tmp.36
+ br bool %tmp.2.i31, label %copy.entry, label %no_exit.i
+
+no_exit.i:
+ %i.0.i.0 = phi uint [ %tmp.14.i, %no_exit.i ], [ 0, %copy.entry12 ]
+ %i.0.i.032 = cast uint %i.0.i.0 to int
+ %tmp.50.sum = add int %i.0.i.032, %index_addr.0.0
+ %tmp.7.i = getelementptr %(item)s* %tmp.24, int %tmp.50.sum
+ %tmp.45.sum = add int %i.0.i.032, %tmp.43.sum
+ %tmp.11.i = getelementptr %(item)s* %tmp.20, int %tmp.45.sum
+ %tmp.12.i = load %(item)s* %tmp.11.i
+ store %(item)s %tmp.12.i, %(item)s* %tmp.7.i
+ %tmp.14.i = add uint %i.0.i.0, 1
+ %tmp.2.i = setlt uint %tmp.14.i, %tmp.57
+ br bool %tmp.2.i, label %no_exit.i, label %copy.entry
+
+copy.entry:
+ store uint %tmp.56, uint* %tmp.1.i.i
+ free %(item)s* %tmp.20
+ store %(item)s* %tmp.24, %(item)s** %tmp.19
+ ret %(item)s %tmp.23
+}
+
internal %(item)s %std.pop(%std.list.%(name)s* %a) {
entry:
%tmp.3 = getelementptr %std.list.%(name)s* %a, int 0, uint 0
Modified: pypy/dist/pypy/translator/llvm/llvmbc.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/llvmbc.py (original)
+++ pypy/dist/pypy/translator/llvm/llvmbc.py Tue Apr 5 02:58:46 2005
@@ -95,15 +95,15 @@
def malloc(self, l_target, l_type, num=1):
self.phi_done = True
s = "%s = malloc %s" % (l_target.llvmname(),
- l_type.llvmname_wo_pointer())
+ l_type.typename_wo_pointer())
if num > 1:
s += ", uint %i" % num
self.instructions.append(s)
def getelementptr(self, l_target, l_ptr, adresses):
self.phi_done = True
- s = "%s = getelementptr %s %s, " % (l_target.llvmname(),
- l_ptr.llvmtype(), l_ptr.llvmname())
+ s = "%s = getelementptr %s, " % (l_target.llvmname(),
+ l_ptr.typed_name())
adr = []
for a in adresses:
try:
@@ -158,8 +158,6 @@
if self.phi_done:
raise LLVMError, "Can't create phi node."
vars_string = []
- print "inserting phi node", l_arg, l_values, blocks
- print l_arg.llvmname(), l_arg.llvmtype()
fd = "" + "%s = phi %s " % (l_arg.llvmname(), l_arg.llvmtype())
fd += ", ".join(["[%s, %s]" % (v.llvmname(), b)
for v, b in zip(l_values, blocks)])
Modified: pypy/dist/pypy/translator/llvm/representation.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/representation.py (original)
+++ pypy/dist/pypy/translator/llvm/representation.py Tue Apr 5 02:58:46 2005
@@ -39,7 +39,7 @@
return self.name
def llvmtype(self):
- return self.type.llvmname()
+ return self.type.typename()
def typed_name(self):
return self.llvmtype() + " " + self.llvmname()
@@ -160,9 +160,6 @@
def llvmname(self):
return "%" + self.name
- def llvmtype(self):
- return self.type.llvmname()
-
class NoneRepr(LLVMRepr):
def get(obj, gen):
if isinstance(obj, Constant) and obj.value is None:
@@ -205,7 +202,7 @@
def get_globals(self):
d = {"len": len(self.s), "gv1": self.glvar1, "gv2": self.glvar2,
- "type": self.type.llvmname_wo_pointer(), "string": self.s}
+ "type": self.type.typename_wo_pointer(), "string": self.s}
s = """%(gv1)s = internal global [%(len)i x sbyte] c"%(string)s"
%(gv2)s = internal global %(type)s {uint %(len)i,\
sbyte* getelementptr ([%(len)i x sbyte]* %(gv1)s, uint 0, uint 0)}"""
@@ -256,4 +253,3 @@
else:
raise AttributeError, ("TupleRepr instance has no attribute %s"
% repr(name))
-
Modified: pypy/dist/pypy/translator/llvm/seqrepr.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/seqrepr.py (original)
+++ pypy/dist/pypy/translator/llvm/seqrepr.py Tue Apr 5 02:58:46 2005
@@ -28,7 +28,7 @@
self.gen = gen
self.l_itemtype = gen.get_repr(obj.s_item)
self.dependencies = sets.Set([self.l_itemtype])
- itemtype = self.l_itemtype.llvmname()
+ itemtype = self.l_itemtype.typename()
self.name = "%%std.list.%s" % itemtype.strip("%").replace("*", "")
self.definition = self.name + " = type {uint, %s*}" % itemtype
@@ -36,8 +36,8 @@
f = file(autopath.this_dir + "/list_template.ll", "r")
s = f.read()
f.close()
- itemtype = self.l_itemtype.llvmname()
- s = s.replace("%(item)s", self.l_itemtype.llvmname())
+ itemtype = self.l_itemtype.typename()
+ s = s.replace("%(item)s", self.l_itemtype.typename())
s = s.replace("%(name)s", itemtype.strip("%").replace("*", ""))
if isinstance(self.l_itemtype, IntTypeRepr):
f1 = file(autopath.this_dir + "/int_list.ll", "r")
@@ -82,11 +82,11 @@
self.gen = gen
self.l_itemtypes = [gen.get_repr(l) for l in obj.items]
self.name = (("{" + ", ".join(["%s"] * len(self.l_itemtypes)) + "}") %
- tuple([l.llvmname() for l in self.l_itemtypes]))
+ tuple([l.typename() for l in self.l_itemtypes]))
def get_functions(self):
s = ("internal int %%std.len(%s %%t) {\n\tret int %i\n}\n" %
- (self.llvmname(), len(self.l_itemtypes)))
+ (self.typename(), len(self.l_itemtypes)))
return s
def t_op_newtuple(self, l_target, args, lblock, l_func):
@@ -94,7 +94,7 @@
l_func.dependencies.update(l_args)
lblock.malloc(l_target, self)
l_ptrs = [self.gen.get_local_tmp(\
- PointerTypeRepr(l.llvmname(),self.gen), l_func)
+ PointerTypeRepr(l.typename(),self.gen), l_func)
for l in self.l_itemtypes]
l_func.dependencies.update(l_ptrs)
for i, l in enumerate(self.l_itemtypes):
Modified: pypy/dist/pypy/translator/llvm/typerepr.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/typerepr.py (original)
+++ pypy/dist/pypy/translator/llvm/typerepr.py Tue Apr 5 02:58:46 2005
@@ -7,7 +7,7 @@
from pypy.objspace.flow.model import last_exception, last_exc_value
from pypy.annotation import model as annmodel
-from pypy.translator.llvm.representation import debug, LLVMRepr
+from pypy.translator.llvm.representation import debug, LLVMRepr, CompileError
from pypy.translator.llvm.representation import LLVM_SIMPLE_TYPES
@@ -19,10 +19,10 @@
return TypeRepr("%std.void", "%std.void = type sbyte", "", gen)
get = staticmethod(get)
- def __init__(self, llvmname, definition, includefile, gen):
- if debug:
- print "TypeRepr: %s, %s" % (llvmname, definition)
- self.name = llvmname
+ def __init__(self, typename, definition, includefile, gen):
+ if debug:
+ print "TypeRepr: %s, %s" % (typename, definition)
+ self.name = typename
self.definition = definition
self.gen = gen
self.includefile = includefile
@@ -44,12 +44,19 @@
pass
return ""
- def llvmname(self):
+ def typename(self):
return self.name + "*"
- def llvmname_wo_pointer(self):
+ def typename_wo_pointer(self):
return self.name
+ def llvmname(self):
+ raise CompileError, "This type is not an object."
+
+ def llvmtype(self):
+ raise CompileError, "This type is not an object."
+
+
class StringTypeRepr(TypeRepr):
def get(obj, gen):
if obj.__class__ is annmodel.SomeString or obj is str:
@@ -66,7 +73,7 @@
self.l_charlist = self.gen.get_repr(
annmodel.SomeList(None, annmodel.SomeChar()))
self.dependencies.add(self.l_charlist)
- self.name = self.l_charlist.llvmname_wo_pointer()
+ self.name = self.l_charlist.typename_wo_pointer()
def t_op_getitem(self, l_target, args, lblock, l_func):
l_args = [self.gen.get_repr(arg) for arg in args]
@@ -96,7 +103,7 @@
self.name = "int"
self.gen = gen
- def llvmname(self):
+ def typename(self):
return self.name
def cast_to_signed(self, l_val, lblock, l_function):
@@ -133,30 +140,31 @@
return l_repr
elif obj.__class__ is annmodel.SomePBC:
if obj.knowntype == object or obj.knowntype == ClassType:
- return SimpleTypeRepr("%std.class", gen)
+ return SimpleTypeRepr("%std.class*", gen)
+ elif obj.__class__ is annmodel.SomeObject and \
+ hasattr(obj, "is_type_of"):
+ return SimpleTypeRepr("%std.class*", gen)
+ elif obj.__class__ is annmodel.SomeObject:
+ return SimpleTypeRepr("%std.object*", gen)
return None
get = staticmethod(get)
- def __init__(self, llvmname, gen):
+ def __init__(self, typename, gen):
if debug:
- print "SimpleTypeRepr: %s" % llvmname
- self.name = llvmname
+ print "SimpleTypeRepr: %s" % typename
+ self.name = typename
self.gen = gen
self.definition = ""
self.includefile = ""
- def llvmname(self):
+ def typename(self):
return self.name
class PointerTypeRepr(TypeRepr):
- def get(obj, gen):
- return None
- get = staticmethod(get)
-
- def __init__(self, type, gen):
- self.type = type
+ def __init__(self, type_, gen):
+ self.type = type_
- def llvmname(self):
+ def typename(self):
return self.type + "*"
class ImpossibleValueRepr(TypeRepr):
@@ -171,7 +179,6 @@
self.dependencies = sets.Set()
self.includefile = ""
- def llvmname(self):
+ def typename(self):
return "void"
-
More information about the Pypy-commit
mailing list