int Variable::Compare(const Variable *v0, const Variable *v1)
{
  TryCompareObjects(v0->GetId(), v1->GetId(), BlockId);
  TryCompareValues(v0->Kind(), v1->Kind());
  TryCompareObjects(v0->GetName(false), v1->GetName(false), String);
  if (v0->Kind() == VK_Arg)
    TryCompareValues(v0->GetIndex(), v1->GetIndex());

  // do not compare source names.
  return 0;
}
Example #2
0
File: type.cpp Project: wh5a/xgill
int CompositeCSU::Compare(const CompositeCSU *csu0, const CompositeCSU *csu1)
{
  // we assume the names of different CSU's are unique, so just checking
  // the name is enough.
  TryCompareObjects(csu0->GetName(), csu1->GetName(), String);
  return 0;
}
Example #3
0
int BlockModset::Compare(const BlockModset *mod0, const BlockModset *mod1)
{
  BlockId *id0 = mod0->GetId();
  BlockId *id1 = mod1->GetId();
  TryCompareObjects(id0, id1, BlockId);
  return 0;
}
Example #4
0
File: type.cpp Project: wh5a/xgill
int Field::Compare(const Field *f0, const Field *f1)
{
  TryCompareObjects(f0->GetCSUType(), f1->GetCSUType(), Type);
  TryCompareObjects(f0->GetName(), f1->GetName(), String);

  // in general, the name/index/CSU data should be enough to distinguish
  // different fields. however, in some frontend error cases we can get
  // confused when making fields and we want to check the other components
  // of the field.

  TryCompareObjects(f0->GetSourceName(), f1->GetSourceName(), String);
  TryCompareObjects(f0->GetType(), f1->GetType(), Type);

  TryCompareValues((int)f0->IsInstanceFunction(),
                   (int)f1->IsInstanceFunction());
  return 0;
}
Example #5
0
int Field::Compare(const Field *f0, const Field *f1)
{
  TryCompareObjects(f0->GetCSUType(), f1->GetCSUType(), Type);
  TryCompareObjects(f0->GetName(), f1->GetName(), String);
  TryCompareValues((int)f0->IsInstanceFunction(),
                   (int)f1->IsInstanceFunction());

  if (f0->GetType() != f1->GetType()) {
    logout << "Warning: Field mismatch on " << f0 << ": "
           << f0->GetType() << " " << f1->GetType() << endl;

    Type *preferred = DropType(f0->GetType()) ? f1->GetType() : f0->GetType();
    ((Field*) f0)->m_type = preferred;
    ((Field*) f1)->m_type = preferred;
  }

  return 0;
}
Example #6
0
File: type.cpp Project: wh5a/xgill
int Type::Compare(const Type *y0, const Type *y1)
{
  TryCompareValues(y0->Kind(), y1->Kind());

  switch (y0->Kind()) {
  case YK_Void:
  case YK_Error:
    break;
  case YK_Int:
  case YK_Float:
    TryCompareValues(y0->Width(), y1->Width());
    TryCompareValues((int)y0->IsSigned(), (int)y1->IsSigned());
    break;
  case YK_Pointer: {
    // we shouldn't ever see pointers with different widths.
    Assert(y0->Width() == y1->Width());

    const TypePointer *ny0 = (const TypePointer*)y0;
    const TypePointer *ny1 = (const TypePointer*)y1;
    TryCompareObjects(ny0->GetTargetType(), ny1->GetTargetType(), Type);
    break;
  }
  case YK_Array: { 
    const TypeArray *ny0 = (const TypeArray*)y0;
    const TypeArray *ny1 = (const TypeArray*)y1;
    TryCompareObjects(ny0->GetElementType(), ny1->GetElementType(), Type);
    TryCompareValues(ny0->GetElementCount(), ny1->GetElementCount());
    break;
  }
  case YK_CSU: {
    const TypeCSU *ny0 = (const TypeCSU*)y0;
    const TypeCSU *ny1 = (const TypeCSU*)y1;
    TryCompareObjects(ny0->GetCSUName(), ny1->GetCSUName(), String);
    break;
  }
  case YK_Function: {
    const TypeFunction *ny0 = (const TypeFunction*)y0;
    const TypeFunction *ny1 = (const TypeFunction*)y1;
    TryCompareObjects(ny0->GetReturnType(), ny1->GetReturnType(), Type);
    TryCompareObjects(ny0->GetCSUType(), ny1->GetCSUType(), Type);
    TryCompareValues((int)ny0->IsVarArgs(), (int)ny1->IsVarArgs());
    TryCompareValues(ny0->GetArgumentCount(), ny1->GetArgumentCount());
    for (size_t aind = 0; aind < ny0->GetArgumentCount(); aind++) {
      Type *arg0 = ny0->GetArgumentType(aind);
      Type *arg1 = ny1->GetArgumentType(aind);
      TryCompareObjects(arg0, arg1, Type);
    }
    break;
  }
  default:
    Assert(false);
  }

  return 0;
}
int Location::Compare(const Location *l0, const Location *l1)
{
  TryCompareObjects(l0->m_filename, l1->m_filename, String);
  TryCompareValues(l0->m_line, l1->m_line);
  return 0;
}
Example #8
0
int BlockSummary::Compare(const BlockSummary *sum0, const BlockSummary *sum1)
{
  TryCompareObjects(sum0->GetId(), sum1->GetId(), BlockId);
  return 0;
}