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

[svn:parrot] r35333 - in trunk/languages/lua/src: lib pmc

From:
fperrad
Date:
January 10, 2009 01:53
Subject:
[svn:parrot] r35333 - in trunk/languages/lua/src: lib pmc
Message ID:
20090110095321.AAB2FCB9F9@x12.develooper.com
Author: fperrad
Date: Sat Jan 10 01:53:20 2009
New Revision: 35333

Modified:
   trunk/languages/lua/src/lib/luaaux.pir
   trunk/languages/lua/src/pmc/luafunction.pmc

Log:
[Lua] traceback
- only with function name (step 1)

Modified: trunk/languages/lua/src/lib/luaaux.pir
==============================================================================
--- trunk/languages/lua/src/lib/luaaux.pir	(original)
+++ trunk/languages/lua/src/lib/luaaux.pir	Sat Jan 10 01:53:20 2009
@@ -993,32 +993,57 @@
     $I0 = $P0
     if $I0 == .EXCEPT_EXIT goto L2
   L1:
-    .local string msg
-    msg = ex
-    .local int lineno
-    .local string traceback, where
-    (traceback, where) = 'traceback'()
-    $S0 = where
+    .local pmc bt
+    bt = ex.'backtrace'()
+    $S0 = where()
     $S0 .= ' '
-    $S0 .= msg
+    $S1 = ex
+    $S0 .= $S1
     $S0 .= "\n"
-    $S0 .= traceback
+    $S1 = traceback(bt)
+    $S0 .= $S1
     .return (1, $S0)
   L2:
     rethrow ex
 .end
 
-.sub 'traceback'
+.sub 'where' :anon
     # dummy implementation
-    .return ("stack traceback:\n\tdummy\n", "_._:0:")
+    .return ("_._:0:")
     # previous one that segfaults (see RT #60206)
     .local pmc obj
-    .local string traceback, where
     new obj, 'Lua'
-    traceback = obj.'traceback'(1)
-    where = obj.'where'()
+    $S0 = obj.'where'()
+    .return ($S0)
+.end
 
-    .return (traceback, where)
+.sub 'traceback' :anon
+    .param pmc bt
+    .local pmc iter, sub, outer, annos
+    new iter, 'Iterator', bt
+    .local string ret
+    ret = "stack traceback:"
+  L1:
+    unless iter goto L2
+    $P0 = shift iter
+    sub = $P0['sub']
+    if null sub goto L2
+    $S0 = sub.'get_name'()
+    outer = sub.'get_outer'()
+    ret .= "\n\t"
+    unless null outer goto L3
+    ret .= "[PIR]:"
+    goto L4
+  L3:
+    ret .= "_._:0:"
+  L4:
+    ret .= " in function '"
+    ret .= $S0
+    ret .= "'"
+    annos = $P0['annotations']
+    goto L1
+  L2:
+    .return (ret)
 .end
 
 

Modified: trunk/languages/lua/src/pmc/luafunction.pmc
==============================================================================
--- trunk/languages/lua/src/pmc/luafunction.pmc	(original)
+++ trunk/languages/lua/src/pmc/luafunction.pmc	Sat Jan 10 01:53:20 2009
@@ -148,6 +148,15 @@
 
 =over 4
 
+*/
+    METHOD STRING *get_name() {
+        const Parrot_sub * const sub = PMC_sub(SELF);
+        STRING *retval = string_copy(INTERP, sub->name);
+        RETURN(STRING *retval);
+    }
+
+/*
+
 =item C<PMC *getfenv()>
 
 =cut



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