Debian Codegraph @

rpython/rlib/rsre/rsre_jit.py

raw symbols SCIP
1 from rpython.rlib.jit import JitDriver
2
3
4 class RSreJitDriver(JitDriver):
5 active = True
6
7 def __init__(self, name, debugprint, **kwds):
8 JitDriver.__init__(self, name='rsre_' + name, **kwds)
9 #
10 def get_printable_location(*args):
11 # we print based on indices in 'args'. We first print
12 # 'ctx.pattern' from the arg number debugprint[0].
13 pattern = args[debugprint[0]]
14 s = str(pattern.pattern)
15 if len(s) > 120:
16 s = s[:110] + '...'
17 if len(debugprint) > 1:
18 # then we print numbers from the args number
19 # debugprint[1] and possibly debugprint[2]
20 info = ' at %d' % (args[debugprint[1]],)
21 if len(debugprint) > 2:
22 info = '%s/%d' % (info, args[debugprint[2]])
23 else:
24 info = ''
25 return 're %s%s %s' % (name, info, s)
26 #
27 self.get_printable_location = get_printable_location
28
29
30 def install_jitdriver(name, **kwds):
31 from rpython.rlib.rsre.rsre_core import AbstractMatchContext
32 jitdriver = RSreJitDriver(name, **kwds)
33 setattr(AbstractMatchContext, 'jitdriver_' + name, jitdriver)
34
35 def install_jitdriver_spec(name, **kwds):
36 from rpython.rlib.rsre.rsre_core import BufMatchContext
37 from rpython.rlib.rsre.rsre_core import StrMatchContext
38 from rpython.rlib.rsre.rsre_core import UnicodeMatchContext
39 from rpython.rlib.rsre.rsre_utf8 import Utf8MatchContext
40 for prefix, concreteclass in [('Buf', BufMatchContext),
41 ('Str', StrMatchContext),
42 ('Uni', UnicodeMatchContext),
43 ('Utf8', Utf8MatchContext)]:
44 jitdriver = RSreJitDriver(prefix + name, **kwds)
45 setattr(concreteclass, 'jitdriver_' + name, jitdriver)