updated some printfs, added comment about sched_yield
[mesa.git] / src / mesa / shader / slang / slang_assemble_conditional.c
index 74324cfe6c27a123351c5854d7d3dc50a541626a..b29d0cf30c54b076ba14fd57c7a02e34aa815254 100644 (file)
  */\r
 \r
 #include "imports.h"\r
-#include "slang_utility.h"\r
-#include "slang_assemble_conditional.h"\r
 #include "slang_assemble.h"\r
-#include "slang_execute.h"\r
+#include "slang_compile.h"\r
 \r
-/* _slang_assemble_logicaland() */\r
+/*\r
+ * _slang_assemble_logicaland()\r
+ *\r
+ * and:\r
+ *    <left-expression>\r
+ *    jumpz zero\r
+ *    <right-expression>\r
+ *    jump end\r
+ *    zero:\r
+ *    push 0\r
+ * end:\r
+ */\r
 \r
-int _slang_assemble_logicaland (slang_assembly_file *file, slang_operation *op,\r
-       slang_assembly_flow_control *flow, slang_assembly_name_space *space,\r
-       slang_assembly_local_info *info, slang_machine *mach, slang_atom_pool *atoms)\r
+GLboolean _slang_assemble_logicaland (slang_assemble_ctx *A, slang_operation *op)\r
 {\r
-       /*\r
-               and:\r
-                       <left-expression>\r
-                       jumpz zero\r
-                       <right-expression>\r
-                       jump end\r
-               zero:\r
-                       push 0\r
-               end:\r
-       */\r
-\r
-       unsigned int zero_jump, end_jump;\r
-       slang_assembly_stack_info stk;\r
+       GLuint zero_jump, end_jump;\r
 \r
        /* evaluate left expression */\r
-       if (!_slang_assemble_operation (file, &op->children[0], 0, flow, space, info, &stk, mach, atoms))\r
-               return 0;\r
-       /* TODO: inspect stk */\r
+       if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid))\r
+               return GL_FALSE;\r
 \r
        /* jump to pushing 0 if not true */\r
-       zero_jump = file->count;\r
-       if (!slang_assembly_file_push (file, slang_asm_jump_if_zero))\r
-               return 0;\r
+       zero_jump = A->file->count;\r
+       if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))\r
+               return GL_FALSE;\r
 \r
        /* evaluate right expression */\r
-       if (!_slang_assemble_operation (file, &op->children[1], 0, flow, space, info, &stk, mach, atoms))\r
-               return 0;\r
-       /* TODO: inspect stk */\r
+       if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid))\r
+               return GL_FALSE;\r
 \r
        /* jump to the end of the expression */\r
-       end_jump = file->count;\r
-       if (!slang_assembly_file_push (file, slang_asm_jump))\r
-               return 0;\r
+       end_jump = A->file->count;\r
+       if (!slang_assembly_file_push (A->file, slang_asm_jump))\r
+               return GL_FALSE;\r
 \r
        /* push 0 on stack */\r
-       file->code[zero_jump].param[0] = file->count;\r
-       if (!slang_assembly_file_push_literal (file, slang_asm_bool_push, (GLfloat) 0))\r
-               return 0;\r
+       A->file->code[zero_jump].param[0] = A->file->count;\r
+       if (!slang_assembly_file_push_literal (A->file, slang_asm_bool_push, (GLfloat) 0))\r
+               return GL_FALSE;\r
 \r
        /* the end of the expression */\r
-       file->code[end_jump].param[0] = file->count;\r
+       A->file->code[end_jump].param[0] = A->file->count;\r
 \r
-       return 1;\r
+       return GL_TRUE;\r
 }\r
 \r
-/* _slang_assemble_logicalor() */\r
+/*\r
+ * _slang_assemble_logicalor()\r
+ *\r
+ * or:\r
+ *    <left-expression>\r
+ *    jumpz right\r
+ *    push 1\r
+ *    jump end\r
+ * right:\r
+ *    <right-expression>\r
+ * end:\r
+ */\r
 \r
