From 1dff630fdd39b23f2cff90de2dd06cd207d73fbf Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Thu, 4 May 2017 05:22:45 +0000 Subject: [PATCH] changed how to calculate the mid point in a binary search loop --- moo/kernel/Except.moo | 11 +++++++++++ moo/lib/moo.c | 9 ++++++--- moo/lib/moo.h | 4 ++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/moo/kernel/Except.moo b/moo/kernel/Except.moo index abf8009..9479c6e 100644 --- a/moo/kernel/Except.moo +++ b/moo/kernel/Except.moo @@ -8,6 +8,17 @@ class Exception(Apex) { var signalContext, handlerContext, messageText. +(* +TODO: can i convert 'thisProcess primError' to a relevant exception? + var(#class) primExceptTable. + + method(#class) forPrimitiveError: no + { + ^self.primExceptTable at: no + } +*) + + method(#class) signal { ^self new signal diff --git a/moo/lib/moo.c b/moo/lib/moo.c index ed9a2ea..268f416 100644 --- a/moo/lib/moo.c +++ b/moo/lib/moo.c @@ -804,13 +804,17 @@ int moo_genpfmethods (moo_t* moo, moo_mod_t* mod, moo_oop_class_t _class, const moo_pfbase_t* moo_findpfbase (moo_t* moo, moo_pfinfo_t* pfinfo, moo_oow_t pfcount, const moo_ooch_t* name, moo_oow_t namelen) { - int left, right, mid, n; + moo_oow_t left, right, mid; + int n; + + /* binary search */ left = 0; right = pfcount - 1; while (left <= right) { - mid = (left + right) / 2; + /*mid = (left + right) / 2;*/ + mid = left + ((right - left) / 2); n = moo_compoocharsoocstr (name, namelen, pfinfo[mid].mthname); if (n < 0) right = mid - 1; @@ -895,7 +899,6 @@ void* moo_getobjtrailer (moo_t* moo, moo_oop_t obj, moo_oow_t* size) return MOO_OBJ_GET_TRAILER_BYTE(obj); } - moo_oop_t moo_findclass (moo_t* moo, moo_oop_set_t nsdic, const moo_ooch_t* name) { moo_oop_association_t ass; diff --git a/moo/lib/moo.h b/moo/lib/moo.h index b546ec2..d4e0528 100644 --- a/moo/lib/moo.h +++ b/moo/lib/moo.h @@ -1281,8 +1281,8 @@ enum moo_synerrnum_t MOO_SYNERR_CLASSDUPL, /* duplicate class */ MOO_SYNERR_CLASSCONTRA, /* contradictory class */ MOO_SYNERR_CLASSNAMEINVAL, /* wrong class name */ - MOO_SYNERR_CLASSTRSIZE, /* non-pointer class inheriting a superclass with trailer size set */ - MOO_SYNERR_CLASSFINAL, /* cannot inherit a #final class */ + MOO_SYNERR_CLASSTRSIZE, /* non-pointer class now allowed to inherit a superclass with trailer size set */ + MOO_SYNERR_CLASSFINAL, /* now allowed to inherit a #final class */ MOO_SYNERR_VARDCLBANNED, /* variable declaration not allowed */ MOO_SYNERR_MODIFIER, /* modifier expected */ MOO_SYNERR_MODIFIERINVAL, /* wrong modifier */