edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/IronPython/IronPython/Compiler/PythonGlobalVariableExpression.cs;C1258456
File: PythonGlobalVariableExpression.cs
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/IronPython/IronPython/Compiler/PythonGlobalVariableExpression.cs;C1258456  (server)    11/9/2009 10:58 AM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/IronPython/IronPython/Compiler/PythonGlobalVariableExpression.cs;InstructionRefactoring
@@ -124,7 +124,7 @@
         #region IInstructionProvider Members
 
         public void AddInstructions(LightCompiler compiler) {
-            compiler.AddInstruction(new PythonGlobalInstruction(_global));
+            compiler.Instructions.Emit(new PythonGlobalInstruction(_global));
         }
 
         #endregion
@@ -206,7 +206,7 @@
 
         public void AddInstructions(LightCompiler compiler) {
             compiler.Compile(_value);
-            compiler.AddInstruction(new PythonSetGlobalInstruction(_global.Global));
+            compiler.Instructions.Emit(new PythonSetGlobalInstruction(_global.Global));
         }
 
         #endregion
@@ -357,7 +357,7 @@
 
         void IInstructionProvider.AddInstructions(LightCompiler compiler) {
             compiler.Compile(_codeContextExpr);
-            compiler.AddInstruction(new LookupGlobalInstruction(_name, _isLocal));
+            compiler.Instructions.Emit(new LookupGlobalInstruction(_name, _isLocal));
         }
 
         #endregion
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/IronPython/IronPython/Compiler/Ast/FunctionDefinition.cs;C1258456
File: FunctionDefinition.cs
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/IronPython/IronPython/Compiler/Ast/FunctionDefinition.cs;C1258456  (server)    11/6/2009 8:15 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/IronPython/IronPython/Compiler/Ast/FunctionDefinition.cs;InstructionRefactoring
@@ -435,10 +435,12 @@
                 }
             }
 
