Beispiel #1
0
//
//  RL_Init: C
// 
// Initialize the REBOL interpreter.
// 
// Returns:
//     Zero on success, otherwise an error indicating that the
//     host library is not compatible with this release.
// Arguments:
//     rargs - REBOL command line args and options structure.
//         See the host-args.c module for details.
//     lib - the host lib (OS_ functions) to be used by REBOL.
//         See host-lib.c for details.
// Notes:
//     This function will allocate and initialize all memory
//     structures used by the REBOL interpreter. This is an
//     extensive process that takes time.
//
RL_API int RL_Init(REBARGS *rargs, void *lib)
{
    int marker;
    REBUPT bounds;
    const char *env_legacy = NULL;

    Host_Lib = cast(REBOL_HOST_LIB *, lib);

    if (Host_Lib->size < HOST_LIB_SIZE) return 1;
    if (((HOST_LIB_VER << 16) + HOST_LIB_SUM) != Host_Lib->ver_sum) return 2;

    bounds = (REBUPT)OS_CONFIG(1, 0);
    if (bounds == 0) bounds = (REBUPT)STACK_BOUNDS;

#ifdef OS_STACK_GROWS_UP
    Stack_Limit = (REBUPT)(&marker) + bounds;
#else
    if (bounds > (REBUPT) &marker) Stack_Limit = 100;
    else Stack_Limit = (REBUPT)&marker - bounds;
#endif

    Init_Core(rargs);

    GC_Active = TRUE; // Turn on GC
    if (rargs->options & RO_TRACE) {
        Trace_Level = 9999;
        Trace_Flags = 1;
    }

    return 0;
}
Beispiel #2
0
*/	RL_API int RL_Init(REBARGS *rargs, void *lib)
/*
**	Initialize the REBOL interpreter.
**
**	Returns:
**		Zero on success, otherwise an error indicating that the
**		host library is not compatible with this release.
**	Arguments:
**		rargs - REBOL command line args and options structure.
**			See the host-args.c module for details.
**		lib - the host lib (OS_ functions) to be used by REBOL.
**			See host-lib.c for details.
**	Notes:
**		This function will allocate and initialize all memory
**		structures used by the REBOL interpreter. This is an
**		extensive process that takes time.
**
***********************************************************************/
{
	int marker;
	REBUPT bounds;
	const char *env_legacy = NULL;

	Host_Lib = cast(REBOL_HOST_LIB *, lib);

	if (Host_Lib->size < HOST_LIB_SIZE) return 1;
	if (((HOST_LIB_VER << 16) + HOST_LIB_SUM) != Host_Lib->ver_sum) return 2;

	bounds = (REBUPT)OS_CONFIG(1, 0);
	if (bounds == 0) bounds = (REBUPT)STACK_BOUNDS;

#ifdef OS_STACK_GROWS_UP
	Stack_Limit = (REBUPT)(&marker) + bounds;
#else
	if (bounds > (REBUPT) &marker) Stack_Limit = 100;
	else Stack_Limit = (REBUPT)&marker - bounds;
#endif

	Init_Core(rargs);

	GC_Active = TRUE; // Turn on GC
	if (rargs->options & RO_TRACE) {
		Trace_Level = 9999;
		Trace_Flags = 1;
	}

	return 0;
}