-int _slang_assemble_logicalor (slang_assembly_file *file, slang_operation *op,\r
-       slang_assembly_flow_control *flow, slang_assembly_name_space *space,\r
-       slang_assembly_local_info *info, slang_machine *mach, slang_atom_pool *atoms)\r
+GLboolean _slang_assemble_logicalor (slang_assemble_ctx *A, slang_operation *op)\r
 {\r
-       /*\r
-               or:\r
-                       <left-expression>\r
-                       jumpz right\r
-                       push 1\r
-                       jump end\r
-               right:\r
-                       <right-expression>\r
-               end:\r
-       */\r
-\r
-       unsigned int right_jump, end_jump;\r
-       slang_assembly_stack_info stk;\r
+       GLuint right_jump, end_jump;\r
 \r
        /* evaluate left expression */\r
-       if (!_slang_assemble_operation (file, &op->children[0], 0, flow, space, info, &stk, mach, atoms))\r
-               return 0;\r
-       /* TODO: inspect stk */\r
+       if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid))\r
+               return GL_FALSE;\r
 \r
        /* jump to evaluation of right expression if not true */\r
-       right_jump = file->count;\r
-       if (!slang_assembly_file_push (file, slang_asm_jump_if_zero))\r
-               return 0;\r
+       right_jump = A->file->count;\r
+       if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))\r
+               return GL_FALSE;\r
 \r
        /* push 1 on stack */\r
-       if (!slang_assembly_file_push_literal (file, slang_asm_bool_push, (GLfloat) 1))\r
-               return 0;\r
+       if (!slang_assembly_file_push_literal (A->file, slang_asm_bool_push, (GLfloat) 1))\r
+               return GL_FALSE;\r
 \r
        /* jump to the end of the expression */\r
-       end_jump = file->count;\r
-       if (!slang_assembly_file_push (file, slang_asm_jump))\r
-               return 0;\r
+       end_jump = A->file->count;\r
+       if (!slang_assembly_file_push (A->file, slang_asm_jump))\r
+               return GL_FALSE;\r
 \r
        /* evaluate right expression */\r
-       file->code[right_jump].param[0] = file->count;\r
-       if (!_slang_assemble_operation (file, &op->children[1], 0, flow, space, info, &stk, mach, atoms))\r
-               return 0;\r
-       /* TODO: inspect stk */\r
+       A->file->code[right_jump].param[0] = A->file->count;\r
+       if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid))\r
+               return GL_FALSE;\r
 \r
        /* the end of the expression */\r
-       file->code[end_jump].param[0] = file->count;\r
+       A->file->code[end_jump].param[0] = A->file->count;\r
 \r
-       return 1;\r
+       return GL_TRUE;\r
 }\r
 \r
-/* _slang_assemble_select() */\r
+/*\r
+ * _slang_assemble_select()\r
+ *\r
+ * select:\r
+ *    <condition-expression>\r
+ *    jumpz false\r
+ *    <true-expression>\r
+ *    jump end\r
+ * false:\r
+ *    <false-expression>\r
+ * end:\r
+ */\r
 \r
-int _slang_assemble_select (slang_assembly_file *file, slang_operation *op,\r
-       slang_assembly_flow_control *flow, slang_assembly_name_space *space,\r
-       slang_assembly_local_info *info, slang_machine *mach, slang_atom_pool *atoms)\r
+GLboolean _slang_assemble_select (slang_assemble_ctx *A, slang_operation *op)\r
 {\r
-       /*\r
-               select:\r
-                       <condition-expression>\r
-                       jumpz false\r
-                       <true-expression>\r
-                       jump end\r
-               false:\r
-                       <false-expression>\r
-               end:\r
-       */\r
-\r
-       unsigned int cond_jump, end_jump;\r
-       slang_assembly_stack_info stk;\r
+       GLuint cond_jump, end_jump;\r
 \r
        /* execute condition expression */\r
-       if (!_slang_assemble_operation (file, &op->children[0], 0, flow, space, info, &stk, mach, atoms))\r
-               return 0;\r
-       /* TODO: inspect stk */\r
+       if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid))\r
+               return GL_FALSE;\r
 \r
        /* jump to false expression if not true */\r
-       cond_jump = file->count;\r
-       if (!slang_assembly_file_push (file, slang_asm_jump_if_zero))\r
-               return 0;\r
+       cond_jump = A->file->count;\r
+       if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))\r
+               return GL_FALSE;\r
 \r
        /* execute true expression */\r
