Skip to content

Commit

Permalink
Add debug map state to MAST::Frame
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Jan 29, 2019
1 parent 3f5204d commit cbb6abc
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/MAST/Nodes.nqp
Expand Up @@ -708,6 +708,13 @@ class MAST::Frame is MAST::Node {
# Mapping of lexical names to lexical index, for lookups.
has %!lexical_map;

# Mapping of names to local indexes, for debuging.
has %!debug_map;

# Integer array with alternating pairings of local index and debug name
# string heap index.
has @!debug_map_idxs;

# Flag bits.
my int $FRAME_FLAG_EXIT_HANDLER := 1;
my int $FRAME_FLAG_IS_THUNK := 2;
Expand Down Expand Up @@ -891,6 +898,8 @@ class MAST::Frame is MAST::Node {
@!local_types := nqp::list();
$!outer := MAST::Node;
%!lexical_map := nqp::hash();
%!debug_map := nqp::hash();
@!debug_map_idxs := nqp::list_i();
@!static_lex_values := nqp::list_i();
$!writer := $writer;
$!compunit := $compunit;
Expand Down Expand Up @@ -920,6 +929,10 @@ class MAST::Frame is MAST::Node {
for @!lexical_names {
nqp::push_i(@!lexical_names_idxs, self.add-string($_));
}
for %!debug_map {
nqp::push_i(@!debug_map_idxs, $_.value.index);
nqp::push_i(@!debug_map_idxs, self.add-string($_.key));
}
}

method set_index(int $idx) {
Expand Down Expand Up @@ -956,6 +969,18 @@ class MAST::Frame is MAST::Node {
$index
}

method add_local_debug_name($name, $local) {
%!debug_map{$name} := $local;
}

method debug_map() {
%!debug_map
}

method debug_map_idxs() {
@!debug_map_idxs
}

method set_outer($outer) {
if nqp::istype($outer, MAST::Frame) {
$!outer := $outer;
Expand Down

0 comments on commit cbb6abc

Please sign in to comment.