From 7af8f4e8f6f296f2ebdd11c0a46b0a6a55bcf2d9 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 8 Jul 2019 00:15:32 -0700 Subject: preserve truthiness of non-booleans Everywhere we check if something is true, we check it by comparing against 0, not 1. --- subx/apps/assort | Bin 28723 -> 28723 bytes subx/apps/dquotes | Bin 35032 -> 35032 bytes subx/apps/pack | Bin 43637 -> 43637 bytes subx/apps/subx-common.subx | 24 ++++++++++++------------ subx/apps/survey | Bin 34274 -> 34274 bytes 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'subx/apps') diff --git a/subx/apps/assort b/subx/apps/assort index 530ad9c6..10573301 100755 Binary files a/subx/apps/assort and b/subx/apps/assort differ diff --git a/subx/apps/dquotes b/subx/apps/dquotes index 6483c2dd..6015a4c6 100755 Binary files a/subx/apps/dquotes and b/subx/apps/dquotes differ diff --git a/subx/apps/pack b/subx/apps/pack index 08164496..73e680b7 100755 Binary files a/subx/apps/pack and b/subx/apps/pack differ diff --git a/subx/apps/subx-common.subx b/subx/apps/subx-common.subx index 83b37e07..6ab82884 100644 --- a/subx/apps/subx-common.subx +++ b/subx/apps/subx-common.subx @@ -1187,10 +1187,10 @@ compute-width-of-slice: # s : (address slice) -> EAX : int e8/call has-metadata?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . if EAX: return 4 - 3d/compare-EAX-and 1/imm32 + # . if (EAX != 0) return 4 + 3d/compare-EAX-and 0/imm32 b8/copy-to-EAX 4/imm32 # ZF is set, so we can overwrite EAX now - 74/jump-if-equal $compute-width-of-slice:end/disp8 + 75/jump-if-not-equal $compute-width-of-slice:end/disp8 # if (has-metadata?(word, "disp32")) return 4 # . EAX = has-metadata?(word, "disp32") # . . push args @@ -1200,10 +1200,10 @@ compute-width-of-slice: # s : (address slice) -> EAX : int e8/call has-metadata?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . if EAX: return 4 - 3d/compare-EAX-and 1/imm32 + # . if (EAX != 0) return 4 + 3d/compare-EAX-and 0/imm32 b8/copy-to-EAX 4/imm32 # ZF is set, so we can overwrite EAX now - 74/jump-if-equal $compute-width-of-slice:end/disp8 + 75/jump-if-not-equal $compute-width-of-slice:end/disp8 # if (has-metadata?(word, "imm16")) return 2 # . EAX = has-metadata?(word, "imm16") # . . push args @@ -1213,10 +1213,10 @@ compute-width-of-slice: # s : (address slice) -> EAX : int e8/call has-metadata?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . if EAX: return 2 - 3d/compare-EAX-and 1/imm32 + # . if (EAX != 0) return 2 + 3d/compare-EAX-and 0/imm32 b8/copy-to-EAX 2/imm32 # ZF is set, so we can overwrite EAX now - 74/jump-if-equal $compute-width-of-slice:end/disp8 + 75/jump-if-not-equal $compute-width-of-slice:end/disp8 # if (has-metadata?(word, "disp16")) return 2 # . EAX = has-metadata?(word, "disp16") # . . push args @@ -1226,10 +1226,10 @@ compute-width-of-slice: # s : (address slice) -> EAX : int e8/call has-metadata?/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - # . if EAX: return 2 - 3d/compare-EAX-and 1/imm32 + # . if (EAX != 0) return 2 + 3d/compare-EAX-and 0/imm32 b8/copy-to-EAX 2/imm32 # ZF is set, so we can overwrite EAX now - 74/jump-if-equal $compute-width-of-slice:end/disp8 + 75/jump-if-not-equal $compute-width-of-slice:end/disp8 # otherwise return 1 b8/copy-to-EAX 1/imm32 $compute-width-of-slice:end: diff --git a/subx/apps/survey b/subx/apps/survey index 1963710f..9979e237 100755 Binary files a/subx/apps/survey and b/subx/apps/survey differ -- cgit 1.4.1-2-gfad0