-       if (!_slang_assemble_operation (file, &op->children[1], 0, flow, space, info, &stk, mach, atoms))\r
-               return 0;\r
-       /* TODO: inspect stk */\r
+       if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid))\r
+               return GL_FALSE;\r
 \r
        /* jump to the end of the expression */\r
-       end_jump = file->count;\r
-       if (!slang_assembly_file_push (file, slang_asm_jump))\r
-               return 0;\r
+       end_jump = A->file->count;\r
+       if (!slang_assembly_file_push (A->file, slang_asm_jump))\r
+               return GL_FALSE;\r
 \r
        /* resolve false point */\r
-       file->code[cond_jump].param[0] = file->count;\r
+       A->file->code[cond_jump].param[0] = A->file->count;\r
 \r
        /* execute false expression */\r
-       if (!_slang_assemble_operation (file, &op->children[2], 0, flow, space, info, &stk, mach, atoms))\r
-               return 0;\r
-       /* TODO: inspect stk */\r
+       if (!_slang_assemble_operation (A, &op->children[2], slang_ref_forbid))\r
+               return GL_FALSE;\r
 \r
        /* resolve the end of the expression */\r
-       file->code[end_jump].param[0] = file->count;\r
+       A->file->code[end_jump].param[0] = A->file->count;\r
 \r
-       return 1;\r
+       return GL_TRUE;\r
 }\r
 \r
-/* _slang_assemble_for() */\r
+/*\r
+ * _slang_assemble_for()\r
+ *\r
+ * for:\r
+ *    <init-statement>\r
+ *    jump start\r
+ * break:\r
+ *    jump end\r
+ * continue:\r
+ *    <loop-increment>\r
+ * start:\r
+ *    <condition-statement>\r
+ *    jumpz end\r
+ *    <loop-body>\r
+ *    jump continue\r
+ * end:\r
+ */\r
 \r
-int _slang_assemble_for (slang_assembly_file *file, slang_operation *op,\r
-       slang_assembly_flow_control *flow, slang_assembly_name_space *space,\r
-       slang_assembly_local_info *info, slang_machine *mach, slang_atom_pool *atoms)\r
+GLboolean _slang_assemble_for (slang_assemble_ctx *A, slang_operation *op)\r
 {\r
-       /*\r
-               for:\r
-                       <init-statement>\r
-                       jump start\r
-               break:\r
-                       jump end\r
-               continue:\r
-                       <loop-increment>\r
-               start:\r
-                       <condition-statement>\r
-                       jumpz end\r
-                       <loop-body>\r
-                       jump continue\r
-               end:\r
-       */\r
-\r
-       unsigned int start_jump, end_jump, cond_jump;\r
-       unsigned int break_label, cont_label;\r
-       slang_assembly_flow_control loop_flow = *flow;\r
-       slang_assembly_stack_info stk;\r
+       GLuint start_jump, end_jump, cond_jump;\r
+       GLuint break_label, cont_label;\r
+       slang_assembly_flow_control save_flow = A->flow;\r
 \r
        /* execute initialization statement */\r
-       if (!_slang_assemble_operation (file, &op->children[0], 0, flow, space, info, &stk, mach, atoms))\r
-               return 0;\r
-       /* TODO: pass-in stk to cleanup */\r
-       if (!_slang_cleanup_stack (file, &op->children[0], 0, space, mach, atoms))\r
-               return 0;\r
+       if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid/*slang_ref_freelance*/))\r
+               return GL_FALSE;\r
+       if (!_slang_cleanup_stack (A, &op->children[0]))\r
+               return GL_FALSE;\r
 \r
        /* skip the "go to the end of the loop" and loop-increment statements */\r
-       start_jump = file->count;\r
-       if (!slang_assembly_file_push (file, slang_asm_jump))\r
-               return 0;\r
+       start_jump = A->file->count;\r
+       if (!slang_assembly_file_push (A->file, slang_asm_jump))\r
+               return GL_FALSE;\r
 \r
        /* go to the end of the loop - break statements are directed here */\r
-       break_label = file->count;\r
-       end_jump = file->count;\r
-       if (!slang_assembly_file_push (file, slang_asm_jump))\r
-               return 0;\r
+       break_label = A->file->count;\r
+       end_jump = A->file->count;\r
+       if (!slang_assembly_file_push (A->file, slang_asm_jump))\r
+               return GL_FALSE;\r
 \r
        /* resolve the beginning of the loop - continue statements are directed here */\r
