public override void Optimize()
            {
                int total = 0, fc = 0;

                do
                {
                    var vartypes = new Dictionary <Variable, Dictionary <Type, List <Expression> > >();
                    var p0       = new Pass0 {
                        vartypes = vartypes
                    };
                    p0.WalkNode(Root);

                    var p1 = new Pass1 {
                        vartypes = vartypes
                    };
                    p1.WalkNode(Root);

                    fc     = p1.Count;
                    total += fc;
                }while (fc > 0);

                //if (total > 0)
                //{
                //  Console.WriteLine("Typed {0} variables", total);
                //}
            }
            public override void Optimize()
            {
                var fixups    = new List <CodeBlock>();
                var refmap    = new Dictionary <Variable, int>();
                var callsites = new Dictionary <Variable, int>();

                Pass0 p0 = new Pass0(refmap, callsites);

                p0.WalkNode(Root);

                Pass1 p1 = new Pass1(fixups, refmap, callsites);

                p1.WalkNode(Root);

                Pass2 p2 = new Pass2();

                p2.WalkNode(Root);

                foreach (var cb in Distinct(fixups))
                {
                    cb.Bind();
                }

                Root.Bind();
            }
            public override void Optimize()
            {
                Pass0 p0 = new Pass0(references);

                p0.WalkNode(Root);

                foreach (var v in references.Keys)
                {
                    foreach (var t in references[v].Keys)
                    {
                        var c = references[v][t];

                        if (t != typeof(object) && c > 1 && t.IsValueType)
                        {
                            var n  = SymbolTable.StringToId(t.Name + "___" + SymbolTable.IdToString(v.Name));
                            var tv = v.Block.CreateVariable(n, Variable.VariableKind.Local, t);
                            v.SetTypedVariable(t, tv);

                            var vv = v;

                            if (vv.Kind == Variable.VariableKind.Local && vv.AssumedValue is BoundExpression)
                            {
                                var assbe = vv.AssumedValue as BoundExpression;
                                if (assbe.Variable.Kind == Variable.VariableKind.Parameter)
                                {
                                    vv = assbe.Variable;
                                }
                            }

                            var inittv = Ast.Write(tv, Ast.SimpleCallHelper(typeof(IronScheme.Runtime.Helpers).GetMethod("UnsafeConvert").MakeGenericMethod(tv.Type), Ast.Read(vv)));

                            var bs = v.Block.Body as BlockStatement;
                            if (bs != null)
                            {
                                Statement[] newbody = new Statement[bs.Statements.Count + 1];
                                newbody[0] = inittv;
                                bs.Statements.CopyTo(newbody, 1);

                                v.Block.Body = Ast.Block(newbody);
                            }
                            else
                            {
                                v.Block.Body = Ast.Block(inittv, v.Block.Body);
                            }
                        }
                    }
                    v.Block.Bind();
                }

                Pass1 p1 = new Pass1(references);

                p1.WalkNode(Root);

                foreach (var v in references.Keys)
                {
                    v.Block.Bind();
                }
            }
            public override void Optimize()
            {
                Pass0 p0 = new Pass0(references);
                p0.WalkNode(Root);

                foreach (var v in references.Keys)
                {
                  foreach (var t in references[v].Keys)
                  {
                var c = references[v][t];

                if (t != typeof(object) && c > 1 && t.IsValueType)
                {
                  var n = SymbolTable.StringToId(t.Name + "___" + SymbolTable.IdToString(v.Name));
                  var tv = v.Block.CreateVariable(n, Variable.VariableKind.Local, t);
                  v.SetTypedVariable(t, tv);

                  var vv = v;

                  if (vv.Kind == Variable.VariableKind.Local && vv.AssumedValue is BoundExpression)
                  {
                var assbe = vv.AssumedValue as BoundExpression;
                if (assbe.Variable.Kind == Variable.VariableKind.Parameter)
                {
                  vv = assbe.Variable;
                }
                  }

                  var inittv = Ast.Write(tv, Ast.SimpleCallHelper(typeof(IronScheme.Runtime.Helpers).GetMethod("UnsafeConvert").MakeGenericMethod(tv.Type), Ast.Read(vv)));

                  var bs = v.Block.Body as BlockStatement;
                  if (bs != null)
                  {
                Statement[] newbody = new Statement[bs.Statements.Count + 1];
                newbody[0] = inittv;
                bs.Statements.CopyTo(newbody, 1);

                v.Block.Body = Ast.Block(newbody);
                  }
                  else
                  {
                v.Block.Body = Ast.Block(inittv, v.Block.Body);
                  }
                }
                  }
                  v.Block.Bind();
                }

                Pass1 p1 = new Pass1(references);
                p1.WalkNode(Root);

                foreach (var v in references.Keys)
                {
                  v.Block.Bind();
                }
            }
      public override void Optimize()
      {
        int total = 0, fc = 0;
        do
        {
          var vartypes = new Dictionary<Variable, Dictionary<Type, List<Expression>>>();
          var p0 = new Pass0 { vartypes = vartypes };
          p0.WalkNode(Root);

          var p1 = new Pass1 { vartypes = vartypes };
          p1.WalkNode(Root);

          fc = p1.Count;
          total += fc;
        }
        while (fc > 0);

        //if (total > 0)
        //{
        //  Console.WriteLine("Typed {0} variables", total);
        //}
      }
            public override void Optimize()
            {
                var fixups = new List<CodeBlock>();
                var refmap = new Dictionary<Variable, int>();
                var callsites = new Dictionary<Variable, int>();

                Pass0 p0 = new Pass0(refmap, callsites);
                p0.WalkNode(Root);

                Pass1 p1 = new Pass1(fixups, refmap, callsites);
                p1.WalkNode(Root);

                Pass2 p2 = new Pass2();
                p2.WalkNode(Root);

                foreach (var cb in Distinct(fixups))
                {
                  cb.Bind();
                }

                Root.Bind();
            }