Skip to content

Commit

Permalink
Eliminate BOUNCE_UNHANDLED
Browse files Browse the repository at this point in the history
Native dispatchers had a return result called UNHANDLED which
was to avoid repetition of a certain error condition.  This
idea added overhead to every situation which was going to
re-dispatch a dispatcher...so this changes it around to where
UNHANDLED is a macro that can be used as `fail (UNHANDLED)`
and act the same way.
  • Loading branch information
hostilefork committed Aug 1, 2023
1 parent 95ebd43 commit 9309900
Show file tree
Hide file tree
Showing 36 changed files with 93 additions and 124 deletions.
2 changes: 1 addition & 1 deletion extensions/clipboard/mod-clipboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static Bounce Clipboard_Actor(
break;
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}


Expand Down
2 changes: 1 addition & 1 deletion extensions/dns/mod-dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ static Bounce DNS_Actor(Frame(*) frame_, REBVAL *port, Symbol(const*) verb)
break;
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}


Expand Down
2 changes: 1 addition & 1 deletion extensions/filesystem/p-dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,5 +280,5 @@ Bounce Dir_Actor(Frame(*) frame_, REBVAL *port, Symbol(const*) verb)
break;
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}
2 changes: 1 addition & 1 deletion extensions/filesystem/p-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,5 +730,5 @@ Bounce File_Actor(Frame(*) frame_, REBVAL *port, Symbol(const*) verb)
break;
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}
2 changes: 1 addition & 1 deletion extensions/network/mod-network.c
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ static Bounce Transport_Actor(
break;
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}


Expand Down
2 changes: 1 addition & 1 deletion extensions/stdio/p-stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,5 +417,5 @@ Bounce Console_Actor(Frame(*) frame_, REBVAL *port, Symbol(const*) verb)
break;
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}
2 changes: 0 additions & 2 deletions src/core/b-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ static void Init_Root_Vars(void)
Init_Return_Signal(&PG_R_Thrown, C_THROWN);
Init_Return_Signal(&PG_R_Redo_Unchecked, C_REDO_UNCHECKED);
Init_Return_Signal(&PG_R_Redo_Checked, C_REDO_CHECKED);
Init_Return_Signal(&PG_R_Unhandled, C_UNHANDLED);
Init_Return_Signal(&PG_R_Continuation, C_CONTINUATION);
Init_Return_Signal(&PG_R_Delegation, C_DELEGATION);
Init_Return_Signal(&PG_R_Suspend, C_SUSPEND);
Expand Down Expand Up @@ -516,7 +515,6 @@ static void Shutdown_Root_Vars(void)
Erase_Cell(&PG_R_Thrown);
Erase_Cell(&PG_R_Redo_Unchecked);
Erase_Cell(&PG_R_Redo_Checked);
Erase_Cell(&PG_R_Unhandled);
Erase_Cell(&PG_R_Continuation);
Erase_Cell(&PG_R_Delegation);
Erase_Cell(&PG_R_Suspend);
Expand Down
3 changes: 0 additions & 3 deletions src/core/evaluator/c-action.c
Original file line number Diff line number Diff line change
Expand Up @@ -1072,9 +1072,6 @@ Bounce Action_Executor(Frame(*) f)
STATE = ST_ACTION_TYPECHECKING;
goto typecheck_then_dispatch;

case C_UNHANDLED: // was used e.g. by `#a + 1`, should we revive this?
fail ("Not handled (review instances of this error!)");

default:
assert(!"Invalid pseudotype returned from action dispatcher");
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/f-series.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ Bounce Series_Common_Action_Maybe_Unhandled(
break;
}

return BOUNCE_UNHANDLED; // not a common operation, uhandled...not Lib(NULL)!
fail (UNHANDLED);
}


Expand Down
4 changes: 2 additions & 2 deletions src/core/t-binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ REBTYPE(Binary)
// !!! See notes in the REBTYPE(String) about alternate cases
// for the POKE'd value.
//
return BOUNCE_UNHANDLED;
fail (PARAM(value));
}

if (i > 0xff)
Expand Down Expand Up @@ -867,7 +867,7 @@ REBTYPE(Binary)
break;
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}


Expand Down
4 changes: 2 additions & 2 deletions src/core/t-bitset.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ REBTYPE(Bitset)
picker,
BITS_NOT(bset) ? Is_Falsey(setval) : Is_Truthy(setval)
)){
return BOUNCE_UNHANDLED;
fail (PARAM(picker));
}
return nullptr; }

Expand Down Expand Up @@ -752,5 +752,5 @@ REBTYPE(Bitset)
break;
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}
4 changes: 2 additions & 2 deletions src/core/t-blank.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ REBTYPE(Blank)
default: break;
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}


Expand Down Expand Up @@ -224,5 +224,5 @@ REBTYPE(Handle)
UNUSED(frame_);
UNUSED(verb);

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}
2 changes: 1 addition & 1 deletion src/core/t-block.c
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ REBTYPE(Array)
break; // fallthrough to error
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}


Expand Down
8 changes: 4 additions & 4 deletions src/core/t-char.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ REBTYPE(Issue)
default:
break;
}
return BOUNCE_UNHANDLED; }
fail (PARAM(property)); }

