Skip to content

Instantly share code, notes, and snippets.

@einarwh
Last active December 31, 2015 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save einarwh/8021717 to your computer and use it in GitHub Desktop.
Save einarwh/8021717 to your computer and use it in GitHub Desktop.
A very simple f-function factory.
private Func<EvalStack, EvalStack> CreateF(Instruction insn)
{
var op = insn.OpCode;
if (op == OpCodes.Ldarg_0)
{
// Prototypical *this* generator!!
return stack => stack.Push(true);
}
if (op == OpCodes.Dup)
{
// Prototypical *this* propagator!!
return stack => stack.Push(stack.Peek());
}
return CreateConsumerF(insn);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment