📄 stl.hhf
字号:
// // prependVal passes toInsert by value, so you should use this // function to insert small objects into the array. method symbol.prependVal( toPrepend:vectorType ); @nodisplay; @noalignstack; begin prependVal; push( eax ); push( ecx ); pushfd(); push( edi ); this._insert ( #{ lea( eax, toPrepend ); push( eax ); }#, this.data, @size( vectorType ) ); pop( edi ); popfd(); pop( ecx ); pop( eax ); end prependVal; #endif #if( (symbol.capabilities_c & stl.supportsInsert_c) <> 0 ) // insertRef- // // Inserts an array element (toInsert) at position posn within // the array. If posn is beyond the end of the array, then this // code appends the value to the end of the array. // // insertRef passes toInsert by reference, so you should use this // function to insert large objects into the array. method symbol.insertRef( var toInsert:vectorType; posn:uns32 ); @nodisplay; @noalignstack; begin insertRef; push( eax ); push( ecx ); pushfd(); push( edi ); intmul( @size( vectorType ), posn, eax ); add( this.data, eax ); this._insert ( #{ push( toInsert ); }#, eax, @size( vectorType ) ); pop( edi ); popfd(); pop( ecx ); pop( eax ); end insertRef; // insertVal- // // Inserts an array element (toInsert) at position posn within // the array. If posn is beyond the end of the array, then this // code appends the value to the end of the array. // // insertVal passes toInsert by value, so you should use this // function to insert small objects into the array. method symbol.insertVal( toInsert:vectorType; posn:uns32 ); @nodisplay; @noalignstack; begin insertVal; push( eax ); push( ecx ); pushfd(); push( edi ); this._insert ( #{ lea( eax, toInsert ); push( eax ); }#, #{ intmul( @size( vectorType ), posn, eax ); add( this.data, eax ); push( eax ); }#, @size( vectorType ) ); pop( edi ); popfd(); pop( ecx ); pop( eax ); end insertVal; #if( (symbol.capabilities_c & stl.supportsCursor_c) <> 0 ) // insertAtRef- // // Inserts an array element just before the element specified // by the cursor passed as the second argument. // // insertAtRef passes toInsert by reference, so you should use this // function to insert large objects into the array. method symbol.insertAtRef( var toInsert:vectorType; cursor:cursorType ); @nodisplay; @noalignstack; begin insertAtRef; push( eax ); push( ecx ); pushfd(); push( edi ); this._insert ( #{ push( toInsert ); }#, cursor, @size( vectorType ) ); pop( edi ); popfd(); pop( ecx ); pop( eax ); end insertAtRef; // insertAtVal- // // Inserts an array element (toInsert) in front of the item // specified by the cursor passed as the second argument. // // insertAtVal passes toInsert by value, so you should use this // function to insert small objects into the array. method symbol.insertAtVal( toInsert:vectorType; cursor:cursorType ); @nodisplay; @noalignstack; begin insertAtVal; push( eax ); push( ecx ); pushfd(); push( edi ); this._insert ( #{ lea( eax, toInsert ); push( eax ); }#, cursor, @size( vectorType ) ); pop( edi ); popfd(); pop( ecx ); pop( eax ); end insertAtVal; #endif #endif #if( (symbol.capabilities_c & stl.supportsRemove_c) <> 0 ) // remove- // Removes the nTH item from the end of the array. // // If n is greater than the number of items in the array, // then this function has no effect. method symbol.remove( n:uns32 ); @nodisplay; @noalignstack; begin remove; push( eax ); intmul( @size( vectorType ), n, eax ); add( this.data, eax ); this._remove( eax, @size( vectorType )); pop( eax ); end remove; // remove_first- // Removes the first item from a vector. method symbol.remove_first; @noframe; begin remove_first; push( eax ); this._remove( this.data, @size( vectorType )); pop( eax ); ret(); end remove_first; // remove_last- // Removes the last item from a vector. method symbol.remove_last; @noframe; begin remove_last; push( eax ); mov( this.endData, eax ); sub( @size( vectorType ), eax ); if( eax > this.data ) then mov( eax, this.endData ); sub( 1, this.numElements ); endif; pop( eax ); end remove_last; #if( (symbol.capabilities_c & stl.supportsCursor_c) <> 0 ) // removeAt- // Removes the item appearing at the location specified // by the cursor passed as a parameter. method symbol.removeAt( cursor:cursorType ); @nodisplay; @noalignstack; begin removeAt; push( eax ); mov( cursor, eax ); this._remove( eax, @size( vectorType )); pop( eax ); end removeAt; #endif #endif #if( (symbol.capabilities_c & stl.supportsForeach_c) <> 0 ) // The following iterators will sequence through // all the elements of the array. On each iteration // of the corresponding foreach loop, this iterator // will return the *address* of the respective vector // element. // // forEachElement returns items from the start to the end of the object // rForEachElement returns items from the end to the start. iterator symbol.forEachElement; @nodisplay; @noalignstack; begin forEachElement; push( eax ); push( edx ); mov( this.data, edx ); while( edx < this.endData ) do push( esi ); push( edx ); mov( edx, eax ); yield(); pop( edx ); pop( esi ); add( @size( vectorType ), edx ); endwhile; pop( edx ); pop( eax ); end forEachElement; #endif #if( (symbol.capabilities_c & stl.supportsrForeach_c) <> 0 ) iterator symbol.rForEachElement; @nodisplay; @noalignstack; begin rForEachElement; push( eax ); push( edx ); mov( this.endData, edx ); while( edx > this.data ) do sub( @size( vectorType ), edx ); push( esi ); push( edx ); mov( edx, eax ); yield(); pop( edx ); pop( esi ); endwhile; pop( edx ); pop( eax ); end rForEachElement; #endif #if( (symbol.capabilities_c & stl.supportsCursor_c) <> 0 ) // nextCursor- // Adjusts the cursor to point at the next element of the // vector and returns this pointer in EAX. If this operation // would cause the cursor to move beyond the end of the // vector, then it just returns this.endData. method symbol.nextCursor( var cursor:cursorType ); @noframe; begin nextCursor; push( eax ); mov( [esp+@offset( cursor )], eax ); push( ebx ); mov( [eax], ebx ); add( @size( vectorType ), ebx ); if( ebx > this.endData ) then mov( this.endData, ebx ); endif; mov( ebx, [eax] ); pop( ebx ); pop( eax ); ret( 4 ); end nextCursor; // prevCursor- // Adjust the cursor to point at the previous element in the vector. // If doing this would position the cursor before the start of the // array, then this just sets the cursor position to the start of // the array. method symbol.prevCursor( var cursor:cursorType ); @noframe; begin prevCursor; push( eax ); mov( [esp+@offset( cursor )], eax ); push( ebx ); mov( [eax], ebx ); sub( @size( vectorType ), ebx ); if( ebx < this.data ) then mov( this.data, ebx ); endif; mov( ebx, [eax] ); pop( ebx ); pop( eax ); ret( 4 ); end prevCursor; // beginCursor- // Puts a pointer to the start of the vector in cursor: method symbol.beginCursor( var cursor:cursorType ); @noframe; begin beginCursor; push( eax ); mov( [esp+@offset( cursor )], eax ); mov( this.data, [eax] ); pop( eax ); ret( 4 ); end beginCursor; // endCursor- // Puts a pointer to the end of the vector in cursor: method symbol.endCursor( var cursor:cursorType ); @noframe; begin endCursor; push( eax ); mov( [esp+@offset( cursor )], eax ); mov( this.endData, [eax] ); pop( eax ); ret( 4 ); end endCursor; // at- // Moves the address of the data element referenced by the // cursor passed as the argument into the EAX register. method symbol.at( cursor:cursorType in eax ); @noframe; begin at; // This is a trivial function, as cursors and pointers // to data elements are the same thing for vectors. ret(); end at; // getAt- // Copies the data item specified by the cursor to // the variable specified by the second argument. // If cursor is out of range, no action is taken. method symbol.getAt( cursor:cursorType; var dest:vectorType ); @nodisplay; @noalignstack; begin getAt; pushfd(); push( edi ); cld(); mov( cursor, edi ); if( edi < this.endData ) then push( esi ); mov( edi, esi ); mov( dest, edi ); #if( @size( vectorType ) = 1 ) movsb(); #elseif( @size( vectorType ) = 2 ) movsw(); #elseif( @size( vectorType ) = 4 ) movsd(); #else push( ecx ); #if( (@size( vectorType ) & %11) = 0 ) mov( @size( vectorType ) div 4, ecx ); rep.movsd(); #elseif( (@size( vectorType ) & %01) = 0 ) mov( @size( vectorType ) div 2, ecx ); rep.movsw(); #else mov( @size( vectorType ), ecx ); rep.movsb(); #endif pop( ecx ); #endif pop( esi ); endif; pop( edi ); popfd(); end getAt; // front- // Returns a cursor value that points at the first element // of the vector in EAX. method symbol.front; @noframe; begin front; mov( this.data, eax ); ret(); end front; // back- // Returns a pointer to the first item *beyond* the end of // the vector in EAX: method symbol.back; @noframe; begin back; mov( this.endData, eax ); ret(); end back; // atFront // Compares the cursor passed as a parameter against the // start of the vector and sets the zero flag if they // are equal (that is, the cursor points at the start // of the vector). method symbol.atFront( cursor:cursorType ); @noframe; begin atFront; push( eax ); mov( [esp+@offset(cursor)], eax ); cmp( eax, this.data ); pop( eax ); ret(); end atFront; // atBack // Compares the cursor passed as a parameter against the // end of the vector and sets the zero flag if they // are equal (that is, the cursor points just beyond the // end of the vector). method symbol.atBack( cursor:cursorType ); @noframe; begin atBack; push( eax ); mov( [esp+@offset(cursor)], eax ); cmp( eax, this.endData ); pop( eax ); ret(); end atBack; // atIndex - // Returns a cursor (in EAX) that references the nTH element // in the vector. Returns endData if n is beyond the end of the // vector. method symbol.atIndex( n:uns32 in eax ); @noframe; begin atIndex; if( eax >= this.numElements ) then mov( this.endData, eax ); else intmul( @size( vectorType ), eax ); add( this.data, eax ); endif; ret(); end atIndex; #endif // getRef- // Computes the address of element n in the array // and returns this value in EAX. If n exceeds the // array bounds, then at returns the address of the // end of the array. method symbol.getRef( n:uns32 in eax ); @noframe; begin getRef; intmul( @size( vectorType ), eax ); add( this.data, eax ); if( eax > this.endData ) then mov( this.endData, eax ); endif; ret(); end getRef; // getVal- // Copies the nTH data item to the specified variable. // If n is out of range, no action is taken. method symbol.getVal( n:uns32; var dest:vectorType ); @nodisplay; @noalignstack; begin getVal; pushfd(); push( edi ); cld(); intmul( @size( vectorType ), n, edi ); add( this.data, edi ); if( edi < this.endData ) then push( esi ); mov( edi, esi ); mov( dest, edi ); #if( @size( vectorType ) = 1 ) movsb(); #elseif( @size( vectorType ) = 2 ) movsw(); #elseif( @size( vectorType ) = 4 ) movsd(); #else push( ecx ); #if( (@size( vectorType ) & %11) = 0 ) mov( @size( vectorType ) div 4, ecx ); rep.movsd(); #elseif( (@size( vectorType ) &
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -