Subj : Re: Loading code into runtime; and error reporting issues To : Alan Kemp From : Brendan Eich Date : Wed Feb 04 2004 03:47 pm Alan Kemp wrote: >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? > Good debugging! Yes, this is expected. If you use JS_CallFunctionName to call a function named "f" in some object, e.g., there is no script that generates the callee expression, as there is when you evaluate a script such as "f()". It's a fact, whether you call it a bug or feature, that is not likely to change. If you may be calling a non-function, say an undefined property, you might use JS_GetProperty first to get "f"'s value, then JS_CallFunctionValue to invoke the value returned by JS_GetProperty if and only if JS_TypeOfValue says that value is JSTYPE_FUNCTION. /be .