develooper Front page | perl.cvs.parrot | Postings from November 2008

[svn:parrot] r32604 - in trunk/languages/lua: . src

From:
fperrad
Date:
November 13, 2008 03:10
Subject:
[svn:parrot] r32604 - in trunk/languages/lua: . src
Message ID:
20081113111047.39810CB9AF@x12.develooper.com
Author: fperrad
Date: Thu Nov 13 03:10:42 2008
New Revision: 32604

Modified:
   trunk/languages/lua/lua.pir
   trunk/languages/lua/src/PASTGrammar.tg
   trunk/languages/lua/src/POSTGrammar.tg
   trunk/languages/lua/src/dumplex.tg
   trunk/languages/lua/src/lua51.pir

Log:
[Lua] compiler
use .tailcall


Modified: trunk/languages/lua/lua.pir
==============================================================================
--- trunk/languages/lua/lua.pir	(original)
+++ trunk/languages/lua/lua.pir	Thu Nov 13 03:10:42 2008
@@ -153,9 +153,9 @@
     $S1 = substr $S0, 0, 1
     unless $S1 == '@' goto L2
     $S0 = substr $S0, 1
-    .return dofile($S0)
+    .tailcall dofile($S0)
   L2:
-    .return dostring($S0, '=LUA_INIT')
+    .tailcall dostring($S0, '=LUA_INIT')
 .end
 
 
@@ -301,9 +301,9 @@
     goto L3
   L4:
     ($P0 :slurpy) = docall($P0, vararg :flat)
-    .return report($P0 :flat)
+    .tailcall report($P0 :flat)
   L2:
-    .return report(1, $S0)
+    .tailcall report(1, $S0)
 .end
 
 
@@ -339,9 +339,9 @@
     ($P0, $S0) = lua_loadfile(name)
     if null $P0 goto L1
     ($P0 :slurpy) = docall($P0)
-    .return report($P0 :flat)
+    .tailcall report($P0 :flat)
   L1:
-    .return report(1, $S0)
+    .tailcall report(1, $S0)
 .end
 
 
@@ -351,9 +351,9 @@
     ($P0, $S0) = lua_loadbuffer(buf, name)
     if null $P0 goto L1
     ($P0 :slurpy) = docall($P0)
-    .return report($P0 :flat)
+    .tailcall report($P0 :flat)
   L1:
-    .return report(1, $S0)
+    .tailcall report(1, $S0)
 .end
 
 
@@ -366,7 +366,7 @@
     new $P1, 'LuaString'
     set $P1, name
     ($P0 :slurpy) = docall($P0, $P1)
-    .return report($P0 :flat)
+    .tailcall report($P0 :flat)
 .end
 
 

Modified: trunk/languages/lua/src/PASTGrammar.tg
==============================================================================
--- trunk/languages/lua/src/PASTGrammar.tg	(original)
+++ trunk/languages/lua/src/PASTGrammar.tg	Thu Nov 13 03:10:42 2008
@@ -34,7 +34,7 @@
     $P0 = get_hll_global ['PAST'], 'Var'
     arg = $P0.'new'('node'=>node, 'name'=>'vararg', 'scope'=>'parameter', 'slurpy'=>1)
     $P0 = get_hll_global ['PAST'], 'Block'
-    .return $P0.'new'(arg, past, 'node'=>node, 'name'=>'&main')
+    .tailcall $P0.'new'(arg, past, 'node'=>node, 'name'=>'&main')
   L1:
     $S1 = $I0
     $S0 = "symbol table (" . $S1
@@ -75,7 +75,7 @@
     $S0 = node.'find_key'()
     $P0 = node[$S0]
     $S0 = concat 'Lua::Grammar::', $S0
-    .return tree.'get'('past', $P0, $S0)
+    .tailcall tree.'get'('past', $P0, $S0)
 }
 
 
@@ -84,7 +84,7 @@
     symbtab = get_hll_global ['Lua';'PAST'], '$symbtab'
     symbtab.'push_scope'()
     $P0 = node['block']
-    .return tree.'get'('past', $P0, 'Lua::Grammar::block')
+    .tailcall tree.'get'('past', $P0, 'Lua::Grammar::block')
 }
 
 
