HighDots Forums  

Seeing a function's code in a debugger (dynamic functions)

Javascript JavaScript language (comp.lang.javascript)


Discuss Seeing a function's code in a debugger (dynamic functions) in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
timothytoe
 
Posts: n/a

Default Seeing a function's code in a debugger (dynamic functions) - 03-10-2008 , 05:29 PM






Is there a way in Firebug to see what code is in a function? All I can
coax out of Firefox is "function()". Same with using Firebug's
console.out.

IE's debugger just tells me it's an Object {...}.

Does anyone know of a way to see the function's code? Getting it into
a string and printing that out would be just dandy.

I'm not looking for a way to see the source (I know how to do that).
I'm changing a function during execution and trying to find a good way
to debug the result. I have my code working now, but it would have
been a lot easier with a way to see what code the function currently
has in it ready to execute.

Reply With Quote
  #2  
Old   
Fritz Schenk
 
Posts: n/a

Default Re: Seeing a function's code in a debugger (dynamic functions) - 03-11-2008 , 01:53 AM






timothytoe wrote:
Quote:
Is there a way in Firebug to see what code is in a function? All I can
coax out of Firefox is "function()". Same with using Firebug's
console.out.

IE's debugger just tells me it's an Object {...}.

Does anyone know of a way to see the function's code? Getting it into
a string and printing that out would be just dandy.

I'm not looking for a way to see the source (I know how to do that).
I'm changing a function during execution and trying to find a good way
to debug the result. I have my code working now, but it would have
been a lot easier with a way to see what code the function currently
has in it ready to execute.
you may try the toString()


Reply With Quote
  #3  
Old   
timothytoe
 
Posts: n/a

Default Re: Seeing a function's code in a debugger (dynamic functions) - 03-11-2008 , 11:49 AM



On Mar 10, 10:53 pm, Fritz Schenk <intra... (AT) aol (DOT) com> wrote:
Quote:
timothytoe wrote:
Is there a way in Firebug to see what code is in a function? All I can
coax out of Firefox is "function()". Same with using Firebug's
console.out.

IE's debugger just tells me it's an Object {...}.

Does anyone know of a way to see the function's code? Getting it into
a string and printing that out would be just dandy.

I'm not looking for a way to see the source (I know how to do that).
I'm changing a function during execution and trying to find a good way
to debug the result. I have my code working now, but it would have
been a lot easier with a way to see what code the function currently
has in it ready to execute.

you may try the toString()
Why thank you very much. I had tried it before but with the wrong
syntax (I didn't realize toString was a function, and I had left the
function-call parentheses off.

console.log(arguments.callee.toString()); works just fine to show the
contents of the current function.

Should make metaprogramming less painful for me in the future.

By the way, callee is nice, but what I really wanted was
arguments.caller, which is nonstandard and unfortunately missing in at
least one major browser. I end up doing a lot of passing of callee
down to the metafunction. "caller" would make my code a lot easier to
read and maintain. Oh well.


Reply With Quote
  #4  
Old   
intrader
 
Posts: n/a

Default Re: Seeing a function's code in a debugger (dynamic functions) - 03-11-2008 , 05:40 PM



timothytoe wrote:
Quote:
On Mar 10, 10:53 pm, Fritz Schenk <intra... (AT) aol (DOT) com> wrote:
timothytoe wrote:
Is there a way in Firebug to see what code is in a function? All I can
coax out of Firefox is "function()". Same with using Firebug's
console.out.
IE's debugger just tells me it's an Object {...}.
Does anyone know of a way to see the function's code? Getting it into
a string and printing that out would be just dandy.
I'm not looking for a way to see the source (I know how to do that).
I'm changing a function during execution and trying to find a good way
to debug the result. I have my code working now, but it would have
been a lot easier with a way to see what code the function currently
has in it ready to execute.
you may try the toString()

Why thank you very much. I had tried it before but with the wrong
syntax (I didn't realize toString was a function, and I had left the
function-call parentheses off.

console.log(arguments.callee.toString()); works just fine to show the
contents of the current function.

Should make metaprogramming less painful for me in the future.

By the way, callee is nice, but what I really wanted was
arguments.caller, which is nonstandard and unfortunately missing in at
least one major browser. I end up doing a lot of passing of callee
down to the metafunction. "caller" would make my code a lot easier to
read and maintain. Oh well.
Yes, it is a shame that it is not in all browsers. Flanagan writes that
"arguments.caller.callee" should give you what you want.

--
intrader


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.