Author: jquelin
Date: Wed Jan 7 04:48:57 2009
New Revision: 35118
Modified:
trunk/languages/befunge/debug.pir
Log:
beginning interaction work
Modified: trunk/languages/befunge/debug.pir
==============================================================================
--- trunk/languages/befunge/debug.pir (original)
+++ trunk/languages/befunge/debug.pir Wed Jan 7 04:48:57 2009
@@ -111,90 +111,37 @@
print "\n"
.end
+# The interpreter has reached a breakpoint. Let's
+# stop and interact with user.
.sub "_debug__interact"
+ DEBUG__INTERACT__LOOP:
_debug__print_status()
-.end
-
-
-# Check whether we should stop the interpreter at the current
-# moment, allowing user to play with the debugger.
-.sub "debug__check_breakpoint"
- .local pmc step
- step = get_global "step"
- if step == 0 goto DEBUG__CHECK_BREAKPOINT__CHAR
- _debug__interact()
- goto DEBUG__CHECK_BREAKPOINT__END
-
- DEBUG__CHECK_BREAKPOINT__CHAR:
- DEBUG__CHECK_BREAKPOINT__END:
-
-.end
+ print "bef> "
+ $P0 = getstdin
+ $S0 = readline $P0
+ chopn $S0, 1
+ $I0 = length $S0
+
+ if $I0 == 0 goto DEBUG__INTERACT__NEXT
+ $S1 = substr $S0, 0, 4
+ if $S1 == "dump" goto DEBUG__INTERACT__DUMP
+ if $S1 == "help" goto DEBUG__INTERACT__HELP
+ if $S1 == "list" goto DEBUG__INTERACT__LIST
+ if $S1 == "next" goto DEBUG__INTERACT__NEXT
+ if $S1 == "quit" goto DEBUG__INTERACT__QUIT
+
+ DEBUG__INTERACT__DUMP:
+ DEBUG__INTERACT__HELP:
+ DEBUG__INTERACT__LIST:
+ print "Not yet implemented...\n"
+ goto DEBUG__INTERACT__LOOP
+ DEBUG__INTERACT__NEXT:
+ DEBUG__INTERACT__QUIT:
=pod
- set I10, P3[0]
- eq 0, I10, DEBUG_CHECK_BREAKPOINT_CHAR
- bsr DEBUG_INTERACT
- branch DEBUG_CHECK_BREAKPOINT_END
-DEBUG_CHECK_BREAKPOINT_CHAR:
- set P4, P3[1]
- exists I10, P4[S0]
- eq 0, I10, DEBUG_CHECK_BREAKPOINT_COORD
- bsr DEBUG_INTERACT
- branch DEBUG_CHECK_BREAKPOINT_END
-DEBUG_CHECK_BREAKPOINT_COORD:
- set S10, I0
- concat S10, ","
- set S11, I1
- concat S10, S11
- exists I10, P4[S10]
- eq 0, I10, DEBUG_CHECK_BREAKPOINT_ROW
- bsr DEBUG_INTERACT
- branch DEBUG_CHECK_BREAKPOINT_END
-DEBUG_CHECK_BREAKPOINT_ROW:
- set S10, "r:"
- set S11, I1
- concat S10, S11
- exists I10, P4[S10]
- eq 0, I10, DEBUG_CHECK_BREAKPOINT_COL
- bsr DEBUG_INTERACT
- branch DEBUG_CHECK_BREAKPOINT_END
-DEBUG_CHECK_BREAKPOINT_COL:
- set S10, "c:"
- set S11, I0
- concat S10, S11
- exists I10, P4[S10]
- eq 0, I10, DEBUG_CHECK_BREAKPOINT_END
- bsr DEBUG_INTERACT
- # Fallback
- # branch DEBUG_CHECK_BREAKPOINT_END
-
-
- DEBUG__CHECK_BREAKPOINT__END:
- .return()
-
-.end
-
-=pod
-
-
-# The interpreter has reached a breakpoint. Let's
-# stop and interact with user.
DEBUG_INTERACT:
- bsr DEBUG_PRINT_STATUS
- print "bef> "
- getstdin P5
- readline S10, P5
- chopn S10, 1
- length I10, S10
- eq I10, 0, DEBUG_INTERACT_NEXT
- substr S11, S10, 0, 4
- eq S11, "dump", DEBUG_INTERACT_DUMP
- eq S11, "help", DEBUG_INTERACT_HELP
- eq S11, "list", DEBUG_INTERACT_LIST
- eq S11, "next", DEBUG_INTERACT_NEXT
- eq S11, "quit", DEBUG_INTERACT_QUIT
substr S11, S10, 0, 5
eq S11, "break", DEBUG_INTERACT_BREAK
substr S11, S10, 0, 6
@@ -242,9 +189,6 @@
print " help - display this message\n"
print "\n"
branch DEBUG_INTERACT
-DEBUG_INTERACT_LIST:
- print "Not yet implemented...\n"
- branch DEBUG_INTERACT
DEBUG_INTERACT_NEXT:
set P3[0], 1 # stop at next instruction
branch DEBUG_INTERACT_END
@@ -260,6 +204,75 @@
DEBUG_INTERACT_END:
ret
+=cut
+
+.end
+
+
+# Check whether we should stop the interpreter at the current
+# moment, allowing user to play with the debugger.
+.sub "debug__check_breakpoint"
+ .local pmc step
+
+ step = get_global "step"
+ if step == 0 goto DEBUG__CHECK_BREAKPOINT__CHAR
+ _debug__interact()
+ goto DEBUG__CHECK_BREAKPOINT__END
+
+ DEBUG__CHECK_BREAKPOINT__CHAR:
+ DEBUG__CHECK_BREAKPOINT__END:
+
+.end
+
+=pod
+
+ set I10, P3[0]
+ eq 0, I10, DEBUG_CHECK_BREAKPOINT_CHAR
+ bsr DEBUG_INTERACT
+ branch DEBUG_CHECK_BREAKPOINT_END
+DEBUG_CHECK_BREAKPOINT_CHAR:
+ set P4, P3[1]
+ exists I10, P4[S0]
+ eq 0, I10, DEBUG_CHECK_BREAKPOINT_COORD
+ bsr DEBUG_INTERACT
+ branch DEBUG_CHECK_BREAKPOINT_END
+DEBUG_CHECK_BREAKPOINT_COORD:
+ set S10, I0
+ concat S10, ","
+ set S11, I1
+ concat S10, S11
+ exists I10, P4[S10]
+ eq 0, I10, DEBUG_CHECK_BREAKPOINT_ROW
+ bsr DEBUG_INTERACT
+ branch DEBUG_CHECK_BREAKPOINT_END
+DEBUG_CHECK_BREAKPOINT_ROW:
+ set S10, "r:"
+ set S11, I1
+ concat S10, S11
+ exists I10, P4[S10]
+ eq 0, I10, DEBUG_CHECK_BREAKPOINT_COL
+ bsr DEBUG_INTERACT
+ branch DEBUG_CHECK_BREAKPOINT_END
+DEBUG_CHECK_BREAKPOINT_COL:
+ set S10, "c:"
+ set S11, I0
+ concat S10, S11
+ exists I10, P4[S10]
+ eq 0, I10, DEBUG_CHECK_BREAKPOINT_END
+ bsr DEBUG_INTERACT
+ # Fallback
+ # branch DEBUG_CHECK_BREAKPOINT_END
+
+
+ DEBUG__CHECK_BREAKPOINT__END:
+ .return()
+
+.end
+
+=pod
+
+
+