1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut synced 2025-06-07 18:45:42 -04:00

Merge branch 'master' of github.com:simcop2387/perlbuut

Conflicts:
	bin/evalserver
This commit is contained in:
Ryan Voots 2011-09-03 11:35:15 -04:00
commit bd17879ca3
4 changed files with 11948 additions and 8349 deletions

View file

@ -1,5 +1,6 @@
#!/home/ryan/perl5/perlbrew/perls/perl-5.14.1/bin/perl
#use local::lib;
# Guess we're being activated inside bin/, so go up a directory.
BEGIN { if( not -e 'lib' and not -e 'etc' and -e 'bb3' ) { chdir ".."; } }
@ -8,7 +9,7 @@ use lib "$FindBin::Bin/../lib";
use EvalServer;
use POSIX qw/setsid/;
$ENV{PATH}="/usr/bin/:/bin/";
$ENV{PATH}="/home/farnsworth/perl5/perlbrew/perls/perl-5.14.0/bin:/usr/bin/:/bin/";
# Only daemonize if we're asked to.
if( $ARGV[0] eq '-d' ) {

19508
deps/env.js vendored

File diff suppressed because one or more lines are too long

View file

@ -42,7 +42,7 @@ sub spawn_eval {
}
warn "Spawning Eval: $args->{code}\n";
my $wheel = POE::Wheel::Run->new(
Program => [ 'perl', $filename ],
Program => [ '/home/farnsworth/perl5/perlbrew/perls/perl-5.14.0/bin/perl', $filename ],
ProgramArgs => [ ],
CloseOnCall => 1, #Make sure all of the filehandles are closed.

View file

@ -1,4 +1,4 @@
#!/usr/bin/perl
#!/home/farnsworth/perl5/perlbrew/perls/perl-5.14.0/bin/perl
use lib '/home/farnsworth/perl5/lib/perl5/x86_64-linux-gnu-thread-multi';
use lib '/home/farnsworth/perl5/lib/perl5';
@ -15,10 +15,13 @@ use List::MoreUtils;
use List::UtilsBy;
use Data::Munge;
use Scalar::MoreUtils;
use Regexp::Common;
use Encode;
require Moose;
require MooseX::Declare;
eval "use MooseX::Declare; class Foo { has dongs => ( is => ro, isa => 'Int' ); };";
require "utf8_heavy.pl";
no warnings;
@ -52,7 +55,7 @@ use Text::ParseWords;
use B::Deparse;
# Javascript Libs
BEGIN{ eval "use JavaScript::SpiderMonkey;"; }
BEGIN{ eval "use JavaScript::V8; use JSON::XS; JavaScript::V8::Context->new()->eval('1')"; }
my $JSENV_CODE = do { local $/; open my $fh, "deps/env.js"; <$fh> };
require 'bytes_heavy.pl';
@ -60,6 +63,7 @@ use Tie::Hash::NamedCapture;
{#no warnings 'constant';
uc "\x{666}"; #Attempt to load unicode libraries.
lc "JONQUIÉRE";
}
binmode STDOUT, ":utf8"; # Enable utf8 output.
@ -145,6 +149,8 @@ use Storable qw/nfreeze/; nfreeze([]); #Preload Nfreeze since it's loaded on dem
my $limit = 150 * $meg;
(
setrlimit(RLIMIT_VMEM, 1024*$meg, 1024*$meg)
and
setrlimit(RLIMIT_DATA, $limit, $limit )
and
setrlimit(RLIMIT_STACK, $limit, $limit )
@ -161,8 +167,6 @@ use Storable qw/nfreeze/; nfreeze([]); #Preload Nfreeze since it's loaded on dem
and
setrlimit(RLIMIT_AS,$limit,$limit)
and
setrlimit(RLIMIT_VMEM,$limit, $limit)
and
setrlimit(RLIMIT_MEMLOCK,100,100)
and
setrlimit(RLIMIT_CPU, 10,10)
@ -244,38 +248,22 @@ use Storable qw/nfreeze/; nfreeze([]); #Preload Nfreeze since it's loaded on dem
my( $code ) = @_;
local $@;
my $js = JavaScript::SpiderMonkey->new;
$js->init;
# This is great evil!
JavaScript::SpiderMonkey::JS_ForceLatest( $js->{context} );
my $js = JavaScript::V8::Context->new;
# Set up the Environment for ENVJS
$js->property_by_path("Envjs.profile", 0);
$js->function_set("print", sub { print @_ } );
$js->bind("print", sub { print @_ } );
$js->bind("write", sub { print @_ } );
for( qw/log debug info warn error/ ) {
$js->eval("Envjs.$_=function(x){}");
}
# for( qw/log debug info warn error/ ) {
# $js->eval("Envjs.$_=function(x){}");
# }
$js->eval($JSENV_CODE) or die $@;
my $modified_code = qq!
var ret = eval("\Q$code\E");
if( ret === null ) {
"null"
}
else if( typeof ret == "object" || typeof ret == "array" ) {
ret.toSource();
}
else { ret }
!;
print $js->ret_eval($modified_code);
my $out = eval { $js->eval($code) };
if( $@ ) { print "ERROR: $@"; }
else { print encode_json $out }
}
sub ruby_code {