Ticket #13280: transform.2.pl

File transform.2.pl, 499 bytes (added by nickm, 5 years ago)
Line 
1#!/usr/bin/perl -p -w -i
2
3BEGIN { %vartypes = (); }
4
5if (/^[{}]/) {
6    %vartypes = ();
7}
8
9if (/^ *crypto_int(\d+) +([a-zA-Z_][_a-zA-Z0-9]*)/) {
10    $vartypes{$2} = $1;
11} elsif (/^ *(?:signed +)char +([a-zA-Z_][_a-zA-Z0-9]*)/) {
12    $vartypes{$1} = '8';
13}
14
15if (/([a-zA-Z_][a-zA-Z_0-9]*) *<< *(\d+)/) {
16    $v = $1;
17    if (exists $vartypes{$v}) {
18        s/$v *<< *(\d+)/SHL$vartypes{$v}($v,$1)/;
19    }
20}
21
22s/\(SHL64\((.*)\)\)/SHL64\($1\)/;
23s/\(SHL32\((.*)\)\)/SHL32\($1\)/;
24s/\(SHL8\((.*)\)\)/SHL8\($1\)/;