Java Code Examples for org.luaj.vm2.Lua#OP_MOD

The following examples show how to use org.luaj.vm2.Lua#OP_MOD . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Exp.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
static int precedence(int op) {
    switch (op) {
        case Lua.OP_OR:
            return 0;
        case Lua.OP_AND:
            return 1;
        case Lua.OP_LT:
        case Lua.OP_GT:
        case Lua.OP_LE:
        case Lua.OP_GE:
        case Lua.OP_NEQ:
        case Lua.OP_EQ:
            return 2;
        case Lua.OP_CONCAT:
            return 3;
        case Lua.OP_ADD:
        case Lua.OP_SUB:
            return 4;
        case Lua.OP_MUL:
        case Lua.OP_DIV:
        case Lua.OP_MOD:
            return 5;
        case Lua.OP_NOT:
        case Lua.OP_UNM:
        case Lua.OP_LEN:
            return 6;
        case Lua.OP_POW:
            return 7;
        default:
            throw new IllegalStateException("precedence of bad op " + op);
    }
}
 
Example 2
Source File: DebugLib.java    From XPrivacyLua with GNU General Public License v3.0 5 votes vote down vote up
static NameWhat getfuncname(DebugLib.CallFrame frame) {
	if (!frame.f.isclosure())
		return new NameWhat(frame.f.classnamestub(), "Java");
	Prototype p = frame.f.checkclosure().p;
	int pc = frame.pc;
	int i = p.code[pc]; /* calling instruction */
	LuaString tm;
	switch (Lua.GET_OPCODE(i)) {
		case Lua.OP_CALL:
		case Lua.OP_TAILCALL: /* get function name */
			return getobjname(p, pc, Lua.GETARG_A(i));
		case Lua.OP_TFORCALL: /* for iterator */
	    	return new NameWhat("(for iterator)", "(for iterator");
	    /* all other instructions can call only through metamethods */
	    case Lua.OP_SELF:
	    case Lua.OP_GETTABUP:
	    case Lua.OP_GETTABLE: tm = LuaValue.INDEX; break;
	    case Lua.OP_SETTABUP:
	    case Lua.OP_SETTABLE: tm = LuaValue.NEWINDEX; break;
	    case Lua.OP_EQ: tm = LuaValue.EQ; break;
	    case Lua.OP_ADD: tm = LuaValue.ADD; break;
	    case Lua.OP_SUB: tm = LuaValue.SUB; break;
	    case Lua.OP_MUL: tm = LuaValue.MUL; break;
	    case Lua.OP_DIV: tm = LuaValue.DIV; break;
	    case Lua.OP_MOD: tm = LuaValue.MOD; break;
	    case Lua.OP_POW: tm = LuaValue.POW; break;
	    case Lua.OP_UNM: tm = LuaValue.UNM; break;
	    case Lua.OP_LEN: tm = LuaValue.LEN; break;
	    case Lua.OP_LT: tm = LuaValue.LT; break;
	    case Lua.OP_LE: tm = LuaValue.LE; break;
	    case Lua.OP_CONCAT: tm = LuaValue.CONCAT; break;
	    default:
	      return null;  /* else no useful name can be found */
	}
	return new NameWhat( tm.tojstring(), "metamethod" );
}
 
Example 3
Source File: Exp.java    From HtmlNative with Apache License 2.0 5 votes vote down vote up
static int precedence(int op) {
	switch ( op ) {
	case Lua.OP_OR: return 0;
	case Lua.OP_AND: return 1;
	case Lua.OP_LT: case Lua.OP_GT: case Lua.OP_LE: case Lua.OP_GE: case Lua.OP_NEQ: case Lua.OP_EQ: return 2;
	case Lua.OP_CONCAT: return 3;
	case Lua.OP_ADD: case Lua.OP_SUB: return 4;
	case Lua.OP_MUL: case Lua.OP_DIV: case Lua.OP_MOD: return 5;
	case Lua.OP_NOT: case Lua.OP_UNM: case Lua.OP_LEN: return 6;
	case Lua.OP_POW: return 7;
	default: throw new IllegalStateException("precedence of bad op "+op);
	}
}
 
