Debian Codegraph @

rpython/rtyper/rbuilder.py

raw symbols SCIP
1 from rpython.annotator.model import SomeChar, SomeUnicodeCodePoint
2 from rpython.rlib.rstring import INIT_SIZE
3 from rpython.rtyper.lltypesystem import lltype
4 from rpython.rtyper.rmodel import Repr
5
6
7 class AbstractStringBuilderRepr(Repr):
8 def rtyper_new(self, hop):
9 if len(hop.args_v) == 0:
10 v_arg = hop.inputconst(lltype.Signed, INIT_SIZE)
11 else:
12 v_arg = hop.inputarg(lltype.Signed, 0)
13 hop.exception_cannot_occur()
14 return hop.gendirectcall(self.ll_new, v_arg)
15
16 def rtype_method_append(self, hop):
17 if isinstance(hop.args_s[1], (SomeChar, SomeUnicodeCodePoint)):
18 vlist = hop.inputargs(self, self.char_repr)
19 func = self.ll_append_char
20 else:
21 vlist = hop.inputargs(self, self.string_repr)
22 func = self.ll_append
23 hop.exception_cannot_occur()
24 return hop.gendirectcall(func, *vlist)
25
26 def rtype_method_append_slice(self, hop):
27 vlist = hop.inputargs(self, self.string_repr,
28 lltype.Signed, lltype.Signed)
29 hop.exception_cannot_occur()
30 return hop.gendirectcall(self.ll_append_slice, *vlist)
31
32 def rtype_method_append_multiple_char(self, hop):
33 vlist = hop.inputargs(self, self.char_repr, lltype.Signed)
34 hop.exception_cannot_occur()
35 return hop.gendirectcall(self.ll_append_multiple_char, *vlist)
36
37 def rtype_method_append_charpsize(self, hop):
38 vlist = hop.inputargs(self, self.raw_ptr_repr, lltype.Signed)
39 hop.exception_cannot_occur()
40 return hop.gendirectcall(self.ll_append_charpsize, *vlist)
41
42 def rtype_method_getlength(self, hop):
43 vlist = hop.inputargs(self)
44 hop.exception_cannot_occur()
45 return hop.gendirectcall(self.ll_getlength, *vlist)
46
47 def rtype_method_build(self, hop):
48 vlist = hop.inputargs(self)
49 hop.exception_cannot_occur()
50 return hop.gendirectcall(self.ll_build, *vlist)
51
52 def rtype_bool(self, hop):
53 vlist = hop.inputargs(self)
54 hop.exception_cannot_occur()
55 return hop.gendirectcall(self.ll_bool, *vlist)
56
57 def convert_const(self, value):
58 if value is None:
59 return self.empty()
60 s = value.build()
61 ll_obj = self.ll_new(len(s))
62 self.ll_append(ll_obj, self.convert_to_ll(s))
63 return ll_obj