develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35112 - trunk/languages/befunge

From:
jquelin
Date:
January 7, 2009 03:15
Subject:
[svn:parrot] r35112 - trunk/languages/befunge
Message ID:
20090107111542.0C38FCB9F9@x12.develooper.com
Author: jquelin
Date: Wed Jan  7 03:15:41 2009
New Revision: 35112

Modified:
   trunk/languages/befunge/befunge.pir
   trunk/languages/befunge/debug.pir

Log:
begin of printing status in debug mode


Modified: trunk/languages/befunge/befunge.pir
==============================================================================
--- trunk/languages/befunge/befunge.pir	(original)
+++ trunk/languages/befunge/befunge.pir	Wed Jan  7 03:15:41 2009
@@ -20,6 +20,7 @@
     .local int debug
     .local pmc playfield
     (playfield,debug) = _parse_argv(argv)
+    set_global "playfield", playfield
 
     # various inits
     .local int x, y, dir, flag
@@ -56,7 +57,7 @@
     val  = playfield[y;x]
     char = chr val
     if debug == 0 goto TICK_NODEBUG
-    debug__check_breakpoint()
+    debug__check_breakpoint(x,y,char,val)
   TICK_NODEBUG:
 
 =pod

Modified: trunk/languages/befunge/debug.pir
==============================================================================
--- trunk/languages/befunge/debug.pir	(original)
+++ trunk/languages/befunge/debug.pir	Wed Jan  7 03:15:41 2009
@@ -31,18 +31,104 @@
 .end
 
 
+.sub "_debug__print_status_coordinates"
+    .param int x
+    .param int y
+
+    print "("
+    print x
+    print ","
+    print y
+    print ")"
+.end
+
+.sub "_debug__print_status_current_char"
+    .param string char 
+    .param int    val
+
+    print "'"
+    print char
+    print "' (ord="
+    print val
+    print ")"
+.end
+
+
+# Print the status of the instruction pointer:
+# coordinates, current char, direction, flags and stack.
+.sub "_debug__print_status"
+    .param int    x
+    .param int    y
+    .param string char 
+    .param int    val
+
+    _debug__print_status_coordinates(x,y)
+    print " - "
+    _debug__print_status_current_char(char,val)
+    print " "
+    print "\n"
+
+=pod
+
+DEBUG_PRINT_STATUS:
+        # Coordinates.
+        # Current char.
+        # Direction.
+        print " dir="
+        print I2
+        # Flags:
+        set S10, " \""
+        eq I4, 1, DEBUG_PRINT_STATUS_FLAG
+        set S10, " #"
+        eq I4, 2, DEBUG_PRINT_STATUS_FLAG
+        set S10, " @"
+        eq I4, 3, DEBUG_PRINT_STATUS_FLAG
+        set S10, "  "
+DEBUG_PRINT_STATUS_FLAG:
+        print S10
+        # Stack.
+        print " stack="
+        set I11, P2
+        set I10, 0
+        ge  I10, I11, DEBUG_PRINT_STATUS_STACK_END
+DEBUG_PRINT_STATUS_STACK_LOOP:
+        set I12, P2[I10]
+        print I12
+        inc I10
+        ge I10, I11, DEBUG_PRINT_STATUS_STACK_END
+        print ","
+        branch DEBUG_PRINT_STATUS_STACK_LOOP
+DEBUG_PRINT_STATUS_STACK_END:
+        print "\n"
+        ret
+
+=cut
+
+.end
+
 .sub "_debug__interact"
+    .param int    x
+    .param int    y
+    .param string char 
+    .param int    val
+
+    _debug__print_status(x,y,char,val)
 .end
 
 
 # Check whether we should stop the interpreter at the current
 # moment, allowing user to play with the debugger.
 .sub "debug__check_breakpoint"
+    .param int    x
+    .param int    y
+    .param string char 
+    .param int    val
+
     .local pmc step
 
     step = get_global "step"
     if step == 0 goto DEBUG__CHECK_BREAKPOINT__CHAR
-    _debug__interact()
+    _debug__interact(x,y,char,val)
     goto DEBUG__CHECK_BREAKPOINT__END
 
   DEBUG__CHECK_BREAKPOINT__CHAR:
@@ -181,50 +267,6 @@
 
 
 
-# Print the status of the instruction pointer:
-# coordinates, current char, direction, flags and stack.
-DEBUG_PRINT_STATUS:
-        # Coordinates.
-        print "("
-        print I0
-        print ","
-        print I1
-        print ")"
-        # Current char.
-        print " - '"
-        print S0
-        print "' (ord="
-        ord I10, S0
-        print I10
-        print ")"
-        # Direction.
-        print " dir="
-        print I2
-        # Flags:
-        set S10, " \""
-        eq I4, 1, DEBUG_PRINT_STATUS_FLAG
-        set S10, " #"
-        eq I4, 2, DEBUG_PRINT_STATUS_FLAG
-        set S10, " @"
-        eq I4, 3, DEBUG_PRINT_STATUS_FLAG
-        set S10, "  "
-DEBUG_PRINT_STATUS_FLAG:
-        print S10
-        # Stack.
-        print " stack="
-        set I11, P2
-        set I10, 0
-        ge  I10, I11, DEBUG_PRINT_STATUS_STACK_END
-DEBUG_PRINT_STATUS_STACK_LOOP:
-        set I12, P2[I10]
-        print I12
-        inc I10
-        ge I10, I11, DEBUG_PRINT_STATUS_STACK_END
-        print ","
-        branch DEBUG_PRINT_STATUS_STACK_LOOP
-DEBUG_PRINT_STATUS_STACK_END:
-        print "\n"
-        ret
 
 
 # Dump the playfield on stdout.



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About