#if defined (__cplusplus) || defined (c_plusplus) #include #ifdef __EXTERN_C__ EXTERN_FUNCTION ( extern int yylex, ()); #else extern int yylex(); #endif extern void yyerror(char *); extern int yyparse(); #endif #include # line 2 "lua.stx" char *rcs_luastx = "$Id: lua.stx,v 3.17 1995/01/13 22:11:12 roberto Exp $"; #include #include #include #include "mem.h" #include "opcode.h" #include "hash.h" #include "inout.h" #include "tree.h" #include "table.h" #include "lua.h" /* to avoid warnings generated by yacc */ int yyparse (void); #define malloc luaI_malloc #define realloc luaI_realloc #define free luaI_free #ifndef LISTING #define LISTING 0 #endif #ifndef CODE_BLOCK #define CODE_BLOCK 256 #endif static int maxcode; static int maxmain; static Long maxcurr; /* to allow maxcurr *= 2 without overflow */ static Byte *funcCode = NULL; static Byte **initcode; static Byte *basepc; static int maincode; static int pc; #define MAXVAR 32 static Long varbuffer[MAXVAR]; /* variables in an assignment list; it's long to store negative Word values */ static int nvarbuffer=0; /* number of variables at a list */ static Word localvar[STACKGAP]; /* store local variable names */ static int nlocalvar=0; /* number of local variables */ #define MAXFIELDS FIELDS_PER_FLUSH*2 static Word fields[MAXFIELDS]; /* fieldnames to be flushed */ static int nfields=0; /* Internal functions */ static void code_byte (Byte c) { if (pc>maxcurr-2) /* 1 byte free to code HALT of main code */ { if (maxcurr >= MAX_INT) lua_error("code size overflow"); maxcurr *= 2; if (maxcurr >= MAX_INT) maxcurr = MAX_INT; basepc = growvector(basepc, maxcurr, Byte); } basepc[pc++] = c; } static void code_word (Word n) { CodeWord code; code.w = n; code_byte(code.m.c1); code_byte(code.m.c2); } static void code_float (float n) { CodeFloat code; code.f = n; code_byte(code.m.c1); code_byte(code.m.c2); code_byte(code.m.c3); code_byte(code.m.c4); } static void code_code (Byte *b) { CodeCode code; code.b = b; code_byte(code.m.c1); code_byte(code.m.c2); code_byte(code.m.c3); code_byte(code.m.c4); } static void code_word_at (Byte *p, Word n) { CodeWord code; code.w = n; *p++ = code.m.c1; *p++ = code.m.c2; } static void push_field (Word name) { if (nfields < STACKGAP-1) fields[nfields++] = name; else lua_error ("too many fields in a constructor"); } static void flush_record (int n) { int i; if (n == 0) return; code_byte(STORERECORD); code_byte(n); for (i=0; i= 0; i--) if (n == localvar[i]) return i; /* local var */ return -1; /* global var */ } /* ** Push a variable given a number. If number is positive, push global variable ** indexed by (number -1). If negative, push local indexed by ABS(number)-1. ** Otherwise, if zero, push indexed variable (record). */ static void lua_pushvar (Long number) { if (number > 0) /* global var */ { code_byte(PUSHGLOBAL); code_word(number-1); } else if (number < 0) /* local var */ { number = (-number) - 1; if (number < 10) code_byte(PUSHLOCAL0 + number); else { code_byte(PUSHLOCAL); code_byte(number); } } else { code_byte(PUSHINDEXED); } } static void lua_codeadjust (int n) { if (n+nlocalvar == 0) code_byte(ADJUST0); else { code_byte(ADJUST); code_byte(n+nlocalvar); } } static void init_function (TreeNode *func) { if (funcCode == NULL) /* first function */ { funcCode = newvector(CODE_BLOCK, Byte); maxcode = CODE_BLOCK; } pc=0; basepc=funcCode; maxcurr=maxcode; nlocalvar=0; if (lua_debug) { code_byte(SETFUNCTION); code_code((Byte *)luaI_strdup(lua_file[lua_nfile-1])); code_word(luaI_findconstant(func)); } } static void codereturn (void) { if (lua_debug) code_byte(RESET); if (nlocalvar == 0) code_byte(RETCODE0); else { code_byte(RETCODE); code_byte(nlocalvar); } } static void codedebugline (void) { if (lua_debug) { code_byte(SETLINE); code_word(lua_linenumber); } } static void adjust_mult_assign (int vars, int exps, int temps) { if (exps < 0) { int r = vars - (-exps-1); if (r >= 0) code_byte(r); else { code_byte(0); lua_codeadjust(temps); } } else if (vars != exps) lua_codeadjust(temps); } static void lua_codestore (int i) { if (varbuffer[i] > 0) /* global var */ { code_byte(STOREGLOBAL); code_word(varbuffer[i]-1); } else if (varbuffer[i] < 0) /* local var */ { int number = (-varbuffer[i]) - 1; if (number < 10) code_byte(STORELOCAL0 + number); else { code_byte(STORELOCAL); code_byte(number); } } else /* indexed var */ { int j; int upper=0; /* number of indexed variables upper */ int param; /* number of itens until indexed expression */ for (j=i+1; j ", 62, "<", 60, "LE", 279, "GE", 280, "CONC", 281, "+", 43, "-", 45, "*", 42, "/", 47, "UNARY", 282, "NOT", 283, "^", 94, "-unknown-", -1 /* ends search */ }; char * yyreds[] = { "-no such reduction-", "functionlist : /* empty */", "functionlist : functionlist", "functionlist : functionlist stat sc", "functionlist : functionlist function", "functionlist : functionlist method", "functionlist : functionlist setdebug", "function : FUNCTION NAME", "function : FUNCTION NAME body", "method : FUNCTION NAME ':' NAME", "method : FUNCTION NAME ':' NAME body", "body : '(' parlist ')' block END", "statlist : /* empty */", "statlist : statlist stat sc", "sc : /* empty */", "sc : ';'", "stat : /* empty */", "stat : stat1", "cond : /* empty */", "cond : expr1", "stat1 : IF expr1 THEN PrepJump block PrepJump elsepart END", "stat1 : WHILE", "stat1 : WHILE expr1 DO PrepJump block PrepJump END", "stat1 : REPEAT", "stat1 : REPEAT block UNTIL cond PrepJump", "stat1 : varlist1 '=' exprlist1", "stat1 : functioncall", "stat1 : LOCAL localdeclist decinit", "elsepart : /* empty */", "elsepart : ELSE block", "elsepart : ELSEIF cond THEN PrepJump block PrepJump elsepart", "block : /* empty */", "block : statlist ret", "ret : /* empty */", "ret : RETURN", "ret : RETURN exprlist sc", "PrepJump : /* empty */", "expr1 : expr", "expr : '(' expr ')'", "expr : expr1 EQ expr1", "expr : expr1 '<' expr1", "expr : expr1 '>' expr1", "expr : expr1 NE expr1", "expr : expr1 LE expr1", "expr : expr1 GE expr1", "expr : expr1 '+' expr1", "expr : expr1 '-' expr1", "expr : expr1 '*' expr1", "expr : expr1 '/' expr1", "expr : expr1 '^' expr1", "expr : expr1 CONC expr1", "expr : '-' expr1", "expr : table", "expr : varexp", "expr : NUMBER", "expr : STRING", "expr : NIL", "expr : functioncall", "expr : NOT expr1", "expr : expr1 AND PrepJump", "expr : expr1 AND PrepJump expr1", "expr : expr1 OR PrepJump", "expr : expr1 OR PrepJump expr1", "table : /* empty */", "table : '{' fieldlist '}'", "functioncall : funcvalue funcParams", "funcvalue : varexp", "funcvalue : varexp ':' NAME", "funcParams : '(' exprlist ')'", "funcParams : table", "exprlist : /* empty */", "exprlist : exprlist1", "exprlist1 : expr", "exprlist1 : exprlist1 ','", "exprlist1 : exprlist1 ',' expr", "parlist : /* empty */", "parlist : parlist1", "parlist1 : NAME", "parlist1 : parlist1 ',' NAME", "fieldlist : /* empty */", "fieldlist : lfieldlist1 lastcomma", "fieldlist : ffieldlist1 lastcomma", "fieldlist : lfieldlist1 ';'", "fieldlist : lfieldlist1 ';' ffieldlist1 lastcomma", "lastcomma : /* empty */", "lastcomma : ','", "ffieldlist1 : ffield", "ffieldlist1 : ffieldlist1 ',' ffield", "ffield : NAME '=' expr1", "lfieldlist1 : expr1", "lfieldlist1 : lfieldlist1 ',' expr1", "varlist1 : var", "varlist1 : varlist1 ',' var", "var : singlevar", "var : varexp '[' expr1 ']'", "var : varexp '.' NAME", "singlevar : NAME", "varexp : var", "localdeclist : NAME", "localdeclist : localdeclist ',' NAME", "decinit : /* empty */", "decinit : '=' exprlist1", "setdebug : DEBUG", }; #endif /* YYDEBUG */ #line 1 "/usr/lang/SC1.0/yaccpar" /* @(#)yaccpar 1.10 89/04/04 SMI; from S5R3 1.10 */ /* ** Skeleton parser driver for yacc output */ /* @(#)RELEASE SC1.0 C++ 2.1 1Mar1991 */ /* ** yacc user known macros and defines */ #define YYERROR goto yyerrlab #define YYACCEPT return(0) #define YYABORT return(1) #define YYBACKUP( newtoken, newvalue )\ {\ if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\ {\ yyerror( "syntax error - cannot backup" );\ goto yyerrlab;\ }\ yychar = newtoken;\ yystate = *yyps;\ yylval = newvalue;\ goto yynewstate;\ } #define YYRECOVERING() (!!yyerrflag) #define YYCOPY(to, from, type) \ (type *) memcpy(to, (char *) from, yynewmax * sizeof(type)) #ifndef YYDEBUG # define YYDEBUG 1 /* make debugging available */ #endif /* ** extern declarations for C++ - check your own code for correctness ** if you have function redefined error messages here. */ #ifdef __cplusplus EXTERN_FUNCTION ( extern int printf, (const char*, DOTDOTDOT) ); EXTERN_FUNCTION ( extern void *memcpy, (void *, const void *, int) ); #endif /* ** user known globals */ int yydebug; /* set to 1 to get debugging */ /* ** driver internal defines */ #define YYFLAG (-1000) /* ** static variables used by the parser */ static YYSTYPE yy_yyv[YYMAXDEPTH], *yyv = yy_yyv; /* value stack */ static int yy_yys[YYMAXDEPTH], *yys = yy_yys; /* state stack */ static YYSTYPE *yypv; /* top of value stack */ static int *yyps; /* top of state stack */ static int yystate; /* current state */ static int yytmp; /* extra var (lasts between blocks) */ #if defined(__cplusplus) || defined(__STDC__) || defined(lint) static int __yaccpar_lint_hack__ = 0; /* if you change the value from 0 to something else, make sure you know what to do with yyerrlab reference. This is a hack - to make sure C++ and lint are happy with the 4.1 yacc code. */ #endif int yynerrs; /* number of errors */ int yyerrflag; /* error recovery flag */ int yychar; /* current input token number */ static unsigned yymaxdepth = YYMAXDEPTH; /* ** yyparse - return 0 if worked, 1 if syntax error not recovered from */ int yyparse() { register YYSTYPE *yypvt = (YYSTYPE*)0 ; /* top of value stack for $vars */ /* ** Initialize externals - yyparse may be called more than once */ yypv = &yyv[-1]; yyps = &yys[-1]; yystate = 0; yytmp = 0; yynerrs = 0; yyerrflag = 0; yychar = -1; #if defined(__cplusplus) || defined(__STDC__) || defined(lint) /* Note that the following can never be executed but simply to please lint and C++ */ switch (__yaccpar_lint_hack__) { case 1: goto yyerrlab; case 2: goto yynewstate; } #endif { register YYSTYPE *yy_pv; /* top of value stack */ register int *yy_ps; /* top of state stack */ register int yy_state; /* current state */ register int yy_n; /* internal state number info */ goto yystack; /* ** get globals into registers. ** branch to here only if YYBACKUP was called. */ yynewstate: yy_pv = yypv; yy_ps = yyps; yy_state = yystate; goto yy_newstate; /* ** get globals into registers. ** either we just started, or we just finished a reduction */ yystack: yy_pv = yypv; yy_ps = yyps; yy_state = yystate; /* ** top of for (;;) loop while no reductions done */ yy_stack: /* ** put a state and value onto the stacks */ #if YYDEBUG /* ** if debugging, look up token value in list of value vs. ** name pairs. 0 and negative (-1) are special values. ** Note: linear search is used since time is not a real ** consideration while debugging. */ if ( yydebug ) { register int yy_i; (void)printf( "State %d, token ", yy_state ); if ( yychar == 0 ) (void)printf( "end-of-file\n" ); else if ( yychar < 0 ) (void)printf( "-none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) break; } (void)printf( "%s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( ++yy_ps >= &yys[ yymaxdepth ] ) /* room on stack? */ { /* ** reallocate and recover. Note that pointers ** have to be reset, or bad things will happen */ int yyps_index = (yy_ps - yys); int yypv_index = (yy_pv - yyv); int yypvt_index = (yypvt - yyv); int yynewmax; yynewmax = yymaxdepth + YYMAXDEPTH; if (yymaxdepth == YYMAXDEPTH) /* first time growth */ { YYSTYPE *newyyv = (YYSTYPE*)malloc(yynewmax*sizeof(YYSTYPE)); int *newyys = (int*)malloc(yynewmax*sizeof(int)); if (newyys != 0 && newyyv != 0) { yys = YYCOPY(newyys, yys, int); yyv = YYCOPY(newyyv, yyv, YYSTYPE); } else yynewmax = 0; /* failed */ } else /* not first time */ { yyv = (YYSTYPE*)realloc((char*)yyv, yynewmax * sizeof(YYSTYPE)); yys = (int*)realloc((char*)yys, yynewmax * sizeof(int)); if (yys == 0 || yyv == 0) yynewmax = 0; /* failed */ } if (yynewmax <= yymaxdepth) /* tables not expanded */ { yyerror( "yacc stack overflow" ); YYABORT; } yymaxdepth = yynewmax; yy_ps = yys + yyps_index; yy_pv = yyv + yypv_index; yypvt = yyv + yypvt_index; } *yy_ps = yy_state; *++yy_pv = yyval; /* ** we have a new state - find out what to do */ yy_newstate: if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG ) goto yydefault; /* simple state */ #if YYDEBUG /* ** if debugging, need to mark whether new token grabbed */ yytmp = yychar < 0; #endif if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) ) yychar = 0; /* reached EOF */ #if YYDEBUG if ( yydebug && yytmp ) { register int yy_i; (void)printf( "Received token " ); if ( yychar == 0 ) (void)printf( "end-of-file\n" ); else if ( yychar < 0 ) (void)printf( "-none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) break; } (void)printf( "%s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) ) goto yydefault; if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar ) /*valid shift*/ { yychar = -1; yyval = yylval; yy_state = yy_n; if ( yyerrflag > 0 ) yyerrflag--; goto yy_stack; } yydefault: if ( ( yy_n = yydef[ yy_state ] ) == -2 ) { #if YYDEBUG yytmp = yychar < 0; #endif if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) ) yychar = 0; /* reached EOF */ #if YYDEBUG if ( yydebug && yytmp ) { register int yy_i; (void)printf( "Received token " ); if ( yychar == 0 ) (void)printf( "end-of-file\n" ); else if ( yychar < 0 ) (void)printf( "-none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) { break; } } (void)printf( "%s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ /* ** look through exception table */ { register int *yyxi = yyexca; while ( ( *yyxi != -1 ) || ( yyxi[1] != yy_state ) ) { yyxi += 2; } while ( ( *(yyxi += 2) >= 0 ) && ( *yyxi != yychar ) ) ; if ( ( yy_n = yyxi[1] ) < 0 ) YYACCEPT; } } /* ** check for syntax error */ if ( yy_n == 0 ) /* have an error */ { /* no worry about speed here! */ switch ( yyerrflag ) { case 0: /* new error */ yyerror( "syntax error" ); goto skip_init; yyerrlab: /* ** get globals into registers. ** we have a user generated syntax type error */ yy_pv = yypv; yy_ps = yyps; yy_state = yystate; yynerrs++; skip_init: case 1: case 2: /* incompletely recovered error */ /* try again... */ yyerrflag = 3; /* ** find state where "error" is a legal ** shift action */ while ( yy_ps >= yys ) { yy_n = yypact[ *yy_ps ] + YYERRCODE; if ( yy_n >= 0 && yy_n < YYLAST && yychk[yyact[yy_n]] == YYERRCODE) { /* ** simulate shift of "error" */ yy_state = yyact[ yy_n ]; goto yy_stack; } /* ** current state has no shift on ** "error", pop stack */ #if YYDEBUG # define _POP_ "Error recovery pops state %d, uncovers state %d\n" if ( yydebug ) (void)printf( _POP_, *yy_ps, yy_ps[-1] ); # undef _POP_ #endif yy_ps--; yy_pv--; } /* ** there is no state on stack with "error" as ** a valid shift. give up. */ YYABORT; case 3: /* no shift yet; eat a token */ #if YYDEBUG /* ** if debugging, look up token in list of ** pairs. 0 and negative shouldn't occur, ** but since timing doesn't matter when ** debugging, it doesn't hurt to leave the ** tests here. */ if ( yydebug ) { register int yy_i; (void)printf( "Error recovery discards " ); if ( yychar == 0 ) (void)printf( "token end-of-file\n" ); else if ( yychar < 0 ) (void)printf( "token -none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) { break; } } (void)printf( "token %s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( yychar == 0 ) /* reached EOF. quit */ YYABORT; yychar = -1; goto yy_newstate; } }/* end if ( yy_n == 0 ) */ /* ** reduction by production yy_n ** put stack tops, etc. so things right after switch */ #if YYDEBUG /* ** if debugging, print the string that is the user's ** specification of the reduction which is just about ** to be done. */ if ( yydebug ) (void)printf( "Reduce by (%d) \"%s\"\n", yy_n, yyreds[ yy_n ] ); #endif yytmp = yy_n; /* value to switch over */ yypvt = yy_pv; /* $vars top of value stack */ /* ** Look in goto table for next state ** Sorry about using yy_state here as temporary ** register variable, but why not, if it works... ** If yyr2[ yy_n ] doesn't have the low order bit ** set, then there is no action to be done for ** this reduction. So, no saving & unsaving of ** registers done. The only difference between the ** code just after the if and the body of the if is ** the goto yy_stack in the body. This way the test ** can be made before the choice of what to do is needed. */ { /* length of production doubled with extra bit */ register int yy_len = yyr2[ yy_n ]; if ( !( yy_len & 01 ) ) { yy_len >>= 1; yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + *( yy_ps -= yy_len ) + 1; if ( yy_state >= YYLAST || yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) { yy_state = yyact[ yypgo[ yy_n ] ]; } goto yy_stack; } yy_len >>= 1; yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + *( yy_ps -= yy_len ) + 1; if ( yy_state >= YYLAST || yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) { yy_state = yyact[ yypgo[ yy_n ] ]; } } /* save until reenter driver code */ yystate = yy_state; yyps = yy_ps; yypv = yy_pv; } /* ** code supplied by user is placed in this switch */ switch( yytmp ) { case 2: # line 411 "lua.stx" { pc=maincode; basepc=*initcode; maxcurr=maxmain; nlocalvar=0; } break; case 3: # line 416 "lua.stx" { maincode=pc; *initcode=basepc; maxmain=maxcurr; } break; case 7: # line 425 "lua.stx" { init_function(yypvt[-0].pNode); } break; case 8: # line 429 "lua.stx" { Word func = luaI_findsymbol(yypvt[-2].pNode); s_tag(func) = LUA_T_FUNCTION; s_bvalue(func) = yypvt[-0].pByte; } break; case 9: # line 437 "lua.stx" { init_function(yypvt[-0].pNode); localvar[nlocalvar]=luaI_findsymbolbyname("self"); add_nlocalvar(1); } break; case 10: # line 443 "lua.stx" { /* assign function to table field */ pc=maincode; basepc=*initcode; maxcurr=maxmain; nlocalvar=0; lua_pushvar(luaI_findsymbol(yypvt[-4].pNode)+1); code_byte(PUSHSTRING); code_word(luaI_findconstant(yypvt[-2].pNode)); code_byte(PUSHFUNCTION); code_code(yypvt[-0].pByte); code_byte(STOREINDEXED0); maincode=pc; *initcode=basepc; maxmain=maxcurr; } break; case 11: # line 458 "lua.stx" { codereturn(); yyval.pByte = newvector(pc, Byte); memcpy(yyval.pByte, basepc, pc*sizeof(Byte)); funcCode = basepc; maxcode=maxcurr; #if LISTING PrintCode(funcCode,funcCode+pc); #endif } break; case 16: # line 475 "lua.stx" { codedebugline(); } break; case 18: # line 477 "lua.stx" { codedebugline(); } break; case 20: # line 480 "lua.stx" { codeIf(yypvt[-4].vLong, yypvt[-2].vLong); } break; case 21: # line 482 "lua.stx" {yyval.vLong=pc;} break; case 22: # line 483 "lua.stx" { basepc[yypvt[-3].vLong] = IFFJMP; code_word_at(basepc+yypvt[-3].vLong+1, pc - (yypvt[-3].vLong + sizeof(Word)+1)); basepc[yypvt[-1].vLong] = UPJMP; code_word_at(basepc+yypvt[-1].vLong+1, pc - (yypvt[-6].vLong)); } break; case 23: # line 490 "lua.stx" {yyval.vLong=pc;} break; case 24: # line 491 "lua.stx" { basepc[yypvt[-0].vLong] = IFFUPJMP; code_word_at(basepc+yypvt[-0].vLong+1, pc - (yypvt[-4].vLong)); } break; case 25: # line 497 "lua.stx" { { int i; adjust_mult_assign(nvarbuffer, yypvt[-0].vInt, yypvt[-2].vInt * 2 + nvarbuffer); for (i=nvarbuffer-1; i>=0; i--) lua_codestore (i); if (yypvt[-2].vInt > 1 || (yypvt[-2].vInt == 1 && varbuffer[0] != 0)) lua_codeadjust (0); } } break; case 26: # line 507 "lua.stx" { code_byte(0); } break; case 27: # line 509 "lua.stx" { add_nlocalvar(yypvt[-1].vInt); adjust_mult_assign(yypvt[-1].vInt, yypvt[-0].vInt, 0); } break; case 30: # line 517 "lua.stx" { codeIf(yypvt[-3].vLong, yypvt[-1].vLong); } break; case 31: # line 520 "lua.stx" {yyval.vInt = nlocalvar;} break; case 32: # line 521 "lua.stx" { if (nlocalvar != yypvt[-2].vInt) { nlocalvar = yypvt[-2].vInt; lua_codeadjust (0); } } break; case 34: # line 531 "lua.stx" { codedebugline(); } break; case 35: # line 532 "lua.stx" { if (yypvt[-1].vInt < 0) code_byte(MULT_RET); codereturn(); } break; case 36: # line 539 "lua.stx" { yyval.vLong = pc; code_byte(0); /* open space */ code_word (0); } break; case 37: # line 545 "lua.stx" { if (yypvt[-0].vInt == 0) code_byte(1); } break; case 38: # line 548 "lua.stx" { yyval.vInt = yypvt[-1].vInt; } break; case 39: # line 549 "lua.stx" { code_byte(EQOP); yyval.vInt = 1; } break; case 40: # line 550 "lua.stx" { code_byte(LTOP); yyval.vInt = 1; } break; case 41: # line 551 "lua.stx" { code_byte(GTOP); yyval.vInt = 1; } break; case 42: # line 552 "lua.stx" { code_byte(EQOP); code_byte(NOTOP); yyval.vInt = 1; } break; case 43: # line 553 "lua.stx" { code_byte(LEOP); yyval.vInt = 1; } break; case 44: # line 554 "lua.stx" { code_byte(GEOP); yyval.vInt = 1; } break; case 45: # line 555 "lua.stx" { code_byte(ADDOP); yyval.vInt = 1; } break; case 46: # line 556 "lua.stx" { code_byte(SUBOP); yyval.vInt = 1; } break; case 47: # line 557 "lua.stx" { code_byte(MULTOP); yyval.vInt = 1; } break; case 48: # line 558 "lua.stx" { code_byte(DIVOP); yyval.vInt = 1; } break; case 49: # line 559 "lua.stx" { code_byte(POWOP); yyval.vInt = 1; } break; case 50: # line 560 "lua.stx" { code_byte(CONCOP); yyval.vInt = 1; } break; case 51: # line 561 "lua.stx" { code_byte(MINUSOP); yyval.vInt = 1;} break; case 52: # line 562 "lua.stx" { yyval.vInt = 1; } break; case 53: # line 563 "lua.stx" { yyval.vInt = 1;} break; case 54: # line 564 "lua.stx" { code_number(yypvt[-0].vFloat); yyval.vInt = 1; } break; case 55: # line 566 "lua.stx" { code_byte(PUSHSTRING); code_word(yypvt[-0].vWord); yyval.vInt = 1; } break; case 56: # line 571 "lua.stx" {code_byte(PUSHNIL); yyval.vInt = 1; } break; case 57: # line 572 "lua.stx" { yyval.vInt = 0; } break; case 58: # line 573 "lua.stx" { code_byte(NOTOP); yyval.vInt = 1;} break; case 59: # line 574 "lua.stx" {code_byte(POP); } break; case 60: # line 575 "lua.stx" { basepc[yypvt[-2].vLong] = ONFJMP; code_word_at(basepc+yypvt[-2].vLong+1, pc - (yypvt[-2].vLong + sizeof(Word)+1)); yyval.vInt = 1; } break; case 61: # line 580 "lua.stx" {code_byte(POP); } break; case 62: # line 581 "lua.stx" { basepc[yypvt[-2].vLong] = ONTJMP; code_word_at(basepc+yypvt[-2].vLong+1, pc - (yypvt[-2].vLong + sizeof(Word)+1)); yyval.vInt = 1; } break; case 63: # line 589 "lua.stx" { code_byte(CREATEARRAY); yyval.vLong = pc; code_word(0); } break; case 64: # line 594 "lua.stx" { code_word_at(basepc+yypvt[-3].vLong, yypvt[-1].vInt); } break; case 65: # line 600 "lua.stx" { code_byte(CALLFUNC); code_byte(yypvt[-1].vInt+yypvt[-0].vInt); } break; case 66: # line 603 "lua.stx" { yyval.vInt = 0; } break; case 67: # line 605 "lua.stx" { code_byte(PUSHSELF); code_word(luaI_findconstant(yypvt[-0].pNode)); yyval.vInt = 1; } break; case 68: # line 613 "lua.stx" { if (yypvt[-1].vInt<0) { code_byte(1); yyval.vInt = -yypvt[-1].vInt; } else yyval.vInt = yypvt[-1].vInt; } break; case 69: # line 614 "lua.stx" { yyval.vInt = 1; } break; case 70: # line 617 "lua.stx" { yyval.vInt = 0; } break; case 71: # line 618 "lua.stx" { yyval.vInt = yypvt[-0].vInt; } break; case 72: # line 621 "lua.stx" { if (yypvt[-0].vInt == 0) yyval.vInt = -1; else yyval.vInt = 1; } break; case 73: # line 622 "lua.stx" { if (yypvt[-1].vInt < 0) code_byte(1); } break; case 74: # line 623 "lua.stx" { int r = yypvt[-3].vInt < 0 ? -yypvt[-3].vInt : yypvt[-3].vInt; yyval.vInt = (yypvt[-0].vInt == 0) ? -(r+1) : r+1; } break; case 75: # line 629 "lua.stx" { lua_codeadjust(0); } break; case 76: # line 630 "lua.stx" { lua_codeadjust(0); } break; case 77: # line 634 "lua.stx" { localvar[nlocalvar]=luaI_findsymbol(yypvt[-0].pNode); add_nlocalvar(1); } break; case 78: # line 639 "lua.stx" { localvar[nlocalvar]=luaI_findsymbol(yypvt[-0].pNode); add_nlocalvar(1); } break; case 79: # line 645 "lua.stx" { yyval.vInt = 0; } break; case 80: # line 647 "lua.stx" { yyval.vInt = yypvt[-1].vInt; flush_list(yypvt[-1].vInt/FIELDS_PER_FLUSH, yypvt[-1].vInt%FIELDS_PER_FLUSH); } break; case 81: # line 649 "lua.stx" { yyval.vInt = yypvt[-1].vInt; flush_record(yypvt[-1].vInt%FIELDS_PER_FLUSH); } break; case 82: # line 651 "lua.stx" { flush_list(yypvt[-1].vInt/FIELDS_PER_FLUSH, yypvt[-1].vInt%FIELDS_PER_FLUSH); } break; case 83: # line 653 "lua.stx" { yyval.vInt = yypvt[-4].vInt+yypvt[-1].vInt; flush_record(yypvt[-1].vInt%FIELDS_PER_FLUSH); } break; case 86: # line 660 "lua.stx" {yyval.vInt=1;} break; case 87: # line 662 "lua.stx" { yyval.vInt=yypvt[-2].vInt+1; if (yyval.vInt%FIELDS_PER_FLUSH == 0) flush_record(FIELDS_PER_FLUSH); } break; case 88: # line 669 "lua.stx" { push_field(luaI_findconstant(yypvt[-2].pNode)); } break; case 89: # line 674 "lua.stx" {yyval.vInt=1;} break; case 90: # line 676 "lua.stx" { yyval.vInt=yypvt[-2].vInt+1; if (yyval.vInt%FIELDS_PER_FLUSH == 0) flush_list(yyval.vInt/FIELDS_PER_FLUSH - 1, FIELDS_PER_FLUSH); } break; case 91: # line 684 "lua.stx" { nvarbuffer = 0; varbuffer[nvarbuffer] = yypvt[-0].vLong; incr_nvarbuffer(); yyval.vInt = (yypvt[-0].vLong == 0) ? 1 : 0; } break; case 92: # line 690 "lua.stx" { varbuffer[nvarbuffer] = yypvt[-0].vLong; incr_nvarbuffer(); yyval.vInt = (yypvt[-0].vLong == 0) ? yypvt[-2].vInt + 1 : yypvt[-2].vInt; } break; case 93: # line 696 "lua.stx" { yyval.vLong = yypvt[-0].vLong; } break; case 94: # line 698 "lua.stx" { yyval.vLong = 0; /* indexed variable */ } break; case 95: # line 702 "lua.stx" { code_byte(PUSHSTRING); code_word(luaI_findconstant(yypvt[-0].pNode)); yyval.vLong = 0; /* indexed variable */ } break; case 96: # line 710 "lua.stx" { Word s = luaI_findsymbol(yypvt[-0].pNode); int local = lua_localname (s); if (local == -1) /* global var */ yyval.vLong = s + 1; /* return positive value */ else yyval.vLong = -(local+1); /* return negative value */ } break; case 97: # line 720 "lua.stx" { lua_pushvar(yypvt[-0].vLong); } break; case 98: # line 723 "lua.stx" {localvar[nlocalvar]=luaI_findsymbol(yypvt[-0].pNode); yyval.vInt = 1;} break; case 99: # line 725 "lua.stx" { localvar[nlocalvar+yypvt[-2].vInt]=luaI_findsymbol(yypvt[-0].pNode); yyval.vInt = yypvt[-2].vInt+1; } break; case 100: # line 731 "lua.stx" { yyval.vInt = 0; } break; case 101: # line 732 "lua.stx" { yyval.vInt = yypvt[-0].vInt; } break; case 102: # line 735 "lua.stx" {lua_debug = yypvt[-0].vInt;} break; } goto yystack; /* reset registers in driver code */ }