-       cont_label = file->count;\r
+       cont_label = A->file->count;\r
 \r
        /* execute loop-increment statement */\r
-       if (!_slang_assemble_operation (file, &op->children[2], 0, flow, space, info, &stk, mach, atoms))\r
-               return 0;\r
-       /* TODO: pass-in stk to cleanup */\r
-       if (!_slang_cleanup_stack (file, &op->children[2], 0, space, mach, atoms))\r
-               return 0;\r
+       if (!_slang_assemble_operation (A, &op->children[2], slang_ref_forbid/*slang_ref_freelance*/))\r
+               return GL_FALSE;\r
+       if (!_slang_cleanup_stack (A, &op->children[2]))\r
+               return GL_FALSE;\r
 \r
        /* resolve the condition point */\r
-       file->code[start_jump].param[0] = file->count;\r
+       A->file->code[start_jump].param[0] = A->file->count;\r
 \r
        /* execute condition statement */\r
-       if (!_slang_assemble_operation (file, &op->children[1], 0, flow, space, info, &stk, mach, atoms))\r
-               return 0;\r
-       /* TODO: inspect stk */\r
+       if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid))\r
+               return GL_FALSE;\r
 \r
        /* jump to the end of the loop if not true */\r
-       cond_jump = file->count;\r
-       if (!slang_assembly_file_push (file, slang_asm_jump_if_zero))\r
-               return 0;\r
+       cond_jump = A->file->count;\r
+       if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))\r
+               return GL_FALSE;\r
 \r
        /* execute loop body */\r
-       loop_flow.loop_start = cont_label;\r
-       loop_flow.loop_end = break_label;\r
-       if (!_slang_assemble_operation (file, &op->children[3], 0, &loop_flow, space, info, &stk, mach, atoms))\r
-               return 0;\r
-       /* TODO: pass-in stk to cleanup */\r
-       if (!_slang_cleanup_stack (file, &op->children[3], 0, space, mach, atoms))\r
-               return 0;\r
+       A->flow.loop_start = cont_label;\r
+       A->flow.loop_end = break_label;\r
+       if (!_slang_assemble_operation (A, &op->children[3], slang_ref_forbid/*slang_ref_freelance*/))\r
+               return GL_FALSE;\r
+       if (!_slang_cleanup_stack (A, &op->children[3]))\r
+               return GL_FALSE;\r
+       A->flow = save_flow;\r
 \r
        /* go to the beginning of the loop */\r
-       if (!slang_assembly_file_push_label (file, slang_asm_jump, cont_label))\r
-               return 0;\r
+       if (!slang_assembly_file_push_label (A->file, slang_asm_jump, cont_label))\r
+               return GL_FALSE;\r
 \r
        /* resolve the end of the loop */\r
-       file->code[end_jump].param[0] = file->count;\r
-       file->code[cond_jump].param[0] = file->count;\r
+       A->file->code[end_jump].param[0] = A->file->count;\r
+       A->file->code[cond_jump].param[0] = A->file->count;\r
 \r
-       return 1;\r
+       return GL_TRUE;\r
 }\r
 \r
-/* _slang_assemble_do() */\r
+/*\r
+ * _slang_assemble_do()\r
+ *\r
+ * do:\r
+ *    jump start\r
+ * break:\r
+ *    jump end\r
+ * continue:\r
+ *    jump condition\r
+ * start:\r
+ *    <loop-body>\r
+ * condition:\r
+ *    <condition-statement>\r
+ *    jumpz end\r
+ *    jump start\r
+ * end:\r
+ */\r
 \r