@@ -136,7 +136,7 @@
     $P0 = node['block']
     blk = tree.'get'('past', $P0, 'Lua::Grammar::block')
     $P0 = get_hll_global ['PAST'], 'Op'
-    .return $P0.'new'(expr, blk, 'node'=>node, 'pasttype'=>'if')
+    .tailcall $P0.'new'(expr, blk, 'node'=>node, 'pasttype'=>'if')
 }
 
 
@@ -155,7 +155,7 @@
     blk = tree.'get'('past', $P0, 'Lua::Grammar::block')
     dec looplevel
     $P0 = get_hll_global ['PAST'], 'Op'
-    .return $P0.'new'(expr, blk, 'node'=>node, 'pasttype'=>'while')
+    .tailcall $P0.'new'(expr, blk, 'node'=>node, 'pasttype'=>'while')
 }
 
 
@@ -174,7 +174,7 @@
     expr = tree.'get'('past', $P0, 'Lua::Grammar::expression')
     dec looplevel
     $P0 = get_hll_global ['PAST'], 'Op'
-    .return $P0.'new'(blk, expr, 'node'=>node, 'pasttype'=>'repeat')
+    .tailcall $P0.'new'(blk, expr, 'node'=>node, 'pasttype'=>'repeat')
 }
 
 
@@ -226,7 +226,7 @@
     push explist, expr
   L3:
     $P0 = get_hll_global ['PAST'], 'Op'
-    .return $P0.'new'(name, explist, 'node'=>node, 'pasttype'=>'fornum')
+    .tailcall $P0.'new'(name, explist, 'node'=>node, 'pasttype'=>'fornum')
 }
 
 
@@ -254,7 +254,7 @@
     .local pmc explist
     explist = tree.'get'('explist', $P0, 'Lua::Grammar::expression_list')
     $P0 = get_hll_global ['PAST'], 'Op'
-    .return $P0.'new'(namelist, explist, 'node'=>node, 'pasttype'=>'forlist')
+    .tailcall $P0.'new'(namelist, explist, 'node'=>node, 'pasttype'=>'forlist')
 }
 
 
@@ -262,7 +262,7 @@
     $S0 = node.'find_key'()
     $P0 = node[$S0]
     $S0 = concat 'Lua::Grammar::', $S0
-    .return tree.'get'('past', $P0, $S0)
+    .tailcall tree.'get'('past', $P0, $S0)
 }
 
 
@@ -294,7 +294,7 @@
     goto L3
   L4:
     $P0 = get_hll_global ['PAST'], 'Op'
-    .return $P0.'new'(namelist, explist, 'node'=>node, 'pasttype'=>'assignlist')
+    .tailcall $P0.'new'(namelist, explist, 'node'=>node, 'pasttype'=>'assignlist')
 }
 
 
@@ -324,9 +324,9 @@
     .local pmc explist
     $P0 = shift $P0
     explist = tree.'get'('explist', $P0, 'Lua::Grammar::expression_list')
-    .return $P1.'new'(explist :flat, 'node'=>node, 'pasttype'=>'return')
+    .tailcall $P1.'new'(explist :flat, 'node'=>node, 'pasttype'=>'return')
   L1:
-    .return $P1.'new'('node'=>node, 'pasttype'=>'return')
+    .tailcall $P1.'new'('node'=>node, 'pasttype'=>'return')
 }
 
 
@@ -335,7 +335,7 @@
     looplevel = get_hll_global ['Lua';'PAST'], '$looplevel'
     if looplevel <= 0 goto L1
     $P0 = get_hll_global ['PAST'], 'Op'
-    .return $P0.'new'('node'=>node, 'pasttype'=>'break')
+    .tailcall $P0.'new'('node'=>node, 'pasttype'=>'break')
   L1:
     node.'syntaxerror'("no loop to break")
 }
@@ -345,7 +345,7 @@
     $P0 = node['assignment']
     unless null $P0 goto L1
     $P0 = node['primary_expression']
