dotter

graphiz helpers
git clone git://deadbeef.fr/dotter.git
Log | Files | Refs | README | LICENSE

commit aa06d7c32f5d4c077045d7aebffcba60a4291e16
parent 50a073b6dcba3862c463b4c6ac86e4daf64a99e6
Author: Morel Bérenger <berengermorel76@gmail.com>
Date:   Mon,  4 Sep 2023 14:23:19 +0200

uml: implement some hackish bitfield overflow detection

Diffstat:
Muml | 45++++++++++++++++++++++++++++-----------------
1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/uml b/uml @@ -15,7 +15,10 @@ function end_class() { printf( "}\"\n]\n" ); } class = ""; + class_type = ""; inside = ""; + fields_max = 0 + fields_cur = 0 } function fun( overload ) { @@ -67,7 +70,8 @@ function depends( type ) { BEGIN { printf( "digraph %s\n{\n", FILENAME ); class = ""; - scope = ""; + class_type = ""; + scope = "[ ]"; inside = ""; } @@ -102,17 +106,18 @@ $1 == "link_font" { printf( "];\n" ); } -$1 == "class" { +$1 == "class" || $1 == "enum" || $1 == "bitfield" { end_class(); + scope = "[ ]"; printf( "\n\n" ); class = $2; + class_type = $1; printf( "%s\n[\n\tshape=\"record\";\n\tlabel=\"{%s", class, class ); -} - -$1 == "enum" || $1 == "bitfield" { - end_class(); - class = $2; - printf( "%s\n[\n\tshape=\"record\";\n\tlabel=\"{«%s» %s", class, $1, class ); + if( NF == 3 ) + { + fields_max = $3 + fields_cur = 0 + } } $1 == "fun" { @@ -147,17 +152,23 @@ $1 == "val" { printf( "|" ); inside = "val"; } - printf( "%s %s", scope, $2 ); - printf( "\l" ); -} - -$1 == "eval" { - if( inside != "eval" ) + error = ""; + if ( fields_max != 0 ) { - printf( "|" ); - inside = "eval"; + ++fields_cur; + if ( fields_cur > fields_max ) + { + error = "error: " + } + } + if ( class_type == "class" ) + { + printf( "%s%s %s", error, scope, $2 ); + } + else + { + printf( "%s%s", error, $2 ); } - printf( "%s", $2 ); printf( "\l" ); }