Пример #1
0
/*
 * Changes the type of the field of a struct
 */
void updateStruct(const ExpressionPtr& structure, TypePtr& type, const ExpressionPtr& identifier) {
	NodeManager& mgr = structure->getNodeManager();
	IRBuilder builder(mgr);

	TypePtr baseType = structure->getType();
	RefTypePtr refTy = baseType.isa<RefTypePtr>();
	StructTypePtr kst = refTy ? refTy->getElementType().as<StructTypePtr>() : structure->getType().as<StructTypePtr>();
	std::string name = identifier->toString();
	NamedTypePtr oldType = kst->getNamedTypeEntryOf(name);
	NamedTypePtr newType = builder.namedType(name, refTy ? builder.refType(type) : type);

	TypePtr newStructType = transform::replaceAll(mgr, baseType, oldType, newType).as<TypePtr>();

	type = newStructType;
}
Пример #2
0
 ExpressionPtr getDNF() const
 {
     // Multiple passes are sometimes required.
     ExpressionPtr result = getDNFImpl();
     int safety = 0;
     while (!result->isDNF())
     {
         std::cout << "Pass " << ": " << result->toString() << std::endl;
         result = result->getDNFImpl();
         if (safety++ > 100)
         {
             throw std::runtime_error("Maximum number of DNF passes exceeded.");
         }
     }
     return result;
 }
Пример #3
0
void test(ExpressionPtr expr)
{
    std::cout << "Before DNF: " << expr->toString() << std::endl;
    std::cout << "After DNF : " << expr->getDNF()->toString() << std::endl << std::endl;
}