9 my $db = DBI
->connect("dbi:SQLite:smatch_db.sqlite", "", "", {AutoCommit
=> 0});
17 if ($text =~ /s64min/) {
19 } elsif ($text =~/s32min/) {
21 } elsif ($text =~ /s16min/) {
23 } elsif ($text =~ /s64max/) {
25 } elsif ($text =~ /s32max/) {
27 } elsif ($text =~ /s16max/) {
29 } elsif ($text =~ /u64max/) {
31 } elsif ($text =~ /u32max/) {
33 } elsif ($text =~ /u16max/) {
36 if ($text =~ /\((.*?)\)/) {
39 if (!($text =~ /^[-0123456789]/)) {
59 foreach my $tmp (@
$union) {
61 push @return_union, $tmp;
65 if ($range{max
} < $tmp->{min
}) {
66 push @return_union, \
%range;
67 push @return_union, $tmp;
69 } elsif ($range{min
} <= $tmp->{min
}) {
70 if ($range{max
} <= $tmp->{max
}) {
71 $range{max
} = $tmp->{max
};
72 push @return_union, \
%range;
75 } elsif ($range{min
} <= $tmp->{max
}) {
76 if ($range{max
} <= $tmp->{max
}) {
77 push @return_union, $tmp;
80 $range{min
} = $tmp->{min
};
83 push @return_union, $tmp;
88 push @return_union, \
%range;
91 return \
@return_union;
99 return "(" . $num . ")";
109 if ($range->{min
} == $range->{max
}) {
110 return print_num
($range->{min
});
112 return print_num
($range->{min
}) . "-" . print_num
($range->{max
});
120 my $printed_range = "";
123 foreach my $range (@
$union) {
125 $printed_range = $printed_range . ",";
128 $printed_range = $printed_range . print_range
($range);
130 my $sql = "insert into type_size values ('$type', '$printed_range');";
135 $db->do("PRAGMA synchronous = OFF");
136 $db->do("PRAGMA cache_size = 800000");
137 $db->do("PRAGMA journal_mode = OFF");
138 $db->do("PRAGMA count_changes = OFF");
139 $db->do("PRAGMA temp_store = MEMORY");
140 $db->do("PRAGMA locking = EXCLUSIVE");
142 my ($sth, @row, $cur_type, $type, @ranges, $range_txt, %range, $min, $max, $union_array, $skip);
144 $sth = $db->prepare('select * from function_type_size order by type');
149 while (@row = $sth->fetchrow_array()) {
150 $raw_line = join ',', @row;
154 if ($cur_type ne "$type") {
155 if ($cur_type ne "" && $skip == 0) {
156 print_info
($cur_type, $union_array);
163 @ranges = split(/,/, $row[3]);
164 foreach $range_txt (@ranges) {
165 if ($range_txt =~ /(.*[^(])-(.*)/) {
166 $min = text_to_int
($1);
167 $max = text_to_int
($2);
169 $min = text_to_int
($range_txt);
172 if ($min =~ /NaN/ || $max =~ /NaN/) {
175 $union_array = add_range
($union_array, $min, $max);
179 print_info
($cur_type, $union_array);