line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Language::LispPerl::Atom; |
2
|
|
|
|
|
|
|
$Language::LispPerl::Atom::VERSION = '0.006'; |
3
|
6
|
|
|
6
|
|
40
|
use Moose; |
|
6
|
|
|
|
|
91
|
|
|
6
|
|
|
|
|
45
|
|
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
26329
|
use Language::LispPerl::Printer; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
105
|
|
6
|
6
|
|
|
6
|
|
22
|
use Language::LispPerl::Logger; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
2637
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $id = 0; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'class' => ( is => 'ro', isa => 'Str', default => 'Atom' ); |
11
|
|
|
|
|
|
|
has 'type' => ( is => 'rw', isa => 'Str', required => 1 ); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'value' => ( is => 'rw', default => '' ); |
14
|
|
|
|
|
|
|
has 'object_id' => ( is => 'ro', isa => 'Str', default => sub{ 'atom'.( $id++ ); } ); |
15
|
|
|
|
|
|
|
has 'meta_data' => ( is => 'rw' ); |
16
|
|
|
|
|
|
|
# An atom that is a function can have a context. |
17
|
|
|
|
|
|
|
has 'context' => ( is => 'rw' ); |
18
|
|
|
|
|
|
|
has 'pos' => ( is => 'ro', default => sub{ |
19
|
|
|
|
|
|
|
return { |
20
|
|
|
|
|
|
|
filename => "unknown", |
21
|
|
|
|
|
|
|
line => 0, |
22
|
|
|
|
|
|
|
col => 0 |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
}); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub to_hash{ |
27
|
80
|
|
|
80
|
0
|
68
|
my ($self) = @_; |
28
|
|
|
|
|
|
|
return { |
29
|
80
|
|
|
|
|
1808
|
class => $self->class(), |
30
|
|
|
|
|
|
|
type => $self->type(), |
31
|
|
|
|
|
|
|
value => Language::LispPerl::Printer::to_perl( $self->value() ), |
32
|
|
|
|
|
|
|
object_id => $self->object_id(), |
33
|
|
|
|
|
|
|
meta_data => Language::LispPerl::Printer::to_perl( $self->meta_data() ), |
34
|
|
|
|
|
|
|
pos => Language::LispPerl::Printer::to_perl( $self->pos() ), |
35
|
|
|
|
|
|
|
# Note that we dont persist the function contexts |
36
|
|
|
|
|
|
|
# This forbids the evaluation of closures in deflated evalers. |
37
|
|
|
|
|
|
|
__class => $self->blessed(), |
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub from_hash{ |
42
|
40
|
|
|
40
|
0
|
40
|
my ($class, $hash) = @_; |
43
|
|
|
|
|
|
|
return $class->new({ |
44
|
40
|
|
|
|
|
71
|
map{ $_ => Language::LispPerl::Reader::from_perl( $hash->{$_} ) } keys %$hash |
|
280
|
|
|
|
|
383
|
|
45
|
|
|
|
|
|
|
}); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub show { |
50
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
51
|
0
|
|
|
|
|
|
my $indent = shift; |
52
|
0
|
0
|
|
|
|
|
$indent = "" if !defined $indent; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
#print $indent . "class: " . $self->{class} . "\n"; |
55
|
0
|
|
|
|
|
|
print $indent . "type: " . $self->{type} . "\n"; |
56
|
0
|
|
|
|
|
|
print $indent . "value: " . $self->{value} . "\n"; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub error { |
60
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
61
|
0
|
|
|
|
|
|
my $msg = shift; |
62
|
0
|
|
|
|
|
|
$msg .= " ["; |
63
|
0
|
|
|
|
|
|
$msg .= Language::LispPerl::Printer::to_string($self); |
64
|
0
|
|
|
|
|
|
$msg .= "] @[file: " . $self->{pos}->{filename}; |
65
|
0
|
|
|
|
|
|
$msg .= " ;line: " . $self->{pos}->{line}; |
66
|
0
|
|
|
|
|
|
$msg .= " ;col: " . $self->{pos}->{col} . "]"; |
67
|
0
|
|
|
|
|
|
Language::LispPerl::Logger::error($msg); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__PACKAGE__->meta()->make_immutable(); |
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|