Questions tagged [intermediate-language]

An intermediate language, in compiler design, is a low-level language that typically resembles an idealized assembly language, often a textual representation of bytecode for a virtual machine. For .NET's CIL, use the [cil] tag.

An intermediate language, in compiler design, is a translation stage after the syntax tree and before the machine code. The term is usually used for final stages of the translation, after high-level optimizations have been performed, but at a stage when the translation is still independent of the target machine.

In particular, “intermediate language” often means a low-level, assembly-like language for a virtual machine such as the JVM, .NET, Prolog's WAM, etc.

For example, the .NET Common Intermediate Language is the assembly language for the virtual machine that is the target of and other compilers.

144 questions
9
votes
2 answers

How and when does .NET actually compile code?

Let's say you write an app in C#, VB, anything with .NET When you hit build, does it really compile your code? I thought so until I started using redgates reflector on some of my assemblies and saw my code verbatim. I would have expected loops to be…
Matt
  • 25,943
  • 66
  • 198
  • 303
8
votes
2 answers

What is the meaning of -2 in this IL instruction?

I was discovering the IL code of a simple program: long x = 0; for(long i = 0;i< int.MaxValue * 2L; i++) { x = i; } Console.WriteLine(x); I build this code in Release mode and this IL code is generated: .method private hidebysig static void …
Selman Genç
  • 100,147
  • 13
  • 119
  • 184
7
votes
1 answer

Translator using Antlr4

I want to create a translator from SQL to XQuery. I want to parse SQL and generate an intermediate structure and then use it to generate the XQuery query. (Note- I want to use an intermediate representation because i'm looking forward to translating…
Great
  • 95
  • 1
  • 4
7
votes
2 answers

Why would you need to emit IL code?

I work in a code base that is quite large and today I found a project that was emitting IL code inside a normal class. The project containing the IL code being emitted was a implementation of a Service Locator MSDN Desctiption. What are the…
ojhawkins
  • 3,200
  • 15
  • 50
  • 67
7
votes
2 answers

IL Compiler for .NET?

This may be a dumb question, but is there a compiler for IL code, similar to that shown by Reflector in IL mode?
RCIX
  • 38,647
  • 50
  • 150
  • 207
7
votes
2 answers

How stable is the LLVM assembly language?

The LLVM Language Reference states that it can be used as an on-disk bitcode representation (suitable for fast loading by a Just-In-Time compiler) How stable is this representation? E.g., can I generate it today using LLVM 3.1 and still expect it…
Tobias
  • 6,388
  • 4
  • 39
  • 64
6
votes
2 answers

How do actually castings work at the CLR level?

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…
devoured elysium
  • 101,373
  • 131
  • 340
  • 557
6
votes
1 answer

Why doesn't C# compile directly to machine code?

CIL is an object-oriented assembly language, and is entirely stack-based. Its bytecode is translated into native code or — most commonly — executed by a virtual machine. Why do we need CIL? Is it not possible to translate C# into native code…
Person.Junkie
  • 1,816
  • 4
  • 21
  • 31
5
votes
1 answer

Why do assemblies with the SecurityTransparent attribute cause instrumented code via a profiler to throw a VerificationException?

It seems when I instrument an assembly using OpenCover, assemblies with the SecurityTransparent attribute (and AllowPartiallyTrustedCallers it seems) will throw a VerificationException. I'd like to know why that is and if there is an alternative…
Shaun Wilde
  • 8,228
  • 4
  • 36
  • 56
5
votes
0 answers

How are "indirect triples" more advantageous than "quadruples" in the intermediate representation of source program

Consider the assignment, a := b*-c + b*-c. Fig. 1 Quadruples for the above statement Below is an excerpt from the red dragon book. Indirect triples can save some space compared with quadruples if the same temporary value is used more than once.…
Abhishek Ghosh
  • 597
  • 7
  • 18
5
votes
0 answers

How does the "ThrowHelper" .Net Framework class help lessen the generated IL code?

I was looking at this and it its starting comments it says it exists because throw new ArgumentNullException("key", Environment.GetResourceString("ArgumentNull_Key")); generates more IL code…
user14092802
  • 105
  • 10
5
votes
1 answer

Three Address Code (TAC / 3AC)

While doing some reading, I came across the terms "Intermediate Language" and "3AC". IL, as I understand, is the middle "step" in the source code compilation process. More specifically, I'm reading about bytecode (Java) and C. The way I interpret…
Carlos
  • 5,405
  • 21
  • 68
  • 114
5
votes
2 answers

InvalidProgramException (Invalid IL Code)?

I was trying to emit the following code as IL code at runtime. class TestObject { public int Hello {get;set;} public int Test {get;set;} } static TestObject test(BinaryReader reader) { var a = new TestObject(); …
AmazingTurtle
  • 1,187
  • 1
  • 15
  • 31
5
votes
4 answers

What does an if look like in IL?

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?
DaveDev
  • 41,155
  • 72
  • 223
  • 385
5
votes
4 answers

Which Tools Perform Post-Compile Modification of IL?

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…
John Saunders
  • 160,644
  • 26
  • 247
  • 397
1
2
3
9 10