From 4bbd5b52bbc480e890fb55ff955953e420a68c25 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Sat, 7 May 2016 01:37:44 +0000 Subject: [PATCH] removed unneeded text --- stix/configure | 22 --------------- stix/configure.ac | 10 ------- stix/kernel/Apex.st | 40 ++++++++++++++++++++++++++- stix/kernel/Class.st | 9 +++++-- stix/kernel/Context.st | 8 +++--- stix/kernel/Stix.st | 6 +++++ stix/kernel/test-011.st | 19 +++++++++++-- stix/lib/comp.c | 1 + stix/lib/exec.c | 60 +++++------------------------------------ stix/lib/stix-cfg.h.in | 12 --------- stix/lib/stix-dos.h | 20 -------------- stix/lib/stix-mac.h | 5 ---- stix/lib/stix-msw.h | 19 ------------- stix/lib/stix-os2.h | 9 ------- 14 files changed, 81 insertions(+), 159 deletions(-) diff --git a/stix/configure b/stix/configure index bc497ef..83bb132 100755 --- a/stix/configure +++ b/stix/configure @@ -19835,28 +19835,6 @@ cat >>confdefs.h <<_ACEOF _ACEOF - -cat >>confdefs.h <<_ACEOF -#define STIX_SIZEOF_STRUCT_SOCKADDR_IN ${ac_cv_sizeof_struct_sockaddr_in} -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define STIX_SIZEOF_STRUCT_SOCKADDR_IN6 ${ac_cv_sizeof_struct_sockaddr_in6} -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define STIX_SIZEOF_STRUCT_SOCKADDR_UN ${ac_cv_sizeof_struct_sockaddr_un} -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define STIX_SIZEOF_SOCKLEN_T ${ac_cv_sizeof_socklen_t} -_ACEOF - - - stix_package_version_major="`echo ${PACKAGE_VERSION} | cut -d. -f1`" stix_package_version_minor="`echo ${PACKAGE_VERSION} | cut -d. -f2`" stix_package_version_patch="`echo ${PACKAGE_VERSION} | cut -d. -f3`" diff --git a/stix/configure.ac b/stix/configure.ac index ec74e8d..3958bca 100644 --- a/stix/configure.ac +++ b/stix/configure.ac @@ -1,9 +1,5 @@ dnl AC_PREREQ([2.67]) -dnl Make sure you change the version information -dnl in include/stix/conf_*.h whenever you change the version -dnl here. Those files don't depend on autoconf, thus requiring -dnl manual change. AC_INIT([stix],[0.6.0],[Chung, Hyung-Hwan (hyunghwan.chung@gmail.com)],[],[http://code.abiyo.net/@stix]) AC_CONFIG_HEADER([lib/stix-cfg.h]) @@ -361,12 +357,6 @@ AC_DEFINE_UNQUOTED(STIX_SIZEOF_OFF64_T, ${ac_cv_sizeof_off64_t}, [sizeof(off64_t AC_DEFINE_UNQUOTED(STIX_SIZEOF_MBSTATE_T, ${ac_cv_sizeof_mbstate_t}, [sizeof(mbstate_t)]) AC_DEFINE_UNQUOTED(STIX_MBLEN_MAX, ${ax_cv_numvalof_MB_LEN_MAX}, [MB_LEN_MAX]) -AC_DEFINE_UNQUOTED(STIX_SIZEOF_STRUCT_SOCKADDR_IN, ${ac_cv_sizeof_struct_sockaddr_in}, [sizeof(struct sockaddr_in)]) -AC_DEFINE_UNQUOTED(STIX_SIZEOF_STRUCT_SOCKADDR_IN6, ${ac_cv_sizeof_struct_sockaddr_in6}, [sizeof(struct sockaddr_in6)]) -AC_DEFINE_UNQUOTED(STIX_SIZEOF_STRUCT_SOCKADDR_UN, ${ac_cv_sizeof_struct_sockaddr_un}, [sizeof(struct sockaddr_un)]) -AC_DEFINE_UNQUOTED(STIX_SIZEOF_SOCKLEN_T, ${ac_cv_sizeof_socklen_t}, [sizeof(socklen_t)]) - - stix_package_version_major="`echo ${PACKAGE_VERSION} | cut -d. -f1`" stix_package_version_minor="`echo ${PACKAGE_VERSION} | cut -d. -f2`" stix_package_version_patch="`echo ${PACKAGE_VERSION} | cut -d. -f3`" diff --git a/stix/kernel/Apex.st b/stix/kernel/Apex.st index 34b5096..30cce85 100644 --- a/stix/kernel/Apex.st +++ b/stix/kernel/Apex.st @@ -201,7 +201,45 @@ ^true. } - + ## ------------------------------------------------------- + ## ------------------------------------------------------- + + #method(#class) inheritsFrom: aClass + { + | c | + c := self superclass. + [c notNil] whileTrue: [ + [ c == aClass ] ifTrue: [^true]. + c := c superclass. + ]. + ^false + } + + #method(#class) isMemberOf: aClass + { + ## a class object is an instance of Class + ## but Class inherits from Apex. On the other hand, + ## most of ordinary classes are under Object again under Apex. + ## special consideration is required here. + ^aClass == Class + } + + #method(#class) isKindOf: aClass + { + ^(self isMemberOf: aClass) or: [self inheritsFrom: aClass]. + } + + #method isMemberOf: aClass + { + ^self class == aClass + } + + #method isKindOf: aClass + { + ^(self isMemberOf: aClass) or: [self class inheritsFrom: aClass]. + } + + ## ------------------------------------------------------- ## ------------------------------------------------------- " diff --git a/stix/kernel/Class.st b/stix/kernel/Class.st index f6eb062..4b51a32 100644 --- a/stix/kernel/Class.st +++ b/stix/kernel/Class.st @@ -14,6 +14,11 @@ ^self. } + + ## ######################################################################## + ## most of the following methods can actuall become class methods of Apex. + ## ######################################################################## + #method name { ^self.name @@ -31,7 +36,7 @@ ^self.spec bitShift: -7 } - #method inheritsFrom: aSuperclass + "#method inheritsFrom: aSuperclass { | c | c := self superclass. @@ -40,5 +45,5 @@ c := c superclass. ]. ^false - } + }" } diff --git a/stix/kernel/Context.st b/stix/kernel/Context.st index ce9657f..847102a 100644 --- a/stix/kernel/Context.st +++ b/stix/kernel/Context.st @@ -56,7 +56,7 @@ ^self.method preambleCode == 10. } - #method findExceptionHandlerBlock: anException + #method findExceptionHandlerBlock: anExceptionClass { ## for this to work, self must be an exception handler context. ## For a single on:do: call, @@ -70,7 +70,7 @@ bound := self basicSize - 1. 8 to: bound by: 2 do: [ :i | exc := self basicAt: i. - ((anException == exc) or: [anException inheritsFrom: exc]) ifTrue: [^self basicAt: (i + 1)]. + ((anExceptionClass == exc) or: [anExceptionClass inheritsFrom: exc]) ifTrue: [^self basicAt: (i + 1)]. ] ]. ^nil. @@ -415,13 +415,13 @@ thisContext isExceptionHandlerContext dump. ctx := thisContext. [ctx notNil] whileTrue: [ (ctx class == MethodContext) - ifTrue: [ (ctx method owner name, ' - ', ctx method name) dump ]. + ifTrue: [ (ctx method owner name, '>>', ctx method name) dump ]. ## TODO: include blockcontext??? ctx := ctx sender. ]. PrimitiveFailureException signal: 'PRIMITIVE FAILED'. } - + #method(#class) cannotInstantiate { Exception signal: 'Cannot instantiate'. diff --git a/stix/kernel/Stix.st b/stix/kernel/Stix.st index 6b38864..8663927 100644 --- a/stix/kernel/Stix.st +++ b/stix/kernel/Stix.st @@ -5,6 +5,8 @@ #include 'Boolean.st'. +######################################################################################### + #class Error(Object) { #method(#class) signal: aString @@ -350,3 +352,7 @@ f isNil ifTrue: [ self error: 'No such function' ]. } + +######################################################################################### + +## #include 'Console.st' diff --git a/stix/kernel/test-011.st b/stix/kernel/test-011.st index ec3a41e..293b9d6 100644 --- a/stix/kernel/test-011.st +++ b/stix/kernel/test-011.st @@ -171,13 +171,28 @@ ## self test4. ## self test5. - ## self test11. + self test11. ## self test12. ##100 timesRepeat: ['>>>>> END OF MAIN' dump]. + +"(Exception isKindOf: Apex) dump. +(Exception isMemberOf: Apex) dump. +(Exception isMemberOf: Class) dump. +(1 isMemberOf: SmallInteger) dump. +(1 isKindOf: Integer) dump. +(1 isKindOf: Class) dump. +(1 isKindOf: Apex) dump. +(Exception isKindOf: Class) dump. +(Exception isKindOf: Apex) dump. +(Exception isKindOf: Object) dump. +(Exception isKindOf: (Apex new)) dump. +(Exception isKindOf: (Object new)) dump." + + '@@@@@@@@@@@@@@@@@@@@@@@@@@@@' dump. ## the following line(return:to:) must cause primitive failure... - [ Processor return: 10 to: 20. ] on: Exception do: [:ex | ex messageText dump]. + ##[ Processor return: 10 to: 20. ] on: Exception do: [:ex | ex messageText dump]. ##[ Processor return: 10 to: 20. ] ## on: PrimitiveFailureException do: [:ex | 'PRIMITIVE FAILURE CAUGHT HERE HERE HERE' dump] diff --git a/stix/lib/comp.c b/stix/lib/comp.c index c95a7c9..ffc47ae 100644 --- a/stix/lib/comp.c +++ b/stix/lib/comp.c @@ -3717,6 +3717,7 @@ static int compile_keyword_message (stix_t* stix, int to_super) saved_kwsel_loc = stix->c->tok.loc; saved_kwsel_len = stix->c->mth.kwsels.len; +/* TODO: optimization for ifTrue: ifFalse: whileTrue: whileFalse .. */ do { kw = stix->c->tok.name; diff --git a/stix/lib/exec.c b/stix/lib/exec.c index 70f6c85..7573b4c 100644 --- a/stix/lib/exec.c +++ b/stix/lib/exec.c @@ -1653,51 +1653,6 @@ printf ("PRIMITVE VALUE RECEIVER IS NOT A BLOCK CONTEXT\n"); return 1; } -static int prim_block_on_do (stix_t* stix, stix_ooi_t nargs) -{ - int x; - stix_oop_oop_t exarr; - stix_oop_context_t blkctx; - stix_ooi_t i, j; - - STIX_ASSERT (nargs >= 2); - - if ((stix_oow_t)nargs & 1) return 0; /* it expects even number of arguments */ - - //for (i = 0; i < nargs; i += 2) - //{ - // exblk = ACTIVE_STACK_GET(stix, stix->sp); - // excls = ACTIVE_STACK_GET(stix, stix->sp - 1); - //} - - x = __block_value (stix, nargs, 0, 0, &blkctx); - if (x <= 0) return x; /* hard failure and soft failure */ - - /* TOOD: implement zero-cost exception handling. - * this implementation requires allocation of a new array - * every time on:do: is executed */ - - stix_pushtmp (stix, (stix_oop_t*)&blkctx); - exarr = (stix_oop_oop_t)stix_instantiate (stix, stix->_array, STIX_NULL, nargs); - stix_poptmp (stix); - if (!exarr) return -1; /* hard failure */ /* TOOD: can't this be treated as a soft failure? */ - - for (i = nargs, j = 0; i > 0;) - { - --i; - exarr->slot[j++] = ACTIVE_STACK_GET(stix, stix->sp - i); - --i; - exarr->slot[j++] = ACTIVE_STACK_GET(stix, stix->sp - i); - } - - -#if defined(STIX_DEBUG_EXEC_001) -printf ("<> SP=%ld\n", (long int)stix->sp); -#endif - SWITCH_ACTIVE_CONTEXT (stix, (stix_oop_context_t)blkctx); - return 1; -} - static int prim_process_resume (stix_t* stix, stix_ooi_t nargs) { stix_oop_t rcv; @@ -2595,15 +2550,14 @@ static prim_t primitives[] = { 2, 2, prim_basic_at_put, "_basic_at_put" }, - { 0, MAX_NARGS, prim_block_value, "_block_value" }, - { 0, MAX_NARGS, prim_block_new_process, "_block_new_process" }, - { 2, MAX_NARGS, prim_block_on_do, "_block_on_do" }, + { 0, MAX_NARGS, prim_block_value, "_block_value" }, + { 0, MAX_NARGS, prim_block_new_process, "_block_new_process" }, - { 0, 0, prim_process_resume, "_process_resume" }, - { 0, 0, prim_process_terminate, "_process_terminate" }, - { 0, 0, prim_process_yield, "_process_yield" }, - { 0, 0, prim_semaphore_signal, "_semaphore_signal" }, - { 0, 0, prim_semaphore_wait, "_semaphore_wait" }, + { 0, 0, prim_process_resume, "_process_resume" }, + { 0, 0, prim_process_terminate, "_process_terminate" }, + { 0, 0, prim_process_yield, "_process_yield" }, + { 0, 0, prim_semaphore_signal, "_semaphore_signal" }, + { 0, 0, prim_semaphore_wait, "_semaphore_wait" }, { 1, 1, prim_processor_schedule, "_processor_schedule" }, { 2, 3, prim_processor_add_timed_semaphore, "_processor_add_timed_semaphore" }, diff --git a/stix/lib/stix-cfg.h.in b/stix/lib/stix-cfg.h.in index 4127223..a20c39d 100644 --- a/stix/lib/stix-cfg.h.in +++ b/stix/lib/stix-cfg.h.in @@ -480,18 +480,6 @@ /* sizeof(short) */ #undef STIX_SIZEOF_SHORT -/* sizeof(socklen_t) */ -#undef STIX_SIZEOF_SOCKLEN_T - -/* sizeof(struct sockaddr_in) */ -#undef STIX_SIZEOF_STRUCT_SOCKADDR_IN - -/* sizeof(struct sockaddr_in6) */ -#undef STIX_SIZEOF_STRUCT_SOCKADDR_IN6 - -/* sizeof(struct sockaddr_un) */ -#undef STIX_SIZEOF_STRUCT_SOCKADDR_UN - /* sizeof(void*) */ #undef STIX_SIZEOF_VOID_P diff --git a/stix/lib/stix-dos.h b/stix/lib/stix-dos.h index b5d1fb3..68b3957 100644 --- a/stix/lib/stix-dos.h +++ b/stix/lib/stix-dos.h @@ -56,11 +56,6 @@ # define STIX_SIZEOF_MBSTATE_T STIX_SIZEOF_LONG # define STIX_MBLEN_MAX 8 - /* these two have only to be large enough */ -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN 32 -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN6 64 -# define STIX_SIZEOF_SOCKLEN_T 4 - #elif defined(__WATCOMC__) && !defined(__386__) # define STIX_SIZEOF_CHAR 1 # define STIX_SIZEOF_SHORT 2 @@ -86,11 +81,6 @@ # define STIX_SIZEOF_MBSTATE_T STIX_SIZEOF_LONG # define STIX_MBLEN_MAX 8 - /* these two have only to be large enough */ -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN 32 -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN6 64 -# define STIX_SIZEOF_SOCKLEN_T 4 - #elif defined(__TURBOC__) /* TODO: be more version specific wchar_t may be available in newer BCC */ # define STIX_SIZEOF_CHAR 1 @@ -117,11 +107,6 @@ # define STIX_SIZEOF_MBSTATE_T STIX_SIZEOF_LONG # define STIX_MBLEN_MAX 8 - /* these two have only to be large enough */ -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN 32 -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN6 64 -# define STIX_SIZEOF_SOCKLEN_T 4 - #elif defined(__ZTC__) && defined(DOS386) /* Zortech in DOSX 386 mode (ztc -mx) */ @@ -149,11 +134,6 @@ # define STIX_SIZEOF_MBSTATE_T STIX_SIZEOF_LONG # define STIX_MBLEN_MAX 8 - /* these two have only to be large enough */ -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN 32 -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN6 64 -# define STIX_SIZEOF_SOCKLEN_T 4 - #else # error Define the size of various data types. #endif diff --git a/stix/lib/stix-mac.h b/stix/lib/stix-mac.h index cc404a5..6583a54 100644 --- a/stix/lib/stix-mac.h +++ b/stix/lib/stix-mac.h @@ -52,11 +52,6 @@ # define STIX_SIZEOF_MBSTATE_T STIX_SIZEOF_LONG # define STIX_MBLEN_MAX 16 - /* these two have only to be large enough */ -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN 32 -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN6 64 -# define STIX_SIZEOF_SOCKLEN_T 4 - #else # error Define the size of various data types. #endif diff --git a/stix/lib/stix-msw.h b/stix/lib/stix-msw.h index 77be468..6f6ee0d 100644 --- a/stix/lib/stix-msw.h +++ b/stix/lib/stix-msw.h @@ -76,11 +76,6 @@ _M_X64 x64 platform # define STIX_SIZEOF_MBSTATE_T STIX_SIZEOF_LONG # define STIX_MBLEN_MAX 16 - /* these two have only to be large enough */ -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN 32 -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN6 64 -# define STIX_SIZEOF_SOCKLEN_T 4 - #elif defined(__GNUC__) || defined(__DMC__) || defined(__POCC__) # define STIX_SIZEOF_CHAR 1 # define STIX_SIZEOF_SHORT 2 @@ -110,10 +105,6 @@ _M_X64 x64 platform # define STIX_SIZEOF_MBSTATE_T STIX_SIZEOF_LONG # define STIX_MBLEN_MAX 16 - /* these two have only to be large enough */ -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN 32 -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN6 64 - #elif defined(_MSC_VER) # define STIX_SIZEOF_CHAR 1 # define STIX_SIZEOF_SHORT 2 @@ -147,11 +138,6 @@ _M_X64 x64 platform # define STIX_SIZEOF_MBSTATE_T STIX_SIZEOF_LONG # define STIX_MBLEN_MAX 8 - /* these two have only to be large enough */ -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN 32 -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN6 64 -# define STIX_SIZEOF_SOCKLEN_T 4 - #elif defined(__BORLANDC__) # define STIX_SIZEOF_CHAR 1 @@ -182,11 +168,6 @@ _M_X64 x64 platform # define STIX_SIZEOF_MBSTATE_T STIX_SIZEOF_LONG # define STIX_MBLEN_MAX 8 - /* these two have only to be large enough */ -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN 32 -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN6 64 -# define STIX_SIZEOF_SOCKLEN_T 4 - #else # error Define the size of various data types. #endif diff --git a/stix/lib/stix-os2.h b/stix/lib/stix-os2.h index daa26c2..0300a10 100644 --- a/stix/lib/stix-os2.h +++ b/stix/lib/stix-os2.h @@ -59,11 +59,6 @@ /* TODO: check the exact value */ # define STIX_MBLEN_MAX 8 - /* these two have only to be large enough */ -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN 32 -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN6 64 -# define STIX_SIZEOF_SOCKLEN_T 4 - #elif defined(__BORLANDC__) # define STIX_SIZEOF_CHAR 1 # define STIX_SIZEOF_SHORT 2 @@ -88,10 +83,6 @@ # define STIX_SIZEOF_MBSTATE_T STIX_SIZEOF_LONG # define STIX_MBLEN_MAX 8 -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN 32 -# define STIX_SIZEOF_STRUCT_SOCKADDR_IN6 64 -# define STIX_SIZEOF_SOCKLEN_T 4 - #else # error Define the size of various data types. #endif