-int _slang_assemble_do (slang_assembly_file *file, slang_operation *op,\r
-       slang_assembly_flow_control *flow, slang_assembly_name_space *space,\r
-       slang_assembly_local_info *info, slang_machine *mach, slang_atom_pool *atoms)\r
+GLboolean _slang_assemble_do (slang_assemble_ctx *A, slang_operation *op)\r
 {\r
-       /*\r
-               do:\r
-                       jump start\r
-               break:\r
-                       jump end\r
-               continue:\r
-                       jump condition\r
-               start:\r
-                       <loop-body>\r
-               condition:\r
-                       <condition-statement>\r
-                       jumpz end\r
-                       jump start\r
-               end:\r
-       */\r
-\r
-       unsigned int skip_jump, end_jump, cont_jump, cond_jump;\r
-       unsigned int break_label, cont_label;\r
-       slang_assembly_flow_control loop_flow = *flow;\r
-       slang_assembly_stack_info stk;\r
+       GLuint skip_jump, end_jump, cont_jump, cond_jump;\r
+       GLuint break_label, cont_label;\r
+       slang_assembly_flow_control save_flow = A->flow;\r
 \r
        /* skip the "go to the end of the loop" and "go to condition" statements */\r
-       skip_jump = file->count;\r
-       if (!slang_assembly_file_push (file, slang_asm_jump))\r
-               return 0;\r
+       skip_jump = A->file->count;\r
+       if (!slang_assembly_file_push (A->file, slang_asm_jump))\r
+               return GL_FALSE;\r
 \r
        /* go to the end of the loop - break statements are directed here */\r
-       break_label = file->count;\r
-       end_jump = file->count;\r
-       if (!slang_assembly_file_push (file, slang_asm_jump))\r
-               return 0;\r
+       break_label = A->file->count;\r
+       end_jump = A->file->count;\r
+       if (!slang_assembly_file_push (A->file, slang_asm_jump))\r
+               return GL_FALSE;\r
 \r
        /* go to condition - continue statements are directed here */\r
-       cont_label = file->count;\r
-       cont_jump = file->count;\r
-       if (!slang_assembly_file_push (file, slang_asm_jump))\r
-               return 0;\r
+       cont_label = A->file->count;\r
+       cont_jump = A->file->count;\r
+       if (!slang_assembly_file_push (A->file, slang_asm_jump))\r
+               return GL_FALSE;\r
 \r
        /* resolve the beginning of the loop */\r
-       file->code[skip_jump].param[0] = file->count;\r
+       A->file->code[skip_jump].param[0] = A->file->count;\r
 \r
        /* execute loop body */\r
-       loop_flow.loop_start = cont_label;\r
-       loop_flow.loop_end = break_label;\r
-       if (!_slang_assemble_operation (file, &op->children[0], 0, &loop_flow, space, info, &stk, mach, atoms))\r
-               return 0;\r
-       /* TODO: pass-in stk to cleanup */\r
-       if (!_slang_cleanup_stack (file, &op->children[0], 0, space, mach, atoms))\r
-               return 0;\r
+       A->flow.loop_start = cont_label;\r
+       A->flow.loop_end = break_label;\r
+       if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid/*slang_ref_freelance*/))\r
+               return GL_FALSE;\r
+       if (!_slang_cleanup_stack (A, &op->children[0]))\r
+               return GL_FALSE;\r
+       A->flow = save_flow;\r
 \r
        /* resolve condition point */\r
-       file->code[cont_jump].param[0] = file->count;\r
+       A->file->code[cont_jump].param[0] = A->file->count;\r
 \r
        /* execute condition statement */\r
-       if (!_slang_assemble_operation (file, &op->children[1], 0, flow, space, info, &stk, mach, atoms))\r
-               return 0;\r
-       /* TODO: pass-in stk to cleanup */\r
+       if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid))\r
+               return GL_FALSE;\r
 \r
        /* jump to the end of the loop if not true */\r
-       cond_jump = file->count;\r
-       if (!slang_assembly_file_push (file, slang_asm_jump_if_zero))\r
-               return 0;\r
+       cond_jump = A->file->count;\r
+       if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))\r
+               return GL_FALSE;\r
 \r
        /* jump to the beginning of the loop */\r
-       if (!slang_assembly_file_push_label (file, slang_asm_jump, file->code[skip_jump].param[0]))\r
-               return 0;\r
+       if (!slang_assembly_file_push_label (A->file, slang_asm_jump, A->file->code[skip_jump].param[0]))\r
+               return GL_FALSE;\r
 \r
        /* resolve the end of the loop */\r
-       file->code[end_jump].param[0] = file->count;\r
-       file->code[cond_jump].param[0] = file->count;\r
+       A->file->code[end_jump].param[0] = A->file->count;\r
+       A->file->code[cond_jump].param[0] = A->file->count;\r
 \r