case SYM_COPY: // since copy result is also immutable, Move() suffices
return Copy_Cell(OUT, issue);
Expand All @@ -363,7 +363,7 @@ REBTYPE(Issue)
// implementation, and will not work if the ISSUE! length is > 1.
//
if (not IS_CHAR(issue))
return BOUNCE_UNHANDLED;
fail ("Math operations only usable on single-character ISSUE!");

// Don't use a Codepoint for chr, because it does signed math and then will
// detect overflow.
Expand All @@ -378,7 +378,7 @@ REBTYPE(Issue)

Cell(const*) picker = ARG(picker);
if (not IS_INTEGER(picker))
return BOUNCE_UNHANDLED;
fail (PARAM(picker));

REBI64 n = VAL_INT64(picker);
if (n <= 0)
Expand Down Expand Up @@ -487,7 +487,7 @@ REBTYPE(Issue)
break; }

default:
return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}

if (chr < 0)
Expand Down
2 changes: 1 addition & 1 deletion src/core/t-comma.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ REBTYPE(Comma)
default: break;
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}
2 changes: 1 addition & 1 deletion src/core/t-date.c
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ REBTYPE(Date)
}
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);

fix_time:
Normalize_Time(&secs, &day);
Expand Down
2 changes: 1 addition & 1 deletion src/core/t-decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ REBTYPE(Decimal)
break;
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);

setDec:
if (not FINITE(d1))
Expand Down
2 changes: 1 addition & 1 deletion src/core/t-function.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,5 +399,5 @@ REBTYPE(Action)
break;
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}
2 changes: 1 addition & 1 deletion src/core/t-integer.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,5 +470,5 @@ REBTYPE(Integer)
break;
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}
2 changes: 1 addition & 1 deletion src/core/t-logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,5 +410,5 @@ REBTYPE(Isotope)
break;
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}
10 changes: 2 additions & 8 deletions src/core/t-map.c
Original file line number Diff line number Diff line change
Expand Up @@ -791,15 +791,9 @@ REBTYPE(Map)

return nullptr; } // no upstream changes needed for REBMAP* reference

return_unhandled:
default:
//
// If you put a `break` here (or other variants, like trying to `goto`
// the below lines) GCC 2.95 on Haiku will warn "control reaches end
// of non-void function" warning. This contortion works. :-/
//
return BOUNCE_UNHANDLED;
break;
}

goto return_unhandled;
fail (UNHANDLED);
}
2 changes: 1 addition & 1 deletion src/core/t-money.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,5 +305,5 @@ REBTYPE(Money)
break;
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}
4 changes: 2 additions & 2 deletions src/core/t-object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ REBTYPE(Context)

ENSURE_MUTABLE(context);
if (not IS_OBJECT(context) and not IS_MODULE(context))
return BOUNCE_UNHANDLED;
fail ("APPEND only works on OBJECT! and MODULE! contexts");

if (Is_Splice(arg)) {
mutable_QUOTE_BYTE(arg) = UNQUOTED_1; // make plain group
Expand Down Expand Up @@ -1267,7 +1267,7 @@ REBTYPE(Context)
break;
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}


Expand Down
2 changes: 1 addition & 1 deletion src/core/t-pair.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ REBTYPE(Pair)
REBVAL *setval = ARG(value);

if (not IS_INTEGER(setval) and not IS_DECIMAL(setval))
return BOUNCE_UNHANDLED;
fail (PARAM(value));

REBVAL *which = (n == 1) ? VAL_PAIR_X(v) : VAL_PAIR_Y(v);

Expand Down
4 changes: 2 additions & 2 deletions src/core/t-string.c
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ REBTYPE(String)
c = Int32(setval);
}
else // CHANGE is a better route for splicing/removal/etc.
return BOUNCE_UNHANDLED;
fail (PARAM(value));

if (c == 0)
fail (Error_Illegal_Zero_Byte_Raw());
Expand Down Expand Up @@ -1218,7 +1218,7 @@ REBTYPE(String)
}
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}


Expand Down
2 changes: 1 addition & 1 deletion src/core/t-time.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,5 +712,5 @@ REBTYPE(Time)
}
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}
4 changes: 2 additions & 2 deletions src/core/t-tuple.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ REBTYPE(Sequence)
break;

default:
return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}

if (v > 255)
Expand Down Expand Up @@ -427,7 +427,7 @@ REBTYPE(Sequence)
break;
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}


Expand Down
2 changes: 1 addition & 1 deletion src/core/t-typeset.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,5 +323,5 @@ REBTYPE(Parameter)
UNUSED(frame_);
UNUSED(verb);

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}
2 changes: 1 addition & 1 deletion src/core/t-varargs.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ REBTYPE(Varargs)
break;
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}


Expand Down
2 changes: 1 addition & 1 deletion src/core/t-void.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,5 @@ REBTYPE(Quasi)
default: break;
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}
2 changes: 1 addition & 1 deletion src/core/t-word.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,5 +375,5 @@ REBTYPE(Word)
break;
}

return BOUNCE_UNHANDLED;
fail (UNHANDLED);
}
Loading

0 comments on commit 9309900

Please sign in to comment.