public virtual bool TryMapping(Tree.Node node, out string ret) { Tree.NodePath path = node.RelPath(d_root); object o; if (d_mapping.TryGetValue(path, out o)) { var li = o as Computation.Loop.Mapped; if (li != null) { var t = This(d_program.StateTable); var i = This(li.IndexTable); if (li.Node.Dimension.IsOne) { ret = String.Format("{0}[{1}[i][{2}]]", t, i, li.Index); } else if (SupportsPointers) { ret = String.Format("({0} + {1}[i][{2}])", t, i, li.Index); } else { throw new Exception("Loop substitutes requiring pointers are not supported yet in this format."); } } else { ret = o.ToString(); } return(true); } else { ret = ""; return(false); } }
public override bool TryMapping(Tree.Node node, out string ret) { Tree.NodePath path = node.RelPath(Root); object o; if (Mapping.TryGetValue(path, out o)) { var li = o as Computation.Loop.Mapped; if (li != null && !li.Node.Dimension.IsOne) { ret = String.Format("Cdn.Utils.array_slice({0}, {1}[i][{2}], {1}[i][{2}] + {3})", This(Program.StateTable), This(li.IndexTable), li.Index, li.Node.Dimension.Size()); return(true); } } return(base.TryMapping(node, out ret)); }
public virtual bool IsMapping(Tree.Node node) { Tree.NodePath path = node.RelPath(d_root); return(d_mapping.ContainsKey(path)); }