@@ -30,7 +30,7 @@ static ForLoopNode()
30
30
public ValueNodeInputViewModel < ITypedExpression < int > > FirstIndex { get ; }
31
31
public ValueNodeInputViewModel < ITypedExpression < int > > LastIndex { get ; }
32
32
33
- public ValueNodeOutputViewModel < VariableReference < int > > CurrentIndex { get ; }
33
+ public ValueNodeOutputViewModel < ITypedExpression < int > > CurrentIndex { get ; }
34
34
35
35
public ForLoopNode ( ) : base ( NodeType . FlowControl )
36
36
{
@@ -60,11 +60,7 @@ public ForLoopNode() : base(NodeType.FlowControl)
60
60
} ;
61
61
this . Inputs . Add ( LastIndex ) ;
62
62
63
- CurrentIndex = new CodeGenOutputViewModel < VariableReference < int > > ( PortType . Integer )
64
- {
65
- Name = "Current Index"
66
- } ;
67
- this . Outputs . Add ( CurrentIndex ) ;
63
+ ForLoop value = new ForLoop ( ) ;
68
64
69
65
var loopBodyChanged = LoopBodyFlow . Values . Connect ( ) . Select ( _ => Unit . Default ) . StartWith ( Unit . Default ) ;
70
66
var loopEndChanged = LoopEndFlow . Values . Connect ( ) . Select ( _ => Unit . Default ) . StartWith ( Unit . Default ) ;
@@ -73,15 +69,22 @@ public ForLoopNode() : base(NodeType.FlowControl)
73
69
Name = "" ,
74
70
Value = Observable . CombineLatest ( loopBodyChanged , loopEndChanged , FirstIndex . ValueChanged , LastIndex . ValueChanged ,
75
71
( bodyChange , endChange , firstI , lastI ) => ( BodyChange : bodyChange , EndChange : endChange , FirstI : firstI , LastI : lastI ) )
76
- . Select ( v => new ForLoop
77
- {
78
- LoopBody = new StatementSequence ( LoopBodyFlow . Values . Items ) ,
79
- LoopEnd = new StatementSequence ( LoopEndFlow . Values . Items ) ,
80
- LowerBound = v . FirstI ?? new IntLiteral { Value = 0 } ,
81
- UpperBound = v . LastI ?? new IntLiteral { Value = 1 }
72
+ . Select ( v => {
73
+ value . LoopBody = new StatementSequence ( LoopBodyFlow . Values . Items ) ;
74
+ value . LoopEnd = new StatementSequence ( LoopEndFlow . Values . Items ) ;
75
+ value . LowerBound = v . FirstI ?? new IntLiteral { Value = 0 } ;
76
+ value . UpperBound = v . LastI ?? new IntLiteral { Value = 1 } ;
77
+ return value ;
82
78
} )
83
79
} ;
84
80
this . Outputs . Add ( FlowIn ) ;
81
+
82
+ CurrentIndex = new CodeGenOutputViewModel < ITypedExpression < int > > ( PortType . Integer )
83
+ {
84
+ Name = "Current Index" ,
85
+ Value = Observable . Return ( new VariableReference < int > { LocalVariable = value . CurrentIndex } )
86
+ } ;
87
+ this . Outputs . Add ( CurrentIndex ) ;
85
88
}
86
89
}
87
90
}
0 commit comments