当前位置: 首页>>代码示例>>C++>>正文


C++ CodeGen::vmiSYS_RETURN方法代码示例

本文整理汇总了C++中CodeGen::vmiSYS_RETURN方法的典型用法代码示例。如果您正苦于以下问题:C++ CodeGen::vmiSYS_RETURN方法的具体用法?C++ CodeGen::vmiSYS_RETURN怎么用?C++ CodeGen::vmiSYS_RETURN使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CodeGen的用法示例。


在下文中一共展示了CodeGen::vmiSYS_RETURN方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sysClassRecogniser

/*
	classRecogniser( key )( object ) -> Bool
*/
Ref * sysClassRecogniser( Ref * pc, MachineClass *vm ) {
	if ( vm->count != 1 ) throw Ginger::Mishap( "Wrong number of arguments" );
	Ref kk = vm->fastPeek();
	if ( !IsObj( kk ) || *RefToPtr4( kk ) != sysClassKey ) throw Ginger::Mishap( "Key needed" );

	CodeGen codegen = vm->codegen();
	codegen->vmiFUNCTION( makeName( "is", RefToPtr4( kk )[ CLASS_OFFSET_TITLE ] ), 1, 1 );
	codegen->vmiSYS_CALL_ARG( sysargRecognise, kk );
	codegen->vmiSYS_RETURN();
	vm->fastPeek() = codegen->vmiENDFUNCTION();
	return pc;
}
开发者ID:Spicery,项目名称:ginger,代码行数:15,代码来源:sysclass.cpp

示例2: sysClassConstructor

/*
	classConstructor( key )( arg1, ..., argN ) -> instance
*/
Ref * sysClassConstructor( Ref * pc, MachineClass *vm ) {
	if ( vm->count != 1 ) throw Ginger::Mishap( "Wrong number of arguments" );
	Ref kk = vm->fastPeek();
	if ( !IsObj( kk ) || *RefToPtr4( kk ) != sysClassKey ) throw Ginger::Mishap( "Key needed" );
	Ref * obj_K = RefToPtr4( kk );
	long n = SmallToLong( obj_K[ CLASS_OFFSET_NFIELDS ] );
	CodeGen codegen = vm->codegen();
	codegen->vmiFUNCTION( makeName( "new", obj_K[ CLASS_OFFSET_TITLE ]), n, 1 );
	//vmiCHECK_COUNT( codegen, n );
	codegen->vmiSYS_CALL_ARGDAT( sysargdatConstruct, kk, n );
	codegen->vmiSYS_RETURN();
	vm->fastPeek() = codegen->vmiENDFUNCTION();
	return pc;
}
开发者ID:Spicery,项目名称:ginger,代码行数:17,代码来源:sysclass.cpp

示例3: sysClassExploder

/*
	classExploder( key )( instance ) -> ( arg1, ..., argN )
*/
Ref * sysClassExploder( Ref * pc, MachineClass * vm ) {
	if ( vm->count != 1 ) throw Ginger::Mishap( "Wrong number of arguments" );
	Ref key = vm->fastPeek();
	if ( !IsObj( key ) ) throw Ginger::Mishap( "Class of object needed" );
	Ref * key_K = RefToPtr4( key );
	if ( *key_K != sysClassKey ) throw Ginger::Mishap( "Class of object needed" );
	const long N = SmallToLong( key_K[ CLASS_OFFSET_NFIELDS ] );

	CodeGen codegen = vm->codegen();
	codegen->vmiFUNCTION( makeName( "dest", key_K[ CLASS_OFFSET_TITLE ] ), 1, N );
	codegen->vmiSYS_CALL_ARG( sysargExplode, key );
	codegen->vmiSYS_RETURN();
	vm->fastPeek() = codegen->vmiENDFUNCTION();
	return pc;
}
开发者ID:Spicery,项目名称:ginger,代码行数:18,代码来源:sysclass.cpp

示例4: sysSetMethod

