| JavaScript documentation | Contained in the JavaScript distribution. |
JavaScript::Script - Pre-compiled JavaScript
If you have a big script that has to be executed over and over again compilation time may be significant.
The method compile in JavaScript::Context provides a mean of returning a pre-compiled script which is
an instance of this class which can be executed without the need of compilation.
Executes the script and returns the result of the last statement.
| JavaScript documentation | Contained in the JavaScript distribution. |
package JavaScript::Script; use strict; use warnings; sub new { my ($pkg, $context, $source) = @_; $pkg = ref $pkg || $pkg; my $script = jss_compile($context, $source); my $self = bless { _impl => $script }, $pkg; return $self; } sub exec { my ($self) = @_; my $rval = jss_execute($self->{_impl}); return $rval; } 1; __END__