-    .return tree.'get'('past', $P0, 'Lua::Grammar::primary_expression')
+    .tailcall tree.'get'('past', $P0, 'Lua::Grammar::primary_expression')
   L1:
     .local pmc varlist, explist
     $P0 = shift $P0
@@ -357,7 +357,7 @@
     expr.'lvalue'(1)
     unshift varlist, expr
     $P0 = get_hll_global ['PAST'], 'Op'
-    .return $P0.'new'(varlist, explist, 'node'=>node, 'pasttype'=>'assignlist')
+    .tailcall $P0.'new'(varlist, explist, 'node'=>node, 'pasttype'=>'assignlist')
 }
 
 
@@ -382,10 +382,10 @@
 transform explist (Lua::Grammar::assignment) :language('PIR') {
     $P0 = node['expression_list']
     if null $P0 goto L1
-    .return tree.'get'('explist', $P0, 'Lua::Grammar::expression_list')
+    .tailcall tree.'get'('explist', $P0, 'Lua::Grammar::expression_list')
   L1:
     $P0 = node['assignment']
-    .return tree.'get'('explist', $P0, 'Lua::Grammar::assignment')
+    .tailcall tree.'get'('explist', $P0, 'Lua::Grammar::assignment')
 }
 
 
@@ -411,7 +411,7 @@
     .return (explist)
   L3:
     $P0 = shift $P0
-    .return tree.'get'('explist', $P0, 'Lua::Grammar::expression_list')
+    .tailcall tree.'get'('explist', $P0, 'Lua::Grammar::expression_list')
 }
 
 
@@ -434,7 +434,7 @@
     past = tree.'get'('past', $P0, 'Lua::Grammar::function_body')
     past.'name'($S0)
     $P0 = get_hll_global ['PAST'], 'Op'
-    .return $P0.'new'(var, past, 'node'=>node, 'pasttype'=>'assign')
+    .tailcall $P0.'new'(var, past, 'node'=>node, 'pasttype'=>'assign')
 }
 
 
@@ -550,7 +550,7 @@
     set_hll_global ['Lua';'PAST'], '$looplevel', looplevel
     set_hll_global ['Lua';'PAST'], '?vararg', has_vararg
     $P0 = get_hll_global ['PAST'], 'Block'
-    .return $P0.'new'(parlist :flat, past, 'node'=>node)
+    .tailcall $P0.'new'(parlist :flat, past, 'node'=>node)
 }
 
 
@@ -603,13 +603,13 @@
 transform key (Lua::Grammar::Name) :language('PIR') {
     $S0 = node.'result_object'()
     $P0 = get_hll_global ['PAST'], 'Val'
-    .return $P0.'new'('node'=>node, 'name'=>'key', 'value'=>$S0)
+    .tailcall $P0.'new'('node'=>node, 'name'=>'key', 'value'=>$S0)
 }
 
 
 transform key (Lua::Grammar::index) :language('PIR') {
     $P0 = node['expression']
-    .return tree.'get'('past', $P0, 'Lua::Grammar::expression')
+    .tailcall tree.'get'('past', $P0, 'Lua::Grammar::expression')
 }
 
 
@@ -632,7 +632,7 @@
 
 transform past (Lua::Grammar::expression) :language('PIR') {
     $P0 = node['expr']
-    .return tree.'get'('past', $P0, 'Lua::Grammar::expr')
+    .tailcall tree.'get'('past', $P0, 'Lua::Grammar::expr')
 }
 
 
@@ -643,7 +643,7 @@
     $S0 = node.'find_key'()
     $P0 = node[$S0]
     $S0 = concat 'Lua::Grammar::', $S0
-    .return tree.'get'('past', $P0, $S0)
+    .tailcall tree.'get'('past', $P0, $S0)
   L1:
     .local pmc optable, optok
     .local string pirop
@@ -677,7 +677,7 @@
     $S0 = node.'find_key'()
     $P0 = node[$S0]
     $S0 = concat 'Lua::Grammar::', $S0
-    .return tree.'get'('past', $P0, $S0)
+    .tailcall tree.'get'('past', $P0, $S0)
 }
 
 
@@ -734,7 +734,7 @@
     $S0 = node.'find_key'()
     $P0 = node[$S0]
     $S0 = concat 'Lua::Grammar::', $S0
-    .return tree.'get'('past', $P0, $S0)
+    .tailcall tree.'get'('past', $P0, $S0)
 }
 
 
@@ -743,7 +743,7 @@
     $P0 = node['expression']
     past = tree.'get'('past', $P0, 'Lua::Grammar::expression')
     $P0 = get_hll_global ['PAST'], 'Op'
-    .return $P0.'new'(past, 'node'=>node, 'pasttype'=>'parenthese')
+    .tailcall $P0.'new'(past, 'node'=>node, 'pasttype'=>'parenthese')
 }
 
 
@@ -754,9 +754,9 @@
     $S0 = node.'result_object'()
     ($I0, $S1) = symbtab.'lookup'($S0)
     unless $I0 goto L1
-    .return $P0.'new'('node'=>node, 'name'=>$S1, 'scope'=>'lexical')
+    .tailcall $P0.'new'('node'=>node, 'name'=>$S1, 'scope'=>'lexical')
   L1:
-    .return $P0.'new'('node'=>node, 'name'=>$S0, 'scope'=>'package')
+    .tailcall $P0.'new'('node'=>node, 'name'=>$S0, 'scope'=>'package')
 }
 
 
@@ -765,7 +765,7 @@
     has_vararg = get_hll_global ['Lua';'PAST'], '?vararg'
     unless has_vararg goto L1
     $P0 = get_hll_global ['PAST'], 'Op'
-    .return $P0.'new'('node'=>node, 'pasttype'=>'vararg')
+    .tailcall $P0.'new'('node'=>node, 'pasttype'=>'vararg')
   L1:
     node.'syntaxerror'("cannot use '...' outside a vararg function")
 }
@@ -773,26 +773,26 @@
 
 transform past (Lua::Grammar::nil) :language('PIR') {
     $P0 = get_hll_global ['PAST'], 'Val'
-    .return $P0.'new'('node'=>node, 'name'=>'LuaNil')
+    .tailcall $P0.'new'('node'=>node, 'name'=>'LuaNil')
 }
 
 
 transform past (Lua::Grammar::true) :language('PIR') {
     $P0 = get_hll_global ['PAST'], 'Val'
-    .return $P0.'new'('node'=>node, 'name'=>'LuaBoolean', 'value'=>1)
+    .tailcall $P0.'new'('node'=>node, 'name'=>'LuaBoolean', 'value'=>1)
 }
 
 
 transform past (Lua::Grammar::false) :language('PIR') {
     $P0 = get_hll_global ['PAST'], 'Val'
-    .return $P0.'new'('node'=>node, 'name'=>'LuaBoolean', 'value'=>0)
+    .tailcall $P0.'new'('node'=>node, 'name'=>'LuaBoolean', 'value'=>0)
 }
 
 
 transform past (Lua::Grammar::number) :language('PIR') {
     $S0 = node.'result_object'()
     $P0 = get_hll_global ['PAST'], 'Val'
-    .return $P0.'new'('node'=>node, 'name'=>'LuaNumber', 'value'=>$S0)
+    .tailcall $P0.'new'('node'=>node, 'name'=>'LuaNumber', 'value'=>$S0)
 }
 
 
@@ -801,7 +801,7 @@
     $P0 = node[$S0]
     $S0 = $P0.'result_object'()
     $P0 = get_hll_global ['PAST'], 'Val'
-    .return $P0.'new'('node'=>node, 'name'=>'LuaString', 'value'=>$S0)
+    .tailcall $P0.'new'('node'=>node, 'name'=>'LuaString', 'value'=>$S0)
 }
 
 =head1 AUTHORS

Modified: trunk/languages/lua/src/POSTGrammar.tg
==============================================================================
--- trunk/languages/lua/src/POSTGrammar.tg	(original)
+++ trunk/languages/lua/src/POSTGrammar.tg	Thu Nov 13 03:10:42 2008
@@ -109,7 +109,7 @@
     post.'outer'(start)
     start.'push'(post)
     $P0 = get_hll_global ['Lua'; 'POST'], 'Chunk'
-    .return $P0.'new'(start, 'node'=>node, 'prologue'=><<'PIRCODE')
+    .tailcall $P0.'new'(start, 'node'=>node, 'prologue'=><<'PIRCODE')
 .include "interpinfo.pasm"
 .HLL "Lua", "lua_group"
 PIRCODE
@@ -136,13 +136,13 @@
 
 
 transform void (PAST::Stmts) :language('PIR') {
-    .return tree.'get'('post', node)
+    .tailcall tree.'get'('post', node)
 }
 
 
 transform void (PAST::Op) :language('PIR') {
     $S0 = node.'pasttype'()
-    .return tree.'get'($S0, node)
+    .tailcall tree.'get'($S0, node)
 }
 
 
@@ -150,9 +150,9 @@
     $S0 = node.'pirop'()
     $I0 = index $S0, 'is'
     unless $I0 >= 0 goto L1
-    .return tree.'get'('cmp', node)
+    .tailcall tree.'get'('cmp', node)
   L1:
-    .return tree.'get'('post', node)
+    .tailcall tree.'get'('post', node)
 }
 
 
@@ -170,7 +170,7 @@
     post.'result'(result)
     .return (post)
   L1:
-    .return tree.'get'($S0, node)
+    .tailcall tree.'get'($S0, node)
 }
 
 
@@ -325,7 +325,7 @@
 
 
 transform or (PAST::Op) :language('PIR') {
-    .return tree.'get'('and', node)
+    .tailcall tree.'get'('and', node)
 }
 
 
@@ -671,7 +671,7 @@
     endlabels = get_hll_global ['Lua';'POST'], '@endlabels'
     $S0 = endlabels[0]
     $P0 = get_hll_global ['POST'], 'Op'
-    .return $P0.'new'($S0, 'node'=>node, 'pirop'=>'goto')
+    .tailcall $P0.'new'($S0, 'node'=>node, 'pirop'=>'goto')
 }
 
 
@@ -779,7 +779,7 @@
 
 
 transform cond (PAST::Val) :language('PIR') {
-    .return tree.'get'('post', node)
+    .tailcall tree.'get'('post', node)
 }
 
 
@@ -806,7 +806,7 @@
     ops.'result'(result)
     .return (ops)
   L1:
-    .return tree.'get'(type, node)
+    .tailcall tree.'get'(type, node)
 }
 
 
@@ -898,13 +898,13 @@
 
 
 transform cond (PAST::Var) :language('PIR') {
-    .return tree.'get'('post', node)
+    .tailcall tree.'get'('post', node)
 }
 
 
 transform post (PAST::Var) :language('PIR') {
     $S0 = node.'scope'()
-    .return tree.'get'($S0, node)
+    .tailcall tree.'get'($S0, node)
 }
 
 
@@ -1056,7 +1056,7 @@
 
 
 transform keyed (PAST::Var) :language('PIR') {
-    .return tree.'get'('package', node)
+    .tailcall tree.'get'('package', node)
 }
 
 

Modified: trunk/languages/lua/src/dumplex.tg
==============================================================================
--- trunk/languages/lua/src/dumplex.tg	(original)
+++ trunk/languages/lua/src/dumplex.tg	Thu Nov 13 03:10:42 2008
@@ -40,7 +40,7 @@
     goto L2
   L1:
     $P0 = get_hll_global ['PAST'], 'Block'
-    .return $P0.'new'(past, 'node'=>node, 'name'=>'anon')
+    .tailcall $P0.'new'(past, 'node'=>node, 'name'=>'anon')
 }
 
 
@@ -55,7 +55,7 @@
     $S1 = concat 'Lua::TestLex::', $S0
     past = tree.'get'('past', $P0, $S1)
     $P0 = get_hll_global ['PAST'], 'Op'
-    .return $P0.'new'(past, 'node'=>node, 'name'=>'println', 'pasttype'=>'call')
+    .tailcall $P0.'new'(past, 'node'=>node, 'name'=>'println', 'pasttype'=>'call')
 }
 
 
