Questions tagged [dynamic-compilation]

Questions about code compilation in runtime. Alternatively, "Just-in-time compilation", "dynamic translation" or "runtime compilation". Used mostly by the runtime environment of tokenizing or interpreted languages.

Questions about code compilation in runtime.

Advantages

  • Compilation can be optimized for the current runtime system. This information is normally unavailable in compilation time.
  • Compilation to binary code is possible even independently from the CPU architecture.
  • Compilation can happen into memory, resulting platform-independent code combined with nearly binary code performance.

Disadvantages

  • Compiler must be part of the runtime environment.
  • Slow startup time.
  • Compile-time errors might appear only in runtime.

References

121 questions
214
votes
7 answers

Is it possible to dynamically compile and execute C# code fragments?

I was wondering if it is possible to save C# code fragments to a text file (or any input stream), and then execute those dynamically? Assuming what is provided to me would compile fine within any Main() block, is it possible to compile and/or…
esac
  • 24,099
  • 38
  • 122
  • 179
142
votes
10 answers

C/C++ line number

In the sake of debugging purposes, can I get the line number in C/C++ compilers? (standard way or specific ways for certain compilers) e.g if(!Logical) printf("Not logical value at line number %d \n",LineNumber); // How to get LineNumber…
Betamoo
  • 14,964
  • 25
  • 75
  • 109
37
votes
9 answers

Dynamically generate classes at runtime in php?

Here's what I want to do: $clsName = substr(md5(rand()),0,10); //generate a random name $cls = new $clsName(); //create a new instance function __autoload($class_name) { //define that instance dynamically } Obviously this isn't what I'm actually…
Will Shaver
  • 12,471
  • 5
  • 49
  • 64
28
votes
5 answers

InvalidCastException for Object of the same type - Custom Control Load

I have a very wired error, one of my custom controls seems that is create two compiled files, and when I try to load it dynamically with LoadControl() is just fail because can not cast the one to the other - even if they are exactly the same. I…
Aristos
  • 66,005
  • 16
  • 114
  • 150
14
votes
2 answers

Where are the Assemblies for an ASP.NET Web Site When Running IIS Express

I know that with dynamic compilation under an ASP.NET Web Site, code behind files get compiled into Assemblies. Where do these DLL's get stored when running IIS Express? Is it in memory only? I don't see them in the bin folder, or in the temp…
SaltProgrammer
  • 1,045
  • 2
  • 13
  • 29
12
votes
3 answers

Specify Output Path for Dynamic Compilation

My dynamic compilation in Java 6 is working perfectly. However, I would like to change the output path. I have tried tons of things (I'll spare you) to no avail. Anyway, here's the working code String[] filesToCompile = { "testFiles/Something.java"…
Dan Rosenstark
  • 68,471
  • 58
  • 283
  • 421
11
votes
1 answer

MEF and MVC 3 - how to load embedded views dynamically from mef container?

I'm building an MVC 3 application where MEF is used. The main idea is to have plug-in mechanism where models, controllers and views are loaded dynamically during runtime from mef container. Each plugin/module consists of two…
8
votes
1 answer

(C#) Compiling class at runtime and calling methods from original code

I'm trying to compile code at runtime in C#, then from the compiled code call a function or initialize a class which is defined in the original code. The code I currently have: using System; using System.Collections.Generic; using…
Yotam Salmon
  • 2,400
  • 22
  • 36
8
votes
1 answer

How safe is an AppDomain sandboxed with SecurityPermissionFlag.Execution?

I have a plug-in vector established using System.AddIn that accepts the body of a pre-defined method, munges the method body into boilerplate code, generates the assembly and executes the method. The assembly references System and System.Core and is…
Sky Sanders
  • 36,396
  • 8
  • 69
  • 90
7
votes
0 answers

Dynamic code loading w/ Haskell

I've been playing around with the plugins package. I want a host application to dynamically compile and load Haskell source files in a sandboxed environment. Compilation works just fine. Loading fails as soon as the plugin references modules…
W. Davis
  • 71
  • 3
7
votes
2 answers

Render ASPX page at runtime from database

Assuming the code below: public class DynamicAspxHandler : IHttpHandler { bool IHttpHandler.IsReusable { get { return false; } } void IHttpHandler.ProcessRequest(HttpContext httpContext) { string aspxContent = PlainASPXContent(); …
Dmytrii Nagirniak
  • 23,696
  • 13
  • 75
  • 130
7
votes
1 answer

Haskell GHC Dynamic Compliation Only works on first compile

Following the GHC tutorial posted here and alterations to this code following the advice in a previous stack overflow question I asked, I have created a program which is able to compile and run a module in Test.hs with a function print to print a…
7
votes
2 answers

Dynamic Compilation in Haskell GHC API Error

I have been trying to get some basic dynamic code compilation working using the GHC API by following a tutorial found here. This code: import GHC import GHC.Paths import DynFlags import Unsafe.Coerce main :: IO () main = defaultErrorHandler…
Craig Innes
  • 1,573
  • 11
  • 23
6
votes
1 answer

'Rectangle' does not exist in the namespace 'System.Drawing'

Using .NET 2.0. System.Drawing is in my References list. Here is my using statement: using System.Drawing; Here is the code: private static Rectangle rScreen; Here is the error on this line: Error Text: The type or namespace name 'Rectangle' does…
user390480
  • 1,655
  • 4
  • 28
  • 61
6
votes
3 answers

Options for dynamic compilation in Java 5

Are there any options other than Janino for on-the-fly compiliation and execution of Java code in v5? I know v6 has the Compiler API, but I need to work with the v5 VM. I essentially need to take a string containing a complete Java class, compile…
Ryan Emerle
  • 15,461
  • 8
  • 52
  • 69
1
2 3
8 9