void IRGenerator::accept(UnaryExpr& expr) { FNTRACE(); static const std::unordered_map< int /*FlowVM::Opcode*/, Value* (IRGenerator::*)(Value*, const std::string&) > ops = { { FlowVM::Opcode::I2S, &IRGenerator::createI2S }, { FlowVM::Opcode::P2S, &IRGenerator::createP2S }, { FlowVM::Opcode::C2S, &IRGenerator::createC2S }, { FlowVM::Opcode::R2S, &IRGenerator::createR2S }, { FlowVM::Opcode::S2I, &IRGenerator::createS2I }, { FlowVM::Opcode::NNEG, &IRGenerator::createNeg }, }; Value* rhs = codegen(expr.subExpr()); auto i = ops.find(expr.op()); if (i != ops.end()) { result_ = (this->*i->second)(rhs, ""); } else { assert(!"Unsupported unary expression in IRGenerator."); result_ = nullptr; } }
// }}} // {{{ expressions void FlowCallVisitor::accept(UnaryExpr& expr) { visit(expr.subExpr()); }