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:
parent
c4ec393153
commit
d3eca7544f
18
modules/compiler_vm/languages/java.pm
Executable file
18
modules/compiler_vm/languages/java.pm
Executable 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;
|
41
modules/compiler_vm/languages/server/java.pm
Executable file
41
modules/compiler_vm/languages/server/java.pm
Executable 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;
|
Loading…
Reference in New Issue
Block a user