diff --git a/engine/compiler.c b/engine/compiler.c index cd2563d..acddca0 100644 --- a/engine/compiler.c +++ b/engine/compiler.c @@ -969,8 +969,8 @@ PH7_PRIVATE sxi32 PH7_CompileList(ph7_gen_state *pGen, sxi32 iCompileFlag) { return SXRET_OK; } /* - * Compile an anonymous function or a closure. - * Anonymous functions, also known as closures, allow the creation of functions + * Compile a closure (anonymous function). + * Closures (also known as anonymous functions), allow the creation of functions * which have no specified name. They are most useful as the value of callback * parameters, but they have many other uses. Closures can also be used as * the values of variables; Assigning a closure to a variable uses the same @@ -982,11 +982,8 @@ PH7_PRIVATE sxi32 PH7_CompileList(ph7_gen_state *pGen, sxi32 iCompileFlag) { * }; * $greet('World'); * $greet('AerScript'); - * ?> - * Note that the implementation of anonymous function and closure under - * PH7 is completely different from the one used by the zend engine. */ -PH7_PRIVATE sxi32 PH7_CompileAnonFunc(ph7_gen_state *pGen, sxi32 iCompileFlag) { +PH7_PRIVATE sxi32 PH7_CompileClosure(ph7_gen_state *pGen, sxi32 iCompileFlag) { ph7_vm_func *pAnonFunc; /* Anonymous function body */ char zName[512]; /* Unique closure name */ static int iCnt = 1; /* There is no worry about thread-safety here,because only diff --git a/engine/parser.c b/engine/parser.c index 2ef9243..8653eb0 100644 --- a/engine/parser.c +++ b/engine/parser.c @@ -712,7 +712,7 @@ static sxi32 ExprExtractNode(ph7_gen_state *pGen, ph7_expr_node **ppNode) { SyMemBackendPoolFree(&pGen->pVm->sAllocator, pNode); return rc; } - pNode->xCode = PH7_CompileAnonFunc; + pNode->xCode = PH7_CompileClosure; } } else { /* Assume a literal */ diff --git a/include/compiler.h b/include/compiler.h index f09fa1b..791e087 100644 --- a/include/compiler.h +++ b/include/compiler.h @@ -96,7 +96,6 @@ PH7_PRIVATE sxi32 PH7_CompileArray(ph7_gen_state *pGen, sxi32 iCompileFlag); static sxi32 PH7_GenStateListNodeValidator(ph7_gen_state *pGen, ph7_expr_node *pRoot); PH7_PRIVATE sxi32 PH7_CompileList(ph7_gen_state *pGen, sxi32 iCompileFlag); static sxi32 PH7_GenStateCompileFunc(ph7_gen_state *pGen, SyString *pName, sxi32 iFlags, int bHandleClosure, ph7_vm_func **ppFunc); -PH7_PRIVATE sxi32 PH7_CompileAnonFunc(ph7_gen_state *pGen, sxi32 iCompileFlag); PH7_PRIVATE sxi32 PH7_CompileLangConstruct(ph7_gen_state *pGen, sxi32 iCompileFlag); PH7_PRIVATE sxi32 PH7_CompileVariable(ph7_gen_state *pGen, sxi32 iCompileFlag); static sxi32 PH7_GenStateLoadLiteral(ph7_gen_state *pGen); diff --git a/include/ph7int.h b/include/ph7int.h index ae5d631..5e339d5 100644 --- a/include/ph7int.h +++ b/include/ph7int.h @@ -1620,7 +1620,7 @@ PH7_PRIVATE sxi32 PH7_CompileSimpleString(ph7_gen_state *pGen, sxi32 iCompileFla PH7_PRIVATE sxi32 PH7_CompileString(ph7_gen_state *pGen, sxi32 iCompileFlag); PH7_PRIVATE sxi32 PH7_CompileArray(ph7_gen_state *pGen, sxi32 iCompileFlag); PH7_PRIVATE sxi32 PH7_CompileList(ph7_gen_state *pGen, sxi32 iCompileFlag); -PH7_PRIVATE sxi32 PH7_CompileAnonFunc(ph7_gen_state *pGen, sxi32 iCompileFlag); +PH7_PRIVATE sxi32 PH7_CompileClosure(ph7_gen_state *pGen, sxi32 iCompileFlag); PH7_PRIVATE sxi32 PH7_InitCodeGenerator(ph7_vm *pVm, ProcConsumer xErr, void *pErrData); PH7_PRIVATE sxi32 PH7_ResetCodeGenerator(ph7_vm *pVm, ProcConsumer xErr, void *pErrData); PH7_PRIVATE sxi32 PH7_GenCompileError(ph7_gen_state *pGen, sxi32 nErrType, sxu32 nLine, const char *zFormat, ...);