Hi Jb,

I know what u mean now. What u mentioned below "var pi = Math.PI" is a local variable declaration. I would be able to see the following if I used it as a variable declaration, but what I meant is I want a field declaration.

ldc.r8 3.1415926535897931
stloc pi

Field declaration eg: "public double pi = Math.PI;"

But I can only detect this field when I assign this value to the field in a method. If I put it as a field declaration or assign this value to the field in a ctr, I won't be able to see the above instr.

Is there anyway I can see it even if I put it as a field declaration or overwrite the field in a ctr?

Hope to hear a reply from you, thanks.
Li Yen


--------------------------------------------------
From: "Jb Evain" <[email protected]>
Sent: Friday, January 08, 2010 5:58 PM
To: <[email protected]>
Subject: Re: [mono-cecil] Field read and write

2010/1/8 Li Yen Wee <[email protected]>:
But how has it got to do with me not being able to detect the field PIValue
as written and Math.PI as read?

Again, if you had bothered to investigate a little bit you would know.
PI is defined as a constant, so the compiler will inline its value
everywhere it's used

var pi = Math.PI is compiled as:

ldc.r8 3.1415926535897931
stloc pi

So if you want to detect where PI is used, you have to check for the
`ldc.r8 Math.PI` pattern.

--
Jb Evain  <[email protected]>




--
--
mono-cecil

-- 
--
mono-cecil

Reply via email to