Exemple #1
0
// If this object is a suspended application, then force it.
Obj*	_force (Obj* obj)
{
	_DEBUG(_lintObjPtr (obj, _ddcHeapBase, _ddcHeapMax));
	_PROFILE_APPLY (forceCount++);

	_ENTER(1);
	_S(0)	= obj;

	// Keep forcing suspensions and following indirections
	//	until we get a real object.
	again:
	switch (_getObjTag (_S(0))) {
	 case _tagSusp:
	 	_S(0) = _forceStep (_S(0));
		goto again;

	 case _tagIndir:
		_S(0) = ((SuspIndir*)_S(0)) ->obj;
		goto again;
	}

	Obj*	tmp	= _S(0);
	_LEAVE(1);

	return	tmp;
}
Exemple #2
0
// ------ Ref
Obj*	primRefUpdate	(Obj* ref_, Obj* x_)
{
	_DEBUG (assert (_getObjTag(ref_) == _tagBase));

	_ENTER(2);
	_S(0)	= ref_;
	_S(1)	= x_;

	// unboxing.
	DataM* refDataM;
	Data* refData;
	int objType = _objType(_S(0));
	switch (objType) {
	 case _ObjTypeDataM:
		refDataM = (DataM*) _force(_S(0));
		Obj***  payload	= (Obj***)refDataM ->payload;
		*payload[1]	= _S(1);
		break;
	 case _ObjTypeData:
		refData = (Data*) _force(_S(0));
		refData->a[0] = _S(1);
		break;
	 default:
		_PANIC("Updating Ref with unknown internal object type");
		break;
	}

	_LEAVE(2);
	return	_primUnit;
}
void get_prev_state_machine( STATE *state )
{
    _ENTER();

    memcpy( state, &state_machine->prev_state, sizeof( STATE ) );

    _LEAVE();
}
void get_current_state_machine( STATE *state )
{
    _ENTER();

    memcpy( state, &state_machine->current_state, sizeof( STATE ) );

    _LEAVE();
}
Exemple #5
0
Obj*	primSuspend1 (Obj* f, Obj* x)
{
	_ENTER(1);
	_S(0)		= x;
	
	SuspIndir* susp	= (SuspIndir*)_allocSusp (f, 1);
	susp->a[0]	= _S(0);
	
	_LEAVE(1);
	return (Obj*)susp;
}	
void set_current_state( int state, int main_cmd, int sub_cmd)
{
    _ENTER();

	STATE st;
    STATE_TYPE(st) = state;
    STATE_MAIN_CMD(st) = main_cmd;
    STATE_SUB_CMD(st) = sub_cmd;
    //STATE_FUNCTION(st) = func;
    set_state_machine( st );
	    _LEAVE();
}
Exemple #7
0
// Do one step of the forcing.
//	This does a single application.
//
Obj*	_forceStep (Obj* susp_)
{
	_DEBUG	 (assert (_getObjTag(susp_) == _tagSusp));
	_ENTER(1);
	_S(0)	= susp_;

	// -----
	SuspIndir* susp	= (SuspIndir*)_S(0);

	Obj* obj	= 0;
	switch (susp->arity) {
		case 0: _PROFILE_APPLY (force[0]++);
			Obj* (*fun)()	= (Obj* (*)()) susp->obj;
			obj	= fun ();
			break;

		case 1:	_PROFILE_APPLY (force[1]++);
			obj	= _apply1 (susp->obj, susp->a[0]);
	 	 	break;

		case 2: _PROFILE_APPLY (force[2]++);
			obj	= _apply2 (susp->obj, susp->a[0], susp->a[1]);
	 		break;

		case 3: _PROFILE_APPLY (force[3]++);
			obj	= _apply3 (susp->obj, susp->a[0], susp->a[1], susp->a[2]);
			break;

		case 4: _PROFILE_APPLY (force[4]++);
			obj	= _apply4 (susp->obj, susp->a[0], susp->a[1], susp->a[2], susp->a[3]);
			break;

		default:
			_panicApply();
	}


	// Overwrite the suspension with an indirection to the result.
	SuspIndir* susp2	= (SuspIndir*)_S(0);
	susp2 ->tagFlags	= (_tagIndir << 8) | _ObjFixedSuspIndir;
	susp2 ->obj		= obj;


#if _DDC_DEBUG
	// Zap any remaining args for debugging purposes
	for (unsigned int i = 0; i < susp2 ->arity; i++)
		susp2 ->a[i]	= 0;
#endif

	_LEAVE(1);
	return obj;
}
Exemple #8
0
Obj*	primSuspend2 (Obj* f, Obj* x1, Obj* x2)
{
	_ENTER(2);
	_S(0)		= x1;
	_S(1)		= x2;
	
	SuspIndir* susp	= (SuspIndir*)_allocSusp (f, 2);
	susp ->a[0]	= _S(0);
	susp ->a[1]	= _S(1);
	
	_LEAVE(2);
	return (Obj*)susp;
}
Exemple #9
0
Obj*	primSuspend3 (Obj* f, Obj* x1, Obj* x2, Obj* x3)
{
	_ENTER(3);
	_S(0)		= x1;
	_S(1)		= x2;
	_S(2)		= x3;
	
	SuspIndir* susp	= (SuspIndir*)_allocSusp (f, 3);
	susp ->a[0]	= _S(0);
	susp ->a[1]	= _S(1);
	susp ->a[2]	= _S(2);
	
	_LEAVE(3);
	return (Obj*)susp;
}
Exemple #10
0
Obj*	primSuspend4 (Obj* f, Obj* x1, Obj* x2, Obj* x3, Obj* x4)
{
	_ENTER(4);
	_S(0)		= x1;
	_S(1)		= x2;
	_S(2)		= x3;
	_S(3)		= x4;
	
	SuspIndir* susp	= (SuspIndir*)_allocSusp (f, 4);
	susp ->a[0]	= _S(0);
	susp ->a[1]	= _S(1);
	susp ->a[2]	= _S(2);
	susp ->a[3]	= _S(3);
	
	_LEAVE(4);
	return (Obj*)susp;
}
void send_msg( void)
{
	STATE state;

	_ENTER();

	get_current_state_machine( &state );
	log_msg(MSGL_VGSM_INFO," exe state_type %d, state main_cmd=%d sub_cmd =%d\n", state.state_type,state.main_cmd,state.sub_cmd);

	if( state.state_function )
	{
		log_msg(MSGL_VGSM_CALL,"state.function exe !! \n");

		state.state_function();
	}

	_LEAVE();
}
void set_state_machine( STATE state )
{
    int type = STATE_TYPE(state_machine->current_state);

    _ENTER();

    memcpy( &state_machine->prev_state, &state_machine->current_state, sizeof( STATE ) );
    memcpy( &state_machine->current_state, &state, sizeof( STATE ) );

    if( ( STATE_TYPE(state) == STATE_NONE ) || ( STATE_TYPE(state) == STATE_ANY ) )
	STATE_TYPE(state_machine->current_state) = type;

#ifdef	_DEBUG
    print_state_machine();
#endif /* _DEBUG */

    _LEAVE();
}
int find_next_state( STATE *next, int flag )
{
    STATE state;
    int ret = 0;

    _ENTER();

    get_current_state_machine( &state );
    ret = find_next_state_for_state( state, next, flag );

#ifdef	_DEBUG
    if( ret )
	print_state(*next);
#endif /* _DEBUG */

    _LEAVE();

    return ret;
}
int change_state_machine( int main_cmd )
{
	_ENTER();

	switch( main_cmd ) {
	case GSM_CALL_CMD:  /* 0x02 : Call Control Commands */
	case GSM_SS_CMD:    /* 0x0C : Supplementary Service Control Command */
		state_machine = &state_machine_call;
		break;
	case GSM_SEC_CMD:   /* 0x05 : Security - SIM control Commands */
		state_machine = &state_machine_sim;
		break;

	case GSM_PWR_CMD:   /* 0x01 : Power Control Commands */
		break;
	case GSM_DATA_CMD:  /* 0x03 : Data Control Commands */
		break;
	case GSM_SMS_CMD:   /* 0x04 : Short Message Service Commands */
		break;
	case GSM_PB_CMD:    /* 0x06 : Phonebook Control Commands */
	case GSM_DISP_CMD:  /* 0x07 : Display Control Commands */
	case GSM_NET_CMD:   /* 0x08 : Network Commands */
	case GSM_SND_CMD:   /* 0x09 : Sound Control Commands */
	case GSM_MISC_CMD:  /* 0x0A : Miscellaneous Control Commands */
	case GSM_SVC_CMD:   /* 0x0B : Service Mode Control Commands - Factory Test or Debug Screen Control */
	case GSM_GPRS_CMD:  /* 0x0D : GPRS Commands */
	case GSM_SAT_CMD:   /* 0x0E : SIM Toolkit Commands */
	case GSM_CFG_CMD:   /* 0x0F : Configuration Commands */
	case GSM_GEN_CMD:   /* 0x80 : General Response Commands */
	default:
		break;
	}

	_LEAVE();

	return 1;
}