intermediate-language

How does the .NET IL .maxstack directive work?

妖精的绣舞 提交于 2020-01-29 04:18:08
问题 I'd like to know how does .maxstack really work. I know it doesn't have to do with the actual size of the types you are declaring but with the number of them. My questions are: does this apply just for the function, or to all the functions that we are calling for? even if it's just for the function were .maxstack is being declared, how do you know what maxstack is if you have branching? You go and see all the "paths" and return the maximum value possible? What happens if I set it to 16 and

Which Tools Perform Post-Compile Modification of IL?

我只是一个虾纸丫 提交于 2020-01-01 03:41:12
问题 A recent mention of PostSharp reminded me of this: Last year where I worked, we were thinking of using PostSharp to inject instrumentation into our code. This was in a Team Foundation Server Team Build / Continuous Integration environment. Thinking about it, I got a nagging feeling about the way PostSharp operates - it edits the IL that is generated by the compilers. This bothered me a bit. I wasn't so much concerned that PostSharp would not do its job correctly; I was worried about the fact

Mechanism to extract specific IL (.NET Intermediate Language) signatures from an assembly

大城市里の小女人 提交于 2019-12-21 23:16:03
问题 I have a list of about 25 types found in the Microsoft .NET assembly mscorlib.dll where I need to extract the IL signatures of the class and its members. I want one file per type, with each signature on one line. So, for example, take the type System.Collections.Generic.Comparer<T> I want to extract the following from the assembly for that type (there are some private members I won't need, but I can handle that manually if needed). .class public abstract auto ansi serializable beforefieldinit

How do actually castings work at the CLR level?

≯℡__Kan透↙ 提交于 2019-12-19 03:09:38
问题 When doing an upcast or downcast, what does really happen behind the scenes? I had the idea that when doing something as: string myString = "abc"; object myObject = myString; string myStringBack = (string)myObject; the cast in the last line would have as only purpose tell the compiler we are safe we are not doing anything wrong. So, I had the idea that actually no casting code would be embedded in the code itself. It seems I was wrong: .maxstack 1 .locals init ( [0] string myString, [1]

How does backpatching work with markers?

回眸只為那壹抹淺笑 提交于 2019-12-11 02:44:51
问题 I've searched all over the Internet and could not find a proper explanation of how backpatching works? Can you please explain me how does backpatching works? How does it work with the markers ? I know it has 2 main types of markers: with next-quad in it with next-list in it I found this code, in which they are taking an input file and creating a file with RISKI language. In their first roll they have: PROGRAM : N FUNCTION M MAIN_FUNCTION and you can see that N and M are markers (they are

Making a language, need a good backend

梦想的初衷 提交于 2019-12-09 12:33:45
问题 I want to make a compiled language. I am currently evaluating backends. So far I am looking at C because of its speed of execution, compiling, and a small, easy to use compiler called TCC. Having read the discussions here about using it as an intermediate language, I am trying to think about how to make it compatible with garbage collection, and handling exceptions. So far, I think I can solve both, but with much overhead. Here are some of my thoughts on the other possible backends: Assembly:

What does an if look like in IL?

感情迁移 提交于 2019-12-06 07:41:50
问题 What does an if statement look like when it's compiled into IL? It's a very simple construct in C#. Can sombody give me a more abstract definition of what it really is? 回答1: Here are a few if statements and how they translate to IL: ldc.i4.s 0x2f var i = 47; stloc.0 ldloc.0 if (i == 47) ldc.i4.s 0x2f bne.un.s L_0012 ldstr "forty-seven!" Console.WriteLine("forty-seven!"); call Console::WriteLine L_0012: ldloc.0 if (i > 0) ldc.i4.0 ble.s L_0020 ldstr "greater than zero!" Console.WriteLine(

Static analysis for partial C++ programs

三世轮回 提交于 2019-12-05 02:04:08
问题 I'm thinking about doing some static analysis project over C++ code samples , as opposed to entire programs. In general static analysis requires some simpler intermediate representation, but such a representation cannot be accurately created without the entire program code. Still, I know there is such a tool for Java - it basically "guesses" missing information and thus allows static analysis to take place even though it's no longer sound or complete. Is there anything similar that can be

Difference between interface as type constraint and interface as parameter?

 ̄綄美尐妖づ 提交于 2019-12-04 18:01:37
问题 If I wanted to create a method that takes an instance of IList as a parameter (or any other interface, but let's use IList as an example), I could create a generic method with a type constraint, e.g.: public static void Foo1<T>(T list) where T : IList { } Alternatively, I could create a method that takes an IList parameter directly: public static void Foo2(IList list) { } For all intents and purposes, it seems like these methods behave exactly the same: List<string> myList = new List<string>(

What does an if look like in IL?

旧巷老猫 提交于 2019-12-04 13:18:49
What does an if statement look like when it's compiled into IL? It's a very simple construct in C#. Can sombody give me a more abstract definition of what it really is? Here are a few if statements and how they translate to IL: ldc.i4.s 0x2f var i = 47; stloc.0 ldloc.0 if (i == 47) ldc.i4.s 0x2f bne.un.s L_0012 ldstr "forty-seven!" Console.WriteLine("forty-seven!"); call Console::WriteLine L_0012: ldloc.0 if (i > 0) ldc.i4.0 ble.s L_0020 ldstr "greater than zero!" Console.WriteLine("greater than zero!"); call Console::WriteLine L_0020: ldloc.0 bool b = (i != 0); ldc.i4.0 ceq ldc.i4.0 ceq stloc