-            compiler.AddInstruction(new FunctionDefinitionInstruction(globalContext, this, defaultCount, globalName));
+            compiler.Instructions.Emit(new FunctionDefinitionInstruction(globalContext, this, defaultCount, globalName));
         }
 
         private static void CompileAssignment(LightCompiler compiler, MSAst.Expression variable, Action<LightCompiler> compileValue) {
+            var instructions = compiler.Instructions;
+
             ClosureExpression closure = variable as ClosureExpression;
             if (closure != null) {
                 compiler.Compile(closure.ClosureCell);
@@ -446,31 +448,30 @@
             LookupGlobalVariable lookup = variable as LookupGlobalVariable;
             if (lookup != null) {
                 compiler.Compile(lookup.CodeContext);
-                compiler.AddInstruction(Instruction.Push(lookup.Name));
+                instructions.EmitLoad(lookup.Name);
             }
 
             compileValue(compiler);
 
             if (closure != null) {
-                compiler.AddInstruction(new FieldAssignInstruction(ClosureExpression._cellField));
+                instructions.EmitStoreField(ClosureExpression._cellField);
                 return;
             }
             if (lookup != null) {
-                compiler.AddInstruction(Instruction.Call(typeof(PythonOps).GetMethod(lookup.IsLocal ? "SetLocal" : "SetGlobal")));
+                instructions.EmitCall(typeof(PythonOps).GetMethod(lookup.IsLocal ? "SetLocal" : "SetGlobal"));
                 return;
             }
 
             MSAst.ParameterExpression functionValueParam = variable as MSAst.ParameterExpression;
             if (functionValueParam != null) {
-                compiler.AddInstruction(Instruction.SetLocal(compiler.GetVariableIndex(functionValueParam)));
-                compiler.AddInstruction(Instruction.Pop());
+                instructions.EmitStoreLocal(compiler.GetVariableIndex(functionValueParam));
                 return;
             }
 
             var globalVar = variable as PythonGlobalVariableExpression;
             if (globalVar != null) {
-                compiler.AddInstruction(new PythonSetGlobalInstruction(globalVar.Global));
-                compiler.AddInstruction(Instruction.Pop());
+                instructions.Emit(new PythonSetGlobalInstruction(globalVar.Global));
+                instructions.EmitPop();
                 return;
             }
             Debug.Assert(false, "Unsupported variable type for light compiling function");
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/IronPython/IronPython/Runtime/Binding/PythonGetMemberBinder.cs;C1230128
File: PythonGetMemberBinder.cs
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/IronPython/IronPython/Runtime/Binding/PythonGetMemberBinder.cs;C1230128  (server)    11/3/2009 5:27 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/IronPython/IronPython/Runtime/Binding/PythonGetMemberBinder.cs;InstructionRefactoring
@@ -395,11 +395,11 @@
 
                                 if (prop != null && (parameters = prop.GetParameters()).Length == 0) {
                                     if (prop.ReturnType == typeof(bool)) {
-                                        return new FastPropertyGet<TSelfType>(type, Instruction.Call(prop, parameters).Invoke).GetPropertyBool;
+                                        return new FastPropertyGet<TSelfType>(type, CallInstruction.Create(prop, parameters).Invoke).GetPropertyBool;
                                     } else if (prop.ReturnType == typeof(int)) {
-                                        return new FastPropertyGet<TSelfType>(type, Instruction.Call(prop, parameters).Invoke).GetPropertyInt;
+                                        return new FastPropertyGet<TSelfType>(type, CallInstruction.Create(prop, parameters).Invoke).GetPropertyInt;
                                     } else {
-                                        return new FastPropertyGet<TSelfType>(type, Instruction.Call(prop, parameters).Invoke).GetProperty;
+                                        return new FastPropertyGet<TSelfType>(type, CallInstruction.Create(prop, parameters).Invoke).GetProperty;
                                     }
                                 }
                             }
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/IronPython/Scripts/generate_dynamic_instructions.py;C1204880
File: generate_dynamic_instructions.py
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/IronPython/Scripts/generate_dynamic_instructions.py;C1204880  (server)    11/3/2009 6:22 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/IronPython/Scripts/generate_dynamic_instructions.py;InstructionRefactoring
@@ -54,39 +54,43 @@
   
     cw.enter_block('internal class DynamicInstruction<%s> : Instruction' % class_type_params)
     cw.write('private CallSite<%s> _site;' % func_type)
+    cw.write('')    
     cw.enter_block('public static Instruction Factory(CallSiteBinder binder)')
     cw.write('return new DynamicInstruction<%s>(CallSite<%s>.Create(binder));' % (class_type_params, func_type))
     cw.exit_block()
+    cw.write('')
     
     cw.enter_block('private DynamicInstruction(CallSite<%s> site)' % func_type)
-    cw.write('this._site = site;')
+    cw.write('_site = site;')
     cw.exit_block()
+    cw.write('')
     
     cw.write('public override int ProducedStack { get { return 1; } }')
     cw.write('public override int ConsumedStack { get { return %d; } }' % n)
+    cw.write('')
     
+    gen_interpreted_run(cw, n)
+    cw.write('')
+    cw.enter_block('public override string ToString()')
+    cw.write('return "Dynamic(" + _site.Binder.ToString() + ")";')
+    cw.exit_block()
+    
+    cw.exit_block()
+    cw.write('')
+    
+def gen_interpreted_run(cw, n):
     cw.enter_block('public override int Run(InterpretedFrame frame)')
-    args = get_args(n)
-    for arg in args[::-1]:
-        cw.write('object %s = frame.Pop();' % arg)
     
-        
-    args = ['_site'] + get_cast_args(n)
-    cw.write('frame.Push(_site.Target(')
+    args = '_site'
+    for i in xrange(0, n):
+        args += ', (T%d)frame.Data[frame.StackIndex - %d]' % (i, n - i)
     
-    for arg in args[:-1]:
-        cw.write('    ' + arg + ',')
-    cw.write('    ' + args[-1]+'));')
-        
-    cw.write('return +1;')
-    cw.exit_block()
+    cw.write('frame.Data[frame.StackIndex - %d] = _site.Target(%s);' % (n, args))
+    cw.write('frame.StackIndex -= %d;' % (n - 1))
+    cw.write('return 1;')
     
-    cw.enter_block('public override string ToString()')
-    cw.write('return "Dynamic(" + _site.Binder.ToString() + ")";')
     cw.exit_block()
     
-    cw.exit_block()
-    
 def gen_types(cw):
     for i in xrange(MAX_TYPES):
         cw.write('case %d: genericType = typeof(DynamicInstruction<%s>); break;' %
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/IronPython/Scripts/generate_reflected_calls.py;C1230128
File: generate_reflected_calls.py
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/IronPython/Scripts/generate_reflected_calls.py;C1230128  (server)    11/3/2009 6:17 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/IronPython/Scripts/generate_reflected_calls.py;InstructionRefactoring
@@ -204,11 +204,7 @@
     cw.write('')
     
     # run
-    cw.enter_block('public override int Run(InterpretedFrame frame)')
-    gen_load_interpreted_arguments(cw, i)
-    cw.write('_target(%s);' % (', '.join(get_cast_args(i)), ))
-    cw.write('return +1;')
-    cw.exit_block()
+    gen_interpreted_run(cw, i, False)
     
     cw.exit_block()
     cw.write('')
@@ -235,20 +231,31 @@
     cw.write('')
     
     # run
-    cw.enter_block('public override int Run(InterpretedFrame frame)')
-    gen_load_interpreted_arguments(cw, i - 1)
-    cw.write('frame.Push(_target(%s));' % (', '.join(get_cast_args(i-1)), ))
-    cw.write('return +1;')
-    cw.exit_block()
+    gen_interpreted_run(cw, i - 1, True)
     
     cw.exit_block()
     cw.write('')
 
-def gen_load_interpreted_arguments(cw, i):
-    if i > 0:
-        cw.write('int firstArgStackIndex = (frame.StackIndex -= %d);' % i)        
-        for j in xrange(0, i):
-            cw.write('object arg%d = frame.Data[firstArgStackIndex + %d];' % (j, j))
+def gen_interpreted_run(cw, n, isFunc):
+    cw.enter_block('public override int Run(InterpretedFrame frame)')
+    
+    args = ''
+    for i in xrange(0, n):
+        if i > 0: args += ', '
+        args += '(T%d)frame.Data[frame.StackIndex - %d]' % (i, n - i)
+    
+    if isFunc:
+        call = 'frame.Data[frame.StackIndex - %d] = _target(%s);' % (n, args)
+        si = n - 1
+    else:
+        call = '_target(%s);' % args
+        si = n
+    
+    cw.write(call)
+    cw.write('frame.StackIndex -= %d;' % si)
+    cw.write('return 1;')
+    
+    cw.exit_block()
 
 def gen_action_helpers(cw):
     for i in xrange(MAX_HELPERS):
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/IronPython/Tests/Modes/ConsoleHelp.Debug.out;C1071937
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/IronPython/Tests/Modes/ConsoleHelp.Release.out;C1071937
File: ConsoleHelp.Release.out
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/IronPython/Tests/Modes/ConsoleHelp.Release.out;C1071937  (server)    11/9/2009 12:58 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/IronPython/Tests/Modes/ConsoleHelp.Release.out;InstructionRefactoring
@@ -1,2 +1,2 @@
 ??????????›???????????????????????????†††††††††††?????4???????????????????†††††††††????????????????????????????/†††††††††††?????????????????†††††††††††?????????????????†††††††††††?????????†††††††††††????????????????????????????†††††††??????????????????†††††††††††???????????????†††††††††††???????????????????????????†††††††††?????????????????????????????????†††††††††††??4????????????????????†††††††††††????????????????????????4†††††††††††????????????????4???????4††††††††††??????????????????????5†††††††††††????????4…?????6†††††††††††??????????4??????-??????????????†††††††††††??4??????????????????†††††††††??????????????????????????????????†††††††††††??°??4?????????????????††††††??????????????????????????????†††?????????????????††††††††??????????????????????????????????††††????????????4??????????????????†††????????????????????††††††††?????????????????????????††††††????????????????????????????†††††††????????????????????????????????????????????????††?????????????????????????????????????††††?????????????????????†††††††††?????????????????????????????????????????????????????††††???????????????????????????????????????†††????????????????????????†††††††?????????????‰????????????????††??????????????????????????††††????????????????????†††††††??????????????????????????????????????????????????????????††??????????????????????????°??????
\ No newline at end of file
+??????????????†††††††††††??4??????????????????†††††††††??????????????????????????????????†††††††††††??°??4?????????????????††††††??????????????????????????????†††????????????????????????†??????????????????????????????????????††††††††??????????????????????????????????††††????????????4??????????????????†††????????????????????††††††††?????????????????????????††††††????????????????????????????†††††††????????????????????????????????????????????????††?????????????????????????????????????††††?????????????????????†††††††††?????????????????????????????????????????????????????††††???????????????????????????????????????†††????????????????????????†††††††?????????????‰????????????????††??????????????????????????††††????????????????????†††††††??????????????????????????????????????????????????????????††??????????????????????????°??????
\ No newline at end of file
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs;C1240182
File: RubyTests.cs
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs;C1240182  (server)    11/3/2009 5:27 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs;InstructionRefactoring
@@ -81,6 +81,8 @@
                 Interpreter3,
                 Interpreter4,
                 Interpreter5,
+                InterpreterNumeric1,
+                InterpreterMethodCalls1,
 
                 Scenario_RubySimpleCall1,
                 Scenario_RubySimpleCall2, 
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/InterpreterTests.cs;C1204880
File: InterpreterTests.cs
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/InterpreterTests.cs;C1204880  (server)    11/3/2009 5:27 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/InterpreterTests.cs;InstructionRefactoring
@@ -26,6 +26,7 @@
 using Microsoft.Scripting.Utils;
 using System.Runtime.CompilerServices;
 using System.Threading;
+using System.Reflection;
 
 namespace IronRuby.Tests {
     using Ast = Expression;
@@ -52,7 +53,6 @@
             ri = l0.LightCompile()();
             Assert(rc == ri);
 
-
             // cross-block goto in try-catch-finally:
             label = Ast.Label(typeof(int));
             var l1 = Ast.Lambda<Func<int>>(
@@ -472,5 +472,134 @@
             ).LightCompile()();
             Assert(strArray8[0, 0, 0, 0, 0, 0, 0, 0] == "bar");
         }
+
+        [Options(NoRuntime = true)]
+        public void InterpreterNumeric1() {
+            Assert(Expression.Lambda<Func<short>>(
+                Expression.Add(Expression.Constant((short)1), Expression.Constant((short)2))
+            ).LightCompile()() == 3);
+
+            Assert(Expression.Lambda<Func<int>>(
+                Expression.Add(Expression.Constant((int)1), Expression.Constant((int)2))
+            ).LightCompile()() == 3);
+
+            Assert(Expression.Lambda<Func<short>>(
+                Expression.AddChecked(Expression.Constant((short)1), Expression.Constant((short)2))
+            ).LightCompile()() == 3);
+
+            Assert(Expression.Lambda<Func<bool>>(
+                Expression.LessThan(Expression.Constant((byte)1), Expression.Constant((byte)2))
+            ).LightCompile()() == true);
+
+            Assert(Expression.Lambda<Func<bool>>(
+                Expression.Equal(Expression.Constant(true), Expression.Constant(false))
+            ).LightCompile()() == false);
+
+            object obj1 = 1;
+            object obj2 = 1;
+            Assert(Expression.Lambda<Func<bool>>(
+                Expression.Equal(Expression.Constant(obj1, typeof(object)), Expression.Constant(obj2, typeof(object)))
+            ).LightCompile()() == false);
+
+            Assert(Expression.Lambda<Func<bool>>(
+                Expression.Equal(Expression.Constant(1), Expression.Constant(1))
+            ).LightCompile()() == true);
+        }
+
+        public class ClassWithMethods2 {
+            private readonly string Str = "<this>";
+
+            public static void SF0() { TestValues.Add("0"); }
+            public static void SF1(string a) { TestValues.Add(a); }
+            public static void SF2(string a, string b) { TestValues.Add(a + b); }
+            public static void SF3(string a, string b, string c) { TestValues.Add(a + b + c); }
+            public static void SF4(string a, string b, string c, string d) { TestValues.Add(a + b + c + d); }
+            public static void SF5(string a, string b, string c, string d, string e) { TestValues.Add(a + b + c + d + e); }
+            public static string SG0() { TestValues.Add("0"); return "G0"; }
+            public static string SG1(string a) { TestValues.Add(a); return "G1"; }
+            public static string SG2(string a, string b) { TestValues.Add(a + b); return "G2"; }
+            public static string SG3(string a, string b, string c) { TestValues.Add(a + b + c); return "G3"; }
+            public static string SG4(string a, string b, string c, string d) { TestValues.Add(a + b + c + d); return "G4"; }
+            public static string SG5(string a, string b, string c, string d, string e) { TestValues.Add(a + b + c + d + e); return "G5"; }
+
+            public void F0() { TestValues.Add(Str + "0"); }
+            public void F1(string a) { TestValues.Add(Str + a); }
+            public void F2(string a, string b) { TestValues.Add(Str + a + b); }
+            public void F3(string a, string b, string c) { TestValues.Add(Str + a + b + c); }
+            public void F4(string a, string b, string c, string d) { TestValues.Add(Str + a + b + c + d); }
+            public void F5(string a, string b, string c, string d, string e) { TestValues.Add(Str + a + b + c + d + e); }
+            public string G0() { TestValues.Add(Str + "0"); return "G0"; }
+            public string G1(string a) { TestValues.Add(Str + a); return "G1"; }
+            public string G2(string a, string b) { TestValues.Add(Str + a + b); return "G2"; }
+            public string G3(string a, string b, string c) { TestValues.Add(Str + a + b + c); return "G3"; }
+            public string G4(string a, string b, string c, string d) { TestValues.Add(Str + a + b + c + d); return "G4"; }
+            public string G5(string a, string b, string c, string d, string e) { TestValues.Add(Str + a + b + c + d + e); return "G5"; }
+        }
+
+        private static MethodInfo GM2(string name) {
+            return typeof(ClassWithMethods2).GetMethod(name);
+        }
+
+        [ThreadStatic]
+        private static List<string> TestValues = new List<string>();
+
+        [Options(NoRuntime = true)]
+        public void InterpreterMethodCalls1() {
+            var sf = Expression.Lambda<Action>(Ast.Block(
+                Ast.Call(null, GM2("SF0")),
+                Ast.Call(null, GM2("SF1"), Ast.Constant("1")),
+                Ast.Call(null, GM2("SF2"), Ast.Constant("1"), Ast.Constant("2")),
+                Ast.Call(null, GM2("SF3"), Ast.Constant("1"), Ast.Constant("2"), Ast.Constant("3")),
+                Ast.Call(null, GM2("SF4"), Ast.Constant("1"), Ast.Constant("2"), Ast.Constant("3"), Ast.Constant("4")),
+                Ast.Call(null, GM2("SF5"), Ast.Constant("1"), Ast.Constant("2"), Ast.Constant("3"), Ast.Constant("4"), Ast.Constant("5"))
+            ));
+
+            var sg = Expression.Lambda<Func<string[]>>(Ast.NewArrayInit(typeof(string),
+                Ast.Call(null, GM2("SG0")),
+                Ast.Call(null, GM2("SG1"), Ast.Constant("1")),
+                Ast.Call(null, GM2("SG2"), Ast.Constant("1"), Ast.Constant("2")),
+                Ast.Call(null, GM2("SG3"), Ast.Constant("1"), Ast.Constant("2"), Ast.Constant("3")),
+                Ast.Call(null, GM2("SG4"), Ast.Constant("1"), Ast.Constant("2"), Ast.Constant("3"), Ast.Constant("4")),
+                Ast.Call(null, GM2("SG5"), Ast.Constant("1"), Ast.Constant("2"), Ast.Constant("3"), Ast.Constant("4"), Ast.Constant("5"))
+            ));
+
+            var i = Expression.Constant(new ClassWithMethods2());
+
+            var f = Expression.Lambda<Action>(Ast.Block(
+                Ast.Call(i, GM2("F0")),
+                Ast.Call(i, GM2("F1"), Ast.Constant("1")),
+                Ast.Call(i, GM2("F2"), Ast.Constant("1"), Ast.Constant("2")),
+                Ast.Call(i, GM2("F3"), Ast.Constant("1"), Ast.Constant("2"), Ast.Constant("3")),
+                Ast.Call(i, GM2("F4"), Ast.Constant("1"), Ast.Constant("2"), Ast.Constant("3"), Ast.Constant("4")),
+                Ast.Call(i, GM2("F5"), Ast.Constant("1"), Ast.Constant("2"), Ast.Constant("3"), Ast.Constant("4"), Ast.Constant("5"))
+            ));
+
+            var g = Expression.Lambda<Func<string[]>>(Ast.NewArrayInit(typeof(string),
+                Ast.Call(i, GM2("G0")),
+                Ast.Call(i, GM2("G1"), Ast.Constant("1")),
+                Ast.Call(i, GM2("G2"), Ast.Constant("1"), Ast.Constant("2")),
+                Ast.Call(i, GM2("G3"), Ast.Constant("1"), Ast.Constant("2"), Ast.Constant("3")),
+                Ast.Call(i, GM2("G4"), Ast.Constant("1"), Ast.Constant("2"), Ast.Constant("3"), Ast.Constant("4")),
+                Ast.Call(i, GM2("G5"), Ast.Constant("1"), Ast.Constant("2"), Ast.Constant("3"), Ast.Constant("4"), Ast.Constant("5"))
+            ));
+
+            sf.Compile()();
+            var c_sg_result = sg.Compile()();
+            f.Compile()();
+            var c_g_result = g.Compile()();
+            string[] c_list = TestValues.ToArray();
+            TestValues.Clear();
+
+            sf.LightCompile()();
+            var i_sg_result = sg.LightCompile()();
+            f.LightCompile()();
+            var i_g_result = g.LightCompile()();
+            string[] i_list = TestValues.ToArray();
+            TestValues.Clear();
+
+            Assert(ArrayUtils.ValueEquals(c_sg_result, i_sg_result));
+            Assert(ArrayUtils.ValueEquals(c_g_result, i_g_result));
+            Assert(ArrayUtils.ValueEquals(c_list, i_list));
+        }
     }
 }
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Instructions/FrameTracking.cs;C1107696
File: FrameTracking.cs
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Instructions/FrameTracking.cs;C1107696  (server)    11/3/2009 5:27 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Instructions/FrameTracking.cs;InstructionRefactoring
@@ -31,7 +31,7 @@
         internal static readonly MSA.Expression Instance = new EnterInterpretedFrameExpression();
 
         public void AddInstructions(LightCompiler compiler) {
-            compiler.AddInstruction(_Instruction.Instance);
+            compiler.Instructions.Emit(_Instruction.Instance);
         }
         
         public sealed override Type/*!*/ Type {
@@ -71,7 +71,7 @@
         internal static readonly MSA.Expression Instance = new LeaveInterpretedFrameExpression();
 
         public void AddInstructions(LightCompiler compiler) {
-            compiler.AddInstruction(_Instruction.Instance);
+            compiler.Instructions.Emit(_Instruction.Instance);
         }
 
         private sealed class _Instruction : Instruction {
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyOptionsParser.cs;C1250989
File: RubyOptionsParser.cs
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyOptionsParser.cs;C1250989  (server)    11/3/2009 5:27 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyOptionsParser.cs;InstructionRefactoring
@@ -349,7 +349,8 @@
                 { "-20",                         "Ruby 2.0 mode" },
 
                 { "-X:ExceptionDetail",          "enable ExceptionDetail mode" },
-                { "-X:NoAdaptiveCompilation",    "disable adaptive compilation" },
+                { "-X:NoAdaptiveCompilation",    "disable adaptive compilation - all code will be compiled" },
+                { "-X:CompilationThreshold",     "the number of iterations before the interpreter starts compiling" },
                 { "-X:PassExceptions",           "do not catch exceptions that are unhandled by script code" },
                 { "-X:PrivateBinding",           "enable binding to private members" },
                 { "-X:ShowClrExceptions",        "display CLS Exception information" },
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Conversions/Converter.Generated.cs;C1205334
File: Converter.Generated.cs
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Conversions/Converter.Generated.cs;C1205334  (server)    11/3/2009 5:27 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Conversions/Converter.Generated.cs;InstructionRefactoring
@@ -88,35 +88,33 @@
             int[] result = new int[(int)MaxNumeric + 1];
 
 #if GENERATOR
-    $ExplicitConversions = {
-        "SByte"      => [         "Byte",          "UInt16",          "UInt32",          "UInt64",                                            ],
-        "Byte"       => ["SByte",                                                                                                             ],
-        "Int16"      => ["SByte", "Byte",          "UInt16",          "UInt32",          "UInt64",                                            ],
-        "UInt16"     => ["SByte", "Byte", "Int16",                                                                                            ],
-        "Int32"      => ["SByte", "Byte", "Int16", "UInt16",          "UInt32",          "UInt64",                                            ],
-        "UInt32"     => ["SByte", "Byte", "Int16", "UInt16", "Int32",                                                                         ],
-        "Int64"      => ["SByte", "Byte", "Int16", "UInt16", "Int32", "UInt32",          "UInt64",                                            ],
-        "UInt64"     => ["SByte", "Byte", "Int16", "UInt16", "Int32", "UInt32", "Int64",                                                      ],
-        "Single"     => ["SByte", "Byte", "Int16", "UInt16", "Int32", "UInt32", "Int64", "UInt64",                     "Decimal", "BigInteger"],
-        "Double"     => ["SByte", "Byte", "Int16", "UInt16", "Int32", "UInt32", "Int64", "UInt64", "Single",           "Decimal", "BigInteger"],
-        "Decimal"    => ["SByte", "Byte", "Int16", "UInt16", "Int32", "UInt32", "Int64", "UInt64", "Single", "Double",                        ],
-        "BigInteger" => ["SByte", "Byte", "Int16", "UInt16", "Int32", "UInt32", "Int64", "UInt64", "Single", "Double", "Decimal",             ],
-    }
-    
-    def generate
-        result = ""
-        $ExplicitConversions.each do |from, toTypes|
-            result << "            result[(int)NumericTypeCode.#{from}] = "
-            toTypes.each_with_index do |to, i|    
-                result << " | " unless i == 0
-                result << "(1 << ((int)NumericTypeCode.#{to}))"
+            ExplicitConversions = {
+                "SByte"      => [         "Byte",          "UInt16",          "UInt32",          "UInt64",                                            ],
+                "Byte"       => ["SByte",                                                                                                             ],
+                "Int16"      => ["SByte", "Byte",          "UInt16",          "UInt32",          "UInt64",                                            ],
+                "UInt16"     => ["SByte", "Byte", "Int16",                                                                                            ],
+                "Int32"      => ["SByte", "Byte", "Int16", "UInt16",          "UInt32",          "UInt64",                                            ],
+                "UInt32"     => ["SByte", "Byte", "Int16", "UInt16", "Int32",                                                                         ],
+                "Int64"      => ["SByte", "Byte", "Int16", "UInt16", "Int32", "UInt32",          "UInt64",                                            ],
+                "UInt64"     => ["SByte", "Byte", "Int16", "UInt16", "Int32", "UInt32", "Int64",                                                      ],
+                "Single"     => ["SByte", "Byte", "Int16", "UInt16", "Int32", "UInt32", "Int64", "UInt64",                     "Decimal", "BigInteger"],
+                "Double"     => ["SByte", "Byte", "Int16", "UInt16", "Int32", "UInt32", "Int64", "UInt64", "Single",           "Decimal", "BigInteger"],
+                "Decimal"    => ["SByte", "Byte", "Int16", "UInt16", "Int32", "UInt32", "Int64", "UInt64", "Single", "Double",                        ],
+                "BigInteger" => ["SByte", "Byte", "Int16", "UInt16", "Int32", "UInt32", "Int64", "UInt64", "Single", "Double", "Decimal",             ],
+            }
+            
+            def generate
+                ExplicitConversions.each do |from, toTypes|
+                    bits = []
+                    toTypes.each do |to|    
+                        bits << "(1 << ((int)NumericTypeCode.#{to}))"
+                    end
+                    puts "result[(int)NumericTypeCode.#{from}] = #{bits.join(' | ')};"
+                end
             end
-          result << ";\n"
-        end
-        append_generated result
-    end
 #endif
-#region Generated by Converter.Generator.rb
+            #region Generated by Converter.Generator.rb
+
             result[(int)NumericTypeCode.SByte] = (1 << ((int)NumericTypeCode.Byte)) | (1 << ((int)NumericTypeCode.UInt16)) | (1 << ((int)NumericTypeCode.UInt32)) | (1 << ((int)NumericTypeCode.UInt64));
             result[(int)NumericTypeCode.Byte] = (1 << ((int)NumericTypeCode.SByte));
             result[(int)NumericTypeCode.Int16] = (1 << ((int)NumericTypeCode.SByte)) | (1 << ((int)NumericTypeCode.Byte)) | (1 << ((int)NumericTypeCode.UInt16)) | (1 << ((int)NumericTypeCode.UInt32)) | (1 << ((int)NumericTypeCode.UInt64));
@@ -129,8 +127,9 @@
             result[(int)NumericTypeCode.Double] = (1 << ((int)NumericTypeCode.SByte)) | (1 << ((int)NumericTypeCode.Byte)) | (1 << ((int)NumericTypeCode.Int16)) | (1 << ((int)NumericTypeCode.UInt16)) | (1 << ((int)NumericTypeCode.Int32)) | (1 << ((int)NumericTypeCode.UInt32)) | (1 << ((int)NumericTypeCode.Int64)) | (1 << ((int)NumericTypeCode.UInt64)) | (1 << ((int)NumericTypeCode.Single)) | (1 << ((int)NumericTypeCode.Decimal)) | (1 << ((int)NumericTypeCode.BigInteger));
             result[(int)NumericTypeCode.Decimal] = (1 << ((int)NumericTypeCode.SByte)) | (1 << ((int)NumericTypeCode.Byte)) | (1 << ((int)NumericTypeCode.Int16)) | (1 << ((int)NumericTypeCode.UInt16)) | (1 << ((int)NumericTypeCode.Int32)) | (1 << ((int)NumericTypeCode.UInt32)) | (1 << ((int)NumericTypeCode.Int64)) | (1 << ((int)NumericTypeCode.UInt64)) | (1 << ((int)NumericTypeCode.Single)) | (1 << ((int)NumericTypeCode.Double));
             result[(int)NumericTypeCode.BigInteger] = (1 << ((int)NumericTypeCode.SByte)) | (1 << ((int)NumericTypeCode.Byte)) | (1 << ((int)NumericTypeCode.Int16)) | (1 << ((int)NumericTypeCode.UInt16)) | (1 << ((int)NumericTypeCode.Int32)) | (1 << ((int)NumericTypeCode.UInt32)) | (1 << ((int)NumericTypeCode.Int64)) | (1 << ((int)NumericTypeCode.UInt64)) | (1 << ((int)NumericTypeCode.Single)) | (1 << ((int)NumericTypeCode.Double)) | (1 << ((int)NumericTypeCode.Decimal));
-#endregion
 
+            #endregion
+
             return result;
         }
     }
