Skip to content

Instantly share code, notes, and snippets.

@pjc0247
Last active November 30, 2018 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pjc0247/7fe3c25f7813abe4a4cd to your computer and use it in GitHub Desktop.
Save pjc0247/7fe3c25f7813abe4a4cd to your computer and use it in GitHub Desktop.

Remit

Runtime-Compile, Runtime-Binding

Things to do

(int n) => {
  var sum = 0;
  for(var i=0;i<n;i++) {
    sum += i;
  }
  return sum;
}

traditional-way

ilGenerator.Emit(OpCodes.Ldc_I4, 0);
ilGenerator.Emit(OpCodes.Stloc_0);
/* ... */

with Remit

var program = Remit.Program.Compile(
  @"
  $loc_1 = 0;
  for(var $loc_0 = 0; $loc_0 <= $arg_0; $loc_0 ++) {
    $loc_1 += $loc_0;
  }
  return $loc_0;
  ");
ilGenerator.Attach(program);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment