r7127: allow for recursive ejs functions
authorAndrew Tridgell <tridge@samba.org>
Tue, 31 May 2005 01:48:04 +0000 (01:48 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:17:20 +0000 (13:17 -0500)
source/lib/ejs/ejsParser.c

index d42d66bcf53afd6cb7adece16c429f4f6895ef70..17fe0ce98af930ceaed3a461ec301b8de5a15db0 100644 (file)
@@ -1128,6 +1128,13 @@ static int parseFunctionDec(Ejs *ep, int state, int flags)
                mprDestroyVar(&v);
                return EJS_STATE_ERR;
        }
+
+       /* register the function name early to allow for recursive
+          function calls (see note in ECMA standard, page 71) */
+       if (!(flags & EJS_FLAGS_ASSIGNMENT)) {
+               currentObj = ejsFindObj(ep, 0, procName, flags);
+               vp = mprSetProperty(currentObj, procName, &v);
+       }
        
        /*
         *      Parse the function body. Turn execute off.