* @brief Creates pointer type. * * @param context Storage for already created functions, types. * @param pointedType Type that this pointer points to. * @param bitWidth Number of bits used by this type. * * @par Preconditions * - @a context is not null * - @a pointedType is not null * * Does not create new pointer type, if one * has already been created and stored in @c context. */
| 34 | * has already been created and stored in @c context. |
| 35 | */ |
| 36 | std::shared_ptr<PointerType> PointerType::create( |
| 37 | const std::shared_ptr<Context> &context, |
| 38 | const std::shared_ptr<Type> &pointedType, |
| 39 | unsigned bitWidth) |
| 40 | { |
| 41 | assert(context && "violated precondition - context cannot be null"); |
| 42 | assert(pointedType && "violated precondition - pointedType cannot be null"); |
| 43 | |
| 44 | auto type = context->getPointerType(pointedType); |
| 45 | if (type) |
| 46 | { |
| 47 | return type; |
| 48 | } |
| 49 | |
| 50 | std::shared_ptr<PointerType> newType(new PointerType(pointedType, bitWidth)); |
| 51 | context->addPointerType(newType); |
| 52 | return newType; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * @brief Returns pointed type. |
nothing calls this directly
no test coverage detected