Example #1
0
void FunctionScope::setParamCounts(AnalysisResultConstPtr ar, int minParam,
                                   int numDeclParam) {
    if (minParam >= 0) {
        m_minParam = minParam;
        m_numDeclParams = numDeclParam;
    } else {
        assert(numDeclParam == minParam);
    }
    assert(m_minParam >= 0 && m_numDeclParams >= m_minParam);
    assert(IMPLIES(hasVariadicParam(), m_numDeclParams > 0));
    if (m_numDeclParams > 0) {
        m_paramNames.resize(m_numDeclParams);
        m_refs.resize(m_numDeclParams);

        if (m_stmt) {
            MethodStatementPtr stmt = dynamic_pointer_cast<MethodStatement>(m_stmt);
            ExpressionListPtr params = stmt->getParams();

            for (int i = 0; i < m_numDeclParams; i++) {
                if (stmt->isRef(i)) m_refs[i] = true;

                ParameterExpressionPtr param =
                    dynamic_pointer_cast<ParameterExpression>((*params)[i]);
                m_paramNames[i] = param->getName();
            }
            assert(m_paramNames.size() == m_numDeclParams);
        }
    }
}
Example #2
0
void FunctionScope::setParamCounts(AnalysisResultPtr ar, int minParam,
                                   int maxParam) {
  m_minParam = minParam;
  m_maxParam = maxParam;
  ASSERT(m_minParam >= 0 && m_maxParam >= m_minParam);
  if (m_maxParam > 0) {
    m_paramNames.resize(m_maxParam);
    m_paramTypes.resize(m_maxParam);
    m_paramTypeSpecs.resize(m_maxParam);
    m_refs.resize(m_maxParam);

    if (m_stmt) {
      MethodStatementPtr stmt = dynamic_pointer_cast<MethodStatement>(m_stmt);
      ExpressionListPtr params = stmt->getParams();

      for (int i = 0; i < m_maxParam; i++) {
        if (stmt->isRef(i)) m_refs[i] = true;

        ParameterExpressionPtr param =
          dynamic_pointer_cast<ParameterExpression>((*params)[i]);
        m_paramNames[i] = param->getName();
        m_paramTypeSpecs[i] = param->getTypeSpec(ar);
      }
    }
  }
}