Exemple #1
0
    String exception :: stack_trace () const
    {
        count_t depth = stk . size () / sizeof ( func_loc_t );

        if ( stk . size () == ( U64 ) 0 )
            return CONST_STRING ( "<no-stack>" );

        if ( rsrc == 0 )
            return CONST_STRING ( "<no-mem>" );

        StringBuffer sb;
        Array < const func_loc_t > a = stk;

        for ( count_t i = 0; i < depth; ++ i )
        {
            const func_loc_t & loc = a [ i ];

            ConstString m ( loc . mod, strlen ( loc . mod ) );
            ConstString f ( loc . file, strlen ( loc . file ) );
            ConstString x ( loc . ext, strlen ( loc . ext ) );
            String fn ( extract_method_name ( loc . func ) );
            //const_str_t fn ( loc . func, strlen ( loc . func ) );

            if ( i == 0 )
                sb . append ( "  %s/%s.%s:%u %s\n", & m, & f, & x, lineno, & fn );
            else
                sb . append ( "  %s/%s.%s %s\n", & m, & f, & x, & fn );
        }

        // this is optional...
        sb . trim_eoln ();

        return sb . to_str ();
    }
Exemple #2
0
PARROT_INLINE
static int
is_invokable(PARROT_INTERP, ARGIN(PMC*sub_obj)) /* HEADERIZER SKIP */
{
    if (VTABLE_isa(interp, sub_obj, CONST_STRING(interp, "Sub")))
        return 1;
    else
        return VTABLE_does(interp, sub_obj, CONST_STRING(interp, "invokable"));
}
Exemple #3
0
static void
callback_CD(PARROT_INTERP, ARGIN(char *external_data), ARGMOD(PMC *user_data))
{
    ASSERT_ARGS(callback_CD)

    PMC *passed_interp;       /* the interp that originated the CB */
    PMC *passed_synchronous;  /* flagging synchronous execution */
    int synchronous = 0;      /* cb is hitting this sub somewhen
                               * inmidst, or not */
    STRING *sc;
    /*
     * 3) check interpreter ...
     */
    sc = CONST_STRING(interp, "_interpreter");
    passed_interp = Parrot_pmc_getprop(interp, user_data, sc);
    if (VTABLE_get_pointer(interp, passed_interp) != interp)
        PANIC(interp, "callback gone to wrong interpreter");

    sc = CONST_STRING(interp, "_synchronous");
    passed_synchronous = Parrot_pmc_getprop(interp, user_data, sc);
    if (!PMC_IS_NULL(passed_synchronous) &&
            VTABLE_get_bool(interp, passed_synchronous))
        synchronous = 1;

    /*
     * 4) check if the call_back is synchronous:
     *    - if yes we are inside the NCI call
     *      we could run the Sub immediately now (I think)
     *    - if no, and that's always safe, post a callback event
     */

    if (synchronous) {
        /*
         * just call the sub
         */
        Parrot_run_callback(interp, user_data, external_data);
    }
    else {
        /*
         * create a CB_EVENT, put user_data and data inside and finito
         *
         * *if* this function is finally no void, i.e. the calling
         * C program awaits a return result from the callback,
         * then wait for the CB_EVENT_xx to finish and return the
         * result
         */
        PMC * const callback = Parrot_pmc_new(interp, enum_class_Callback);
        Parrot_Callback_attributes * const cb_data = PARROT_CALLBACK(callback);
        cb_data->user_data     = user_data;
        cb_data->external_data = (PMC*) external_data;

        Parrot_cx_schedule_immediate(interp, callback);
    }
}
Exemple #4
0
	void Player::initializeRenderResources()
	{
		m_debugText = NODE_SERVICE(m_serviceProvider)->
			createNodeT<TextField *>( CONST_STRING( m_serviceProvider, TextField ) );

		m_debugText->setFontName( STRINGIZE_STRING_LOCAL(m_serviceProvider, "__CONSOLE_FONT__") );
		m_debugText->setTextID( STRINGIZE_STRING_LOCAL(m_serviceProvider, "__ID_TEXT_CONSOLE") );
		m_debugText->setLocalColor( ColourValue( 1.0, 0.0, 0.0, 1.0 ) );
		m_debugText->enable();

		const Resolution & contentResolution = APPLICATION_SERVICE( m_serviceProvider )
			->getContentResolution();

		mt::vec2f cr;
		contentResolution.calcSize( cr );
		Viewport vp( 0.f, 0.f, cr.x, cr.y );

		m_camera2D = NODE_SERVICE( m_serviceProvider )
			->createNodeT<RenderCameraOrthogonal *>( CONST_STRING( m_serviceProvider, RenderCameraOrthogonal ) );

		m_camera2D->setOrthogonalViewport( vp );
				
		m_camera2D->enable();

		this->setRenderCamera( m_camera2D );

		m_viewport2D = NODE_SERVICE( m_serviceProvider )
			->createNodeT<RenderViewport *>( CONST_STRING( m_serviceProvider, RenderViewport ) );

		m_viewport2D->setViewport( vp );
		m_viewport2D->enable();

		this->setRenderViewport( m_viewport2D );

		m_arrowCamera2D = NODE_SERVICE( m_serviceProvider )
			->createNodeT<RenderCameraOrthogonal *>( CONST_STRING( m_serviceProvider, RenderCameraOrthogonal ) );

		m_arrowCamera2D->setOrthogonalViewport( vp );
		m_arrowCamera2D->enable();

		if( m_arrow != nullptr )
		{
			m_arrow->setRenderCamera( m_arrowCamera2D );
			m_arrow->setRenderViewport( m_renderViewport );
			m_arrow->setRenderClipplane( m_renderClipplane );
		}
		
		m_debugCamera2D = NODE_SERVICE( m_serviceProvider )
			->createNodeT<RenderCameraOrthogonal *>( CONST_STRING( m_serviceProvider, RenderCameraOrthogonal ) );

		m_debugCamera2D->setOrthogonalViewport( vp );

		m_debugCamera2D->enable();
	}
Exemple #5
0
PARROT_INLINE
PARROT_CANNOT_RETURN_NULL
PARROT_WARN_UNUSED_RESULT
static PMC *
get_pmc_proxy(PARROT_INTERP, INTVAL type)
{
    ASSERT_ARGS(get_pmc_proxy)
    PMC * type_class;

    /* Check if not a PMC or invalid type number */
    if (type > interp->n_vtable_max || type <= 0)
        return PMCNULL;

    type_class = interp->vtables[type]->pmc_class;
    if (type != enum_class_Class
        && type_class->vtable->base_type == enum_class_Class) {
        return type_class;
    }
    else {
        PMC * const parrot_hll = Parrot_ns_get_namespace_keyed_str(interp, interp->root_namespace, CONST_STRING(interp, "parrot"));
        PMC * const pmc_ns =
            Parrot_ns_make_namespace_keyed_str(interp, parrot_hll,
                interp->vtables[type]->whoami);
        PMC * proxy = VTABLE_get_class(interp, pmc_ns);

        /* Create proxy if not found */
        if (PMC_IS_NULL(proxy)) {
            proxy = Parrot_pmc_new_init_int(interp, enum_class_PMCProxy, type);
            Parrot_pcc_invoke_method_from_c_args(interp, pmc_ns, CONST_STRING(interp, "set_class"), "P->", proxy);
        }
        return proxy;
    }
}
Exemple #6
0
	ResourceReferencePtr ResourceManager::generateResource( const ConstString& _type ) const
	{
		ResourceReferencePtr resource = PROTOTYPE_SERVICE( m_serviceProvider )
			->generatePrototypeT<ResourceReference *>( CONST_STRING( m_serviceProvider, Resource ), _type );

		if( resource == nullptr )
		{
			LOGGER_ERROR( m_serviceProvider )("ResourceManager::generateResource not registered resource type '%s'"
				, _type.c_str()
				);

			return nullptr;
		}

		LOGGER_INFO( m_serviceProvider )("ResourceManager::generateResource type %s"
			, _type.c_str()
			);

		if( resource->initialize() == false )
		{
			return nullptr;
		}

		return resource;
	}
