/** Remove a constraint
 * @param parName :: The name of a parameter which constarint to remove.
 */
void CompositeFunction::removeConstraint(const std::string &parName) {
  auto i = parameterIndex(parName);
  auto constraint = IFunction::getConstraint(i);
  if (constraint != nullptr) {
    IFunction::removeConstraint(parName);
  } else {
    size_t iPar = parameterIndex(parName);
    size_t iFun = functionIndex(iPar);
    getFunction(iFun)->removeConstraint(parameterLocalName(iPar));
  }
}
/** Remove a constraint
 * @param parName :: The name of a parameter which constarint to remove.
 */
void ParamFunction::removeConstraint(const std::string &parName) {
  size_t iPar = parameterIndex(parName);
  for (auto it = m_constraints.begin(); it != m_constraints.end(); ++it) {
    if (iPar == (**it).getIndex()) {
      delete *it;
      m_constraints.erase(it);
      break;
    }
  }
}
Beispiel #3
0
void Database::Statement::output(const Pair &pair)
{
	String key;
	LineSerializer keySerializer(&key);
	pair.serializeKey(keySerializer);
	key.trim();
	
	int parameter = parameterIndex(key);
	if(parameter != 0) 
	{
		mOutputParameter = parameter;
		++mOutputLevel;
		pair.serializeValue(*this);
		--mOutputLevel;
	}
}
Beispiel #4
0
/** Removes the tie off a parameter. The parameter becomes active
 * This method can be used when constructing and editing the IFunction in a GUI
 * @param parName :: The name of the parameter which ties will be removed.
 */
void IFunction::removeTie(const std::string& parName)
{
  size_t i = parameterIndex(parName);
  this->removeTie(i);
}
Beispiel #5
0
bool CallCandidate::isMoreSpecific(const CallCandidate * other) const {
  bool same = true;

  if (paramAssignments_.size() != other->paramAssignments_.size()) {
    diag.info() << "different number of args.";
    return false;
  }

  // TODO: Factor in return type.

  /*if (!resultType()->isEqual(other->resultType())) {
    if (!resultType()->isSubtype(other->resultType())) {
      return false;
    }

    same = false;
  }*/

  // Note - I think we want to compare candidates in their *unbound* state.
  // So other than type aliases, we don't want to dereference any types.
  size_t argCount = paramAssignments_.size();
  for (size_t i = 0; i < argCount; ++i) {
    QualifiedType t0 = paramType(i);
    QualifiedType t1 = other->paramType(i);

    TypeRelation::RelativeSpecificity rspec = TypeRelation::isMoreSpecific(t0, t1);
    if (rspec == TypeRelation::NOT_MORE_SPECIFIC) {
      return false;
    } else if (rspec == TypeRelation::MORE_SPECIFIC) {
      same = false;
    } else {
      // Variadic parameters are less specific than non-variadic parameters.
      const ParameterDefn * p0 = fnType_->param(parameterIndex(i));
      const ParameterDefn * p1 = other->fnType_->param(other->parameterIndex(i));
      if (p0->isVariadic()) {
        if (!p1->isVariadic()) {
          return false;
        }
      } else if (p1->isVariadic()) {
        same = false;
      }
    }
  }

  if (same) {
    // If this method has fewer default params than the other, then it is more
    // specific.
    if (method_->params().size() < other->method()->params().size()) {
      return true;
    }

    // If one is a template, than it is less specific than the other.
    // TODO: If they are both templates, choose the one with the smaller number
    // of template parameters. Although explicitly bound parameters should not count, only
    // deduced parameters.
    if (!method_->isTemplate() && other->method()->isTemplate()) {
      return true;
    }

    if (method_->isTemplate() && !other->method()->isTemplate()) {
      return false;
    }

    if (typeParams_ == NULL && other->typeParams_ != NULL) {
      return true;
    }

    if (typeParams_ != NULL && other->typeParams_ != NULL) {
    }

    // TODO: This is a temporary kludge - should really compare the two template parameter
    // lists and see which one is more tightly bound.
    if (!method_->hasUnboundTypeParams() && other->method()->hasUnboundTypeParams()) {
      return true;
    }

    if (conditionCount_ > other->conditionCount_) {
      return true;
    }
  }

  // Return true if they are not the same.
  return !same;
}
Beispiel #6
0
QualifiedType CallCandidate::paramType(int argIndex) const {
  return paramTypes_[parameterIndex(argIndex)];
}
Beispiel #7
0
/** Remove a constraint
 * @param parName :: The name of a parameter which constarint to remove.
 */
void CompositeFunction::removeConstraint(const std::string &parName) {
  size_t iPar = parameterIndex(parName);
  size_t iFun = functionIndex(iPar);
  getFunction(iFun)->removeConstraint(parameterLocalName(iPar));
}