Example 4
Source File: DebugLib.java    From HtmlNative with Apache License 2.0 5 votes vote down vote up
static NameWhat getfuncname(DebugLib.CallFrame frame) {
	if (!frame.f.isclosure())
		return new NameWhat(frame.f.classnamestub(), "Java");
	Prototype p = frame.f.checkclosure().p;
	int pc = frame.pc;
	int i = p.code[pc]; /* calling instruction */
	LuaString tm;
	switch (Lua.GET_OPCODE(i)) {
		case Lua.OP_CALL:
		case Lua.OP_TAILCALL: /* get function name */
			return getobjname(p, pc, Lua.GETARG_A(i));
		case Lua.OP_TFORCALL: /* for iterator */
	    	return new NameWhat("(for iterator)", "(for iterator");
	    /* all other instructions can call only through metamethods */
	    case Lua.OP_SELF:
	    case Lua.OP_GETTABUP:
	    case Lua.OP_GETTABLE: tm = LuaValue.INDEX; break;
	    case Lua.OP_SETTABUP:
	    case Lua.OP_SETTABLE: tm = LuaValue.NEWINDEX; break;
	    case Lua.OP_EQ: tm = LuaValue.EQ; break;
	    case Lua.OP_ADD: tm = LuaValue.ADD; break;
	    case Lua.OP_SUB: tm = LuaValue.SUB; break;
	    case Lua.OP_MUL: tm = LuaValue.MUL; break;
	    case Lua.OP_DIV: tm = LuaValue.DIV; break;
	    case Lua.OP_MOD: tm = LuaValue.MOD; break;
	    case Lua.OP_POW: tm = LuaValue.POW; break;
	    case Lua.OP_UNM: tm = LuaValue.UNM; break;
	    case Lua.OP_LEN: tm = LuaValue.LEN; break;
	    case Lua.OP_LT: tm = LuaValue.LT; break;
	    case Lua.OP_LE: tm = LuaValue.LE; break;
	    case Lua.OP_CONCAT: tm = LuaValue.CONCAT; break;
	    default:
	      return null;  /* else no useful name can be found */
	}
	return new NameWhat( tm.tojstring(), "metamethod" );
}
 
Example 5
Source File: Exp.java    From luaj with MIT License 5 votes vote down vote up
static int precedence(int op) {
	switch ( op ) {
	case Lua.OP_OR: return 0;
	case Lua.OP_AND: return 1;
	case Lua.OP_LT: case Lua.OP_GT: case Lua.OP_LE: case Lua.OP_GE: case Lua.OP_NEQ: case Lua.OP_EQ: return 2;
	case Lua.OP_CONCAT: return 3;
	case Lua.OP_ADD: case Lua.OP_SUB: return 4;
	case Lua.OP_MUL: case Lua.OP_DIV: case Lua.OP_MOD: return 5;
	case Lua.OP_NOT: case Lua.OP_UNM: case Lua.OP_LEN: return 6;
	case Lua.OP_POW: return 7;
	default: throw new IllegalStateException("precedence of bad op "+op);
	}
}
 
Example 6
Source File: JavaBuilder.java    From luaj with MIT License 5 votes vote down vote up
public void binaryop(int o) {
	String op;
	switch (o) {
		default: 
		case Lua.OP_ADD: op = "add"; break;
		case Lua.OP_SUB: op = "sub"; break;
		case Lua.OP_MUL: op = "mul"; break;
		case Lua.OP_DIV: op = "div"; break;
		case Lua.OP_MOD: op = "mod"; break;
		case Lua.OP_POW: op = "pow"; break;
	}
       append(factory.createInvoke(STR_LUAVALUE, op, TYPE_LUAVALUE, ARG_TYPES_LUAVALUE, Constants.INVOKEVIRTUAL));
}
 
Example 7
Source File: DebugLib.java    From luaj with MIT License 5 votes vote down vote up
static NameWhat getfuncname(DebugLib.CallFrame frame) {
	if (!frame.f.isclosure())
		return new NameWhat(frame.f.classnamestub(), "Java");
	Prototype p = frame.f.checkclosure().p;
	int pc = frame.pc;
	int i = p.code[pc]; /* calling instruction */
	LuaString tm;
	switch (Lua.GET_OPCODE(i)) {
		case Lua.OP_CALL:
		case Lua.OP_TAILCALL: /* get function name */
			return getobjname(p, pc, Lua.GETARG_A(i));
		case Lua.OP_TFORCALL: /* for iterator */
	    	return new NameWhat("(for iterator)", "(for iterator");
	    /* all other instructions can call only through metamethods */
	    case Lua.OP_SELF:
	    case Lua.OP_GETTABUP:
	    case Lua.OP_GETTABLE: tm = LuaValue.INDEX; break;
	    case Lua.OP_SETTABUP:
	    case Lua.OP_SETTABLE: tm = LuaValue.NEWINDEX; break;
	    case Lua.OP_EQ: tm = LuaValue.EQ; break;
	    case Lua.OP_ADD: tm = LuaValue.ADD; break;
	    case Lua.OP_SUB: tm = LuaValue.SUB; break;
	    case Lua.OP_MUL: tm = LuaValue.MUL; break;
	    case Lua.OP_DIV: tm = LuaValue.DIV; break;
	    case Lua.OP_MOD: tm = LuaValue.MOD; break;
	    case Lua.OP_POW: tm = LuaValue.POW; break;
	    case Lua.OP_UNM: tm = LuaValue.UNM; break;
	    case Lua.OP_LEN: tm = LuaValue.LEN; break;
	    case Lua.OP_LT: tm = LuaValue.LT; break;
	    case Lua.OP_LE: tm = LuaValue.LE; break;
	    case Lua.OP_CONCAT: tm = LuaValue.CONCAT; break;
	    default:
	      return null;  /* else no useful name can be found */
	}
	return new NameWhat( tm.tojstring(), "metamethod" );
}
 