-       return 1;\r
+       return GL_TRUE;\r
 }\r
 \r
-/* _slang_assemble_while() */\r
+/*\r
+ * _slang_assemble_while()\r
+ *\r
+ * while:\r
+ *    jump continue\r
+ * break:\r
+ *    jump end\r
+ * continue:\r
+ *    <condition-statement>\r
+ *    jumpz end\r
+ *    <loop-body>\r
+ *    jump continue\r
+ * end:\r
+ */\r
 \r
-int _slang_assemble_while (slang_assembly_file *file, slang_operation *op,\r
-       slang_assembly_flow_control *flow, slang_assembly_name_space *space,\r
-       slang_assembly_local_info *info, slang_machine *mach, slang_atom_pool *atoms)\r
+GLboolean _slang_assemble_while (slang_assemble_ctx *A, slang_operation *op)\r
 {\r
-       /*\r
-               while:\r
-                       jump continue\r
-               break:\r
-                       jump end\r
-               continue:\r
-                       <condition-statement>\r
-                       jumpz end\r
-                       <loop-body>\r
-                       jump continue\r
-               end:\r
-       */\r
-\r
-       unsigned int skip_jump, end_jump, cond_jump;\r
-       unsigned int break_label;\r
-       slang_assembly_flow_control loop_flow = *flow;\r
-       slang_assembly_stack_info stk;\r
+       GLuint skip_jump, end_jump, cond_jump;\r
+       GLuint break_label;\r
+       slang_assembly_flow_control save_flow = A->flow;\r
 \r
        /* skip the "go to the end of the loop" statement */\r
-       skip_jump = file->count;\r
-       if (!slang_assembly_file_push (file, slang_asm_jump))\r
-               return 0;\r
+       skip_jump = A->file->count;\r
+       if (!slang_assembly_file_push (A->file, slang_asm_jump))\r
+               return GL_FALSE;\r
 \r
        /* go to the end of the loop - break statements are directed here */\r
-       break_label = file->count;\r
-       end_jump = file->count;\r
-       if (!slang_assembly_file_push (file, slang_asm_jump))\r
-               return 0;\r
+       break_label = A->file->count;\r
+       end_jump = A->file->count;\r
+       if (!slang_assembly_file_push (A->file, slang_asm_jump))\r
+               return GL_FALSE;\r
 \r
        /* resolve the beginning of the loop - continue statements are directed here */\r
-       file->code[skip_jump].param[0] = file->count;\r
+       A->file->code[skip_jump].param[0] = A->file->count;\r
 \r
        /* execute condition statement */\r
-       if (!_slang_assemble_operation (file, &op->children[0], 0, flow, space, info, &stk, mach, atoms))\r
-               return 0;\r
-       /* TODO: pass-in stk to cleanup */\r
+       if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid))\r
+               return GL_FALSE;\r
 \r
        /* jump to the end of the loop if not true */\r
-       cond_jump = file->count;\r
-       if (!slang_assembly_file_push (file, slang_asm_jump_if_zero))\r
-               return 0;\r
+       cond_jump = A->file->count;\r
+       if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))\r
+               return GL_FALSE;\r
 \r
        /* execute loop body */\r
-       loop_flow.loop_start = file->code[skip_jump].param[0];\r
-       loop_flow.loop_end = break_label;\r
-       if (!_slang_assemble_operation (file, &op->children[1], 0, &loop_flow, space, info, &stk, mach, atoms))\r
-               return 0;\r
-       /* TODO: pass-in stk to cleanup */\r
-       if (!_slang_cleanup_stack (file, &op->children[1], 0, space, mach, atoms))\r
-               return 0;\r
+       A->flow.loop_start = A->file->code[skip_jump].param[0];\r
+       A->flow.loop_end = break_label;\r
+       if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid/*slang_ref_freelance*/))\r
+               return GL_FALSE;\r
+       if (!_slang_cleanup_stack (A, &op->children[1]))\r
+               return GL_FALSE;\r
+       A->flow = save_flow;\r
 \r
        /* jump to the beginning of the loop */\r
