⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stl.hhf

📁 High Level assembly language(HLA)软件
💻 HHF
📖 第 1 页 / 共 5 页
字号:
// stl.hhf -- HLA Standard Template Library//// 11/09/2005-//	Added vector template to library.//// 11/12/2005-//	Added deque template to library.#includeonce( "memory.hhf" )#includeonce( "strings.hhf" )#includeonce( "cset.hhf" )#includeonce( "excepts.hhf" )namespace stl;const	true := @global:true;	false := @global:false;	hierarchyNames:string[] :=		[			"isContainer",						"isRandomAccess",			"isArray",					"isVector",			"isDeque",			"isList",			"isTable"				];	capabilityNames:string[] :=		[			"supportsOutput",			"supportsCompare",			"supportsInsert",					"supportsRemove",					"supportsAppend",					"supportsPrepend",					"supportsSwap",			"supportsForeach",			"supportsrForeach",			"supportsCursor",			"supportsSearch",					"supportsElementSwap",			"supportsObjSwap",			"elementsAreObjects"		];	performanceNames:string[] :=		[			"fastInsert",						"fastRemove",						"fastAppend",						"fastPrepend",						"fastSwap",			"fastSearch",						"fastElementSwap"				];	// Generate a list of constant declarations, based on the	// above strings. Each declaration takes the form:	//	//		<name>_c := @{i};	//	//	where "<name>" corresponds to one of the above strings and	//	i is an incrementing value (0..n).	?bitNum :uns32 := 0;	#for( cn in capabilityNames )		@text( cn + "_c := @{" + string(bitNum) + "}" );		?bitNum := bitNum + 1;	#endfor	?bitNum :uns32 := 0;	#for( cn in hierarchyNames )		@text( cn + "_c := @{" + string(bitNum) + "}" );		?bitNum := bitNum + 1;	#endfor	?bitNum :uns32 := 0;	#for( cn in performanceNames )		@text( cn + "_c := @{" + string(bitNum) + "}" );		?bitNum := bitNum + 1;	#endfor///////////////////////////////////////////////////////////////////////////////// parseCapabilities-// parseHierarchy-// parsePerformance-////	Processes user-defined capability lists.////	Each entry in a capability list takes the following form:////		<name>:1// -or-//		<name>:0////	Where <name> is one of the names in one of the capability lists.//	Note that no spaces may appear around the ":" character.//	A value of zero disables the capability, a value of one enables it.#macro parseCapabilities( capabilities, userList ):	caps,	curCapability, 	index,	setting, 	found;	?caps := capabilities;	#for( curCapability in userList )		// See if the current user-specified entry begins with		// one of the valid capability names:		?index := 0;		?found := false;		#while( !found & index < @elements(stl.capabilityNames)  )			?found := 				@index( curCapability, 0, stl.capabilityNames[index] ) = 0;			?index := index + 1;		#endwhile		// Okay, if we found a valid name, let's process it.		#if( found )			?index := index - 1;			?setting :uns32:= 				uns32				( 					@substr					( 						curCapability, 						@length( stl.capabilityNames[index] )+1,						10000					)				);			#if( setting = 0 )				?caps := caps & 					!@text					(						"stl." +stl.capabilityNames[index] + "_c"					);								#else				?caps := caps | 					@text					(						"stl." +stl.capabilityNames[index] + "_c"					);								#endif					#endif 			#endfor	caps#endmacro#macro parsePerformance( performance, userList ):	perform,	curPerform, 	index,	setting, 	found;	?perform := performance;	#for( curPerform in userList )		// See if the current user-specified entry begins with		// one of the valid capability names:		?index := 0;		?found := false;		#while( !found & index < @elements(stl.performanceNames)  )			?found := 				@index( curPerform, 0, stl.performanceNames[index] ) = 0;			?index := index + 1;		#endwhile		// Okay, if we found a valid name, let's process it.		#if( found )			?index := index - 1;			?setting := 				uns32				( 					@substr					( 						curPerform, 						@length( stl.performanceNames[index] )+1,						10000					)				);			#if( setting = 0 )				?perform := perform & 					!@text					(						"stl." +stl.performanceNames[index] + "_c"					);								#else				?perform := perform | 					@text					(						"stl." +stl.performanceNames[index] + "_c"					);								#endif					#endif 			#endfor	perform#endmacro///////////////////////////////////////////////////////////////////////////////// checkTraits-//	Verifies that all user-specified traits (found in "toCheck") are present//	in the list of valid traits ("validTraits")#macro checkTraits( toCheck, validTraits ):	curTrait, 	userTrait,	found;	#for( userTrait in toCheck )		// See if the current user-specified entry begins with		// one of the valid capability names:		?found :boolean := false;		#for( curTrait in validTraits )			?found := 				found | (@index( userTrait, 0, curTrait ) = 0);		#endfor		// If we didn't find the user-specified trait, complain:		#if( !found )			#error			( 				"Unknown trait specified in template declaration: " +				userTrait			)								#endif 			#endfor#endmacro////////////////////////////////////////////////////////////////////////////////// stdCompares-////	Generates a standard set of comparison operations for built-in HLA types.#macro stdCompares( theType );	#if	( 			@ptype( theType ) = hla.ptBoolean		|	@ptype( theType ) = hla.ptByte		|	@ptype( theType ) = hla.ptUns8		|	@ptype( theType ) = hla.ptChar	)		method symbol.isEqual		( 			var left:theType; 			var right:theType 		);	@nodisplay; @nostackalign;		begin isEqual;			push( ebx );			mov( left, ebx );			mov( [ebx], al );			mov( right, ebx );			cmp( al, [ebx] );			sete( al );			and( $ff, eax );			pop( ebx );		end isEqual;		method symbol.isLess		( 			var left:theType; 			var right:theType 		);	@nodisplay; @nostackalign;		begin isLess;			push( ebx );			mov( left, ebx );			mov( [ebx], al );			mov( right, ebx );			cmp( al, [ebx] );			setb( al );			and( $ff, eax );			pop( ebx );		end isLess;		method symbol.isLessEqual		( 			var left:theType; 			var right:theType 		);	@nodisplay; @nostackalign;		begin isLessEqual;			push( ebx );			mov( left, ebx );			mov( [ebx], al );			mov( right, ebx );			cmp( al, [ebx] );			setbe( al );			and( $ff, eax );			pop( ebx );		end isLessEqual;	#elseif	( 			@ptype( theType ) = hla.ptWord		|	@ptype( theType ) = hla.ptUns16		|	@ptype( theType ) = hla.ptWChar	)		method symbol.isEqual		( 			var left:theType; 			var right:theType 		);	@nodisplay; @nostackalign;		begin isEqual;			push( ebx );			mov( left, ebx );			mov( [ebx], ax );			mov( right, ebx );			cmp( ax, [ebx] );			sete( al );			and( $ff, eax );			pop( ebx );		end isEqual;		method symbol.isLess		( 			var left:theType; 			var right:theType 		);	@nodisplay; @nostackalign;		begin isLess;			push( ebx );			mov( left, ebx );			mov( [ebx], ax );			mov( right, ebx );			cmp( ax, [ebx] );			setb( al );			and( $ff, eax );			pop( ebx );		end isLess;		method symbol.isLessEqual		( 			var left:theType; 			var right:theType 		);	@nodisplay; @nostackalign;		begin isLessEqual;			push( ebx );			mov( left, ebx );			mov( [ebx], ax );			mov( right, ebx );			cmp( ax, [ebx] );			setbe( al );			and( $ff, eax );			pop( ebx );		end isLessEqual;	#elseif	( 			@ptype( theType ) = hla.ptDWord		|	@ptype( theType ) = hla.ptUns32	)		method symbol.isEqual		( 			var left:theType; 			var right:theType 		);	@nodisplay; @nostackalign;		begin isEqual;			push( ebx );			mov( left, ebx );			mov( [ebx], eax );			mov( right, ebx );			cmp( eax, [ebx] );			sete( al );			and( $ff, eax );			pop( ebx );		end isEqual;		method symbol.isLess		( 			var left:theType; 			var right:theType 		);	@nodisplay; @nostackalign;		begin isLess;			push( ebx );			mov( left, ebx );			mov( [ebx], eax );			mov( right, ebx );			cmp( eax, [ebx] );			setb( al );			and( $ff, eax );			pop( ebx );		end isLess;		method symbol.isLessEqual		( 			var left:theType; 			var right:theType 		);	@nodisplay; @nostackalign;		begin isLessEqual;			push( ebx );			mov( left, ebx );			mov( [ebx], eax );			mov( right, ebx );			cmp( eax, [ebx] );			setbe( al );			and( $ff, eax );			pop( ebx );		end isLessEqual;	#elseif	( 			@ptype( theType ) = hla.ptQWord		|	@ptype( theType ) = hla.ptUns64	)		method symbol.isEqual		( 			var left:theType; 			var right:theType 		);	@nodisplay; @nostackalign;		begin isEqual;			push( ebx );			push( ecx );			mov( left, ebx );			mov( [ebx+4], eax );			mov( right, ecx );			cmp( eax, [ecx+4] );			if( @e ) then				mov( [ebx], eax );				cmp( eax, [ecx] );			endif;			sete( al );			and( $ff, eax );			pop( ecx );			pop( ebx );		end isEqual;		method symbol.isLess		( 			var left:theType; 			var right:theType 		);	@nodisplay; @nostackalign;		begin isLess;			push( ebx );			push( ecx );			mov( left, ebx );			mov( [ebx+4], eax );			mov( right, ecx );			cmp( eax, [ecx+4] );			if( @e ) then				mov( [ebx], eax );				cmp( eax, [ecx] );			endif;			setb( al );			and( $ff, eax );			pop( ecx );			pop( ebx );		end isLess;		method symbol.isLessEqual		( 			var left:theType; 			var right:theType 		);	@nodisplay; @nostackalign;		begin isLessEqual;			push( ebx );			push( ecx );			mov( left, ebx );			mov( [ebx+4], eax );			mov( right, ecx );			cmp( eax, [ecx+4] );			if( @e ) then				mov( [ebx], eax );				cmp( eax, [ecx] );			endif;			setbe( al );			and( $ff, eax );			pop( ecx );			pop( ebx );		end isLessEqual;	#elseif	( 			@ptype( theType ) = hla.ptLWord		|	@ptype( theType ) = hla.ptUns128	)		method symbol.isEqual		( 			var left:theType; 			var right:theType 		);	@nodisplay; @nostackalign;		begin isEqual;			push( ebx );			push( ecx );			mov( left, ebx );			mov( [ebx+12], eax );			mov( right, ecx );			cmp( eax, [ecx+12] );			if( @e ) then				mov( [ebx+8], eax );				cmp( eax, [ecx+8] );				if( @e ) then					mov( [ebx+4], eax );					cmp( eax, [ecx+4] );					if( @e ) then						mov( [ebx], eax );						cmp( eax, [ecx] );					endif;				endif;			endif;			sete( al );			and( $ff, eax );			pop( ecx );			pop( ebx );		end isEqual;		method symbol.isLess		( 			var left:theType; 			var right:theType 		);	@nodisplay; @nostackalign;		begin isLess;			push( ebx );			push( ecx );			mov( left, ebx );			mov( [ebx+12], eax );			mov( right, ecx );			cmp( eax, [ecx+12] );			if( @e ) then				mov( [ebx+8], eax );				cmp( eax, [ecx+8] );				if( @e ) then					mov( [ebx+4], eax );					cmp( eax, [ecx+4] );					if( @e ) then						mov( [ebx], eax );						cmp( eax, [ecx] );					endif;				endif;			endif;			setb( al );			and( $ff, eax );			pop( ecx );			pop( ebx );		end isLess;		method symbol.isLessEqual		( 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -