Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save masak/386512 to your computer and use it in GitHub Desktop.
Save masak/386512 to your computer and use it in GitHub Desktop.
$ cat get-ticks
use v6;
use Yapsi;
my $out = '';
my $clear = method ($out:) { $out = '' }
my $io-collector = class { method say($i) {$out ~= $i ~ "\n"} };
class Tardis::Debugger is Yapsi::Runtime {
method tick {
say 'tick';
my %p;
for $!env.pads.keys -> $block {
my @variables;
for $!env.pads{$block}.keys -> $var {
push @variables, $var => self.get-value-of($var);
}
%p{$block} = @variables;
}
say %p.perl;
say 'io position: ', $out.chars;
}
}
my $program = 'my $a; $a = 42; ++$a; say $a';
Tardis::Debugger.new(:io($io-collector)).run(
Yapsi::Compiler.new.compile($program)
);
$ alpha get-ticks
tick
{"main" => ["\$a" => "Any()"]}
io position: 0
tick
{"main" => ["\$a" => 42]}
io position: 0
tick
{"main" => ["\$a" => 43]}
io position: 0
tick
{"main" => ["\$a" => 43]}
io position: 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment