fixed some minor build flaws

This commit is contained in:
hyunghwan.chung 2016-05-13 15:10:34 +00:00
parent 36a54fd29f
commit 801b6d92d4
14 changed files with 240 additions and 158 deletions

View File

@ -297,3 +297,23 @@
self class cannotInstantiate
}
}
#class Object(Apex)
{
}
#class UndefinedObject(Apex)
{
#method isNil
{
^true
}
#method notNil
{
^false.
}
}

View File

@ -1,63 +0,0 @@
#class(#pointer) Array(Collection)
{
#method size
{
^self basicSize.
}
#method ubound
{
^(self basicSize - 1).
}
#method at: anInteger
{
^self basicAt: anInteger.
}
#method at: anInteger put: aValue
{
^self basicAt: anInteger put: aValue.
}
#method first
{
^self at: 0.
}
#method last
{
^self at: (self ubound).
}
#method do: aBlock
{
0 to: (self ubound) do: [:i | aBlock value: (self at: i)].
}
#method copy: anArray
{
0 to: (anArray ubound) do: [:i | self at: i put: (anArray at: i) ].
}
}
#class(#character) String(Array)
{
#method , aString
{
## concatenate two strings.
## TOOD: make this a primitive for performance.
| newsize newstr self_ubound|
newsize := self basicSize + aString basicSize.
##newstr := self class basicNew: newsize.
newstr := String basicNew: newsize. ## TODO: redefine , for symbol... it's a work arouind... symbols are not contacated to a symbol at this moment.
self_ubound := self ubound.
0 to: self_ubound do: [:i | newstr at: i put: (self at: i)].
0 to: (aString ubound) do: [:i | newstr at: (i + self_ubound + 1) put: (aString at: i)].
^newstr
}
}
#class(#character) Symbol(String)
{
}

View File

@ -1,13 +0,0 @@
#class(#byte) ByteArray(Collection)
{
#method at: anInteger
{
^self basicAt: anInteger.
}
#method at: anInteger put: aValue
{
^self basicAt: anInteger put: aValue.
}
}

View File

@ -1,31 +0,0 @@
#class Set(Collection)
{
#dcl tally bucket.
}
#class SymbolSet(Set)
{
}
#class Dictionary(Set)
{
}
#class SystemDictionary(Dictionary)
{
}
#class Namespace(Set)
{
}
#class PoolDictionary(Set)
{
}
#class MethodDictionary(Dictionary)
{
}

View File

@ -1,3 +1,122 @@
#class Collection(Object)
{
}
## -------------------------------------------------------------------------------
#class(#pointer) Array(Collection)
{
#method size
{
^self basicSize.
}
#method ubound
{
^(self basicSize - 1).
}
#method at: anInteger
{
^self basicAt: anInteger.
}
#method at: anInteger put: aValue
{
^self basicAt: anInteger put: aValue.
}
#method first
{
^self at: 0.
}
#method last
{
^self at: (self ubound).
}
#method do: aBlock
{
0 to: (self ubound) do: [:i | aBlock value: (self at: i)].
}
#method copy: anArray
{
0 to: (anArray ubound) do: [:i | self at: i put: (anArray at: i) ].
}
}
## -------------------------------------------------------------------------------
#class(#character) String(Array)
{
#method , aString
{
## concatenate two strings.
## TOOD: make this a primitive for performance.
| newsize newstr self_ubound|
newsize := self basicSize + aString basicSize.
##newstr := self class basicNew: newsize.
newstr := String basicNew: newsize. ## TODO: redefine , for symbol... it's a work arouind... symbols are not contacated to a symbol at this moment.
self_ubound := self ubound.
0 to: self_ubound do: [:i | newstr at: i put: (self at: i)].
0 to: (aString ubound) do: [:i | newstr at: (i + self_ubound + 1) put: (aString at: i)].
^newstr
}
}
## -------------------------------------------------------------------------------
#class(#character) Symbol(String)
{
}
## -------------------------------------------------------------------------------
#class(#byte) ByteArray(Collection)
{
#method at: anInteger
{
^self basicAt: anInteger.
}
#method at: anInteger put: aValue
{
^self basicAt: anInteger put: aValue.
}
}
## -------------------------------------------------------------------------------
#class Set(Collection)
{
#dcl tally bucket.
}
#class SymbolSet(Set)
{
}
#class Dictionary(Set)
{
}
#class SystemDictionary(Dictionary)
{
}
#class Namespace(Set)
{
}
#class PoolDictionary(Set)
{
}
#class MethodDictionary(Dictionary)
{
}

View File

@ -1,4 +0,0 @@
#class Object(Apex)
{
}

View File

