Re: [mono-cecil] replacing float types

68 views
Skip to first unread message

Jb Evain

unread,
Mar 13, 2013, 5:06:32 AM3/13/13
to mono-...@googlegroups.com
Hi,

Wouldn't it be easier to say decompile the 3rd party library using
ILSpy or any another decompiler, fix the code, and recompile it back?

I mean, you can certainly do it with Cecil, but it's going to be more
tedious (tediouser?).

Jb


On Mon, Mar 11, 2013 at 6:42 PM, <martijn...@yahoo.com> wrote:
> Hi,
>
> Someone pointed me to cecil for a problem I've run into;
> I'm using a fixedpoint class to make sure my calculations deliver
> deterministic results across different platforms. Now I also want to apply
> this to a 3rdpart library I'm using, but this library is using floats, which
> I'd like to replace using the custom fixedpoint struct (which uses operator
> overloading for all operations). Is this possible using cecil and if so,
> does anyone have any pointers/tips to get me started? I guess I have to
> replace all math functions like cos/sin/tan etc with respective fixedpoint
> ones too?
>
> Thanks!
>
> Martijn
>
> --
> --
> --
> mono-cecil
> ---
> You received this message because you are subscribed to the Google Groups
> "mono-cecil" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mono-cecil+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

martijn...@yahoo.com

unread,
Mar 13, 2013, 4:05:01 PM3/13/13
to mono-...@googlegroups.com
I actually thought (hoped ;) it would be less tedious using Cecil; I'd only have to write the parser once and be able to run it on any library in question? Also, I'd be able to take advantages of updates the original author does on the origninal lib, and run it through the replace procedure again.
 
I started doing some tests, but run into problems quickly:
 
The Cecil replace code:
 
And the test module in which I'm trying to replace floats with int's:
 
It seems to find all floats, but if I try to replace something (In the example I only try so for float method return types), it will cause my test to thow a "not supported by the language".. Any ideas / suggestions?
 
Thanks!
 
Martijn

Jb Evain

unread,
Mar 15, 2013, 10:27:11 AM3/15/13
to mono-...@googlegroups.com
Hey Martijn,

Primitive are special beasts, you probably don't want to create them
manually. Use the module's TypeSystem instead.

Jb

martijn...@yahoo.com

unread,
Mar 26, 2013, 3:20:14 PM3/26/13
to mono-...@googlegroups.com
Thanks, that did the trick, I was able to ge things running when using:

TypeReference r_type = module.Import(typeof(int));

..now back to the original problem, do you think the steps in the code I posted would be a good start to approach this problem?
 
 
Op vrijdag 15 maart 2013 15:27:11 UTC+1 schreef Jb Evain het volgende:
Reply all
Reply to author
Forward
0 new messages