TriAxis.RunSharp.CodeGen.Local C# (CSharp) Method

Local() public method

public Local ( Type type, Operand init ) : ContextualOperand
type IKVM.Reflection.Type
init Operand
return ContextualOperand
        public ContextualOperand Local(Type type, Operand init)
		{
			Operand var = Local(type);
			Assign(var, init);
			return new ContextualOperand(var, TypeMapper);
		}
#endregion

Same methods

CodeGen::Local ( ) : ContextualOperand
CodeGen::Local ( Operand init ) : ContextualOperand
CodeGen::Local ( System type ) : ContextualOperand
CodeGen::Local ( System type, Operand init ) : ContextualOperand
CodeGen::Local ( Type type ) : ContextualOperand

Usage Example

Example #1
0
        static void DynamicMethodExamples()
        {
            DynamicMethodGen dmg = DynamicMethodGen.Static(typeof(Program)).Method(typeof(void)).Parameter(typeof(string), "name");
            CodeGen          g   = dmg.GetCode();

            g.Try();
            {
                Operand name = g.Local(typeof(string), g.Arg("name"));
                g.WriteLine("Hello {0}!", name);
            }
            g.CatchAll();
            {
                g.WriteLine("Error");
            }
            g.End();

            DynamicMethod dm = dmg.GetCompletedDynamicMethod(true);

            // reflection-style invocation
            dm.Invoke(null, new object[] { "Dynamic Method" });

            // delegate invocation
            Action <string> hello = (Action <string>)dm.CreateDelegate(typeof(Action <string>));

            hello("Delegate");
        }
All Usage Examples Of TriAxis.RunSharp.CodeGen::Local