line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Goo::Thing::pm::Perl6Compiler; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
############################################################################### |
6
|
|
|
|
|
|
|
# Nigel Hamilton |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
9
|
|
|
|
|
|
|
# All Rights Reserved |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
12
|
|
|
|
|
|
|
# Filename: Goo::Thing::pm::Perl6Compiler.pm |
13
|
|
|
|
|
|
|
# Description: Compile a Perl program |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# Date Change |
16
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
17
|
|
|
|
|
|
|
# 01/08/05 Factored out of ProgramEditor as part of the new Goo |
18
|
|
|
|
|
|
|
# 30/08/2005 Added method: processError |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
############################################################################## |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
4
|
use Goo::Object; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
25
|
1
|
|
|
1
|
|
5
|
use Goo::Prompter; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
16
|
|
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
4
|
use base qw(Goo::Object); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
322
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# constant! |
30
|
|
|
|
|
|
|
my $last_error_file = "/tmp/last-goo-error.txt"; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
############################################################################### |
34
|
|
|
|
|
|
|
# |
35
|
|
|
|
|
|
|
# run - keep adding a thing to the program |
36
|
|
|
|
|
|
|
# |
37
|
|
|
|
|
|
|
############################################################################### |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub run { |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
0
|
1
|
|
my ($this, $thing) = @_; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $filename = $thing->get_full_path(); |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
Goo::Prompter::say("Compiling ..."); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# remove any previous erros |
48
|
0
|
|
|
|
|
|
unlink($last_error_file); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# redirect STDERR to STDOUT |
51
|
|
|
|
|
|
|
#my $results = `/usr/bin/perl -c $filename &2 > &1`; |
52
|
0
|
|
|
|
|
|
my $results = `/usr/bin/pugs -c $filename 2 &> $last_error_file`; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# do we have any errors? |
55
|
0
|
0
|
|
|
|
|
if (-e $last_error_file) { |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# oops - compilation included an error - lets jump to it |
58
|
0
|
|
|
|
|
|
process_error($thing); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
Goo::Prompter::notify("Finished compiling.\nPress a key to continue."); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
############################################################################### |
68
|
|
|
|
|
|
|
# |
69
|
|
|
|
|
|
|
# process_error - enable the user to jump to the last error |
70
|
|
|
|
|
|
|
# |
71
|
|
|
|
|
|
|
############################################################################### |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub process_error { |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
0
|
1
|
|
my ($thing) = @_; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $error_report = Goo::FileUtilities::slurp($last_error_file); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# show the errors! |
80
|
0
|
|
|
|
|
|
print $error_report; |
81
|
|
|
|
|
|
|
|
82
|
0
|
0
|
|
|
|
|
if ($error_report =~ m/.*line\s+(\d+)/s) { |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
my $error_on_line = $1; |
85
|
|
|
|
|
|
|
|
86
|
0
|
0
|
|
|
|
|
if (Goo::Prompter::confirm("Jump to error on line $error_on_line?")) { |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# there was an error - jump to the line |
89
|
0
|
|
|
|
|
|
$thing->do_action("J", $error_on_line); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 NAME |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Goo::Thing::pm::Perl6Compiler - Compile a Perl6 program |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 SYNOPSIS |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
use Goo::Thing::pm::Perl6Compiler; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 DESCRIPTION |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 METHODS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=over |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item run |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
compile a Perl6 program using /usr/bin/pugs |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item process_error |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
enable the user to jump to the last error |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=back |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 AUTHOR |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 SEE ALSO |
134
|
|
|
|
|
|
|
|