From 7308ca2173ccb4049d986bb08e8d3d08fca58b4e Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Fri, 11 Nov 2016 11:09:23 +0100 Subject: new instanciator class without IML.Reader, Context class will handle temorary parsing structures --- src/IML/Context.cs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/IML') diff --git a/src/IML/Context.cs b/src/IML/Context.cs index 2b505e06..e5bad2d4 100644 --- a/src/IML/Context.cs +++ b/src/IML/Context.cs @@ -20,7 +20,9 @@ // along with this program. If not, see . using System; using System.Collections.Generic; +using System.Reflection; using System.Reflection.Emit; +using System.Xml; namespace Crow.IML { @@ -29,6 +31,10 @@ namespace Crow.IML /// public class Context { + public XmlTextReader reader = null; + public Type RootType = null; + public Node CurrentNode = null; + public DynamicMethod dm = null; public ILGenerator il = null; //public SubNodeType curSubNodeType; public Stack nodesStack = new Stack (); @@ -36,8 +42,26 @@ namespace Crow.IML public Dictionary Names = new Dictionary (); public Dictionary> PropertyBindings = new Dictionary> (); - public Context () + public Context (Type rootType) { + RootType = rootType; + dm = new DynamicMethod ("dyn_instantiator", + MethodAttributes.Family | MethodAttributes.FamANDAssem | MethodAttributes.NewSlot, + CallingConventions.Standard, + typeof (void), new Type [] { typeof (object), typeof (Interface) }, RootType, true); + il = dm.GetILGenerator (256); + + initILGen (); + } + void initILGen () + { + il.DeclareLocal (typeof (GraphicObject)); + il.Emit (OpCodes.Nop); + //set local GraphicObject to root object passed as 1st argument + il.Emit (OpCodes.Ldarg_0); + il.Emit (OpCodes.Stloc_0); + CompilerServices.emitSetCurInterface (il); } + } } \ No newline at end of file -- cgit v1.3.1-4-g156e