1515 */
1616package org .jamplate .glucose .spec .command .hashfor ;
1717
18- import org .jamplate .unit .Spec ;
1918import org .jamplate .function .Analyzer ;
2019import org .jamplate .function .Compiler ;
2120import org .jamplate .glucose .instruction .flow .IRepeat ;
2221import org .jamplate .glucose .instruction .memory .frame .IDumpFrame ;
2322import org .jamplate .glucose .instruction .memory .frame .IGlueFrame ;
23+ import org .jamplate .glucose .instruction .memory .frame .IPopFrame ;
2424import org .jamplate .glucose .instruction .memory .frame .IPushFrame ;
2525import org .jamplate .glucose .instruction .memory .heap .ISet ;
2626import org .jamplate .glucose .instruction .memory .resource .IPushConst ;
3838import org .jamplate .model .Instruction ;
3939import org .jamplate .model .Sketch ;
4040import org .jamplate .model .Tree ;
41+ import org .jamplate .unit .Spec ;
4142import org .jetbrains .annotations .NotNull ;
4243
44+ import static org .jamplate .glucose .internal .analyzer .BinaryFlowAnalyzer .flow ;
4345import static org .jamplate .glucose .internal .util .Values .text ;
4446import static org .jamplate .impl .analyzer .FilterAnalyzer .filter ;
4547import static org .jamplate .impl .analyzer .HierarchyAnalyzer .hierarchy ;
4648import static org .jamplate .impl .compiler .FilterCompiler .filter ;
47- import static org .jamplate .glucose .internal .analyzer .BinaryFlowAnalyzer .flow ;
4849import static org .jamplate .util .Functions .analyzer ;
4950import static org .jamplate .util .Functions .compiler ;
5051import static org .jamplate .util .Query .*;
@@ -202,6 +203,8 @@ public Compiler getCompiler() {
202203 //compile as a foreach REPEAT
203204 return new Block (
204205 tree ,
206+ //push the loop frame
207+ new IPushFrame (tree ),
205208 //push an anchoring null
206209 new IPushConst (tree , Value .NULL ),
207210 //value sandbox
@@ -214,29 +217,33 @@ public Compiler getCompiler() {
214217 //glue the answer
215218 new IGlueFrame (tree ),
216219 //cast the answer into array
217- new ICastArray (tree ),
220+ new ICastArray (tree ), /*[ [first,second,third] ]*/
218221 //reverse the array
219- new IReverse (tree ),
222+ new IReverse (tree ), /*[ [third,second,first] ]*/
220223 //dump the frame
221224 new IDumpFrame (tree )
222225 ),
223226 //spread the evaluated value
224- new ISplit (tree ),
227+ new ISplit (tree ), /*[ third, second, first ]*/
225228 //duplicate the value
226- new IDup (tree ),
229+ new IDup (tree ), /*[ third, second, first, first ]*/
227230 //check if anchor
228- new IDefined (tree ),
231+ new IDefined (tree ), /*[ third, second, first, boolean ]*/
229232 //iterate until the anchoring null
230233 new IRepeat (tree , new Block (
231234 tree ,
232235 //push the allocation address
233- keyI ,
236+ keyI , /*[third, second, first, key]*/
234237 //swap the address with the value
235- new ISwap (tree ),
238+ new ISwap (tree ), /*[third, second, key, first]*/
236239 //allocate the loop variable, at top frame
237- new ISet (tree ),
240+ new ISet (tree ), /*[third, second]*/
241+ //push body frame
242+ new IPushFrame (tree ),
238243 //execute the body
239244 bodyI ,
245+ //pop body frame
246+ new IPopFrame (tree ),
240247 //duplicate the value
241248 new IDup (tree ),
242249 //check if null
@@ -247,7 +254,9 @@ public Compiler getCompiler() {
247254 //swap the anchoring null with the allocation address
248255 new ISwap (tree ),
249256 //allocate the anchoring null to the allocation address, at top frame
250- new ISet (tree )
257+ new ISet (tree ),
258+ //pop the loop frame
259+ new IPopFrame (tree )
251260 );
252261 }
253262 );
0 commit comments