aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/IML/Context.cs
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-11-22 17:49:16 +0100
committerjpbruyere <jp.bruyere@hotmail.com>2016-11-22 17:49:16 +0100
commitf416267010e2d44badae89ceb76df3b27dd69a67 (patch)
tree59fd7e8e44af4a6674bbbe50ebaedefbf089992a /src/IML/Context.cs
parentf7512fd4b75d815f4b78fcc844523d2bfc5f2bd1 (diff)
debug
Diffstat (limited to 'src/IML/Context.cs')
-rw-r--r--src/IML/Context.cs31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/IML/Context.cs b/src/IML/Context.cs
index e5d33374..965d0062 100644
--- a/src/IML/Context.cs
+++ b/src/IML/Context.cs
@@ -38,11 +38,12 @@ namespace Crow.IML
{
public XmlTextReader reader = null;
public Type RootType = null;
- public Node CurrentNode = null;
+ public int CurrentIndex = 0;
+
public DynamicMethod dm = null;
public ILGenerator il = null;
//public SubNodeType curSubNodeType;
- public Stack<Node> nodesStack = new Stack<Node> ();
+ public NodeStack nodesStack = new NodeStack ();
public Dictionary<string, List<NodeAddress>> Names = new Dictionary<string, List<NodeAddress>>();
public Dictionary<string, Dictionary<string, MemberAddress>> PropertyBindings = new Dictionary<string, Dictionary<string, MemberAddress>> ();
@@ -64,13 +65,31 @@ namespace Crow.IML
}
public NodeAddress CurrentNodeAddress {
- get {
- NodeAddress tmp = new NodeAddress(nodesStack.ToArray ());
- tmp.Add (CurrentNode);
- return tmp;
+ get {
+ Node[] n = nodesStack.ToArray ();
+ Array.Reverse (n);
+ return new NodeAddress(n);
}
}
+ public Type CurrentNodeType {
+ get { return nodesStack.Peek().CrowType; }
+ }
+ public MethodInfo CurrentAddMethod {
+ get {
+ if (typeof (Group).IsAssignableFrom (CurrentNodeType))
+ return CompilerServices.miAddChild;
+ if (typeof (Container).IsAssignableFrom (CurrentNodeType))
+ return CompilerServices.miSetChild;
+ if (typeof (TemplatedContainer).IsAssignableFrom (CurrentNodeType))
+ return CurrentIndex < 0 ? CompilerServices.miLoadTmp : CompilerServices.miSetContent;
+ if (typeof (TemplatedGroup).IsAssignableFrom (CurrentNodeType))
+ return CurrentIndex < 0 ? CompilerServices.miLoadTmp : CompilerServices.miAddItem;
+ if (typeof (TemplatedControl).IsAssignableFrom (CurrentNodeType))
+ return CompilerServices.miLoadTmp;
+ return null;
+ }
+ }
void initILGen ()
{
il.DeclareLocal (typeof (GraphicObject));