Esempio n. 1
0
static int statement (LexState *ls) {
  int line = ls->linenumber;  /* may be needed for error messages */
  switch (ls->t.token) {
    case TK_IF: {  /* stat -> ifstat */
      ifstat(ls, line);
      return 0;
    }
    case TK_WHILE: {  /* stat -> whilestat */
      whilestat(ls, line);
      return 0;
    }
    case TK_DO: {  /* stat -> DO block END */
      luaX_next(ls);  /* skip DO */
      block(ls);
      check_match(ls, TK_END, TK_DO, line);
      return 0;
    }
    case TK_FOR: {  /* stat -> forstat */
      forstat(ls, line);
      return 0;
    }
    case TK_REPEAT: {  /* stat -> repeatstat */
      repeatstat(ls, line);
      return 0;
    }
    case TK_FUNCTION: {
      funcstat(ls, line);  /* stat -> funcstat */
      return 0;
    }
    case TK_LOCAL: {  /* stat -> localstat */
      luaX_next(ls);  /* skip LOCAL */
      if (testnext(ls, TK_FUNCTION))  /* local function? */
        localfunc(ls);
      else
        localstat(ls);
      return 0;
    }
    case TK_RETURN: {  /* stat -> retstat */
      retstat(ls);
      return 1;  /* must be last statement */
    }
    case TK_BREAK: {  /* stat -> breakstat */
      luaX_next(ls);  /* skip BREAK */
      breakstat(ls);
      return 1;  /* must be last statement */
    }
#if LUA_EXT_CONTINUE
    case TK_CONTINUE: {  /* stat -> continuestat */
      luaX_next(ls);  /* skip CONTINUE */
      continuestat(ls);
      return 1;  /* must be last statement */
    }
#endif /* LUA_EXT_CONTINUE */
    default: {
      exprstat(ls);
      return 0;  /* to avoid warnings */
    }
  }
}
Esempio n. 2
0
static
void
exec(const Ast *ast) {
//printf("executing "); pn(ast);
	Value *v;
	switch(ast->class) {
	case N_BLOCK:
		block(ast);
		return;
	case N_IF:
		ifstat(ast);
		return;
	case N_WHILE:
		whilestat(ast);
		return;
	case N_DECLARATION:
		declaration(ast);
		return;
	case N_FUNCTION:
		return;
	case N_RETURN:
		returnstat(ast);
		return;
	case N_CALL:
	case N_ASSIGNMENT:
	case N_IDENTIFIER:
	case N_NEG:
	case N_NOT:
	case N_EQ:
	case N_NEQ:
	case N_AND:
	case N_IOR:
	case N_XOR:
	case N_LT:
	case N_LE:
	case N_GE:
	case N_GT:
	case N_ADD:
	case N_SUB:
	case N_MUL:
	case N_DIV:
	case N_POW:
	case N_MOD:
	case N_BOOLEAN:
	case N_INTEGER:
	case N_FLOAT:
	case N_STRING:
	case N_SET:
	case N_R:
		v = eval(ast);
//do { print_tree(2, ast); dprintf(2, " evaluates to "); pv(v); } while(0);
		value_free(v);
		return;
	}
printf("EXECFAIL %d ", ast->class); pn(ast);
	assert(false && "should not be reached");
}
Esempio n. 3
0
static int ifstat_payload ( struct net_device *netdev ) {
	ifstat ( netdev );
	return 0;
}
Esempio n. 4
0
static int statement (LexState *ls) {
  int line = ls->linenumber;  /* may be needed for error messages */
  switch (ls->t.token) {
    case TK_IF: {  /* stat -> ifstat */
      ifstat(ls, line);
      return 0;
    }
    case TK_WHILE: {  /* stat -> whilestat */
      whilestat(ls, line);
      return 0;
    }
    case TK_DO: {  /* stat -> DO block END */
      luaX_next(ls);  /* skip DO */
      block(ls);
      check_match(ls, TK_END, TK_DO, line);
      return 0;
    }
    case TK_FOR: {  /* stat -> forstat */
      forstat(ls, line);
      return 0;
    }
    case TK_REPEAT: {  /* stat -> repeatstat */
      repeatstat(ls, line);
      return 0;
    }
    case TK_FUNCTION: {
      funcstat(ls, line);  /* stat -> funcstat */
      return 0;
    }
    case TK_LOCAL: {  /* stat -> localstat */
      luaX_next(ls);  /* skip LOCAL */
      if (testnext(ls, TK_FUNCTION))  /* local function? */
        localfunc(ls);
      else
        localstat(ls);
      return 0;
    }
    case TK_RETURN: {  /* stat -> retstat */
      retstat(ls);
      return 1;  /* must be last statement */
    }
    case TK_BREAK: {  /* stat -> breakstat */
      luaX_next(ls);  /* skip BREAK */
      if (testnext(ls, TK_NUMBER)) { /* multi scope 'break n' */
        breakstat(ls, ls->t.seminfo.r);
      } else breakstat(ls, 1);
      return 1;  /* must be last statement */
    }
    case TK_CONTINUE: {  /* stat -> continuestat */
      luaX_next(ls);  /* skip CONTINUE */
      continuestat(ls);
      return 1;	  /* must be last statement */
    }
    case TK_INC: {  /* added 0.5.2.*/
      luaX_next(ls);
      changevalue(ls, OP_ADD);
      return 0;
    }
    case TK_DEC: {  /* added 0.5.2.*/
      luaX_next(ls);
      changevalue(ls, OP_SUB);
      return 0;
    }
    case TK_CASE: {  /* added 0.5.2.*/
      selectstat(ls, line);
      return 0;
    }
    default: {
      exprstat(ls);
      return 0;  /* to avoid warnings */
    }
  }
}