mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-24 03:33:06 +01:00
Add support for TenDRA compiler
This commit is contained in:
parent
77e95a69ae
commit
45e403b51f
36
modules/compiler_vm/languages/server/tendra.pm
Executable file
36
modules/compiler_vm/languages/server/tendra.pm
Executable file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
package tendra;
|
||||
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";
|
||||
}
|
||||
|
||||
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; /home/compiler/prog <<< echo $input_quoted > .output\"");
|
||||
|
||||
$result = "";
|
||||
open(FILE, '.output');
|
||||
while(<FILE>) {
|
||||
$result .= $_;
|
||||
last if length $result >= 1024 * 20;
|
||||
}
|
||||
close(FILE);
|
||||
|
||||
$result =~ s/\s+$//;
|
||||
|
||||
$self->{output} .= $result;
|
||||
}
|
||||
|
||||
1;
|
35
modules/compiler_vm/languages/tendra.pm
Executable file
35
modules/compiler_vm/languages/tendra.pm
Executable file
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
package tendra;
|
||||
use parent '_c_base';
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
|
||||
$self->{sourcefile} = 'prog.c';
|
||||
$self->{execfile} = 'prog';
|
||||
$self->{default_options} = '-Xp';
|
||||
$self->{cmdline} = 'tcc -Wa,-32 -Wl,-melf_i386 -g $sourcefile $options -o $execfile';
|
||||
|
||||
$self->{prelude} = <<'END';
|
||||
#define _XOPEN_SOURCE 9001
|
||||
#define __USE_XOPEN
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#include <locale.h>
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
|
||||
END
|
||||
}
|
||||
|
||||
1;
|
Loading…
Reference in New Issue
Block a user