/**
	setSlot( CLASS:Class, POSITION:Small, METHOD:Method )
	
	1. 	The method is inserted into the correct position in the class's
		slot array. To start with, only one method per slot will be
		permitted.
		
	2.	A call to setMethod is then made with an unsafe access function
		as the method's function. The values are passed on the stack. 
		No stack checks are needed as the size of the argument lists of
		the two functions are the same.
*/
Ref * sysSetSlot( Ref * pc, MachineClass * vm ) {
	if ( vm->count != 3 ) throw Ginger::Mishap( "Wrong number of arguments" );

	Ref method = vm->fastPop();
	Ref position = vm->fastPop();
	Ref gclass = vm->fastPop();

	if ( !IsMethod( method ) ) throw Ginger::Mishap( "Method needed" ).culprit( "Method", refToString( method ) );
	if ( !IsSmall( position ) ) throw Ginger::Mishap( "Small needed" ).culprit( "Position", refToString( position ) );
	if ( !IsClass( gclass ) ) throw Ginger::Mishap( "Class needed" ).culprit( "Class", refToString( gclass ) );
	
	long pos = SmallToLong( position );
	long nfields = SmallToLong( RefToPtr4( gclass )[ CLASS_OFFSET_NFIELDS ] );
	if ( not( 1 <= pos && pos <= nfields ) ) {
		throw 
			Ginger::Mishap( "Position out of range" ).
			culprit( "Position", pos ).
			culprit( "Number of fields", nfields )
		;
	}
	
	//	Update the class-slot.
	INDEX( INDEX( gclass, CLASS_OFFSET_SLOTS ), pos ) = method;

	//	Push onto the stack to get protection from garbage collection.
	vm->fastPush( gclass );
	vm->fastPush( method );

	//	ENDFUNCTION does not in fact cause a garbage collection, as it
	//	forces the heap to grow. However this is a more accurate way
	//	to write the code. 
	//
	//	The following block should not be in-lined but extracted as a 
	//	service function.
	{
		CodeGen codegen = vm->codegen();
		//	TODO: Supply a useful name.
		codegen->vmiFUNCTION( 1, 1 );
		codegen->vmiFIELD( pos );
		codegen->vmiSYS_RETURN();
		vm->fastPush( codegen->vmiENDFUNCTION() );
	}

	//	We do not need to modify vm->count, it's already 3.
	//	Simply chain into sysSetMethod. 
	return sysSetMethod( pc, vm );
}
开发者ID:gjhiggins,项目名称:ginger,代码行数:59,代码来源:sysmethod.cpp

示例5: Mishap

Ref * sysClassUnsafeAccessor( Ref * pc, MachineClass *vm ) {
	if ( vm->count != 2 ) throw Ginger::Mishap( "Wrong number of arguments" );
	Ref N = vm->fastPop();
	if ( !IsSmall( N ) ) throw Ginger::Mishap( "Integer index needed" );
	Ref kk = vm->fastPeek();
	if ( !isKey( kk ) ) throw Ginger::Mishap( "Key needed" );
	long nargs = SmallToLong( RefToPtr4( kk )[ CLASS_OFFSET_NFIELDS ] );
	long index = SmallToLong( N );
	if ( 1 <= index && index <= nargs ) {
		CodeGen codegen = vm->codegen();
		//	TODO: Figure out name.
		codegen->vmiFUNCTION( 1, 1 );
		codegen->vmiFIELD( index );
		codegen->vmiSYS_RETURN();
		vm->fastPeek() = codegen->vmiENDFUNCTION();
	} else {
		throw Ginger::Mishap( "ToBeDone" );
	}
	return pc;
}
开发者ID:Spicery,项目名称:ginger,代码行数:20,代码来源:sysclass.cpp

示例6: makeSysFn

Ref makeSysFn( CodeGen codegen, std::string fn_name, Ref default_value ) {

	SysMap::iterator smit = SysMap::systemFunctionsMap().find( fn_name );
	if ( smit == SysMap::systemFunctionsMap().end() ) {
		return default_value;
	}
	SysInfo & info = smit->second;
	
	Ref x = info.coreFunctionObject;
	if ( x != NULL ) return x;

	codegen->vmiFUNCTION( fn_name, info.in_arity.count(), info.out_arity.count() );
	
	//	We have two different kinds of system functions. Those that are
	//	implemented as native instructions and those that are implemented
	//	by hand-written functions.
	//
	//	The test that distinguishes them is unsatisfactory because it fails
	//	to distinguish an omitted something from a genuine choice.
	//	REFACTOR.
	//
	if ( info.isSysCall() ) {
		//	Hand-written function.
		codegen->vmiSYS_CALL( info.syscall );	
	} else if ( info.isVMOp() ) {
		//	Native instruction.
		codegen->vmiINSTRUCTION( info.instruction );
	} else {
		throw SystemError( "Internal error" );
	}
	codegen->vmiSYS_RETURN();
	Ref r = codegen->vmiENDFUNCTION( false );
	
	info.coreFunctionObject = r;
	return r;
	
}
开发者ID:Spicery,项目名称:ginger,代码行数:37,代码来源:makesysfn.cpp


注:本文中的CodeGen::vmiSYS_RETURN方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。