Example #1
0
static void STD_Load( DaoProcess *proc, DaoValue *p[], int N )
{
	DString *name = p[0]->xString.data;
	int import = p[1]->xInteger.value;
	int runim = p[2]->xInteger.value;
	int safe = p[3]->xInteger.value;
	int wasProt = 0;
	int res = 0;
	DaoVmSpace *vms = proc->vmSpace;
	DaoNamespace *ns;
	DString_ToMBS( name );
	if( safe ) vms->options |= DAO_OPTION_SAFE;
	if( vms->options & DAO_OPTION_SAFE ) wasProt = 1;
	DArray_PushFront( vms->pathLoading, proc->activeNamespace->path );
	ns = DaoVmSpace_LoadEx( vms, DString_GetMBS( name ), runim );
	DaoProcess_PutValue( proc, (DaoValue*) ns );
	if( ! wasProt ) vms->options &= ~DAO_OPTION_SAFE;
	if( ns ){ /* in the case that it is cancelled from console */
		DArray_PushFront( vms->pathLoading, ns->path );
		res = DaoProcess_Call( proc, ns->mainRoutine, NULL, NULL, 0 );
		if( proc->stopit | vms->stopit ){
			DaoProcess_RaiseException( proc, DAO_ERROR, "loading cancelled" );
		}else if( res ){
			DaoProcess_RaiseException( proc, res, "loading failed" );
		}
		DArray_PopFront( vms->pathLoading );
	}else{
		DaoProcess_RaiseException( proc, DAO_ERROR, "loading failed" );
	}
	DArray_PopFront( vms->pathLoading );
	if( import && ns ) DaoNamespace_AddParent( proc->activeNamespace, ns );
}
Example #2
0
static void DaoSTD_Load( DaoProcess *proc, DaoValue *p[], int N )
{
	DaoNamespace *ns;
	DaoVmSpace *vms = proc->vmSpace;
	DString *name = p[0]->xString.value;
	int import = p[1]->xInteger.value;
	int runim = p[2]->xInteger.value;
	int res = 0;

	DList_PushFront( vms->pathLoading, proc->activeNamespace->path );
	ns = DaoVmSpace_LoadEx( vms, DString_GetData( name ), runim );
	DaoProcess_PutValue( proc, (DaoValue*) ns );
	if( ns == NULL ) DaoProcess_RaiseError( proc, NULL, "loading failed" );
	DList_PopFront( vms->pathLoading );
	if( import && ns ) DaoNamespace_AddParent( proc->activeNamespace, ns );
}
Example #3
0
static void STD_Load( DaoProcess *proc, DaoValue *p[], int N )
{
	DString *name = p[0]->xString.data;
	int import = p[1]->xInteger.value;
	int runim = p[2]->xInteger.value;
	int safe = p[3]->xInteger.value;
	int wasProt = 0;
	int res = 0;
	DaoVmSpace *vms = proc->vmSpace;
	DaoNamespace *ns;
	DString_ToMBS( name );
	if( safe ) vms->options |= DAO_OPTION_SAFE;
	if( vms->options & DAO_OPTION_SAFE ) wasProt = 1;
	DArray_PushFront( vms->pathLoading, proc->activeNamespace->path );
	ns = DaoVmSpace_LoadEx( vms, DString_GetMBS( name ), runim );
	DaoProcess_PutValue( proc, (DaoValue*) ns );
	if( ! wasProt ) vms->options &= ~DAO_OPTION_SAFE;
	if( ns == NULL ) DaoProcess_RaiseException( proc, DAO_ERROR, "loading failed" );
	DArray_PopFront( vms->pathLoading );
	if( import && ns ) DaoNamespace_AddParent( proc->activeNamespace, ns );
}