solution for try-catch problem and graphs

This commit is contained in:
Carlos Galindo 2019-12-08 14:49:52 +00:00
parent 743093c3d5
commit 904b44e229
9 changed files with 341 additions and 95 deletions

51
img/catch-no-dep.dot Normal file
View file

@ -0,0 +1,51 @@
digraph g {
before [label = "", style=invis, width =0.001, height = 0.001];
t [label = "try"];
f [label = <x_in = x<br/>f()>];
er [label = "error return"];
nr [label = "normal return"];
o [label = "x = x_out"];
o1 [label = "x = x_out"];
o2 [label = "x = x_out"];
o3 [label = "x = x_out"];
c1 [label = "catch (ExceptionA e)"]
c2 [label = "catch (ExceptionB e)"]
c3 [label = "catch (Exception e)"]
l1 [label = "log(\"Type A\")"];
l2 [label = "log(\"Type B\")"];
l3 [label = "log(\"Exception\")"];
after [label = "next"];
after2 [label = "", style= invis, height = 0.0001, width = 0.0001]
before -> t -> f -> er -> {c1, c2, c3};
f -> nr -> o -> after;
c1 -> o1 -> l1;
c2 -> o2 -> l2;
c3 -> o3 -> l3;
{t nr c1 c2 c3} -> after [style = dashed, constraint = false];
{l1 l2 l3} -> after -> after2;
BEFORE [label = "", style = invis, width = 0.001, height = 0.001];
T [label = "try"];
F [label = "f()"];
X_IN [label = "x_in = x"];
X_OUT_NORMAL [label = "x = x_out"];
X_OUT_1 [label = "x = x_out"];
X_OUT_2 [label = "x = x_out"];
X_OUT_3 [label = "x = x_out"];
NORMAL_RET [label = "normal return"];
ERROR_RET [label = "error return"];
C1 [label = "catch (ExceptionA e)"]
C2 [label = "catch (ExceptionB e)"]
C3 [label = "catch (Exception e)"]
L1 [label = "log(\"Type A\")"];
L2 [label = "log(\"Type B\")"];
L3 [label = "log(\"Exception\")"];
NEXT [label = "next"];
BEFORE -> NEXT;
BEFORE -> T -> F -> {X_IN NORMAL_RET ERROR_RET}
NORMAL_RET -> X_OUT_NORMAL
ERROR_RET -> {C1 C2 C3}
C1 -> {X_OUT_1 L1}
C2 -> {X_OUT_2 L2}
C3 -> {X_OUT_3 L3}
}

BIN
img/catch-no-dep.pdf Normal file

Binary file not shown.

16
img/catch-order.dot Normal file
View file

@ -0,0 +1,16 @@
digraph g {
ea [label="ExceptionA e"];
eb [label="ExceptionB e"];
eb1[label="ExceptionB1 e"];
eb2[label="ExceptionB2 e"];
e [label="Exception e"];
eb2 -> ea -> eb1 -> eb -> e;
EA [label="ExceptionA e"];
EB [label="ExceptionB e"];
EB1 [label="ExceptionB1 e"];
EB2 [label="ExceptionB2 e"];
E [label="Exception e"];
{EA EB} -> E;
{EB1 EB2} -> EB;
}

BIN
img/catch-order.pdf Normal file

Binary file not shown.

View file

@ -0,0 +1,40 @@
digraph g {
enter [style = filled];
mxin [label = "x = x_in", style = filled];
try [style = filled];
x_in [label = "x_in = x", style = filled];
f [label = "f()", style = filled];
nr [label = "normal return"];
x_out_nr [label = "x = x_out"];
er [label = "error return"];
catch [label = "catch (Exception e)"];
x_out_catch [label = "x = x_out"];
log [label = "log(\"error\")"];
x_0 [label = "x = 0", style = filled];
x_in2 [label = "x_in = x", style = filled];
f2 [label = "f()", style = filled];
nr2 [label = "normal return"];
er2 [label = "error return"];
ee [label = "error exit"];
x_out_nr2 [label = "x = x_out"];
x_out_ee [label = "x = x_out"];
enter -> {mxin try};
try -> f -> {x_in nr er}
nr -> x_out_nr
er -> catch -> {x_out_catch log}
enter -> {x_0 f2}
f2 -> {x_in2 nr2 er2}
nr2 -> x_out_nr2
er2 -> ee -> x_out_ee;
{edge [color = red, constraint = false];
mxin -> x_in;
x_0 -> x_in2;
}
{edge [color = blue, constraint = false];
x_in -> {x_out_nr x_out_catch}
x_in2 -> {x_out_nr2 x_out_ee}
}
}

BIN
img/incorrect-try-catch.pdf Normal file

Binary file not shown.