From aa37bdc780ab3cd3c5d79715cc48d56221e0bfb2 Mon Sep 17 00:00:00 2001 From: Bob Nystrom Date: Sat, 27 Jun 2015 08:36:20 -0700 Subject: [PATCH] Include method name in block argument debug name. --- src/vm/wren_compiler.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/vm/wren_compiler.c b/src/vm/wren_compiler.c index 97677b29..67d118d8 100644 --- a/src/vm/wren_compiler.c +++ b/src/vm/wren_compiler.c @@ -1339,7 +1339,6 @@ static ObjFn* endCompiler(Compiler* compiler, // Emit arguments for each upvalue to know whether to capture a local or // an upvalue. - // TODO: Do something more efficient here? for (int i = 0; i < compiler->numUpvalues; i++) { emit(compiler->parent, compiler->upvalues[i].isLocal ? 1 : 0); @@ -1716,8 +1715,13 @@ static void methodCall(Compiler* compiler, Code instruction, finishBody(&fnCompiler, false); - // TODO: Use the name of the method the block is being provided to. - endCompiler(&fnCompiler, "(fn)", 4); + // Name the function based on the method its passed to. + char blockName[MAX_METHOD_SIGNATURE + 15]; + int blockLength; + signatureToString(&signature, blockName, &blockLength); + memmove(blockName + blockLength, " block argument", 16); + + endCompiler(&fnCompiler, blockName, blockLength + 15); } // TODO: Allow Grace-style mixfix methods?