Skip to content
Browse files

Handle loop construct properly.

  • Loading branch information...
1 parent 4791845 commit 9d8e698900021f85a4f535ae43cb03e90481c1f0 @jnthn committed Aug 22, 2012
Showing with 43 additions and 1 deletion.
  1. +1 −1 TODO
  2. +42 −0 bin/perl6-debug.nqp
View
2 TODO
@@ -1,5 +1,5 @@
* Check and maybe improve statement modifier handling
* Fix elsif handling
-* Handle stepping through loop and require
+* Handle stepping through require
* Improve accuracy of highlighting the exception-throwing code
* Allow setting breakpoint on a routine name
View
42 bin/perl6-debug.nqp
@@ -198,6 +198,48 @@ class Perl6::HookActions is Perl6::Actions {
}
}
+ method statement_control:sym<loop>($/) {
+ if $*DEBUG_HOOKS.has_hook('statement_cond') {
+ for <e1 e2 e3> -> $expr {
+ if $/{$expr} -> $m {
+ $m[0].'!make'(QAST::Stmts.new(
+ QAST::Op.new(
+ :op('call'),
+ QAST::WVal.new( :value($*DEBUG_HOOKS.get_hook('statement_cond')) ),
+ $*W.add_string_constant(pir::find_caller_lex__ps('$?FILES') // '<unknown>'),
+ ps_qast(),
+ $*W.add_string_constant('loop'),
+ $*W.add_numeric_constant('Int', widen_expr_from($m[0])),
+ $*W.add_numeric_constant('Int', widen_expr_to($m[0]))
+ ),
+ $m[0].ast
+ ));
+ }
+ }
+ }
+ Perl6::Actions.statement_control:sym<loop>($/);
+ }
+
+ sub widen_expr_from($e) {
+ my $from := $e.from;
+ for @($e) {
+ if $_.from < $from {
+ $from := $_.from;
+ }
+ }
+ $from
+ }
+
+ sub widen_expr_to($e) {
+ my $to := $e.to;
+ for @($e) {
+ if $_.to > $to {
+ $to := $_.to;
+ }
+ }
+ $to
+ }
+
method statement_control:sym<for>($/) {
Perl6::Actions.statement_control:sym<for>($/);
simple_xblock_hook($/);

0 comments on commit 9d8e698

Please sign in to comment.
Something went wrong with that request. Please try again.