@ -1,6 +1,4 @@
#include 'Apex.st'.
#include 'Object.st'.
#include 'UndefinedObject.st'.
#include 'Class.st'.
#include 'Boolean.st'.
@ -249,9 +247,7 @@
#include 'Collection.st'.
#include 'Collection-ByteArray.st'.
#include 'Collection-Array.st'.
#include 'Collection-Set.st'.
## #include 'Collec~1.st'.
#class(#pointer) CompiledMethod(Object)
{

View File

@ -1,12 +0,0 @@
#class UndefinedObject(Apex)
{
#method isNil
{
^true
}
#method notNil
{
^false.
}
}

View File

@ -26,6 +26,12 @@
#include "stix-prv.h"
#if defined(_WIN32)
# include <windows.h>
#elif defined(__MSDOS__)
# include <time.h>
#else
/* TODO: remove this header after having changed clock_gettime() to a
* platform independent function */
# if defined(HAVE_TIME_H)
@ -35,9 +41,6 @@
# if defined(HAVE_SYS_TIME_H)
# include <sys/time.h>
# endif
#if defined(_WIN32)
# include <windows.h>
#endif
#define PROC_STATE_RUNNING 3
@ -189,7 +192,24 @@ static void vm_cleanup (stix_t* stix)
static STIX_INLINE void vm_gettime (stix_t* stix, stix_ntime_t* now)
{
#if defined(HAVE_CLOCK_GETTIME)
#if defined(__MSDOS__) && defined(_INTELC32_)
clock_t c;
/* TODO: handle overflow?? */
c = clock ();
now->sec = c / CLOCKS_PER_SEC;
#if (CLOCKS_PER_SEC == 1000)
now->nsec = STIX_MSEC_TO_NSEC(c % CLOCKS_PER_SEC);
#elif (CLOCKS_PER_SEC == 1000000L)
now->nsec = STIX_USEC_TO_NSEC(c % CLOCKS_PER_SEC);
#elif (CLOCKS_PER_SEC == 1000000000L)
now->nsec = (c % CLOCKS_PER_SEC);
#else
# error UNSUPPORTED CLOCKS_PER_SEC
#endif
printf ("%05ld %010ld\n", (long)now->sec, (long)now->nsec);
#elif defined(HAVE_CLOCK_GETTIME)
struct timespec ts;
#if defined(CLOCK_MONOTONIC)
clock_gettime (CLOCK_MONOTONIC, &ts);
@ -221,6 +241,26 @@ static STIX_INLINE void vm_sleep (stix_t* stix, const stix_ntime_t* dur)
Sleep (STIX_SECNSEC_TO_MSEC(dur->sec,dur->nsec));
}
#elif defined(__MSDOS__) && defined(_INTELC32_)
clock_t c;
c = clock ();
c += dur->sec * CLOCKS_PER_SEC;
#if (CLOCKS_PER_SEC == 1000)
c += STIX_NSEC_TO_MSEC(dur->nsec);
#elif (CLOCKS_PER_SEC == 1000000L)
c += STIX_NSEC_TO_USEC(dur->nsec);
#elif (CLOCKS_PER_SEC == 1000000000L)
c += dur->nsec;
#else
# error UNSUPPORTED CLOCKS_PER_SEC
#endif
/* TODO: handle clock overvlow */
/* TODO: check if there is abortion request or interrupt */
while (c > clock()) ;
#else
struct timespec ts;
ts.tv_sec = dur->sec;
@ -495,7 +535,7 @@ static void resume_process (stix_t* stix, stix_oop_process_t proc)
{
/* SUSPENED ---> RUNNING */
//printf ("TO RESUME PROCESS = %p %d SUSPENED ----> RUNNING\n", proc, (int)STIX_OOP_TO_SMOOI(proc->state));
/*printf ("TO RESUME PROCESS = %p %d SUSPENED ----> RUNNING\n", proc, (int)STIX_OOP_TO_SMOOI(proc->state));*/
STIX_ASSERT ((stix_oop_t)proc->prev == stix->_nil);
STIX_ASSERT ((stix_oop_t)proc->next == stix->_nil);
@ -530,11 +570,11 @@ static void suspend_process (stix_t* stix, stix_oop_process_t proc)
nrp = find_next_runnable_process (stix);
//printf ("TO SUSPEND...%p %d\n", proc, (int)STIX_OOP_TO_SMOOI(proc->state));
/*printf ("TO SUSPEND...%p %d\n", proc, (int)STIX_OOP_TO_SMOOI(proc->state));*/
if (nrp == proc)
{
/* no runnable process after suspension */
//printf ("NO RUNNABLE PROCESS AFTER SUPSENDISION\n");
/*printf ("NO RUNNABLE PROCESS AFTER SUPSENDISION\n");*/
sleep_active_process (stix, PROC_STATE_RUNNABLE);
unchain_from_processor (stix, proc, PROC_STATE_SUSPENDED);
@ -545,7 +585,7 @@ static void suspend_process (stix_t* stix, stix_oop_process_t proc)
}
else
{
//printf ("SWITCHING TO XXXXXXXXXXXXXXXXXXXXx\n");
/*printf ("SWITCHING TO XXXXXXXXXXXXXXXXXXXXx\n");*/
/* keep the unchained process at the runnable state for
* the immediate call to switch_to_process() below */
unchain_from_processor (stix, proc, PROC_STATE_RUNNABLE);
@ -617,7 +657,7 @@ static stix_oop_process_t signal_semaphore (stix_t* stix, stix_oop_semaphore_t s
if ((stix_oop_t)sem->waiting_head == stix->_nil)
{
//printf ("signal semaphore...1111\n");
/*printf ("signal semaphore...1111\n");*/
/* no process is waiting on this semaphore */
count = STIX_OOP_TO_SMOOI(sem->count);
count++;
@ -634,7 +674,7 @@ static stix_oop_process_t signal_semaphore (stix_t* stix, stix_oop_semaphore_t s
unchain_from_semaphore (stix, proc);
resume_process (stix, proc); /* TODO: error check */
//printf ("signal semaphore...2222 DONE -> resumed process -> proc state %d\n", (int)STIX_OOP_TO_SMOOI(proc->state));
/*printf ("signal semaphore...2222 DONE -> resumed process -> proc state %d\n", (int)STIX_OOP_TO_SMOOI(proc->state));*/
/* return the resumed process */
return proc;
@ -652,14 +692,14 @@ static void await_semaphore (stix_t* stix, stix_oop_semaphore_t sem)
/* it's already signalled */
count--;
sem->count = STIX_SMOOI_TO_OOP(count);
//printf (">>>>>>>>>>>>>> AWAIT SEMAPHORE - NO SUSPENDING ...................\n");
/*printf (">>>>>>>>>>>>>> AWAIT SEMAPHORE - NO SUSPENDING ...................\n");*/
}
else
{
/* not signaled. need to wait */
proc = stix->processor->active;
//printf (">>>>>>>>>>>>>> AWAIT SEMAPHORE - SUEPENDING ACTIVE PROCESS..........state=>[%d].....PROC %p\n", (int)STIX_OOP_TO_SMOOI(proc->state), proc);
/*printf (">>>>>>>>>>>>>> AWAIT SEMAPHORE - SUEPENDING ACTIVE PROCESS..........state=>[%d].....PROC %p\n", (int)STIX_OOP_TO_SMOOI(proc->state), proc);*/
/* suspend the active process */
suspend_process (stix, proc);
@ -668,7 +708,7 @@ static void await_semaphore (stix_t* stix, stix_oop_semaphore_t sem)
STIX_ASSERT (sem->waiting_tail == proc);
//printf (">>>>>>>>>>>>>> AWAIT SEMAPHORE - SUEPENDING ACTIVE PROCESS....XX......state=>[%d]..PROC %p\n", (int)STIX_OOP_TO_SMOOI(proc->state), proc);
/*printf (">>>>>>>>>>>>>> AWAIT SEMAPHORE - SUEPENDING ACTIVE PROCESS....XX......state=>[%d]..PROC %p\n", (int)STIX_OOP_TO_SMOOI(proc->state), proc);*/
STIX_ASSERT (stix->processor->active != proc);
}
}
@ -1824,12 +1864,12 @@ static int prim_processor_add_timed_semaphore (stix_t* stix, stix_ooi_t nargs)
/* TODO: make clock_gettime to be platform independent
*
* this code assumes that the monotonic clock returns a small value
* that can fit into a small integer, even after some addtions... */
* that can fit into a SmallInteger, even after some addtions... */
vm_gettime (stix, &now);
STIX_ADDNTIMESNS (&ft, &now, STIX_OOP_TO_SMOOI(sec), STIX_OOP_TO_SMOOI(nsec));
if (ft.sec < 0 || ft.sec > STIX_SMOOI_MAX)
{
/* soft error - cannot represent the e:xpiry time in
/* soft error - cannot represent the exxpiry time in
* a small integer. */
return 0;
}
@ -3805,7 +3845,7 @@ printf (">>>>>>>>>>>>>>>> METHOD RETURN FROM WITHIN A BLOCK. NON-LOCAL RETURN..
{
/* the sender of the intial context is nil.
* use this fact to tell an initial context from a normal context. */
STIX_ASSERT (stix->active_context->receiver_or_source == stix->_nil);
/* STIX_ASSERT (stix->active_context->receiver_or_source == stix->_nil);*/
/* when sender is nil, the following condition must be true.
* but it's not always true the other way around */

View File

@ -65,7 +65,7 @@ void* stix_allocheapmem (stix_t* stix, stix_heap_t* heap, stix_oow_t size)
{
stix_uint8_t* ptr;
//printf ("heap ptr %p %p %lld %lld\n", heap->ptr, heap->limit, (long long int)size, (long long int)(heap->limit - heap->ptr));
/*printf ("heap ptr %p %p %lld %lld\n", heap->ptr, heap->limit, (long long int)size, (long long int)(heap->limit - heap->ptr));*/
/* check the heap size limit */
if (heap->ptr >= heap->limit || heap->limit - heap->ptr < size)
{

View File

@ -611,6 +611,11 @@ struct stix_cmgr_t
/* =========================================================================
* COMPILER FEATURE TEST MACROS
* =========================================================================*/
#if defined(_INTELC32_) && !defined(__has_builtin)
/* intel c code builder 1.0 ended up with an error without this override */
#define __has_builtin(x) 0
#endif
#if defined(__has_builtin)
#if __has_builtin(__builtin_ctz)
#define STIX_HAVE_BUILTIN_CTZ

View File

@ -134,6 +134,33 @@
# define STIX_SIZEOF_MBSTATE_T STIX_SIZEOF_LONG
# define STIX_MBLEN_MAX 8
#elif defined(_INTELC32_)
/* Intel C Code Builder 1.0 */
# define STIX_SIZEOF_CHAR 1
# define STIX_SIZEOF_SHORT 2
# define STIX_SIZEOF_INT 4
# define STIX_SIZEOF_LONG 4
# define STIX_SIZEOF_LONG_LONG 0
# define STIX_SIZEOF_VOID_P 4
# define STIX_SIZEOF_FLOAT 4
# define STIX_SIZEOF_DOUBLE 8
# define STIX_SIZEOF_LONG_DOUBLE 8
# define STIX_SIZEOF_WCHAR_T 1
# define STIX_SIZEOF___INT8 0
# define STIX_SIZEOF___INT16 0
# define STIX_SIZEOF___INT32 0
# define STIX_SIZEOF___INT64 0
# define STIX_SIZEOF___INT128 0
# define STIX_SIZEOF_OFF64_T 0
# define STIX_SIZEOF_OFF_T 4
# define STIX_SIZEOF_MBSTATE_T STIX_SIZEOF_LONG
# define STIX_MBLEN_MAX 8
#else
# error Define the size of various data types.
#endif

View File

@ -54,7 +54,7 @@
/* this is for gc debugging */
/*#define STIX_DEBUG_PROCESSOR*/
#define STIX_DEBUG_GC_001
/*#define STIX_DEBUG_GC_001*/
/*#define STIX_DEBUG_GC_002*/
#define STIX_DEBUG_COMP_001
/*#define STIX_DEBUG_COMP_002*/
@ -96,14 +96,12 @@
# else
# define STIX_MEMCMP(dst,src,size) memcmp(dst,src,size)
# endif
#elif defined(__GNUC__) && (__GNUC__ >= 3 || (defined(__GNUC_MINOR) && __GNUC__ == 2 && __GNUC_MINOR__ >= 91))
/* gcc 2.91 or higher */
# define STIX_MEMSET(dst,src,size) __builtin_memset(dst,src,size)
# define STIX_MEMCPY(dst,src,size) __builtin_memcpy(dst,src,size)
# define STIX_MEMMOVE(dst,src,size) __builtin_memmove(dst,src,size)
# define STIX_MEMCMP(dst,src,size) __builtin_memcmp(dst,src,size)
#else
# define STIX_MEMSET(dst,src,size) memset(dst,src,size)
# define STIX_MEMCPY(dst,src,size) memcpy(dst,src,size)

View File

@ -88,7 +88,7 @@ enum stix_trait_t
STIX_NOGC = (1 << 0),
/* wait for running process when exiting from the main method */
STIX_AWAIT_PROCS = (1 << 1),
STIX_AWAIT_PROCS = (1 << 1)
};
typedef enum stix_trait_t stix_trait_t;
@ -204,7 +204,7 @@ enum stix_obj_type_t
STIX_OBJ_TYPE_CHAR,
STIX_OBJ_TYPE_BYTE,
STIX_OBJ_TYPE_HALFWORD,
STIX_OBJ_TYPE_WORD,
STIX_OBJ_TYPE_WORD
/*
STIX_OBJ_TYPE_UINT8,