namespace coco
{
+class UnitF;
+
using InstrList = coco::DLinkedList<Instr, Block>::Head;
/**
public:
InstrList *head(void) const override;
+
+public:
+ virtual UnitF *asUnitF(void) { return nullptr; }
+ virtual const UnitF *asUnitF(void) const { return nullptr; }
};
} // namespace coco
// DO NOTHING
}
+public:
+ UnitF *asUnitF(void) override { return this; }
+ const UnitF *asUnitF(void) const override { return this; }
+
private:
Op *_op;
ASSERT_EQ(ins.op(), nullptr);
}
+TEST(IR_UNIT_F, asUnitF)
+{
+ coco::PtrLink<coco::Instr, coco::Block> link;
+ coco::UnitF ins{&link};
+
+ coco::Instr *mutable_ptr = &ins;
+ const coco::Instr *immutable_ptr = &ins;
+
+ ASSERT_NE(mutable_ptr->asUnitF(), nullptr);
+ ASSERT_EQ(mutable_ptr->asUnitF(), immutable_ptr->asUnitF());
+}
+
TEST(IR_UNIT_F, op_update)
{
coco::PtrLink<coco::Instr, coco::Block> link;