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.

133 questions
8
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
  • 24,106
  • 61
  • 180
  • 291
7
votes
4 answers

Which Assembly Language to Learn

I'm interested in learning Assembly, specifically because I find polymorphic code rather interesting and I'm kind of confused as to which I should learn. I heard x86 is the most common to learn or start with, but aren't most applications (written…
7
votes
6 answers

Making a language, need a good backend

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…
Unknown
  • 43,382
  • 24
  • 132
  • 174
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
  • 35,702
  • 48
  • 141
  • 204
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
  • 90,453
  • 117
  • 313
  • 521
6
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,052
  • 14
  • 44
  • 67
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
  • 7,860
  • 4
  • 32
  • 52
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,256
  • 19
  • 64
  • 113
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,046
  • 14
  • 27
5
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,516
  • 4
  • 18
  • 27
5
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
  • 5,950
  • 3
  • 33
  • 60
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
  • 157,405
  • 24
  • 229
  • 388
4
votes
3 answers

Static analysis for partial C++ programs

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…
Oak
  • 24,536
  • 5
  • 83
  • 146
4
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…
4
votes
1 answer

Question about how the C# Compiler emits TypeRef information

I found this interesting thing when I was trying out the new feature “optional parameters” in C# 4.0. I know that there are two ways to use “optional parameters” in C# 4.0: static void TestMethod(int parameter = 5) { } static void…
1
2
3
8 9