예제 #1
0
void PropagateTypeTasklet::EditInstruction(Instruction* const inst_ptr) {
  auto& inst = *inst_ptr;

  if (auto const fieldptr_inst = inst.DynamicCast<FieldPtrI>()) {
    if (auto const r1 = fieldptr_inst->GetRx()) {
      if (auto const vardef_inst = r1->GetDefI()->DynamicCast<VarDefI>()) {
        auto& cell_class = *vardef_inst->output_type()
          .StaticCast<ConstructedClass>();

        fieldptr_inst->GetOperandBox(1)->Replace(*cell_class.Find(*Q_value));

        UpdateOutputType(
          inst,
          PointerType::Intern(cell_class.GetTypeArg()));
      }
    }

  } else if (inst.Is<LoadI>()) {
    if (auto const  ptrty =
            inst.GetSx()->GetTy().DynamicCast<PointerType>()) {
      UpdateOutputType(inst, ptrty->pointee_type());
    } else {
      AddErrorInfo(
        VmErrorInfo(
            inst.source_info(),
            VmError_Instruction_Invalid,
            inst,
            String::Format("Expect pointer type: %s", inst.op0().GetTy())));
    }

  } else if (auto const select_inst = inst.DynamicCast<SelectI>()) {
    auto const nth = select_inst->GetIy();
    auto& valsty = *select_inst->GetVx()->GetDefI()->output_type()
            .StaticCast<ValuesType>();
    if (nth >= valsty.Count()) {
      AddErrorInfo(
        VmErrorInfo(
            inst.source_info(),
            VmError_Instruction_Invalid,
            inst,
            String::Format("Too large index(%d) for %s", nth, valsty)));
      return;
    }

    UpdateOutputType(inst, valsty.Get(nth));

  } else if (auto const vardef_inst = inst.DynamicCast<VarDefI>()) {
    auto& ty = vardef_inst->GetSy()->GetTy();
    UpdateOutputType(inst, Ty_ClosedCell->Construct(ty));

  } else {
    UpdateOutputType(inst, inst.output_type());
  }
}
예제 #2
0
/*===========================================================================
 *
 * Class CSrErrorDlg Method - void AddLastError (void);
 *
 *=========================================================================*/
void CSrErrorDlg::AddLastError (void) {
  CSrError* pError;

  pError = SrErrorHandler->GetLastError();
  if (pError != NULL) pError->SetTag(1);
  AddErrorInfo(pError, -1);

}
예제 #3
0
/*===========================================================================
 *
 * Class CSrErrorDlg Method - void AddAllErrors (void);
 *
 *=========================================================================*/
void CSrErrorDlg::AddAllErrors (void) {
  CSrError* pError;
  dword     Index;

  for (Index = 0; Index < SrErrorHandler->GetNumErrors(); ++Index) {
    pError = SrErrorHandler->GetError(Index);
    pError->SetTag(1);
    AddErrorInfo(pError, Index + 1);
  }

}
예제 #4
0
/*===========================================================================
 *
 * Class CSrErrorDlg Method - void AddAllUntaggedErrors (void);
 *
 *=========================================================================*/
void CSrErrorDlg::AddAllUntaggedErrors (void) {
  CSrError* pError;
  dword     Index;
  dword     Count = 0;

  for (Index = 0; Index < SrErrorHandler->GetNumErrors(); ++Index) {
    pError = SrErrorHandler->GetError(Index);
    if (pError->GetTag() > 0) continue;
    pError->SetTag(1);
    ++Count;
    AddErrorInfo(pError, Count);
  }

}