[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] pnet/image image.h, 1.32, 1.33 meta_build.c, 1.32,
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] pnet/image image.h, 1.32, 1.33 meta_build.c, 1.32, 1.33 misc_token.c, 1.6, 1.7 |
Date: |
Tue, 14 Oct 2003 04:12:24 +0000 |
Update of /cvsroot/dotgnu-pnet/pnet/image
In directory subversions:/tmp/cvs-serv3249/image
Modified Files:
image.h meta_build.c misc_token.c
Log Message:
Search for owned items in a way that avoids loading an
item unless it is actually the one that was sought.
Index: meta_build.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/meta_build.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** meta_build.c 25 Sep 2003 01:37:49 -0000 1.32
--- meta_build.c 14 Oct 2003 04:12:21 -0000 1.33
***************
*** 274,281 ****
* from the function, or zero if there are no matches.
*/
! typedef int (*SearchRawFunc)(ILUInt32 *values, ILToken searchFor);
! static ILUInt32 SearchForRawToken(ILImage *image, SearchRawFunc func,
! ILToken
ownedType, ILToken *firstMatch,
! ILToken
searchFor)
{
ILUInt32 values[IL_IMAGE_TOKEN_COLUMNS];
--- 274,280 ----
* from the function, or zero if there are no matches.
*/
! ILUInt32 _ILSearchForRawToken(ILImage *image, ILSearchRawFunc func,
! ILToken ownedType,
ILToken *firstMatch,
! ILToken searchFor,
int valueField)
{
ILUInt32 values[IL_IMAGE_TOKEN_COLUMNS];
***************
*** 297,301 ****
return 0;
}
! cmp = (*func)(values, searchFor);
if(cmp == 0)
{
--- 296,300 ----
return 0;
}
! cmp = (*func)(values, searchFor, valueField);
if(cmp == 0)
{
***************
*** 310,314 ****
return 0;
}
! if((*func)(values, searchFor) != 0)
{
break;
--- 309,313 ----
return 0;
}
! if((*func)(values, searchFor,
valueField) != 0)
{
break;
***************
*** 328,332 ****
return 0;
}
! if((*func)(values, searchFor) != 0)
{
break;
--- 327,331 ----
return 0;
}
! if((*func)(values, searchFor,
valueField) != 0)
{
break;
***************
*** 356,360 ****
return 0;
}
! if((*func)(values, searchFor) == 0)
{
/* This is the first match in the table.
Determine
--- 355,359 ----
return 0;
}
! if((*func)(values, searchFor, valueField) == 0)
{
/* This is the first match in the table.
Determine
***************
*** 369,373 ****
return 0;
}
! if((*func)(values, searchFor) != 0)
{
break;
--- 368,372 ----
return 0;
}
! if((*func)(values, searchFor,
valueField) != 0)
{
break;
***************
*** 1446,1450 ****
* Search for a PInvoke token in a raw token table.
*/
! static int Search_PInvoke(ILUInt32 *values, ILToken token1)
{
ILToken token2 = (ILToken)(values[IL_OFFSET_IMPLMAP_METHOD]);
--- 1445,1449 ----
* Search for a PInvoke token in a raw token table.
*/
! static int Search_PInvoke(ILUInt32 *values, ILToken token1, int valueField)
{
ILToken token2 = (ILToken)(values[IL_OFFSET_IMPLMAP_METHOD]);
***************
*** 1486,1491 ****
/* Search the ImplMap table for a matching PInvoke declaration */
! if(SearchForRawToken(image, Search_PInvoke, IL_META_TOKEN_IMPL_MAP,
! &token, searchFor) == 0)
{
return;
--- 1485,1490 ----
/* Search the ImplMap table for a matching PInvoke declaration */
! if(_ILSearchForRawToken(image, Search_PInvoke, IL_META_TOKEN_IMPL_MAP,
! &token, searchFor, 0) == 0)
{
return;
***************
*** 2677,2681 ****
* Search for a custom attribute declaration in a raw token table.
*/
! static int Search_CustomAttr(ILUInt32 *values, ILToken token1)
{
ILToken token2 = (ILToken)(values[IL_OFFSET_CUSTOMATTR_OWNER]);
--- 2676,2680 ----
* Search for a custom attribute declaration in a raw token table.
*/
! static int Search_CustomAttr(ILUInt32 *values, ILToken token1, int valueField)
{
ILToken token2 = (ILToken)(values[IL_OFFSET_CUSTOMATTR_OWNER]);
***************
*** 2767,2773 ****
/* Find the custom attribute information for this token */
! numTokens = SearchForRawToken(item->image, Search_CustomAttr,
!
IL_META_TOKEN_CUSTOM_ATTRIBUTE,
! &token,
(ILToken)(item->token));
/* Load the custom attribute tokens for this item */
--- 2766,2772 ----
/* Find the custom attribute information for this token */
! numTokens = _ILSearchForRawToken(item->image, Search_CustomAttr,
!
IL_META_TOKEN_CUSTOM_ATTRIBUTE,
! &token,
(ILToken)(item->token), 0);
/* Load the custom attribute tokens for this item */
Index: image.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/image.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** image.h 29 Sep 2003 07:11:31 -0000 1.32
--- image.h 14 Oct 2003 04:12:21 -0000 1.33
***************
*** 501,504 ****
--- 501,516 ----
unsigned long token, unsigned long
tokenKind);
+ /*
+ * Search the raw values in an owned item table for a token match.
+ * Returns the first token that matches in the "ownedType" table
+ * in "firstMatch". The number of tokens that match is returned
+ * from the function, or zero if there are no matches.
+ */
+ typedef int (*ILSearchRawFunc)(ILUInt32 *values, ILToken searchFor,
+ int valueField);
+ ILUInt32 _ILSearchForRawToken(ILImage *image, ILSearchRawFunc func,
+ ILToken ownedType,
ILToken *firstMatch,
+ ILToken searchFor,
int valueField);
+
#ifdef IL_USE_WRITER
Index: misc_token.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/misc_token.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** misc_token.c 13 Jun 2003 06:44:04 -0000 1.6
--- misc_token.c 14 Oct 2003 04:12:21 -0000 1.7
***************
*** 237,240 ****
--- 237,268 ----
* values that we are using here.
*/
+ static int OwnedItemCompareRaw(ILUInt32 *values, ILToken searchFor,
+ int valueField)
+ {
+ ILToken token1 = searchFor;
+ ILToken token1Stripped = (token1 & ~IL_META_TOKEN_MASK);
+ ILToken token2 = (ILToken)(values[valueField]);
+ ILToken token2Stripped = (token2 & ~IL_META_TOKEN_MASK);
+ if(token1Stripped < token2Stripped)
+ {
+ return -1;
+ }
+ else if(token1Stripped > token2Stripped)
+ {
+ return 1;
+ }
+ else if(token1 < token2)
+ {
+ return -1;
+ }
+ else if(token1 > token2)
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+ }
static int OwnedItemCompare(void *item, void *userData)
{
***************
*** 266,269 ****
--- 294,322 ----
}
+ /*
+ * Search for an owned item.
+ */
+ static void *SearchForOwnedItem(ILImage *image, ILToken tokenType,
+ void *owner,
int valueField)
+ {
+ ILUInt32 token, num;
+ if(!owner)
+ {
+ return 0;
+ }
+ if(image->type == IL_IMAGETYPE_BUILDING)
+ {
+ return ILImageSearchForToken(image, tokenType,
OwnedItemCompare, owner);
+ }
+ num = _ILSearchForRawToken(image, OwnedItemCompareRaw, tokenType,
&token,
+ ((ILProgramItem
*)owner)->token,
+ valueField);
+ if(num != 1)
+ {
+ return 0;
+ }
+ return ILImageTokenInfo(image, token);
+ }
+
ILConstant *ILConstantGetFromOwner(ILProgramItem *owner)
{
***************
*** 297,303 ****
/* Search for the constant token */
! return (ILConstant *)ILImageSearchForToken
(owner->image, IL_META_TOKEN_CONSTANT,
! OwnedItemCompare, (void *)owner);
}
--- 350,356 ----
/* Search for the constant token */
! return (ILConstant *)SearchForOwnedItem
(owner->image, IL_META_TOKEN_CONSTANT,
! (void *)owner, IL_OFFSET_CONSTANT_REFERENCE);
}
***************
*** 356,363 ****
return 0;
}
! return (ILFieldRVA *)ILImageSearchForToken
(owner->member.programItem.image,
IL_META_TOKEN_FIELD_RVA,
! OwnedItemCompare, (void *)owner);
}
--- 409,416 ----
return 0;
}
! return (ILFieldRVA *)SearchForOwnedItem
(owner->member.programItem.image,
IL_META_TOKEN_FIELD_RVA,
! (void *)owner, IL_OFFSET_FIELDRVA_FIELD);
}
***************
*** 415,422 ****
/* Search for the layout token */
! return (ILFieldLayout *)ILImageSearchForToken
(owner->member.programItem.image,
IL_META_TOKEN_FIELD_LAYOUT,
! OwnedItemCompare, (void *)owner);
}
--- 468,475 ----
/* Search for the layout token */
! return (ILFieldLayout *)SearchForOwnedItem
(owner->member.programItem.image,
IL_META_TOKEN_FIELD_LAYOUT,
! (void *)owner, IL_OFFSET_FIELDLAYOUT_FIELD);
}
***************
*** 518,524 ****
/* Search for the token */
! return (ILFieldMarshal *)ILImageSearchForToken
(owner->image, IL_META_TOKEN_FIELD_MARSHAL,
! OwnedItemCompare, (void *)owner);
}
--- 571,577 ----
/* Search for the token */
! return (ILFieldMarshal *)SearchForOwnedItem
(owner->image, IL_META_TOKEN_FIELD_MARSHAL,
! (void *)owner, IL_OFFSET_FIELDMARSHAL_TOKEN);
}
***************
*** 588,594 ****
/* Search for the layout token */
! return (ILClassLayout *)ILImageSearchForToken
(owner->programItem.image,
IL_META_TOKEN_CLASS_LAYOUT,
! OwnedItemCompare, (void *)owner);
}
--- 641,647 ----
/* Search for the layout token */
! return (ILClassLayout *)SearchForOwnedItem
(owner->programItem.image,
IL_META_TOKEN_CLASS_LAYOUT,
! (void *)owner, IL_OFFSET_CLASSLAYOUT_TYPE);
}
***************
*** 676,682 ****
ILDeclSecurity *ILDeclSecurityGetFromOwner(ILProgramItem *owner)
{
! return (ILDeclSecurity *)ILImageSearchForToken
(owner->image, IL_META_TOKEN_DECL_SECURITY,
! OwnedItemCompare, (void *)owner);
}
--- 729,735 ----
ILDeclSecurity *ILDeclSecurityGetFromOwner(ILProgramItem *owner)
{
! return (ILDeclSecurity *)SearchForOwnedItem
(owner->image, IL_META_TOKEN_DECL_SECURITY,
! (void *)owner, IL_OFFSET_DECLSECURITY_TOKEN);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] pnet/image image.h, 1.32, 1.33 meta_build.c, 1.32, 1.33 misc_token.c, 1.6, 1.7,
Rhys Weatherley <address@hidden> <=