Exemple #7
0
static void
scm_error_internal(const char *func_name, ScmObj obj,
                   const char *msg, va_list args)
{
    ScmObj reason, err_obj;

    if (l_error_looped)
        scm_fatal_error("bug: double error on preparing error object");

    /* It is supposed that no continuation switching occurs on this guarded
     * duration. So the global variable based guard works properly. */
    l_error_looped = scm_true;
#if (SCM_USE_FORMAT && SCM_USE_SRFI6)
    reason = scm_vformat(SCM_FALSE, SCM_FMT_INTERNAL, msg, args);
    if (func_name) {
        reason = scm_format(SCM_FALSE, SCM_FMT_RAW_C,
                            "in ~S: ~S~S",
                            func_name, SCM_STRING_STR(reason),
                            (EQ(obj, NO_ERR_OBJ) ? "" : ":"));
    }
#else
    reason = CONST_STRING(msg);
#endif

    err_obj = scm_make_error_obj(reason,
                                 (EQ(obj, NO_ERR_OBJ)) ? SCM_NULL : LIST_1(obj));
    l_error_looped = scm_false;

    scm_raise_error(err_obj);
    /* NOTREACHED */
}
Exemple #8
0
static 
rc_t 
Server( KNSManager* mgr )  
{   
    rc_t rc = 0;
    KEndPoint ep;
    String name; 

    CONST_STRING(&name, KEYRING_IPC_NAME);
    rc = KNSManagerInitIPCEndpoint(mgr, &ep, &name);
    if (rc == 0)
    {
        KSocket* listener;
        rc = KNSMakeListener ( &listener, &ep );
        if (rc == 0)
        {
            shutDown = false;
            while (!shutDown && rc == 0)
            {
                KStream* stream;
                LogMsg ( klogInfo, "KeyringServer: listening");
                rc = KNSListen ( listener, &stream ); /* may not return from here if no more incoming connections arrive */
                if (rc == 0)
                {
                    KThread* worker;
                    LogMsg ( klogInfo, "KeyringServer: detected connection");
                    rc = KThreadMake ( &worker, WorkerThreadFn, stream);
                    if (rc == 0 && worker != NULL)
                    {
                        KThreadWait(worker, NULL);
                        LogMsg ( klogInfo, "KeyringServer: out of worker");
                    }
                    else
                        LogErr(klogErr, rc, "KeyringServer: KThreadMake failed");
                }
                else
                    LogErr(klogErr, rc, "KeyringServer: KNSListen failed");
            }
            LogMsg ( klogInfo, "KeyringServer: shutting down");
            
            /* TODO: make sure no incoming messages get dropped (stop accepting connections? wait for all active threads to exit?) 
                - lock the server */
                
            if (keyring != NULL)
            {
                KeyRingRelease(keyring);
                keyring = NULL;
            }
                
            KSocketRelease(listener);
        }
        else
            LogErr(klogErr, rc, "KeyringServer: KNSMakeListener failed");
    }
    else
        LogErr(klogErr, rc, "KeyringServer: KNSManagerInitIPCEndpoint failed");
    LogMsg ( klogInfo, "KeyringServer: listener shut down");
    return rc;
}
Exemple #9
0
SCM_EXPORT ScmObj
scm_p_sscm_version(void)
{
    DECLARE_FUNCTION("sscm-version", procedure_fixed_0);

    /* PACKAGE_VERSION may be overridden by a master package such as uim. */
    return CONST_STRING(SSCM_VERSION_STRING);
}
Exemple #10
0
/*

=item C<PMC * Parrot_ex_build_exception(PARROT_INTERP, INTVAL severity, long
error, STRING *msg)>

Constructs a new exception object from the passed in arguments.

=cut

*/
PARROT_EXPORT
PARROT_CANNOT_RETURN_NULL
PMC *
Parrot_ex_build_exception(PARROT_INTERP, INTVAL severity,
        long error, ARGIN_NULLOK(STRING *msg))
{
    ASSERT_ARGS(Parrot_ex_build_exception)
    const int exception_type_id = Parrot_hll_get_ctx_HLL_type(interp, enum_class_Exception);
    PMC * const exception = Parrot_pmc_new(interp, exception_type_id);

    VTABLE_set_integer_keyed_str(interp, exception, CONST_STRING(interp, "severity"), severity);
    VTABLE_set_integer_keyed_str(interp, exception, CONST_STRING(interp, "type"), error);
    if (msg)
        VTABLE_set_string_native(interp, exception, msg);

    return exception;
}
Exemple #11
0
static scm_bool
srfi34_providedp(void)
{
    if (!l_srfi34_is_provided) {
        /* expensive */
        l_srfi34_is_provided = scm_providedp(CONST_STRING("srfi-34"));
    }
    return l_srfi34_is_provided;
}
Exemple #12
0
SCM_EXPORT ScmObj
scm_p_symbol2string(ScmObj sym)
{
    DECLARE_FUNCTION("symbol->string", procedure_fixed_1);

    ENSURE_SYMBOL(sym);

    return CONST_STRING(SCM_SYMBOL_NAME(sym));
}
Exemple #13
0
    String exception :: func () const
    {
        if ( stk . size () == ( U64 ) 0 )
            return CONST_STRING ( "<no-stack>" );

        const Array < func_loc_t > a = stk;
        const char * text = a [ 0 ] . func;

        return ConstString ( text, strlen ( text ) );
    }
Exemple #14
0
void
Parrot_oo_extract_methods_from_namespace(PARROT_INTERP, ARGIN(PMC *self), ARGIN(PMC *ns))
{
    ASSERT_ARGS(Parrot_oo_extract_methods_from_namespace)
    PMC *methods, *vtable_overrides;

    /* Pull in methods from the namespace, if any. */
    if (PMC_IS_NULL(ns))
        return;

    /* Import any methods. */
    Parrot_pcc_invoke_method_from_c_args(interp, ns, CONST_STRING(interp, "get_associated_methods"), "->P", &methods);

    if (!PMC_IS_NULL(methods)) {
        PMC * const iter = VTABLE_get_iter(interp, methods);

        while (VTABLE_get_bool(interp, iter)) {
            STRING * const meth_name = VTABLE_shift_string(interp, iter);
            PMC    * const meth_sub  = VTABLE_get_pmc_keyed_str(interp, methods,
                meth_name);
            VTABLE_add_method(interp, self, meth_name, meth_sub);
        }
    }

    /* Import any vtables. */
    Parrot_pcc_invoke_method_from_c_args(interp, ns, CONST_STRING(interp, "get_associated_vtable_methods"), "->P", &vtable_overrides);

    if (!PMC_IS_NULL(vtable_overrides)) {
        PMC * const iter = VTABLE_get_iter(interp, vtable_overrides);
        while (VTABLE_get_bool(interp, iter)) {
            STRING * const vtable_index_str = VTABLE_shift_string(interp, iter);
            PMC    * const vtable_sub       = VTABLE_get_pmc_keyed_str(interp,
                vtable_overrides, vtable_index_str);

            /* Look up the name of the vtable function from the index. */
            const INTVAL vtable_index = Parrot_str_to_int(interp, vtable_index_str);
            const char * const meth_c = Parrot_vtable_slot_names[vtable_index];
            STRING     * const vtable_name   = Parrot_str_new(interp, meth_c, 0);
            VTABLE_add_vtable_override(interp, self, vtable_name, vtable_sub);
        }
    }
}
Exemple #15
0
    String exception :: where () const
    {
        if ( stk . size () == ( U64 ) 0 )
            return CONST_STRING ( "<no-stack>" );

        if ( rsrc == 0 )
            return CONST_STRING ( "<no-mem>" );

        const Array < func_loc_t > a = stk;
        const func_loc_t & loc = a [ 0 ];

        ConstString m ( loc . mod, strlen ( loc . mod ) );
        ConstString f ( loc . file, strlen ( loc . file ) );
        ConstString x ( loc . ext, strlen ( loc . ext ) );
        String fn ( extract_method_name ( loc . func ) );
        //const_str_t fn ( loc . func, strlen ( loc . func ) );

        StringBuffer sb ( "%s/%s.%s:%u %s", & m, & f, & x, lineno, & fn );
        return sb . to_str ();
    }
Exemple #16
0
bool validateKey(WrenVM* vm, Value arg)
{
  if (IS_BOOL(arg) || IS_CLASS(arg) || IS_FIBER(arg) || IS_NULL(arg) ||
      IS_NUM(arg) || IS_RANGE(arg) || IS_STRING(arg))
  {
    return true;
  }

  vm->fiber->error = CONST_STRING(vm, "Key must be a value type or fiber.");
  return false;
}
Exemple #17
0
    AccountInterfacePtr AccountManager::newAccount_( const WString& _accountID )
    {
        String utf8_path;
        if( Helper::unicodeToUtf8( m_serviceProvider, _accountID, utf8_path ) == false )
        {
            LOGGER_ERROR(m_serviceProvider)("AccountManager::newAccount_ can't convert accountID '%ls' to utf8"
                , _accountID.c_str() 
                );

            return nullptr;
        }

        ConstString folder = Helper::stringizeString( m_serviceProvider, utf8_path );

        if( FILE_SERVICE(m_serviceProvider)
            ->existDirectory( CONST_STRING(m_serviceProvider, user), folder ) == false )
        {
            if( FILE_SERVICE(m_serviceProvider)
                ->createDirectory( CONST_STRING(m_serviceProvider, user), folder ) == false )
            {
                LOGGER_ERROR(m_serviceProvider)("AccountManager::createAccount_: Account '%ls' failed create directory '%s'"
                    , _accountID.c_str() 
                    , folder.c_str()
                    );

                return nullptr;
            }
        }

        AccountPtr newAccount = m_factoryAccounts.createObject();

		uint32_t projectVersion = APPLICATION_SERVICE( m_serviceProvider )
			->getProjectVersion();
		
		if( newAccount->initialize( m_serviceProvider, _accountID, folder, projectVersion ) == false )
		{
			return nullptr;				 
		}

        return newAccount;
    }
Exemple #18
0
	void AccountManager::deleteAccount( const WString& _accountID )
	{
		TMapAccounts::iterator it_find = m_accounts.find( _accountID );

		if( it_find == m_accounts.end() )
		{
			LOGGER_ERROR(m_serviceProvider)("AccountManager::deleteAccount Can't delete account '%ls'. There is no account with such ID"
				, _accountID.c_str() 
				);

			return;
		}

        AccountInterfacePtr account = it_find->second;

		if( m_currentAccount != nullptr )
		{
			const WString & name = m_currentAccount->getName();

            if( name == _accountID )
			{
                this->unselectCurrentAccount_();
			}
		}

		const FilePath & folder = account->getFolder();

        if( FILE_SERVICE(m_serviceProvider)
            ->existDirectory( CONST_STRING(m_serviceProvider, user), folder ) == true )
        {
		    FILE_SERVICE(m_serviceProvider)
                ->removeDirectory( CONST_STRING(m_serviceProvider, user), folder );
        }

		m_accounts.erase( it_find );

        if( m_accountProvider != nullptr )
        {
            m_accountProvider->onDeleteAccount( _accountID );
        }  
	}
