Skip Menu |

This queue is for tickets about the JavaScript-SpiderMonkey CPAN distribution.

Report information
The Basics
Id: 29359
Status: open
Priority: 0/
Queue: JavaScript-SpiderMonkey

People
Owner: Nobody in particular
Requestors: agentzh [...] yahoo.cn
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.19
Fixed in: (no value)



Subject: Request for the 'eval_file' method
Hi, Thomas, I'd love to see a new method named "eval_file" because I really need it ATM. I think it is NOT as simple as the following: use File::Slurp; sub eval_file { my ($self, $filename) = @_; $self->eval(read_file($filename)); } Because we still need to reset the file name and line number in the spidermonkey engine. Or the positional info contained in the diagnostics produced by J::SM will be meaningless. Also, the existing 'eval' method sets the starting line number to 0, resulting in bogus positional info in diagnostics. Like this: Error: ReferenceError: include is not defined at line 0: (null) Thanks! agentz
From: benkasminbullock [...] gmail.com
On Fri Sep 14 03:37:29 2007, AGENT wrote: Show quoted text
> Hi, Thomas, > > I'd love to see a new method named "eval_file" because I really need
it Show quoted text
> ATM. I think it is NOT as simple as the following: > > use File::Slurp; > sub eval_file { > my ($self, $filename) = @_; > $self->eval(read_file($filename)); > } > > Because we still need to reset the file name and line number in the > spidermonkey engine. Or the positional info contained in the
diagnostics Show quoted text
> produced by J::SM will be meaningless.
This seems like a good idea to me. At the moment "Eval" sets the file name to "Perl" but it would be nice if there was an eval_file method which could set the file name in the call to JavaScript::SpiderMonkey::JS_EvaluateScript( $self->{context}, $self->{global_object}, $script, $] > 5.007 ? bytes::length($script) : length($script), "Perl", <--- here 1); Show quoted text
> Also, the existing 'eval' method sets the starting line number to 0, > resulting in bogus positional info in diagnostics. Like this: > > Error: ReferenceError: include is not defined at line 0: (null)
This line error should be fixed now in the most recent patch, if it's accepted.