summaryrefslogtreecommitdiff
path: root/lib/O.pm
blob: 40d336e12211fc67269d41a8ce3501b0cc3be055 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package O;
use B qw(minus_c);
use Carp;    

sub import {
    my ($class, $backend, @options) = @_;
    eval "use B::$backend ()";
    if ($@) {
	croak "use of backend $backend failed: $@";
    }
    my $compilesub = &{"B::${backend}::compile"}(@options);
    if (ref($compilesub) eq "CODE") {
	minus_c;
	eval 'END { &$compilesub() }';
    } else {
	die $compilesub;
    }
}

1;