Anarres-Mud-Driver
view release on metacpan or search on metacpan
lib/Driver/Compiler/Check.pm view on Meta::CPAN
StmtCase => 'CODE', # Generate a label
StmtDefault => 'CODE', # Sort out the labels
StmtIf => 'CODE', # Handle the 'else' clause!
StmtBreak => 'CODE', # Get the break target
StmtContinue=> 'CODE', # Get the continue target
StmtReturn => 'CODE', # Output type must match function
Sscanf => 'CODE', # Urgh!
);
# This looks like a fast way of generating the choice table for
# promotable operators, but does depend a little on the naming
# of opcodes! If there are any special cases, they need to be put
# into %OPCHOICES as literals. I'm going to get lynched for this.
{
%OPCHOICES = ();
no strict qw(refs);
my $package = __PACKAGE__;
$package =~ s/[^:]+$/Node/;
foreach my $op (keys %OPTYPES) {
next unless $OPTYPES{$op} eq 'CHOOSE';
t/01_type.t view on Meta::CPAN
ok($$t eq 's', 'Construct T_STRING (from cache)');
$t = new Anarres::Mud::Driver::Compiler::Type("*s");
ok($$t eq '*s', 'Construct string pointer');
$t = new Anarres::Mud::Driver::Compiler::Type("*s");
ok($$t eq '*s', 'Construct string pointer from cache');
$t = T_CLASS("a", T_STRING);
ok($$t =~ m/^{/, 'Construct T_CLASS');
ok($t->dump eq '{a:s}', 'Class dump looks OK');
$t = T_CLASS("b", T_STRING, T_INTEGER, T_CLASS("c", T_STRING, T_INTEGER));
ok($$t =~ m/^{/, 'Construct complex T_CLASS');
# print STDERR $t->dump, "\n";
ok($t->dump eq '{b:si{c:si}}', 'Complex class dump looks OK');
my $cond = 1;
my $cache = \%Anarres::Mud::Driver::Compiler::Type::CACHE;
foreach (keys %$cache) {
$cond = 0 unless $_ eq ${$cache->{$_}};
}
ok($cond, 'Cache integrity check');
$t = T_CLASS("d", T_STRING, T_INTEGER, T_CLASS("e", T_STRING, T_INTEGER));
$u = T_CLASS("f", T_STRING, T_INTEGER, T_CLASS("g", T_STRING));
t/10_program.t view on Meta::CPAN
use strict;
use Data::Dumper;
use Test::More tests => 3;
use_ok('Anarres::Mud::Driver::Program');
my $program = new Anarres::Mud::Driver::Program(
Path => '/tmp/foo',
);
ok(defined($program), 'We constructed something ...');
ok(ref($program) =~ m/::Program$/, '... which looks like a program');
t/20_compiler.t view on Meta::CPAN
use strict;
use Data::Dumper;
use Test::More tests => 3;
use_ok('Anarres::Mud::Driver::Compiler');
my $compiler = new Anarres::Mud::Driver::Compiler;
ok(defined($compiler), 'We constructed something ...');
ok(ref($compiler) =~ m/::Compiler$/, '... which looks like a compiler');
t/60_compile.t view on Meta::CPAN
use_ok('Anarres::Mud::Driver::Compiler');
use_ok('Anarres::Mud::Driver::Efun::Core');
my $compiler = new Anarres::Mud::Driver::Compiler;
ok(defined($compiler), 'We constructed a compiler');
exit unless $local;
my $program = $compiler->compile($source);
ok(defined($program), 'Got a return value from compile() ...');
ok(ref($program) =~ m/::Program$/, '... which looks like a program');
# print $program->dump;
ok($program->dump, 'Program appears to dump');
my $ch;
eval {
$ch = $program->check;
ok($ch, 'Typechecked program');
};
( run in 0.526 second using v1.01-cache-2.11-cpan-64827b87656 )