예제 #1
0
 public override void VisitLeaf(ITreeValueNode node)
 {
     if (!TreeNodeIsDimensionVariable(node))
     {
         base.VisitLeaf(node);
         return;
     }
     else
     {
         (ITreeValueNode parent, int dim) = GetDimensionVariableParent(node);
         if (Tree.InputVariableNodes.Contains(parent))
         {
             base.VisitLeaf(node);
             return;
         }
         else
         {
             ITermShape parentShape           = parent.ValueAs <ITermShape>();
             ITermShape substituteParentShape =
                 InputShapes.FirstOrDefault(s => s.Dimensions.SequenceEqual(parentShape.Dimensions));
             if (substituteParentShape == null)
             {
                 throw new TileGeneratorException(this, "Could not find input variable node to substitute for "
                                                  + $"{parentShape.Label}.");
             }
             else
             {
                 Context.Push(substituteParentShape.Label.ToUpper() + "DIM" + dim.ToString());
             }
         }
     }
 }
예제 #2
0
        public override string WriteValueText(ITreeValueNode vn)
        {
            switch (vn.NodeType)
            {
            case ValueNodeType.TENSOR: return(base.WriteValueText(vn).ToUpper());

            case ValueNodeType.INDEXSET: return(base.WriteValueText(vn).ToLower());

            default: return(base.WriteValueText(vn));
            }
        }
예제 #3
0
        public virtual string WriteValueText(ITreeValueNode vn)
        {
            switch (vn.NodeType)
            {
            case ValueNodeType.TENSOR:
                return(vn.Label);

            case ValueNodeType.VARIABLE:
                return(string.Empty);

            case ValueNodeType.INDEXSET:
                IEnumerable <ITerm> indices = vn.ValueAs <IEnumerable <ITerm> >();
                return(indices.Select(i => i.Label).Aggregate((a, b) => a + ", " + b));

            default: throw new Exception($"Unknown value type: {vn.NodeType.ToString()}.");
            }
        }
예제 #4
0
        public override void VisitLeaf(ITreeValueNode node)
        {
            Node srcNode   = Context.InternalNode;
            Node graphNode = null;

            switch (node.Value)
            {
            case Term t:
                graphNode       = Graph.AddNode(t.Id);
                graphNode.Label = new Label(t.Name);
                break;

            case null: break;

            default:
                throw new Exception(
                          $"Unknown value in ValueNode: {node.Value} of type {node.Value.GetType().Name}.");
            }

            if (graphNode != null)
            {
                Graph.AddEdge(srcNode.Id, graphNode.Id);
            }
        }
예제 #5
0
 public abstract void VisitLeaf(ITreeValueNode node);
예제 #6
0
 public override void VisitLeaf(ITreeValueNode node)
 {
     Context.Push(Writer.WriteValueText(node));
 }