line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Anarres::Mud::Driver::Compiler::Dump; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
1857
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
122
|
|
4
|
3
|
|
|
3
|
|
17
|
use Carp qw(:DEFAULT cluck); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
411
|
|
5
|
3
|
|
|
3
|
|
17
|
use Exporter; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
97
|
|
6
|
3
|
|
|
3
|
|
16
|
use Data::Dumper; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
154
|
|
7
|
3
|
|
|
3
|
|
18
|
use Anarres::Mud::Driver::Compiler::Type qw(:all); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
864
|
|
8
|
3
|
|
|
3
|
|
18
|
use Anarres::Mud::Driver::Compiler::Node qw(@NODETYPES); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1214
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
push(@Anarres::Mud::Driver::Compiler::Node::ISA, __PACKAGE__); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub dumptype { |
13
|
1
|
|
|
1
|
0
|
4
|
my $self = shift; |
14
|
1
|
50
|
|
|
|
8
|
return "" unless $self->type; |
15
|
0
|
0
|
|
|
|
0
|
my $flags = |
|
|
0
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$self->flags & F_CONST ? "z" : "" . |
17
|
|
|
|
|
|
|
$self->flags & F_LVALUE ? "=" : "" ; |
18
|
0
|
|
|
|
|
0
|
return "[" . $flags . $self->type->dump(@_) . "] "; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub dump { |
22
|
1
|
|
|
1
|
0
|
383
|
my $self = shift; |
23
|
1
|
|
|
|
|
10
|
$self->dumpblock( [ $self->values ], @_ ); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub dumpblock { |
27
|
1
|
|
|
1
|
0
|
4
|
my ($self, $vals, $indent, @rest) = @_; |
28
|
1
|
|
|
|
|
2
|
$indent++; |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
10
|
my $op = $self->opcode; |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
0
|
my @fields = map { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
33
|
1
|
|
|
|
|
3
|
! $_ ? "" |
34
|
|
|
|
|
|
|
: ! ref($_) ? "q[$_]" |
35
|
|
|
|
|
|
|
: ref($_) !~ /::/ ? "[" . ref($_) . "]" |
36
|
|
|
|
|
|
|
: $_->dump($indent, @rest) |
37
|
|
|
|
|
|
|
} @$vals; |
38
|
1
|
|
|
|
|
5
|
my $sep = "\n" . ("\t" x $indent); |
39
|
1
|
|
|
|
|
8
|
return join($sep, |
40
|
|
|
|
|
|
|
"(" . $self->dumptype($indent, @rest) . lc $op, |
41
|
|
|
|
|
|
|
@fields |
42
|
|
|
|
|
|
|
) . ")"; |
43
|
|
|
|
|
|
|
# return join($sep, "([V] block", @locals, @stmts) . ")"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
{ |
47
|
|
|
|
|
|
|
package Anarres::Mud::Driver::Compiler::Node::String; |
48
|
3
|
|
|
3
|
|
1889
|
use String::Escape qw(quote printable); |
|
3
|
|
|
|
|
10876
|
|
|
3
|
|
|
|
|
2283
|
|
49
|
0
|
|
|
0
|
|
|
sub dump { return quote(printable($_[0]->value(0))) } |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
{ |
53
|
|
|
|
|
|
|
package Anarres::Mud::Driver::Compiler::Node::Integer; |
54
|
0
|
|
|
0
|
|
|
sub dump { return $_[0]->value(0) } |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
{ |
58
|
|
|
|
|
|
|
package Anarres::Mud::Driver::Compiler::Node::Variable; |
59
|
|
|
|
|
|
|
sub dump { |
60
|
0
|
|
|
0
|
|
|
my $self = shift; |
61
|
|
|
|
|
|
|
# my $var = $self->value(0); |
62
|
|
|
|
|
|
|
# XXX Typechecking should replace with an object? |
63
|
|
|
|
|
|
|
# return ref($var) ? $var->dump : $var; |
64
|
0
|
|
|
|
|
|
return "(" . $self->dumptype . "variable " |
65
|
|
|
|
|
|
|
. $self->value(0) . ")"; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
{ |
70
|
|
|
|
|
|
|
package Anarres::Mud::Driver::Compiler::Node::VarLocal; |
71
|
|
|
|
|
|
|
sub dump { |
72
|
0
|
|
|
0
|
|
|
"(" . $_[0]->dumptype . "varlocal " . $_[0]->value(0) . ")"; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
{ |
77
|
|
|
|
|
|
|
package Anarres::Mud::Driver::Compiler::Node::VarGlobal; |
78
|
|
|
|
|
|
|
sub dump { |
79
|
0
|
|
|
0
|
|
|
"(" . $_[0]->dumptype . "varglobal " . $_[0]->value(0) . ")"; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
{ |
84
|
|
|
|
|
|
|
package Anarres::Mud::Driver::Compiler::Node::VarStatic; |
85
|
|
|
|
|
|
|
sub dump { |
86
|
0
|
|
|
0
|
|
|
"(" . $_[0]->dumptype . "varstatic " . $_[0]->value(0) . ")"; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
{ |
91
|
|
|
|
|
|
|
package Anarres::Mud::Driver::Compiler::Node::Parameter; |
92
|
|
|
|
|
|
|
sub dump { |
93
|
0
|
|
|
0
|
|
|
my $self = shift; |
94
|
0
|
|
|
|
|
|
return "(" . $self->dumptype . "parameter " |
95
|
|
|
|
|
|
|
. $self->value(0) . ")"; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
{ |
100
|
|
|
|
|
|
|
package Anarres::Mud::Driver::Compiler::Node::Funcall; |
101
|
|
|
|
|
|
|
sub dump { |
102
|
0
|
|
|
0
|
|
|
my $self = shift; |
103
|
0
|
|
|
|
|
|
my @args = $self->values; |
104
|
0
|
|
|
|
|
|
my $method = shift @args; |
105
|
0
|
|
|
|
|
|
@args = map { " " . $_->dump(@_) } @args; |
|
0
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
return "(" . $self->dumptype(@_) . "funcall '" . |
107
|
|
|
|
|
|
|
$method->name . "'" . join("", @args) . ")" |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
{ |
112
|
|
|
|
|
|
|
package Anarres::Mud::Driver::Compiler::Node::CallOther; |
113
|
|
|
|
|
|
|
sub dump { |
114
|
0
|
|
|
0
|
|
|
my $self = shift; |
115
|
0
|
|
|
|
|
|
my @values = $self->values; |
116
|
0
|
|
|
|
|
|
my $exp = shift @values; |
117
|
0
|
|
|
|
|
|
my $name = shift @values; |
118
|
0
|
|
|
|
|
|
my $type = $self->dumptype; |
119
|
0
|
0
|
|
|
|
|
@values = map { ref($_) =~ /::/ ? " " . $_->dump(@_) : $_ } |
|
0
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
@values; |
121
|
0
|
|
|
|
|
|
return "(" . $type . "callother " . $exp->dump(@_) . " -> '" . |
122
|
|
|
|
|
|
|
$name . "'" . join("", @values) . ")" |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
{ |
127
|
|
|
|
|
|
|
package Anarres::Mud::Driver::Compiler::Node::Block; |
128
|
|
|
|
|
|
|
sub dump { |
129
|
0
|
|
|
0
|
|
|
my $self = shift; |
130
|
0
|
|
|
|
|
|
return $self->dumpblock( |
131
|
0
|
|
|
|
|
|
[ @{ $self->value(0) }, # locals |
132
|
0
|
|
|
|
|
|
@{ $self->value(1) }, # statements |
133
|
|
|
|
|
|
|
], @_ ); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
{ |
138
|
|
|
|
|
|
|
package Anarres::Mud::Driver::Compiler::Node::StmtIf; |
139
|
|
|
|
|
|
|
sub dump { |
140
|
0
|
|
|
0
|
|
|
my $self = shift; |
141
|
0
|
|
|
|
|
|
my ($cond, $if, $else) = $self->values; |
142
|
0
|
0
|
|
|
|
|
my $vals = defined $else |
143
|
|
|
|
|
|
|
? [ $cond, $if, $else, ] |
144
|
|
|
|
|
|
|
: [ $cond, $if, ]; |
145
|
0
|
|
|
|
|
|
return $self->dumpblock($vals, @_); |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
if (0) { |
150
|
|
|
|
|
|
|
my $package = __PACKAGE__; |
151
|
3
|
|
|
3
|
|
20
|
no strict qw(refs); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
343
|
|
152
|
|
|
|
|
|
|
my @missing; |
153
|
|
|
|
|
|
|
foreach (@NODETYPES) { |
154
|
|
|
|
|
|
|
# next if defined $OPCODETABLE{$_}; # XXX No dump table |
155
|
|
|
|
|
|
|
next if defined &{ "$package\::$_\::dump" }; |
156
|
|
|
|
|
|
|
push(@missing, $_); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
print "No dump in @missing\n" if @missing; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
1; |