3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-24 19:52:34 +01:00

Add Java language to compiler_vm

This commit is contained in:
Pragmatic Software 2015-04-10 03:43:45 -07:00
parent c4ec393153
commit d3eca7544f
2 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,18 @@
#!/usr/bin/env perl
use warnings;
use strict;
package java;
use parent '_default';
sub initialize {
my ($self, %conf) = @_;
$self->{sourcefile} = 'prog.java';
$self->{execfile} = 'prog';
$self->{default_options} = '';
$self->{cmdline} = 'javac $options $sourcefile';
}
1;

View File

@ -0,0 +1,41 @@
#!/usr/bin/perl
use warnings;
use strict;
package java;
use parent '_default';
sub postprocess {
my $self = shift;
# no errors compiling, but if output contains something, it must be diagnostic messages
if(length $self->{output}) {
$self->{output} =~ s/^\s+//;
$self->{output} =~ s/\s+$//;
$self->{output} = "[$self->{output}]\n";
}
print "Executing java\n";
my $input_quoted = quotemeta $self->{input};
$input_quoted =~ s/\\"/"'\\"'"/g;
my ($retval, $result) = $self->execute(60, "bash -c \"date -s \@$self->{date}; ulimit -t 1; echo $input_quoted | java prog > .output\"");
$result = "";
open(FILE, '.output');
while(<FILE>) {
$result .= $_;
last if length $result >= 1024 * 20;
}
close(FILE);
$result =~ s/\s+$//;
if (not length $result) {
$self->{no_output} = 1;
}
$self->{output} .= $result;
}
1;