예제 #1
0
bool Compiler::CompileInstructions() {
    cs_.InitEntryBlock();
    stack_.InitValues();
    cs_.B_.CreateBr(cs_.blocks_[0]);

    for (cs_.curr_ = 0; cs_.curr_ < cs_.proto_->sizecode; ++cs_.curr_) {
        cs_.B_.SetInsertPoint(cs_.blocks_[cs_.curr_]);
        cs_.instr_ = cs_.proto_->code[cs_.curr_];
        //cs_.DebugPrint(luaP_opnames[GET_OPCODE(cs_.instr_)]);
        switch (GET_OPCODE(cs_.instr_)) {
            case OP_MOVE:     CompileMove(); break;
            case OP_LOADK:    CompileLoadk(false); break;
            case OP_LOADKX:   CompileLoadk(true); break;
            case OP_LOADBOOL: CompileLoadbool(); break;
            case OP_LOADNIL:  CompileLoadnil(); break;
            case OP_GETUPVAL: CompileGetupval(); break;
            case OP_GETTABUP: CompileGettabup(); break;
            case OP_GETTABLE: CompileGettable(); break;
            case OP_SETTABUP: CompileSettabup(); break;
            case OP_SETUPVAL: CompileSetupval(); break;
            case OP_SETTABLE: CompileSettable(); break;
            case OP_NEWTABLE: CompileNewtable(); break;
            case OP_SELF:     CompileSelf(); break;

            case OP_ADD: case OP_SUB: case OP_MUL: case OP_MOD: case OP_POW:  
            case OP_DIV: case OP_IDIV:
                              Arith(cs_, stack_).Compile(); break;

            case OP_BAND: case OP_BOR: case OP_BXOR: case OP_SHL: case OP_SHR:
                              Logical(cs_, stack_).Compile(); break;

            case OP_UNM:      CompileUnm(); break;
            case OP_BNOT:     CompileBNot(); break;
            case OP_NOT:      CompileNot(); break;
            case OP_LEN:      CompileLen(); break;
            case OP_CONCAT:   CompileConcat(); break;
            case OP_JMP:      CompileJmp(); break;
            case OP_EQ:       CompileCmp("luaV_equalobj"); break;
            case OP_LT:       CompileCmp("luaV_lessthan"); break;
            case OP_LE:       CompileCmp("luaV_lessequal"); break;
            case OP_TEST:     CompileTest(); break;
            case OP_TESTSET:  CompileTestset(); break;
            case OP_CALL:     CompileCall(); break;
            case OP_TAILCALL: CompileTailcall(); break;
            case OP_RETURN:   CompileReturn(); break;
            case OP_FORLOOP:  CompileForloop(); break;
            case OP_FORPREP:  CompileForprep(); break;
            case OP_TFORCALL: CompileTforcall(); break;
            case OP_TFORLOOP: CompileTforloop(); break;
            case OP_SETLIST:  CompileSetlist(); break;
            case OP_CLOSURE:  CompileClosure(); break;
            case OP_VARARG:   Vararg(cs_, stack_).Compile(); break;
            case OP_EXTRAARG: /* ignored */ break;
        }
        if (!cs_.blocks_[cs_.curr_]->getTerminator())
            cs_.B_.CreateBr(cs_.blocks_[cs_.curr_ + 1]);
    }
    return true;
}
예제 #2
0
파일: Logical.hpp 프로젝트: kmillar/rho
	static Logical NA() { return Logical(NA_LOGICAL); }
예제 #3
0
파일: Logical.hpp 프로젝트: kmillar/rho
    // Inline definitions of operators.
    inline Logical Logical::operator!() const {
	if (isNA()) {
	    return NA();
	}
	return Logical(1 - m_value);
    }
예제 #4
0
BufferOffset Assembler::ands(const Register& rd, const Register& rn, const Operand& operand) {
  return Logical(rd, rn, operand, ANDS);
}