phax / jcodemodel

A heavily extended fork of the com.sun.codemodel (from 2013/09)
Other
92 stars 34 forks source link

[feature] chaining blocks and instructions #97

Open glelouet opened 3 years ago

glelouet commented 3 years ago

I think it may be better to have some kind of navigation inside the blocks. Typically I can create a sub block in a JBlock, why not also be able to go back ?

Here is an example : to represent

if(a) {
 for(int i=0;i>0;){ }
} else {
 while(true){}
}

a call would be ( assuming bl is the current block)

bl._if(a) // create a if and go in the then block
 ._for(integer, "i", lit(0)) // create a for 
 .test(fr->fr.var("i").lt(a 0)) // make the <0
.update() // and go in the for block with a new variable
 .up() // return in the then
 .elseBlock()
 ._while(cm.true);

I started working on this in the branch https://github.com/guiguilechat/jcodemodel/tree/blockrework

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.