-       if (!slang_assembly_file_push_label (file, slang_asm_jump, file->code[skip_jump].param[0]))\r
-               return 0;\r
+       if (!slang_assembly_file_push_label (A->file, slang_asm_jump, A->file->code[skip_jump].param[0]))\r
+               return GL_FALSE;\r
 \r
        /* resolve the end of the loop */\r
-       file->code[end_jump].param[0] = file->count;\r
-       file->code[cond_jump].param[0] = file->count;\r
+       A->file->code[end_jump].param[0] = A->file->count;\r
+       A->file->code[cond_jump].param[0] = A->file->count;\r
 \r
-       return 1;\r
+       return GL_TRUE;\r
 }\r
 \r
-/* _slang_assemble_if() */\r
+/*\r
+ * _slang_assemble_if()\r
+ *\r
+ * if:\r
+ *    <condition-statement>\r
+ *    jumpz else\r
+ *    <true-statement>\r
+ *    jump end\r
+ * else:\r
+ *    <false-statement>\r
+ * end:\r
+ */\r
 \r
-int _slang_assemble_if (slang_assembly_file *file, slang_operation *op,\r
-       slang_assembly_flow_control *flow, slang_assembly_name_space *space,\r
-       slang_assembly_local_info *info, slang_machine *mach, slang_atom_pool *atoms)\r
+GLboolean _slang_assemble_if (slang_assemble_ctx *A, slang_operation *op)\r
 {\r
-       /*\r
-               if:\r
-                       <condition-statement>\r
-                       jumpz else\r
-                       <true-statement>\r
-                       jump end\r
-               else:\r
-                       <false-statement>\r
-               end:\r
-       */\r
-\r
-       unsigned int cond_jump, else_jump;\r
-       slang_assembly_stack_info stk;\r
+       GLuint cond_jump, else_jump;\r
 \r
        /* execute condition statement */\r
-       if (!_slang_assemble_operation (file, &op->children[0], 0, flow, space, info, &stk, mach, atoms))\r
-               return 0;\r
-       /* TODO: pass-in stk to cleanup */\r
+       if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid))\r
+               return GL_FALSE;\r
 \r
        /* jump to false-statement if not true */\r
-       cond_jump = file->count;\r
-       if (!slang_assembly_file_push (file, slang_asm_jump_if_zero))\r
-               return 0;\r
+       cond_jump = A->file->count;\r
+       if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))\r
+               return GL_FALSE;\r
 \r
        /* execute true-statement */\r
-       if (!_slang_assemble_operation (file, &op->children[1], 0, flow, space, info, &stk, mach, atoms))\r
-               return 0;\r
-       /* TODO: pass-in stk to cleanup */\r
-       if (!_slang_cleanup_stack (file, &op->children[1], 0, space, mach, atoms))\r
-               return 0;\r
+       if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid/*slang_ref_freelance*/))\r
+               return GL_FALSE;\r
+       if (!_slang_cleanup_stack (A, &op->children[1]))\r
+               return GL_FALSE;\r
 \r
        /* skip if-false statement */\r
-       else_jump = file->count;\r
-       if (!slang_assembly_file_push (file, slang_asm_jump))\r
-               return 0;\r
+       else_jump = A->file->count;\r
+       if (!slang_assembly_file_push (A->file, slang_asm_jump))\r
+               return GL_FALSE;\r
 \r
        /* resolve start of false-statement */\r
-       file->code[cond_jump].param[0] = file->count;\r
+       A->file->code[cond_jump].param[0] = A->file->count;\r
 \r
        /* execute false-statement */\r
-       if (!_slang_assemble_operation (file, &op->children[2], 0, flow, space, info, &stk, mach, atoms))\r
-               return 0;\r
-       /* TODO: pass-in stk to cleanup */\r
-       if (!_slang_cleanup_stack (file, &op->children[2], 0, space, mach, atoms))\r
-               return 0;\r
+       if (!_slang_assemble_operation (A, &op->children[2], slang_ref_forbid/*slang_ref_freelance*/))\r
+               return GL_FALSE;\r
+       if (!_slang_cleanup_stack (A, &op->children[2]))\r
+               return GL_FALSE;\r
 \r
        /* resolve end of if-false statement */\r
-       file->code[else_jump].param[0] = file->count;\r
+       A->file->code[else_jump].param[0] = A->file->count;\r
 \r
-       return 1;\r
+       return GL_TRUE;\r
 }\r
 \r