@@ -67,7 +67,7 @@
     $S0 = node.'result_object'()
     $S1 = concat "keyword:\t", $S0
     $P0 = get_hll_global ['PAST'], 'Val'
-    .return $P0.'new'('node'=>node, 'value'=>$S1)
+    .tailcall $P0.'new'('node'=>node, 'value'=>$S1)
 }
 
 
@@ -79,7 +79,7 @@
     $S0 = node.'result_object'()
     $S1 = concat "punct:\t", $S0
     $P0 = get_hll_global ['PAST'], 'Val'
-    .return $P0.'new'('node'=>node, 'value'=>$S1)
+    .tailcall $P0.'new'('node'=>node, 'value'=>$S1)
 }
 
 
@@ -91,7 +91,7 @@
     $S0 = node.'result_object'()
     $S1 = concat "Name:\t", $S0
     $P0 = get_hll_global ['PAST'], 'Val'
-    .return $P0.'new'('node'=>node, 'value'=>$S1)
+    .tailcall $P0.'new'('node'=>node, 'value'=>$S1)
 }
 
 
@@ -117,7 +117,7 @@
     internal_error('unknown string')
   L9:
     $P0 = get_hll_global ['PAST'], 'Val'
-    .return $P0.'new'('node'=>node, 'value'=>$S1)
+    .tailcall $P0.'new'('node'=>node, 'value'=>$S1)
 }
 
 
@@ -129,7 +129,7 @@
     $S0 = node.'result_object'()
     $S1 = concat "Number:\t", $S0
     $P0 = get_hll_global ['PAST'], 'Val'
-    .return $P0.'new'('node'=>node, 'value'=>$S1)
+    .tailcall $P0.'new'('node'=>node, 'value'=>$S1)
 }
 
 =back

Modified: trunk/languages/lua/src/lua51.pir
==============================================================================
--- trunk/languages/lua/src/lua51.pir	(original)
+++ trunk/languages/lua/src/lua51.pir	Thu Nov 13 03:10:42 2008
@@ -60,7 +60,7 @@
 .sub 'ostgrammar' :method
     .param string value        :optional
     .param int has_value       :opt_flag
-    .return self.'attr'('$ostgrammar', value, has_value)
+    .tailcall self.'attr'('$ostgrammar', value, has_value)
 .end
 
 
@@ -85,11 +85,11 @@
     ostgrammar_namekeys = split '::', ostgrammar_name
     ostgrammar = new ostgrammar_namekeys
     ostbuilder = ostgrammar.'apply'(source)
-    .return ostbuilder.'get'('post')
+    .tailcall ostbuilder.'get'('post')
 
   default_ostgrammar:
     $P0 = compreg 'PAST'
-    .return $P0.'compile'(source, adverbs :flat :named)
+    .tailcall $P0.'compile'(source, adverbs :flat :named)
 .end
 
 
@@ -160,25 +160,25 @@
 .sub 'ops_const' :method
     .param pmc value           :optional
     .param int has_value       :opt_flag
-    .return self.'attr'('ops_const', value, has_value)
+    .tailcall self.'attr'('ops_const', value, has_value)
 .end
 
 .sub 'ops_subr' :method
     .param pmc value           :optional
     .param int has_value       :opt_flag
-    .return self.'attr'('ops_subr', value, has_value)
+    .tailcall self.'attr'('ops_subr', value, has_value)
 .end
 
 .sub 'storage_const' :method
     .param pmc value           :optional
     .param int has_value       :opt_flag
-    .return self.'attr'('storage_const', value, has_value)
+    .tailcall self.'attr'('storage_const', value, has_value)
 .end
 
 .sub 'storage_lex' :method
     .param pmc value           :optional
     .param int has_value       :opt_flag
-    .return self.'attr'('storage_lex', value, has_value)
+    .tailcall self.'attr'('storage_lex', value, has_value)
 .end
 
 
@@ -192,7 +192,7 @@
 .sub 'prologue' :method
     .param pmc value           :optional
     .param int has_value       :opt_flag
-    .return self.'attr'('prologue', value, has_value)
+    .tailcall self.'attr'('prologue', value, has_value)
 .end
 
 



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