Git Product home page Git Product logo

Comments (4)

jbevain avatar jbevain commented on May 20, 2024

Sorry but I don't understand what you think the problem is. Please write the complete IL of the method, and what you think is wrong in which instruction.

from cecil.

mehfuzh avatar mehfuzh commented on May 20, 2024

Hi Evain,
Here goes the full IL
[0]: {IL_0000: nop}
[1]: {IL_0001: ldarg.1}
[2]: {IL_0002: stloc.1}
[3]: {IL_0003: ldloc.1}
[4]: {IL_0004: switch IL_0013,IL_0018}
[5]: {IL_0011: br.s IL_001d}
[6]: {IL_0013: nop}
[7]: {IL_0014: ldc.i4.2}
[8]: {IL_0015: stloc.0}
[9]: {IL_0016: br.s IL_0022}
[10]: {IL_0018: nop}
[11]: {IL_0019: ldc.i4.4}
[12]: {IL_001a: stloc.0}
[13]: {IL_001b: br.s IL_0022}
[14]: {IL_001d: nop}
[15]: {IL_001e: ldc.i4.0}
[16]: {IL_001f: stloc.0}
[17]: {IL_0020: br.s IL_0022}
[18]: {IL_0022: ldloc.0}
[19]: {IL_0023: ret}

Now, when i am at IL_0004 and I call instruction.Operand contains array of OpCodes.Nop, instead of the branch instructions br.s IL_001d and br.s IL_0022 needed to create control flow for switch. As IL_0013 points to nop , it is literally valid but invalid in case of processing branch. For switch statement with return , MSIL generates an extra nop instruction. I was thinking if instruction.Operand call can return instructions for IL_0011 and IL_0016 instead of IL_0013 and IL_0018 respectively.

from cecil.

jbevain avatar jbevain commented on May 20, 2024

Sorry but you're wrong here. The switch is properly constructed and contains the appropriate instructions. It doesn't make any sense for the operands to contain something else than the actual jump points in the jump table.

And it's invalid in no case at all, if you want to build a CFG for a switch statement, you have to create basic blocks starting at each jump points of the switch and starting at its next instruction. Closing.

from cecil.

mehfuzh avatar mehfuzh commented on May 20, 2024

Thanks for the clarification, much appreciated.

from cecil.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.