===================================================================
edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Scripts/CodeGenerator.rb;C1162008
File: CodeGenerator.rb
===================================================================
--- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Scripts/CodeGenerator.rb;C1162008  (server)    11/9/2009 11:28 AM
+++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Scripts/CodeGenerator.rb;InstructionRefactoring
@@ -33,12 +33,13 @@
   eval_metavariables(content)
 
   expanded_count = 0
-  content.gsub!(/(^\s*#if GENERATOR(.*?)^\s*(#else.*?^(.*?)^\s*)?#endif\s*)^\s*#region Generated by(.*?)^\s*#endregion/m) do
+  content.gsub!(/(^\s*#if GENERATOR(.*?)^\s*(#else.*?^(.*?)^\s*)?#endif\s*)^(\s*)#region Generated by(.*?)^\s*#endregion/m) do
     expanded_count += 1
     
     prefix = $1
     generators = $2
     template = $4
+    indentation = $5
     
     generator_class = Class.new(Generator)
     generator_class.class_eval generators
@@ -46,9 +47,10 @@
     
     generator.template = template
     generator.generated = ""
+    generator.indentation = indentation.dup
     generator.generate
     
-    "#{prefix}#region Generated by #{generator_file}\r\n#{generator.generated}#endregion"
+    "#{prefix}#{indentation}#region Generated by #{generator_file}\r\n\r\n#{generator.generated}\r\n#{indentation}#endregion"
   end
   
   puts "Templates expanded: #{expanded_count}"
@@ -65,23 +67,53 @@
   ParamStart = Regexp.escape('/*$')
   ParamEnd = Close
   
-  attr_accessor :template, :generated
+  attr_accessor :template, :generated, :indentation
   
   def generate
     t = @template.dup
       
     # $MethodName
-    t.gsub!(/#{ParamStart}([A-Za-z0-9]+)#{ParamEnd}/) { send($1) }
+    t.gsub!(/#{ParamStart}([A-Za-z0-9]+)#{ParamEnd}/) do
+      (m = method $1) rescue raise "Templating function `#{$1}' not defined."
+	  m.call
+	end
     
     # $MethodName{...}
-    t.gsub!(/#{ParamStart}([A-Za-z0-9]+)[{]#{ParamEnd}(.*?)#{Open}[}]#{Close}/) { send($1, $2) }
+    t.gsub!(/#{ParamStart}([A-Za-z0-9]+)[{]#{ParamEnd}(.*?)#{Open}[}]#{Close}/) do 
+      (m = method $1) rescue raise "Templating function `#{$1}' not defined."
+      if m.arity == 0
+        m.call
+      else
+        m.call($2)
+      end
+    end
     
     @generated << t
   end
   
-  def append_generated str
-    @generated << str.gsub!("\n", "\r\n")
+  def indent
+    if block_given?
+      indent
+      yield
+      dedent
+    else
+      @indentation << "    "
+    end
   end
+  
+  def dedent
+    @indentation = @indentation[0..-5]
+  end
+  
+  def puts(str = "")
+    @generated << @indentation
+    @generated << str
+    @generated << "\r\n"
+  end
+  
+  def print str
+    @generated << str
+  end
 end
 
 #
===================================================================
