aboutsummaryrefslogtreecommitdiff
path: root/lua.stx
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-12-15 14:17:20 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-12-15 14:17:20 -0200
commit45e533599f08d849951b49bcab0be4fd735a966d (patch)
treeb8e3b175989f694391dd3da4191894f5df1e7d75 /lua.stx
parent94144a7821c0fa412d5d228ab5197a8ebaaa3c25 (diff)
downloadlua-45e533599f08d849951b49bcab0be4fd735a966d.tar.gz
lua-45e533599f08d849951b49bcab0be4fd735a966d.tar.bz2
lua-45e533599f08d849951b49bcab0be4fd735a966d.zip
optimization: closures without upvalues don't need to be closures
Diffstat (limited to 'lua.stx')
-rw-r--r--lua.stx14
1 files changed, 9 insertions, 5 deletions
diff --git a/lua.stx b/lua.stx
index eb7748d2..8bf40d6c 100644
--- a/lua.stx
+++ b/lua.stx
@@ -1,6 +1,6 @@
1%{ 1%{
2/* 2/*
3** $Id: lua.stx,v 1.21 1997/12/09 13:35:19 roberto Exp roberto $ 3** $Id: lua.stx,v 1.22 1997/12/09 16:01:08 roberto Exp roberto $
4** Syntax analizer and code generator 4** Syntax analizer and code generator
5** See Copyright Notice in lua.h 5** See Copyright Notice in lua.h
6*/ 6*/
@@ -555,10 +555,14 @@ static void func_onstack (TProtoFunc *f)
555 int c = next_constant(L->currState); 555 int c = next_constant(L->currState);
556 ttype(&L->currState->f->consts[c]) = LUA_T_PROTO; 556 ttype(&L->currState->f->consts[c]) = LUA_T_PROTO;
557 L->currState->f->consts[c].value.tf = (L->currState+1)->f; 557 L->currState->f->consts[c].value.tf = (L->currState+1)->f;
558 for (i=0; i<nupvalues; i++) 558 if (nupvalues == 0)
559 lua_pushvar((L->currState+1)->upvalues[i]); 559 code_constant(c);
560 code_constant(c); 560 else {
561 code_oparg(CLOSURE, 2, nupvalues, -nupvalues); 561 for (i=0; i<nupvalues; i++)
562 lua_pushvar((L->currState+1)->upvalues[i]);
563 code_constant(c);
564 code_oparg(CLOSURE, 2, nupvalues, -nupvalues);
565 }
562} 566}
563 567
564 568