mirror of
https://github.com/lua/lua.git
synced 2024-12-13 12:03:25 +08:00
CREATEARRAY now has an argument, the size of the array to create.
This commit is contained in:
parent
41e4c5798e
commit
f53460aab9
16
lua.stx
16
lua.stx
@ -1,6 +1,6 @@
|
||||
%{
|
||||
|
||||
char *rcs_luastx = "$Id: lua.stx,v 2.10 1994/10/17 19:05:32 celes Exp roberto $";
|
||||
char *rcs_luastx = "$Id: lua.stx,v 2.11 1994/10/21 19:00:12 roberto Exp roberto $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -528,10 +528,8 @@ expr : '(' expr ')' { $$ = $2; }
|
||||
|
||||
table :
|
||||
{
|
||||
code_byte(PUSHWORD);
|
||||
$<vLong>$ = pc; code_word(0);
|
||||
incr_ntemp();
|
||||
code_byte(CREATEARRAY);
|
||||
$<vLong>$ = pc; code_word(0);
|
||||
}
|
||||
'{' fieldlist '}'
|
||||
{
|
||||
@ -918,7 +916,15 @@ static void PrintCode (Byte *code, Byte *end)
|
||||
printf ("%d ADJUST %d\n", p-code, *(++p));
|
||||
p++;
|
||||
break;
|
||||
case CREATEARRAY: printf ("%d CREATEARRAY\n", (p++)-code); break;
|
||||
case CREATEARRAY:
|
||||
{
|
||||
CodeWord c;
|
||||
int n = p-code;
|
||||
p++;
|
||||
get_word(c,p);
|
||||
printf ("%d CREATEARRAY\n", n, c.w);
|
||||
break;
|
||||
}
|
||||
case EQOP: printf ("%d EQOP\n", (p++)-code); break;
|
||||
case LTOP: printf ("%d LTOP\n", (p++)-code); break;
|
||||
case LEOP: printf ("%d LEOP\n", (p++)-code); break;
|
||||
|
16
opcode.c
16
opcode.c
@ -3,7 +3,7 @@
|
||||
** TecCGraf - PUC-Rio
|
||||
*/
|
||||
|
||||
char *rcs_opcode="$Id: opcode.c,v 2.10 1994/10/17 19:00:40 celes Exp roberto $";
|
||||
char *rcs_opcode="$Id: opcode.c,v 2.11 1994/11/01 17:54:31 roberto Exp roberto $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -346,17 +346,15 @@ int lua_execute (Byte *pc)
|
||||
break;
|
||||
|
||||
case CREATEARRAY:
|
||||
if (tag(top-1) == T_NIL)
|
||||
nvalue(top-1) = 1;
|
||||
else
|
||||
{
|
||||
if (tonumber(top-1)) return 1;
|
||||
if (nvalue(top-1) <= 0) nvalue(top-1) = 1;
|
||||
}
|
||||
avalue(top-1) = lua_createarray(nvalue(top-1));
|
||||
{
|
||||
CodeWord size;
|
||||
get_word(size,pc);
|
||||
top++;
|
||||
avalue(top-1) = lua_createarray(size.w);
|
||||
if (avalue(top-1) == NULL)
|
||||
return 1;
|
||||
tag(top-1) = T_ARRAY;
|
||||
}
|
||||
break;
|
||||
|
||||
case EQOP:
|
||||
|
Loading…
Reference in New Issue
Block a user