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

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

From:
jquelin
Date:
January 7, 2009 04:02
Subject:
[svn:parrot] r35114 - trunk/languages/befunge
Message ID:
20090107120228.79A08CB9F9@x12.develooper.com
Author: jquelin
Date: Wed Jan  7 04:02:26 2009
New Revision: 35114

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

Log:
using global to store the status


Modified: trunk/languages/befunge/befunge.pir
==============================================================================
--- trunk/languages/befunge/befunge.pir	(original)
+++ trunk/languages/befunge/befunge.pir	Wed Jan  7 04:02:26 2009
@@ -23,14 +23,17 @@
     set_global "playfield", playfield
 
     # various inits
-    .local int x, y, dir, flag
-    x = 0       # x coord of the pc
-    y = 0       # y coord of the pc
-    dir  = 1    # direction of the pc
-    flag = 0    # 1=string-mode, 2=bridge, 3=end
+    .local pmc status
+    status = new 'Hash'
+    status["x"] = 0       # x coord of the pc
+    status["y"] = 0       # y coord of the pc
+    status["dir"]  = 1    # direction of the pc
+    status["flag"] = 0    # 1=string-mode, 2=bridge, 3=end
+    set_global "status", status
 
     .local pmc stack
     stack = new 'ResizablePMCArray'
+    set_global "stack", stack
 
     .local num seed
     seed = time
@@ -51,13 +54,20 @@
         # S2 = user input
         # S0 = current instruction
 
-    .local int    val
+    .local int    x, y, val
     .local string char
   TICK:
+    status = get_global "status"
+    x    = status["x"]
+    y    = status["y"]
     val  = playfield[y;x]
     char = chr val
+    status["char"] = char
+    status["val"]  = val
+    set_global "status", status
+
     if debug == 0 goto TICK_NODEBUG
-    debug__check_breakpoint(x,y,char,val)
+    debug__check_breakpoint()
   TICK_NODEBUG:
 
 =pod

Modified: trunk/languages/befunge/debug.pir
==============================================================================
--- trunk/languages/befunge/debug.pir	(original)
+++ trunk/languages/befunge/debug.pir	Wed Jan  7 04:02:26 2009
@@ -32,8 +32,13 @@
 
 
 .sub "_debug__print_status_coordinates"
-    .param int x
-    .param int y
+    .local pmc status
+    .local int x
+    .local int y
+
+    status = get_global "status"
+    x = status["x"]
+    y = status["y"]
 
     print "("
     print x
@@ -43,8 +48,13 @@
 .end
 
 .sub "_debug__print_status_current_char"
-    .param string char 
-    .param int    val
+    .local pmc    status
+    .local string char 
+    .local int    val
+
+    status = get_global "status"
+    char = status["char"]
+    val  = status["val"]
 
     print "'"
     print char
@@ -57,14 +67,9 @@
 # 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)
+    _debug__print_status_coordinates()
     print " - "
-    _debug__print_status_current_char(char,val)
+    _debug__print_status_current_char()
     print " "
     print "\n"
 
@@ -107,28 +112,18 @@
 .end
 
 .sub "_debug__interact"
-    .param int    x
-    .param int    y
-    .param string char 
-    .param int    val
-
-    _debug__print_status(x,y,char,val)
+    _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"
-    .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(x,y,char,val)
+    _debug__interact()
     goto DEBUG__CHECK_BREAKPOINT__END
 
   DEBUG__CHECK_BREAKPOINT__CHAR:



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