mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 16:55:11 +01:00
Tweak liveness analysis for if-else chains
This commit is contained in:
1 parent
14f5859311
commit
97eb1290f5
3 files changed
+12
-13
No files matched your search
@@ -349,7 +349,7 @@ func (h *livenessHelper) doIOManip(r livenesses, n *a.IOManip, depth uint32) err
|
|||||||
func (h *livenessHelper) doIf(r livenesses, n *a.If, depth uint32) error {
|
func (h *livenessHelper) doIf(r livenesses, n *a.If, depth uint32) error {
|
||||||
scratch := make(livenesses, len(r))
|
scratch := make(livenesses, len(r))
|
||||||
result := make(livenesses, len(r))
|
result := make(livenesses, len(r))
|
||||||
for ; n != nil; n = n.ElseIf() {
|
for {
|
||||||
if err := h.doExpr(r, n.Condition()); err != nil {
|
if err := h.doExpr(r, n.Condition()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -360,11 +360,17 @@ func (h *livenessHelper) doIf(r livenesses, n *a.If, depth uint32) error {
|
|||||||
}
|
}
|
||||||
result.reconcile(scratch)
|
result.reconcile(scratch)
|
||||||
|
|
||||||
|
if ei := n.ElseIf(); ei != nil {
|
||||||
|
n = ei
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
copy(scratch, r)
|
copy(scratch, r)
|
||||||
if err := h.doBlock(scratch, n.BodyIfFalse(), depth); err != nil {
|
if err := h.doBlock(scratch, n.BodyIfFalse(), depth); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
result.reconcile(scratch)
|
result.reconcile(scratch)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
copy(r, result)
|
copy(r, result)
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -121,6 +121,11 @@ func (q *checker) tcheckStatement(n *a.Node) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case a.KIf:
|
case a.KIf:
|
||||||
|
for n := n.AsIf(); n != nil; n = n.ElseIf() {
|
||||||
|
if (n.ElseIf() != nil) && (len(n.BodyIfFalse()) > 0) {
|
||||||
|
return fmt.Errorf("check: if has an else-if and an else-not-if")
|
||||||
|
}
|
||||||
|
}
|
||||||
for n := n.AsIf(); n != nil; n = n.ElseIf() {
|
for n := n.AsIf(); n != nil; n = n.ElseIf() {
|
||||||
cond := n.Condition()
|
cond := n.Condition()
|
||||||
if cond.Effect() != 0 {
|
if cond.Effect() != 0 {
|
||||||
|
|||||||
@@ -6634,7 +6634,6 @@ struct wuffs_bmp__decoder__struct {
|
|||||||
uint64_t scratch;
|
uint64_t scratch;
|
||||||
} s_decode_image_config[1];
|
} s_decode_image_config[1];
|
||||||
struct {
|
struct {
|
||||||
wuffs_base__status v_status;
|
|
||||||
uint64_t scratch;
|
uint64_t scratch;
|
||||||
} s_decode_frame[1];
|
} s_decode_frame[1];
|
||||||
struct {
|
struct {
|
||||||
@@ -8514,9 +8513,6 @@ struct wuffs_json__decoder__struct {
|
|||||||
uint32_t v_expect;
|
uint32_t v_expect;
|
||||||
uint32_t v_expect_after_value;
|
uint32_t v_expect_after_value;
|
||||||
} s_decode_tokens[1];
|
} s_decode_tokens[1];
|
||||||
struct {
|
|
||||||
uint32_t v_neg;
|
|
||||||
} s_decode_inf_nan[1];
|
|
||||||
} private_data;
|
} private_data;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -23384,9 +23380,6 @@ wuffs_bmp__decoder__decode_frame(
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
|
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
|
||||||
if (coro_susp_point) {
|
|
||||||
v_status = self->private_data.s_decode_frame[0].v_status;
|
|
||||||
}
|
|
||||||
switch (coro_susp_point) {
|
switch (coro_susp_point) {
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||||
|
|
||||||
@@ -23513,7 +23506,6 @@ wuffs_bmp__decoder__decode_frame(
|
|||||||
suspend:
|
suspend:
|
||||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||||
self->private_data.s_decode_frame[0].v_status = v_status;
|
|
||||||
|
|
||||||
goto exit;
|
goto exit;
|
||||||
exit:
|
exit:
|
||||||
@@ -34278,9 +34270,6 @@ wuffs_json__decoder__decode_inf_nan(
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t coro_susp_point = self->private_impl.p_decode_inf_nan[0];
|
uint32_t coro_susp_point = self->private_impl.p_decode_inf_nan[0];
|
||||||
if (coro_susp_point) {
|
|
||||||
v_neg = self->private_data.s_decode_inf_nan[0].v_neg;
|
|
||||||
}
|
|
||||||
switch (coro_susp_point) {
|
switch (coro_susp_point) {
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||||
|
|
||||||
@@ -34388,7 +34377,6 @@ wuffs_json__decoder__decode_inf_nan(
|
|||||||
goto suspend;
|
goto suspend;
|
||||||
suspend:
|
suspend:
|
||||||
self->private_impl.p_decode_inf_nan[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
self->private_impl.p_decode_inf_nan[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||||
self->private_data.s_decode_inf_nan[0].v_neg = v_neg;
|
|
||||||
|
|
||||||
goto exit;
|
goto exit;
|
||||||
exit:
|
exit:
|
||||||
|
|||||||
Reference in new issue
Block a user