TypePtr DynamicFunctionCall::inferTypes(AnalysisResultPtr ar, TypePtr type,
                                        bool coerce) {
  reset();
  ConstructPtr self = shared_from_this();
  if (!m_className.empty()) {
    ClassScopePtr cls = resolveClass();
    if (!cls) {
      if (isRedeclared()) {
        getScope()->getVariables()->
          setAttribute(VariableTable::NeedGlobalPointer);
      } else if (getScope()->isFirstPass()) {
        Compiler::Error(Compiler::UnknownClass, self);
      }
    } else {
      m_classScope = cls;
    }
  }

  ar->containsDynamicFunctionCall();

  if (m_class) {
    m_class->inferAndCheck(ar, Type::Any, false);
  }
  m_nameExp->inferAndCheck(ar, Type::String, false);
  if (m_params) {
    for (int i = 0; i < m_params->getCount(); i++) {
      (*m_params)[i]->inferAndCheck(ar, Type::Variant, true);
    }
  }
  return Type::Variant;
}
Exemplo n.º 2
0
TypePtr DynamicFunctionCall::inferTypes(AnalysisResultPtr ar, TypePtr type,
                                        bool coerce) {
    reset();
    ConstructPtr self = shared_from_this();
    if (!m_className.empty()) {
        ClassScopePtr cls = ar->resolveClass(m_className);
        if (!cls || cls->isRedeclaring()) {
            if (cls) {
                m_redeclared = true;
                ar->getScope()->getVariables()->
                setAttribute(VariableTable::NeedGlobalPointer);
            }
            if (!cls && ar->isFirstPass()) {
                ar->getCodeError()->record(self, CodeError::UnknownClass, self);
            }
        } else {
            m_validClass = true;
        }
    }

    ar->containsDynamicFunctionCall();

    if (ar->isFirstPass()) {
        ar->getCodeError()->record(self, CodeError::UseDynamicFunction, self);
    }
    m_nameExp->inferAndCheck(ar, Type::String, false);
    if (m_params) {
        for (int i = 0; i < m_params->getCount(); i++) {
            (*m_params)[i]->inferAndCheck(ar, Type::Variant, true);
        }
    }
    return Type::Variant;
}