Exemple #19
0
bool validateKey(WrenVM* vm, Value* args, int index)
{
  Value arg = args[index];
  if (IS_BOOL(arg) || IS_CLASS(arg) || IS_NULL(arg) ||
      IS_NUM(arg) || IS_RANGE(arg) || IS_STRING(arg))
  {
    return true;
  }

  args[0] = CONST_STRING(vm, "Key must be a value type.");
  return false;
}
Exemple #20
0
static void
verify_CD(ARGIN(char *external_data), ARGMOD_NULLOK(PMC *user_data))
{
    ASSERT_ARGS(verify_CD)
    PARROT_INTERP = NULL;
    PMC    *interp_pmc;
    STRING *sc;

    /*
     * 1.) user_data is from external code so:
     *     verify that we get a PMC that is one that we have passed in
     *     as user data, when we prepared the callback
     */

    /* a NULL pointer or a pointer not aligned is very likely wrong */
    if (!user_data)
        PANIC(interp, "user_data is NULL");
    if (PMC_IS_NULL(user_data))
        PANIC(interp, "user_data is PMCNULL");
    if ((UINTVAL)user_data & 3)
        PANIC(interp, "user_data doesn't look like a pointer");

    /* Fetch original interpreter from prop */
    LOCK(interpreter_array_mutex);

    interp      = interpreter_array[0];
    sc          = CONST_STRING(interp, "_interpreter");
    interp_pmc  = VTABLE_getprop(interp, user_data, sc);
    GETATTR_ParrotInterpreter_interp(interp, interp_pmc, interp);

    UNLOCK(interpreter_array_mutex);
    if (!interp)
        PANIC(interp, "interpreter not found for callback");

    /*
     * 2) some more checks
     * now we should have the interpreter where that callback
     * did originate - do some further checks on the PMC
     */

    /* if that doesn't look like a PMC we are still lost */
    if (!PObj_is_PMC_TEST(user_data))
        PANIC(interp, "user_data isn't a PMC");

    if (!user_data->vtable)
        PANIC(interp, "user_data hasn't a vtable");
    /*
     * ok fine till here
     */
    callback_CD(interp, external_data, user_data);
}
Exemple #21
0
uint32_t calculateRange(WrenVM* vm, Value* args, ObjRange* range,
                        uint32_t* length, int* step)
{
  *step = 0;

  // Corner case: an empty range at zero is allowed on an empty sequence.
  // This way, list[0..-1] and list[0...list.count] can be used to copy a list
  // even when empty.
  if (*length == 0 && range->from == 0 &&
      range->to == (range->isInclusive ? -1 : 0)) {
    return 0;
  }

  uint32_t from = validateIndexValue(vm, args, *length, range->from,
                                     "Range start");
  if (from == UINT32_MAX) return UINT32_MAX;

  // Bounds check the end manually to handle exclusive ranges.
  double value = range->to;
  if (!validateIntValue(vm, args, value, "Range end")) return UINT32_MAX;

  // Negative indices count from the end.
  if (value < 0) value = *length + value;

  // Convert the exclusive range to an inclusive one.
  if (!range->isInclusive)
  {
    // An exclusive range with the same start and end points is empty.
    if (value == from)
    {
      *length = 0;
      return from;
    }

    // Shift the endpoint to make it inclusive, handling both increasing and
    // decreasing ranges.
    value += value >= from ? -1 : 1;
  }

  // Check bounds.
  if (value < 0 || value >= *length)
  {
    args[0] = CONST_STRING(vm, "Range end out of bounds.");
    return UINT32_MAX;
  }

  uint32_t to = (uint32_t)value;
  *length = abs((int)(from - to)) + 1;
  *step = from < to ? 1 : -1;
  return from;
}
Exemple #22
0
SCM_EXPORT ScmObj
scm_p_current_char_codec(void)
{
    const char *encoding;
    DECLARE_FUNCTION("%%current-char-codec", procedure_fixed_0);

#if SCM_USE_MULTIBYTE_CHAR
    encoding = SCM_CHARCODEC_ENCODING(scm_current_char_codec);
#else
    encoding = "ISO-8859-1";
#endif

    return CONST_STRING(encoding);
}
Exemple #23
0
void
Parrot_runcore_exec_init(PARROT_INTERP)
{
    ASSERT_ARGS(Parrot_runcore_exec_init)

    Parrot_runcore_t *coredata = mem_allocate_typed(Parrot_runcore_t);
    coredata->name             = CONST_STRING(interp, "exec");
    coredata->id               = PARROT_EXEC_CORE;
    coredata->opinit           = PARROT_CORE_OPLIB_INIT;
    coredata->runops           = runops_exec_core;
    coredata->destroy          = NULL;
    coredata->prepare_run      = NULL;
    coredata->flags            = 0;

    Parrot_runcore_register(interp, coredata);
}
Exemple #24
0
void
Parrot_runcore_debugger_init(PARROT_INTERP)
{
    ASSERT_ARGS(Parrot_runcore_debugger_init)

    Parrot_runcore_t *coredata = mem_allocate_typed(Parrot_runcore_t);
    coredata->name             = CONST_STRING(interp, "debugger");
    coredata->id               = PARROT_DEBUGGER_CORE;
    coredata->opinit           = PARROT_CORE_OPLIB_INIT;
    coredata->prepare_run      = init_prederef;
    coredata->runops           = runops_debugger_core;
    coredata->destroy          = NULL;
    coredata->flags            = 0;

    PARROT_RUNCORE_FUNC_TABLE_SET(coredata);

    Parrot_runcore_register(interp, coredata);
}
Exemple #25
0
void
Parrot_runcore_switch_init(PARROT_INTERP)
{
    ASSERT_ARGS(Parrot_runcore_switch_init)

    Parrot_runcore_t *coredata = mem_allocate_typed(Parrot_runcore_t);
    coredata->name             = CONST_STRING(interp, "switch");
    coredata->id               = PARROT_SWITCH_CORE;
    coredata->opinit           = PARROT_CORE_SWITCH_OPLIB_INIT;
    coredata->runops           = runops_switch_core;
    coredata->prepare_run      = init_prederef;
    coredata->destroy          = NULL;
    coredata->flags            = 0;

    PARROT_RUNCORE_PREDEREF_OPS_SET(coredata);

    Parrot_runcore_register(interp, coredata);
}
Exemple #26
0
void
Parrot_runcore_cgoto_init(PARROT_INTERP)
{
    ASSERT_ARGS(Parrot_runcore_cgoto_init)

    Parrot_runcore_t *coredata = mem_allocate_typed(Parrot_runcore_t);
    coredata->name             = CONST_STRING(interp, "cgoto");
    coredata->id               = PARROT_CGOTO_CORE;
    coredata->opinit           = PARROT_CORE_CG_OPLIB_INIT;
    coredata->runops           = runops_cgoto_core;
    coredata->destroy          = NULL;
    coredata->prepare_run      = NULL;
    coredata->flags            = 0;

    PARROT_RUNCORE_FUNC_TABLE_SET(coredata);
    PARROT_RUNCORE_CGOTO_OPS_SET(coredata);

    Parrot_runcore_register(interp, coredata);
}
Exemple #27
0
/* alter schema load
 *  'alter <schema> load STRING'
 */