Example 8
Source File: LuaParser.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
public int Binop() throws ParseException {
    switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
        case 82:
            jj_consume_token(82);
        {
            if (true) return Lua.OP_ADD;
        }
        break;
        case 83:
            jj_consume_token(83);
        {
            if (true) return Lua.OP_SUB;
        }
        break;
        case 84:
            jj_consume_token(84);
        {
            if (true) return Lua.OP_MUL;
        }
        break;
        case 85:
            jj_consume_token(85);
        {
            if (true) return Lua.OP_DIV;
        }
        break;
        case 86:
            jj_consume_token(86);
        {
            if (true) return Lua.OP_POW;
        }
        break;
        case 87:
            jj_consume_token(87);
        {
            if (true) return Lua.OP_MOD;
        }
        break;
        case 88:
            jj_consume_token(88);
        {
            if (true) return Lua.OP_CONCAT;
        }
        break;
        case 89:
            jj_consume_token(89);
        {
            if (true) return Lua.OP_LT;
        }
        break;
        case 90:
            jj_consume_token(90);
        {
            if (true) return Lua.OP_LE;
        }
        break;
        case 91:
            jj_consume_token(91);
        {
            if (true) return Lua.OP_GT;
        }
        break;
        case 92:
            jj_consume_token(92);
        {
            if (true) return Lua.OP_GE;
        }
        break;
        case 93:
            jj_consume_token(93);
        {
            if (true) return Lua.OP_EQ;
        }
        break;
        case 94:
            jj_consume_token(94);
        {
            if (true) return Lua.OP_NEQ;
        }
        break;
        case AND:
            jj_consume_token(AND);
        {
            if (true) return Lua.OP_AND;
        }
        break;
        case OR:
            jj_consume_token(OR);
        {
            if (true) return Lua.OP_OR;
        }
        break;
        default:
            jj_la1[32] = jj_gen;
            jj_consume_token(-1);
            throw new ParseException();
    }
    throw new Error("Missing return statement in function");
}
 
Example 9
Source File: DebugLib.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
static NameWhat getfuncname(DebugLib.CallFrame frame) {
    if (!frame.f.isclosure())
        return new NameWhat(frame.f.classnamestub(), "Java");
    Prototype p = frame.f.checkclosure().p;
    int pc = frame.pc;
    int i = p.code[pc]; /* calling instruction */
    LuaString tm;
    switch (Lua.GET_OPCODE(i)) {
        case Lua.OP_CALL:
        case Lua.OP_TAILCALL: /* get function name */
            return getobjname(p, pc, Lua.GETARG_A(i));
        case Lua.OP_TFORCALL: /* for iterator */
            return new NameWhat("(for iterator)", "(for iterator");
        /* all other instructions can call only through metamethods */
        case Lua.OP_SELF:
        case Lua.OP_GETTABUP:
        case Lua.OP_GETTABLE:
            tm = LuaValue.INDEX;
            break;
        case Lua.OP_SETTABUP:
        case Lua.OP_SETTABLE:
            tm = LuaValue.NEWINDEX;
            break;
        case Lua.OP_EQ:
            tm = LuaValue.EQ;
            break;
        case Lua.OP_ADD:
            tm = LuaValue.ADD;
            break;
        case Lua.OP_SUB:
            tm = LuaValue.SUB;
            break;
        case Lua.OP_MUL:
            tm = LuaValue.MUL;
            break;
        case Lua.OP_DIV:
            tm = LuaValue.DIV;
            break;
        case Lua.OP_MOD:
            tm = LuaValue.MOD;
            break;
        case Lua.OP_POW:
            tm = LuaValue.POW;
            break;
        case Lua.OP_UNM:
            tm = LuaValue.UNM;
            break;
        case Lua.OP_LEN:
            tm = LuaValue.LEN;
            break;
        case Lua.OP_LT:
            tm = LuaValue.LT;
            break;
        case Lua.OP_LE:
            tm = LuaValue.LE;
            break;
        case Lua.OP_CONCAT:
            tm = LuaValue.CONCAT;
            break;
        default:
            return null;  /* else no useful name can be found */
    }
    return new NameWhat(tm.tojstring(), "metamethod");
}