Subj : Re: Loading code into runtime; and error reporting issues To : netscape.public.mozilla.jseng From : "Alan Kemp" Date : Wed Feb 04 2004 08:59 pm "Brendan Eich" wrote in message news:40213E33.9080209@meer.net... > Alan Kemp wrote: [snip] > That's correct. ECMA specifies, based on SpiderMonkey's progenitor, and > on cloned implementations, circa 1996, that functions are bound only on > entering an execution context. Compiling doesn't execute anything. Ah thanks, things make a lot more sense now :-) > >Secondly, when an attempt to call an undefined function is made I have an > >error reporter setup to grab the error and handle it. However, there seems > >to be no way of telling when function name was called from the error > >reporter? I would like to provide a more meaningful output than the default > >"undefined is not a function". Is that information available at this stage? > > > > Sure, you should be getting names. Sample JS shell session: > > js> var f; > js> f() > 2: TypeError: f is not a function > js> function f(){return 42;} > js> f() > 42 > js> g() > 5: ReferenceError: g is not defined > js> > > If you don't see the same results for the same input with your > embedding, then we'll need to debug the code that calls > js_DecompileValueGenerator before passing the decompiled reference > expression to the error reporter. You might breakpoint there and see > what you can see. I traced through the code untill I finally got to js_DecompileValueGenerator, and the place its getting tripped up is here: /* * At this point, pc may or may not be null, i.e., we could be in * a script activation, or we could be in a native frame that was * called by another native function. Check pc and script. */ if (!pc) goto do_fallback; Where by upon going to do_fallback the string "undefined" is returned which is then used as the function name. Upon further investigation I have discovered that its only script functions that I am calling from my c++ code that get names "undefined" in the error report. If I call a funtion that then calls another function (which doesn't exist) the error report correctly shows the name of the function I tried to call. Is this expected behaviour? Or am I likely doing something wrong elsewhere? Thanks for the help, Alan .