15460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//===- ContextFactory.cpp -------------------------------------------------===// 25460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao// 35460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao// The MCLinker Project 45460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao// 55460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao// This file is distributed under the University of Illinois Open Source 65460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao// License. See LICENSE.TXT for details. 75460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao// 85460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//===----------------------------------------------------------------------===// 937b74a387bb3993387029859c2d9d051c41c724eStephen Hines#include "mcld/MC/ContextFactory.h" 105460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 1137b74a387bb3993387029859c2d9d051c41c724eStephen Hines#include "mcld/LD/LDContext.h" 1237b74a387bb3993387029859c2d9d051c41c724eStephen Hines 1337b74a387bb3993387029859c2d9d051c41c724eStephen Hinesnamespace mcld { 145460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 155460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//===---------------------------------------------------------------------===// 165460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao// LDContextFactory 175460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei LiaoContextFactory::ContextFactory(size_t pNum) 1837b74a387bb3993387029859c2d9d051c41c724eStephen Hines : UniqueGCFactoryBase<sys::fs::Path, LDContext, 0>(pNum) { 195460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao} 205460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 2137b74a387bb3993387029859c2d9d051c41c724eStephen HinesContextFactory::~ContextFactory() { 225460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao} 235460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 2437b74a387bb3993387029859c2d9d051c41c724eStephen HinesLDContext* ContextFactory::produce(const sys::fs::Path& pPath) { 255460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao LDContext* result = find(pPath); 2637b74a387bb3993387029859c2d9d051c41c724eStephen Hines if (result == NULL) { 275460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao result = UniqueGCFactoryBase<sys::fs::Path, LDContext, 0>::allocate(); 285460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao new (result) LDContext(); 295460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao f_KeyMap.insert(std::make_pair(pPath, result)); 305460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao } 315460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao return result; 325460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao} 335460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao 3437b74a387bb3993387029859c2d9d051c41c724eStephen HinesLDContext* ContextFactory::produce(const char* pPath) { 3537b74a387bb3993387029859c2d9d051c41c724eStephen Hines return produce(sys::fs::Path(pPath)); 3637b74a387bb3993387029859c2d9d051c41c724eStephen Hines} 3737b74a387bb3993387029859c2d9d051c41c724eStephen Hines 3837b74a387bb3993387029859c2d9d051c41c724eStephen HinesLDContext* ContextFactory::produce() { 39affc150dc44fab1911775a49636d0ce85333b634Zonr Chang LDContext* result = allocate(); 40affc150dc44fab1911775a49636d0ce85333b634Zonr Chang new (result) LDContext(); 41affc150dc44fab1911775a49636d0ce85333b634Zonr Chang return result; 42affc150dc44fab1911775a49636d0ce85333b634Zonr Chang} 43affc150dc44fab1911775a49636d0ce85333b634Zonr Chang 4437b74a387bb3993387029859c2d9d051c41c724eStephen Hines} // namespace mcld 45