Author: fperrad
Date: Wed Jun 6 11:18:24 2007
New Revision: 18842
Modified:
trunk/languages/lua/src/PASTGrammar.tg
trunk/languages/lua/src/POSTGrammar.tg
Log:
[Lua]
- fix Lua function name
- function: now use the newclosure op
Modified: trunk/languages/lua/src/PASTGrammar.tg
==============================================================================
--- trunk/languages/lua/src/PASTGrammar.tg (original)
+++ trunk/languages/lua/src/PASTGrammar.tg Wed Jun 6 11:18:24 2007
@@ -363,6 +363,7 @@
past.'init'('node'=>$P0, 'name'=>'self', 'scope'=>'parameter')
set_hll_global ['Lua::PAST'], '$?self', past
L1:
+ $S0 = tree.'get'('name', $P0, 'Lua::Grammar::functionname')
$P0 = node['function_body']
past = tree.'get'('past', $P0, 'Lua::Grammar::function_body')
past.'name'($S0)
@@ -370,6 +371,26 @@
}
+transform name (Lua::Grammar::functionname) :language('PIR') {
+ .local string name
+ name = ''
+ $P0 = node['name']
+ .local pmc iter
+ iter = new .Iterator, $P0
+ L2:
+ unless iter goto L1
+ if name == '' goto L3
+ name = concat '.'
+ L3:
+ $P0 = shift iter
+ $S0 = $P0.'result_object'()
+ name = concat $S0
+ goto L2
+ L1:
+ .return (name)
+}
+
+
transform past (Lua::Grammar::functionname) :language('PIR') {
.local pmc past, iter, key
$P0 = node['name']
Modified: trunk/languages/lua/src/POSTGrammar.tg
==============================================================================
--- trunk/languages/lua/src/POSTGrammar.tg (original)
+++ trunk/languages/lua/src/POSTGrammar.tg Wed Jun 6 11:18:24 2007
@@ -66,11 +66,13 @@
$S0 = node.'unique'('fct_')
$S1 = node.'escape'(name)
ops.'push_pirop'('inline', ' .const .Sub %0 = %1', $S0, $S1)
- $P0 = ops.'push_pirop'('get_global')
- $P0.'arglist'($P0, '"_G"')
- #ops.'push_pirop'('callmethod', 'setfenv', $S0, $P0, 'result'=>'')
- ops.'push_pirop'('callmethod', 'setfenv', $S0, $P0)
- ops.'result'($S0)
+ $P0 = ops.'push_pirop'('newclosure')
+ $P0.'arglist'($P0, $S0)
+ $P1 = ops.'push_pirop'('get_global')
+ $P1.'arglist'($P1, '"_G"')
+ #ops.'push_pirop'('callmethod', 'setfenv', $P0, $P1, 'result'=>'')
+ ops.'push_pirop'('callmethod', 'setfenv', $P0, $P1)
+ ops.'result'($P0)
.return (ops)
}