Alien-LibJIT
view release on metacpan or search on metacpan
libjit/dpas/dpas-parser.y view on Meta::CPAN
if(!jit_insn_branch_if_not
(dpas_current_function(),
dpas_sem_get_value($2), &label))
{
dpas_out_of_memory();
}
/* Push into an "if" context, to remember the label */
push_if(label);
} IfTail {
/* Set the final label at the end of the "if" */
if(if_stack[if_stack_size - 1] != jit_label_undefined)
{
if(!jit_insn_label
(dpas_current_function(),
&(if_stack[if_stack_size - 1])))
{
dpas_out_of_memory();
}
}
--if_stack_size;
}
;
IfTail
: Statement
| Statement K_ELSE {
jit_label_t label = jit_label_undefined;
/* Jump to the end of the "if" statement */
if(!jit_block_current_is_dead(dpas_current_function()))
{
if(!jit_insn_branch(dpas_current_function(), &label))
{
dpas_out_of_memory();
}
}
/* Set the position of the "else" clause */
if(!jit_insn_label
(dpas_current_function(),
&(if_stack[if_stack_size - 1])))
{
dpas_out_of_memory();
}
/* Replace the end point of the "if" */
if_stack[if_stack_size - 1] = label;
} Statement
;
WhileStatement
: K_WHILE {
jit_label_t label = jit_label_undefined;
/* Jump to the beginning of the expression block.
Right now, the expression block is at the head
of the loop body. Once we've process the entire
body, we will move the expression block to the end */
if(!jit_insn_branch(dpas_current_function(), &label))
{
dpas_out_of_memory();
}
/* Mark the start of the expression block */
if(!jit_insn_label(dpas_current_function(), &label))
{
dpas_out_of_memory();
}
/* Push the label onto the loop stack */
push_loop(label, jit_label_undefined, jit_label_undefined);
} BooleanExpression K_DO {
/* Test the expression and jump to the top of the body */
if(!dpas_sem_is_error($3))
{
if(!jit_insn_branch_if
(dpas_current_function(),
dpas_sem_get_value($3),
&(loop_stack[loop_stack_size - 1].top_label)))
{
dpas_out_of_memory();
}
}
/* Mark the end of the expression block and the start
of the while loop's body. This is also the end
of the code we'll need to move to the end */
if(!jit_insn_label
(dpas_current_function(),
&(loop_stack[loop_stack_size - 1].top_label)))
{
dpas_out_of_memory();
}
} Statement {
/* Move the expression blocks down to this point */
jit_insn_move_blocks_to_end
(dpas_current_function(),
loop_stack[loop_stack_size - 1].expr_label,
loop_stack[loop_stack_size - 1].top_label);
/* Define the "exit" label to this point in the code */
if(loop_stack[loop_stack_size - 1].exit_label
!= jit_label_undefined)
{
if(!jit_insn_label
(dpas_current_function(),
&(loop_stack[loop_stack_size - 1].exit_label)))
{
dpas_out_of_memory();
}
}
/* Pop the top-most entry from the loop stack */
--loop_stack_size;
}
( run in 0.495 second using v1.01-cache-2.11-cpan-5b529ec07f3 )