static
rc_t kqsh_alter_schema_load ( KSymTable *tbl, KTokenSource *src, KToken *t, KSymbol *sym )
{
    rc_t rc;
    String path;
    struct VSchema *schema = ( void* ) sym -> u . obj;

    switch ( t -> id )
    {
    case eString:
    case eEscapedString:
        path = t -> str;
        path . addr += 1;
        path . size -= 2;
        break;

    case eUntermString:
    case eUntermEscapedString:
        CONST_STRING ( & t -> str, "<unterminated string>" );
    default:
        return expected ( t, klogErr, "path string" );
    }

    /* consume semi-colon */
    if ( next_token ( tbl, src, t ) -> id != eSemiColon )
        return expected ( t, klogErr, ";" );

    rc = _VSchemaParseFile ( schema, "%.*s", ( int ) path . size, path . addr );
    if ( rc != 0 )
    {
        PLOGERR ( klogErr,  (klogErr, rc, "cannot load file '$(path)' into schema '$(name)'",
                  "path=%.*s,name=%.*s"
                  , ( int ) path . size, path . addr
                             , ( int ) sym -> name . size, sym -> name . addr));
    }
    else if ( interactive )
    {
        kqsh_printf ( "loaded file '%S' into schema '%N' ( %p )\n",
                      & path, sym, schema );
    }

    return rc;
}
Exemple #28
0
static rc_t init_ictx( struct ictx * ictx, const dump_context * ctx, const Args * args )
{
    rc_t rc = KFileMakeStdIn ( &( ictx->std_in ) );
    DISP_RC( rc, "KFileMakeStdIn() failed" );
    if ( rc == 0 )
    {
        ictx->ctx = ctx;
        ictx->args = args;
        VectorInit( &ictx->history, 0, 10 );
        ictx->interactive = ( KFileType ( ictx->std_in ) == kfdCharDev );
        ictx->done = false;
        
        CONST_STRING( &(ictx->PROMPT), "\nvdb $" );
        StringInit( &(ictx->SInputLine), &( ictx->inputline[0] ), sizeof( ictx->inputline ), 0 );
        
        rc = vdp_init_ctx( &ictx->vsctx, args );
    }
    return rc;
}
Exemple #29
0
void
Parrot_runcore_profiling_init(PARROT_INTERP)
{
    ASSERT_ARGS(Parrot_runcore_profiling_init)

    Parrot_profiling_runcore_t *coredata =
            mem_gc_allocate_zeroed_typed(interp, Parrot_profiling_runcore_t);

    coredata->name        = CONST_STRING(interp, "profiling");
    coredata->id          = PARROT_PROFILING_CORE;
    coredata->opinit      = PARROT_CORE_OPLIB_INIT;
    coredata->runops      = (Parrot_runcore_runops_fn_t) init_profiling_core;
    coredata->destroy     = NULL;
    coredata->prepare_run = NULL;
    coredata->flags       = 0;

    PARROT_RUNCORE_FUNC_TABLE_SET(coredata);

    Parrot_runcore_register(interp, (Parrot_runcore_t *) coredata);
}
Exemple #30
0
/* alter schema add text
 *  'alter <schema> add text STRING'
 */
static
rc_t kqsh_alter_schema_add_text ( KSymTable *tbl, KTokenSource *src, KToken *t, KSymbol *sym )
{
    rc_t rc;
    String text;
    struct VSchema *schema = ( void* ) sym -> u . obj;

    switch ( t -> id )
    {
    case eString:
    case eEscapedString:
        text = t -> str;
        text . addr += 1;
        text . size -= 2;
        break;

    case eUntermString:
    case eUntermEscapedString:
        CONST_STRING ( & t -> str, "<unterminated string>" );
    default:
        return expected ( t, klogErr, "schema text string" );
    }

    /* consume semi-colon */
    if ( next_token ( tbl, src, t ) -> id != eSemiColon )
        return expected ( t, klogErr, ";" );

    /* parse text */
    rc = _VSchemaParseText ( schema, "kqsh-console", text . addr, text . size );
    if ( rc != 0 )
    {
        PLOGERR ( klogErr,  (klogErr, rc, "cannot add text into schema '$(name)'",
                             "name=%.*s", ( int ) sym -> name . size, sym -> name . addr));
    }
    else if ( interactive )
    {
        kqsh_printf ( "added text to schema '%N' ( %p )\n", sym, schema );
    }

    return rc;
}