@@ -26,13 +26,19 @@ private Node FindEntryNode()
2626 return Graph . Nodes . First ( n => n . Value is EntryNode ) . Value ;
2727 }
2828
29- public void Execute ( object ? [ ] inputs , object ? [ ] outputs )
29+ public void Execute ( object ? self , object ? [ ] inputs , object ? [ ] outputs )
3030 {
3131 var node = FindEntryNode ( ) ;
3232
33- var execConnection = node . Execute ( null , inputs , inputs ) ;
33+ var execConnection = node . Execute ( self , null , inputs , inputs ) ;
3434 if ( execConnection == null )
3535 throw new Exception ( "Entry node should have an output connection" ) ;
36+ if ( inputs . Length != node . Outputs . Count )
37+ throw new Exception ( "EntryNode doesn't have the same amount of inputs as the provided inputs array" ) ;
38+
39+ for ( int i = 0 ; i < inputs . Length ; ++ i )
40+ Connections [ node . Outputs [ i ] ] = inputs [ i ] ;
41+
3642
3743 var stack = new Stack < Connection > ( ) ; // stack of input connections on nodes that can alter execution path
3844
@@ -55,15 +61,15 @@ public void Execute(object?[] inputs, object?[] outputs)
5561 for ( int i = 0 ; i < outputs . Length ; i ++ )
5662 {
5763 var output = nodeToExecute . Inputs [ i ] ;
58- outputs [ i ] = CrawlBackInputs ( output ) ;
64+ outputs [ i ] = CrawlBackInputs ( self , output ) ;
5965 }
6066 return ;
6167 }
6268
63- var nodeInputs = GetNodeInputs ( nodeToExecute ) ;
69+ var nodeInputs = GetNodeInputs ( self , nodeToExecute ) ;
6470 var nodeOutputs = new object ? [ nodeToExecute . Outputs . Count ] ;
6571
66- execConnection = nodeToExecute . Execute ( connectionToExecute , nodeInputs , nodeOutputs ) ;
72+ execConnection = nodeToExecute . Execute ( self , connectionToExecute , nodeInputs , nodeOutputs ) ;
6773 for ( int i = 0 ; i < nodeOutputs . Length ; i ++ )
6874 {
6975 var output = nodeToExecute . Outputs [ i ] ;
@@ -75,21 +81,21 @@ public void Execute(object?[] inputs, object?[] outputs)
7581 }
7682 }
7783
78- private object ? [ ] GetNodeInputs ( Node node )
84+ private object ? [ ] GetNodeInputs ( object ? self , Node node )
7985 {
8086 var inputs = new object ? [ node . Inputs . Count ] ;
8187
8288 for ( int i = 0 ; i < node . Inputs . Count ; i ++ )
8389 {
8490 var input = node . Inputs [ i ] ;
8591
86- inputs [ i ] = CrawlBackInputs ( input ) ;
92+ inputs [ i ] = CrawlBackInputs ( self , input ) ;
8793 }
8894
8995 return inputs ;
9096 }
9197
92- private object ? CrawlBackInputs ( Connection inputConnection )
98+ private object ? CrawlBackInputs ( object ? self , Connection inputConnection )
9399 {
94100 var other = inputConnection . Connections . FirstOrDefault ( ) ;
95101 if ( other == null )
@@ -101,11 +107,11 @@ public void Execute(object?[] inputs, object?[] outputs)
101107
102108 // if this is not a flow node, we are allowed to execute the node on demande to calculate the outputs
103109 // this will also automatically crawl back the inputs of the node we are executing
104- var inputs = GetNodeInputs ( other . Parent ) ;
110+ var inputs = GetNodeInputs ( self , other . Parent ) ;
105111 var outputs = new object ? [ other . Parent . Outputs . Count ] ;
106112
107113 object ? myOutput = null ;
108- other . Parent . Execute ( null , inputs , outputs ) ;
114+ other . Parent . Execute ( self , null , inputs , outputs ) ;
109115 for ( int i = 0 ; i < outputs . Length ; i ++ )
110116 {
111117 var output = other . Parent . Outputs [ i ] ;
0 commit comments