From 170a4ea08fab58f11b62701fe89b08735e4c0629 Mon Sep 17 00:00:00 2001 From: Daniel Buckmaster Date: Mon, 29 Dec 2014 22:33:42 +1100 Subject: [PATCH] Add anonymous functions before other statements. --- Engine/source/console/codeBlock.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Engine/source/console/codeBlock.cpp b/Engine/source/console/codeBlock.cpp index c8cd57223..05a2ab798 100644 --- a/Engine/source/console/codeBlock.cpp +++ b/Engine/source/console/codeBlock.cpp @@ -482,7 +482,10 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con { if (gAnonFunctionList) { - gStatementList->append(gAnonFunctionList); + // Prepend anonymous functions to statement list, so they're defined already when + // the statements run. + gAnonFunctionList->append(gStatementList); + gStatementList = gAnonFunctionList; } } @@ -622,7 +625,10 @@ const char *CodeBlock::compileExec(StringTableEntry fileName, const char *inStri { if (gAnonFunctionList) { - gStatementList->append(gAnonFunctionList); + // Prepend anonymous functions to statement list, so they're defined already when + // the statements run. + gAnonFunctionList->append(gStatementList); + gStatementList = gAnonFunctionList; } }