From a92e6b95e4866b282e7b83ca9c1e7e8b4e8c6cd9 Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Wed, 25 May 2011 18:07:55 -0400 Subject: [PATCH] fixing print-values --- js-assembler/mini-runtime.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/js-assembler/mini-runtime.js b/js-assembler/mini-runtime.js index eae16fd..9f1872d 100644 --- a/js-assembler/mini-runtime.js +++ b/js-assembler/mini-runtime.js @@ -485,14 +485,25 @@ Primitives['print-values'] = new Closure( function(MACHINE) { var outputPort = MACHINE.params.currentOutputPort; + var prependNewline = false; if (MACHINE.argcount > 0) { - outputPort.write(MACHINE, MACHINE.val); - outputPort.write(MACHINE, "\n"); + if (MACHINE.val !== undefined) { + if (prependNewline) { + outputPort.write(MACHINE, "\n"); + } + outputPort.write(MACHINE, MACHINE.val); + prependNewline = true; + } for(var i = 0; i < MACHINE.argcount - 1; i++) { - outputPort.write(MACHINE, "\n"); - outputPort.write(MACHINE, - MACHINE.env[MACHINE.env.length - 1 - i]); + if (MACHINE.env[MACHINE.env.length - 1 - i] !== undefined) { + if (prependNewline) { + outputPort.write(MACHINE, "\n"); + } + outputPort.write(MACHINE, + MACHINE.env[MACHINE.env.length - 1 - i]); + prependNewline = true; + } } outputPort.write(MACHINE, "\n"); }