line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Inline::Guile; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
86003
|
use strict; |
|
3
|
|
|
3
|
|
7
|
|
|
3
|
|
|
|
|
113
|
|
|
3
|
|
|
|
|
13
|
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
88
|
|
4
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
3
|
|
4
|
|
|
3
|
|
|
|
|
197
|
|
|
3
|
|
|
|
|
13
|
|
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
143
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Inline; |
7
|
|
|
|
|
|
|
our @ISA = qw(Inline); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
|
1986
|
use Guile; |
|
3
|
|
|
3
|
|
9
|
|
|
3
|
|
|
|
|
97
|
|
|
3
|
|
|
|
|
13
|
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
69
|
|
12
|
3
|
|
|
3
|
|
13
|
use Carp qw(croak confess); |
|
3
|
|
|
3
|
|
3
|
|
|
3
|
|
|
|
|
1883
|
|
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
1713
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# register for Inline |
15
|
|
|
|
|
|
|
sub register { |
16
|
|
|
|
|
|
|
return { |
17
|
0
|
|
|
0
|
0
|
0
|
language => 'Guile', |
18
|
|
|
|
|
|
|
aliases => ['GUILE'], |
19
|
|
|
|
|
|
|
type => 'interpreted', |
20
|
|
|
|
|
|
|
suffix => 'go', |
21
|
|
|
|
|
|
|
}; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# check options |
25
|
|
|
|
|
|
|
sub validate { |
26
|
3
|
|
|
3
|
0
|
66
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
3
|
|
|
|
|
24
|
while(@_ >= 2) { |
29
|
0
|
|
|
|
|
0
|
my ($key, $value) = (shift, shift); |
30
|
0
|
|
|
|
|
0
|
croak("Unsupported option found: \"$key\"."); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# required method - doesn't do anything useful |
35
|
|
|
|
|
|
|
sub build { |
36
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# magic dance steps to a successful Inline compile... |
39
|
0
|
|
|
|
|
0
|
my $path = "$self->{API}{install_lib}/auto/$self->{API}{modpname}"; |
40
|
0
|
|
|
|
|
0
|
my $obj = $self->{API}{location}; |
41
|
0
|
0
|
|
|
|
0
|
$self->mkpath($path) unless -d $path; |
42
|
0
|
0
|
|
|
|
0
|
$self->mkpath($self->{API}{build_dir}) unless -d $self->{API}{build_dir}; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# touch my monkey |
45
|
0
|
0
|
|
|
|
0
|
open(OBJECT, ">$obj") or die "Unable to open object file: $obj : $!"; |
46
|
0
|
0
|
|
|
|
0
|
close(OBJECT) or die "Unable to close object file: $obj : $!"; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# load the code into the interpreter |
50
|
|
|
|
|
|
|
sub load { |
51
|
3
|
|
|
3
|
0
|
11
|
my $self = shift; |
52
|
3
|
|
|
|
|
19
|
my $code = $self->{API}{code}; |
53
|
3
|
|
50
|
|
|
11
|
my $pkg = $self->{API}{pkg} || 'main'; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# append testing mark |
56
|
3
|
|
|
|
|
7
|
$code .= "\n1\n"; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# try evaluating the code |
59
|
3
|
|
|
|
|
4
|
my $result; |
60
|
3
|
|
|
|
|
5
|
eval { $result = Guile::eval_str($code); }; |
|
3
|
|
|
|
|
37
|
|
61
|
3
|
50
|
|
|
|
855
|
croak("Inline::Guile : Problem evaluating Guile code:\n$code\n\nReason: $@") |
62
|
|
|
|
|
|
|
if $@; |
63
|
0
|
0
|
|
|
|
|
croak("Inline::Guile : Problem evaluating Guile code:\n$code\n") |
64
|
|
|
|
|
|
|
unless $result == 1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# look for possible global defines |
67
|
0
|
|
|
|
|
|
while($code =~ /define\s+(\S+)/g |
68
|
|
|
|
|
|
|
# + cperl-mode, I hate you. |
69
|
|
|
|
|
|
|
){ |
70
|
0
|
|
|
|
|
|
my $name = $1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# try to lookup a procedure object |
73
|
0
|
|
|
|
|
|
my $proc = Guile::lookup($name); |
74
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
if (Guile::procedure_p($proc)) { |
76
|
|
|
|
|
|
|
# got a live one, register it |
77
|
3
|
|
|
3
|
|
16
|
no strict 'refs'; |
|
3
|
|
|
3
|
|
6
|
|
|
3
|
|
|
|
|
470
|
|
|
3
|
|
|
|
|
17
|
|
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
516
|
|
78
|
0
|
|
|
0
|
|
|
*{"${pkg}::$name"} = sub { Guile::apply($proc, [@_]); } |
|
0
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# no info implementation yet |
85
|
0
|
|
|
0
|
1
|
|
sub info { } |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
__END__ |