Debian Codegraph @

rpython/jit/tool/pypytrace-mode.el

raw
1 (provide 'pypytrace-mode)
2 (eval-when-compile
3 (require 'generic-x)
4 (require 'hi-lock)
5 (require 'compile)
6 (require 'cus-edit))
7
8 (defun set-truncate-lines ()
9 (setq truncate-lines t))
10
11 (defun pypytrace-beginning-of-defun ()
12 (search-backward "{")
13 (beginning-of-line))
14
15 (defun pypytrace-end-of-defun ()
16 (search-forward "}")
17 (end-of-line))
18
19
20 ;; to generate the list of keywords:
21 ;; from rpython.jit.metainterp import resoperation
22 ;; print ' '.join(sorted('"%s"' % op.lower() for op in resoperation.opname.values() if not op.startswith('GUARD')))
23
24
25
26 (define-generic-mode
27 'pypytrace-mode ;; name of the mode to create
28 nil
29 '("arraylen_gc" "call" "call_assembler" "call_loopinvariant" "call_may_force" "call_pure" "call_release_gil" "cast_float_to_int" "cast_int_to_float" "cond_call_gc_wb" "copystrcontent" "copyunicodecontent" "debug_merge_point" "finish" "float_abs" "float_add" "float_eq" "float_ge" "float_gt" "float_le" "float_lt" "float_mul" "float_ne" "float_neg" "float_sub" "float_truediv" "force_token" "getarrayitem_gc" "getarrayitem_gc_pure" "getarrayitem_raw" "getfield_gc" "getfield_gc_pure" "getfield_raw" "getfield_raw_pure" "int_add" "int_add_ovf" "int_and" "int_eq" "int_floordiv" "int_ge" "int_gt" "int_invert" "int_is_true" "int_is_zero" "int_le" "int_lshift" "int_lt" "int_mod" "int_mul" "int_mul_ovf" "int_ne" "int_neg" "int_or" "int_rshift" "int_sub" "int_sub_ovf" "int_xor" "jit_debug" "jump" "new" "new_array" "new_with_vtable" "newstr" "newunicode" "ptr_eq" "ptr_ne" "quasiimmut_field" "read_timestamp" "same_as" "setarrayitem_gc" "setarrayitem_raw" "setfield_gc" "setfield_raw" "strgetitem" "strlen" "strsetitem" "uint_floordiv" "uint_ge" "uint_gt" "uint_le" "uint_lt" "uint_rshift" "unicodegetitem" "unicodelen" "unicodesetitem" "virtual_ref" "virtual_ref_finish") ;; keywords
30 '( ;; additional regexps
31 ("^# Loop.*" . 'hi-blue)
32 ("\\[.*\\]" . 'font-lock-comment-face) ;; comment out argument lists
33 ("guard_[a-z_]*" . 'widget-button-pressed)
34 ("\\(ptr\\|p\\)[0-9][0-9]*" . 'font-lock-variable-name-face)
35 ("i[0-9][0-9]*" . 'custom-button-pressed-unraised)
36 ("\\(descr=<.*FieldDescr \\)\\([^ ]*\\.\\)\\([^ ]*\\)\\( .*>\\)"
37 (1 'font-lock-comment-face)
38 (2 'font-lock-variable-name-face)
39 (3 'escape-glyph)
40 (4 'font-lock-comment-face))
41 ("<.*FieldDescr \\([^ ]*\\)" (1 'font-lock-variable-name-face))
42 ;; comment out debug_merge_point, but then highlight specific part of it
43 ("^debug_merge_point.*" . font-lock-comment-face)
44 ("^\\(debug_merge_point\\).*code object\\(.*\\). file \\('.*'\\). \\(line .*\\)> \\(.*\\)"
45 (1 'compilation-warning t)
46 (2 'escape-glyph t)
47 (3 'font-lock-string-face t)
48 (4 'escape-glyph t)
49 (5 'custom-variable-tag t)))
50 '("\\.trace$")
51 '(set-truncate-lines
52 (lambda ()
53 (set (make-local-variable 'beginning-of-defun-function)
54 'pypytrace-beginning-of-defun)
55 (set (make-local-variable 'end-of-defun-function) 'pypytrace-end-of-defun))
56 )
57 "A mode for pypy traces files")
58
59 ;; debug helpers
60 ;; (switch-to-buffer-other-window "strslice2.trace")
61 ;; (pypytrace-mode)
62