Midas/src/c-compiler/region/common/lgtweaks/lgtweaks.cpp
WeakFatPtrLE LgtWeaks::assembleInterfaceWeakRef(
    FunctionState* functionState,
    LLVMBuilderRef builder,
    Reference* sourceType,
    Reference* targetType,
    InterfaceKind* interfaceKindM,
    InterfaceFatPtrLE sourceInterfaceFatPtrLE) {
  assert(sourceType->ownership == Ownership::OWN || sourceType->ownership == Ownership::SHARE);
  // curious, if its a borrow, do we just return sourceRefLE?

  auto controlBlockPtrLE =
      kindStructsSource->getControlBlockPtr(
          FL(), functionState, builder, interfaceKindM, sourceInterfaceFatPtrLE);
  auto lgtiLE = getLgtiFromControlBlockPtr(globalState, builder, kindStructsSource, sourceType,
      controlBlockPtrLE);
  auto currentGenLE = getActualGenFromLGT(functionState, builder, lgtiLE);
  auto headerLE = makeLgtiHeader(globalState, weakRefStructsSource, builder, interfaceKindM, lgtiLE, currentGenLE);

  auto weakRefStructLT =
      weakRefStructsSource->getInterfaceWeakRefStruct(interfaceKindM);

  return fatWeaks_.assembleWeakFatPtr(
      functionState, builder, targetType, weakRefStructLT, headerLE, sourceInterfaceFatPtrLE.refLE);
}
// Makes a non-weak interface ref into a weak interface ref
Makes a non-weak interface ref into a weak interface ref
Makes a non - weak interface ref into a weak interface ref
WeakFatPtrLE LgtWeaks::assembleInterfaceWeakRef(
    FunctionState* functionState,
    LLVMBuilderRef builder,
    Reference* sourceType,
    Reference* targetType,
    InterfaceKind* interfaceKindM,
    InterfaceFatPtrLE sourceInterfaceFatPtrLE) {
  assert(sourceType->ownership == Ownership::OWN || sourceType->ownership == Ownership::SHARE);
  auto controlBlockPtrLE =
      kindStructsSource->getControlBlockPtr(
          FL(), functionState, builder, interfaceKindM, sourceInterfaceFatPtrLE);
  auto lgtiLE = getLgtiFromControlBlockPtr(globalState, builder, kindStructsSource, sourceType,
      controlBlockPtrLE);
  auto currentGenLE = getActualGenFromLGT(functionState, builder, lgtiLE);
  auto headerLE = makeLgtiHeader(globalState, weakRefStructsSource, builder, interfaceKindM, lgtiLE, currentGenLE);
  auto weakRefStructLT =
      weakRefStructsSource->getInterfaceWeakRefStruct(interfaceKindM);
  return fatWeaks_.assembleWeakFatPtr(
      functionState, builder, targetType, weakRefStructLT, headerLE, sourceInterfaceFatPtrLE.refLE);
}
WeakFatPtrLE LgtWeaks :: assembleInterfaceWeakRef ( FunctionState * functionState , LLVMBuilderRef builder , Reference * sourceType , Reference * targetType , InterfaceKind * interfaceKindM , InterfaceFatPtrLE sourceInterfaceFatPtrLE ) { assert ( sourceType -> ownership == Ownership :: OWN || sourceType -> ownership == Ownership :: SHARE ) ; auto controlBlockPtrLE = kindStructsSource -> getControlBlockPtr ( FL ( ) , functionState , builder , interfaceKindM , sourceInterfaceFatPtrLE ) ; auto lgtiLE = getLgtiFromControlBlockPtr ( globalState , builder , kindStructsSource , sourceType , controlBlockPtrLE ) ; auto currentGenLE = getActualGenFromLGT ( functionState , builder , lgtiLE ) ; auto headerLE = makeLgtiHeader ( globalState , weakRefStructsSource , builder , interfaceKindM , lgtiLE , currentGenLE ) ; auto weakRefStructLT = weakRefStructsSource -> getInterfaceWeakRefStruct ( interfaceKindM ) ; return fatWeaks_ . assembleWeakFatPtr ( functionState , builder , targetType , weakRefStructLT , headerLE , sourceInterfaceFatPtrLE . refLE ) ; }
Makes a non-weak interface ref into a weak interface ref
Makes a non - weak interface ref into a weak interface ref
// curious, if its a borrow, do we just return sourceRefLE?