use of priv.bajdcc.LALR1.grammar.codegen.CodegenBlock in project jMiniLang by bajdcc.
the class StmtFor method genCode.
@Override
public void genCode(ICodegen codegen) {
if (var != null) {
var.genCode(codegen);
codegen.genCode(RuntimeInst.ipop);
}
CodegenBlock cb = new CodegenBlock();
RuntimeInstUnary start = codegen.genCode(RuntimeInst.ijmp, -1);
cb.breakId = codegen.getCodeIndex();
RuntimeInstUnary breakJmp = codegen.genCode(RuntimeInst.ijmp, -1);
cb.continueId = codegen.getCodeIndex();
RuntimeInstUnary continueJmp = codegen.genCode(RuntimeInst.ijmp, -1);
start.op1 = codegen.getCodeIndex();
if (cond != null) {
cond.genCode(codegen);
codegen.genCode(RuntimeInst.ijf, cb.breakId);
}
codegen.getBlockService().enterBlockEntry(cb);
block.genCode(codegen);
codegen.getBlockService().leaveBlockEntry();
continueJmp.op1 = codegen.getCodeIndex();
if (ctrl != null) {
ctrl.genCode(codegen);
codegen.genCode(RuntimeInst.ipop);
}
codegen.genCode(RuntimeInst.ijmp, start.op1);
breakJmp.op1 = codegen.getCodeIndex();
}
use of priv.bajdcc.LALR1.grammar.codegen.CodegenBlock in project jMiniLang by bajdcc.
the class StmtForeach method genCode.
@Override
public void genCode(ICodegen codegen) {
codegen.genCode(RuntimeInst.ipushx);
codegen.genCode(RuntimeInst.ipush, codegen.genDataRef(var.object));
codegen.genCode(RuntimeInst.ialloc);
codegen.genCode(RuntimeInst.ipop);
CodegenBlock cb = new CodegenBlock();
RuntimeInstUnary start = codegen.genCode(RuntimeInst.ijmp, -1);
cb.breakId = codegen.getCodeIndex();
codegen.genCode(RuntimeInst.ipop);
codegen.genCode(RuntimeInst.iyldx);
RuntimeInstUnary breakJmp = codegen.genCode(RuntimeInst.ijmp, -1);
cb.continueId = codegen.getCodeIndex();
RuntimeInstUnary continueJmp = codegen.genCode(RuntimeInst.ijmp, -1);
start.op1 = cb.continueId;
int content = codegen.getCodeIndex();
enumerator.genCode(codegen);
codegen.genCode(RuntimeInst.ijnan, cb.breakId);
codegen.genCode(RuntimeInst.ipush, codegen.genDataRef(var.object));
codegen.genCode(RuntimeInst.istore);
codegen.genCode(RuntimeInst.ipop);
codegen.getBlockService().enterBlockEntry(cb);
block.genCode(codegen);
codegen.getBlockService().leaveBlockEntry();
continueJmp.op1 = codegen.getCodeIndex();
codegen.genCode(RuntimeInst.ijmp, content);
breakJmp.op1 = codegen.getCodeIndex();
}
use of priv.bajdcc.LALR1.grammar.codegen.CodegenBlock in project jMiniLang by bajdcc.
the class StmtWhile method genCode.
@Override
public void genCode(ICodegen codegen) {
CodegenBlock cb = new CodegenBlock();
RuntimeInstUnary start = codegen.genCode(RuntimeInst.ijmp, -1);
cb.breakId = codegen.getCodeIndex();
RuntimeInstUnary breakJmp = codegen.genCode(RuntimeInst.ijmp, -1);
cb.continueId = codegen.getCodeIndex();
RuntimeInstUnary continueJmp = codegen.genCode(RuntimeInst.ijmp, -1);
start.op1 = codegen.getCodeIndex();
cond.genCode(codegen);
codegen.genCode(RuntimeInst.ijf, cb.breakId);
codegen.getBlockService().enterBlockEntry(cb);
block.genCode(codegen);
codegen.getBlockService().leaveBlockEntry();
continueJmp.op1 = codegen.getCodeIndex();
codegen.genCode(RuntimeInst.ijmp, start.op1);
breakJmp.op1 = codegen.getCodeIndex();
}
Aggregations