From ecd1053c2660ab8e804ef2c7361ff20c8a36d0cd Mon Sep 17 00:00:00 2001 From: jjgarcia Date: Thu, 19 Jun 2008 15:01:23 +0000 Subject: [PATCH] Allow COND forms to use REG0 to store computations, instead of forcing use of VALUES. --- src/c/compiler.d | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/c/compiler.d b/src/c/compiler.d index a3bf32d57..a6b4da9d1 100644 --- a/src/c/compiler.d +++ b/src/c/compiler.d @@ -985,28 +985,30 @@ c_cond(cl_object args, int flags) { compile_body(clause, flags); } else { /* Compile the test. If no more forms, just output - the first value (this is guaranteed by OP_JT) */ - if (Null(clause)) { - if (Null(args)) { + the first value (this is guaranteed by OP_JT), but make + sure it is stored in the appropriate place. */ + if (Null(args)) { + if (Null(clause)) { c_values(cl_list(1,test), flags); - return flags; + } else { + compile_form(test, (flags & FLAG_VALUES)? FLAG_VALUES: FLAG_REG0); + label_nil = asm_jmp(OP_JNIL); + compile_body(clause, flags); + asm_complete(OP_JNIL, label_nil); } - compile_form(test, FLAG_VALUES); + } else if (Null(clause)) { + compile_form(test, (flags & FLAG_VALUES)? FLAG_VALUES : FLAG_REG0); label_exit = asm_jmp(OP_JT); c_cond(args, flags); asm_complete(OP_JT, label_exit); } else { - compile_form(test, FLAG_VALUES); + compile_form(test, FLAG_REG0); label_nil = asm_jmp(OP_JNIL); compile_body(clause, flags); - if (Null(args)) - asm_complete(OP_JNIL, label_nil); - else { - label_exit = asm_jmp(OP_JMP); - asm_complete(OP_JNIL, label_nil); - c_cond(args, flags); - asm_complete(OP_JMP, label_exit); - } + label_exit = asm_jmp(OP_JMP); + asm_complete(OP_JNIL, label_nil); + c_cond(args, flags); + asm_complete(OP_JMP, label_exit); } } return flags;