소스 검색

Add anonymous functions before other statements.

Daniel Buckmaster 10 년 전
부모
커밋
170a4ea08f
1개의 변경된 파일8개의 추가작업 그리고 2개의 파일을 삭제
  1. 8 2
      Engine/source/console/codeBlock.cpp

+ 8 - 2
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;
       }
    }