Пример #1
0
bool get_call_info(const CallInfo *&ci, void *&extra,
                   const char *s, strhash_t hash) {
  extra = NULL;
  const char *ss = get_renamed_function(s);
  if (ss != s) { s = ss; hash = -1; }
  return get_call_info_builtin(ci, extra, s, hash);
}
void FunctionStatement::init(void *parser, bool ref,
                             const vector<ParameterPtr> &params,
                             StatementListStatementPtr body,
                             bool has_call_to_get_args) {
  m_ref = ref;
  m_params = params;
  m_body = body;
  m_hasCallToGetArgs = has_call_to_get_args;
  const CallInfo* cit1;
  void* vt1;
  if (get_call_info_no_eval(cit1, vt1, m_name)) {
    m_invalid =
      get_call_info_builtin(cit1, vt1, m_name->data(), m_name->hash()) ? -1 : 1;
  }

  bool seenOptional = false;
  set<string> names;
  m_callInfo.m_argCount = m_closureCallInfo.m_argCount = m_params.size();
  for (unsigned int i = 0; i < m_params.size(); i++) {
    ParameterPtr param = m_params[i];

    std::string name = param->name();
    if (names.find(name) != names.end()) {
      raise_notice("%s:%d %s() has 2 parameters with the same name: $%s",
                   m_loc.file, m_loc.line0, m_name.c_str(), name.c_str());
    } else {
      names.insert(name);
    }

    if (!seenOptional) {
      if (param->isOptional()) {
        seenOptional = true;
      }
    } else if (!param->isOptional()) {
/*
      raise_notice("%s:%d %s() has required parameter after optional one: $%s",
                   m_loc.file, m_loc.line0, m_name.c_str(), name.c_str());
*/
      param->addNullDefault(parser);
    }
    if (param->isRef()) {
      m_callInfo.m_refFlags        |= 1 << i;
      m_closureCallInfo.m_refFlags |= 1 << i;
    }

    if (param->getIdx() == -1) {
      param->setIdx(declareVariable(name));
    }
  }
}
bool get_call_info_no_eval(const CallInfo *&ci, void *&extra, const char *s, int64 hash) {
  DECLARE_GLOBAL_VARIABLES(g);
  extra = NULL;
  if (hash < 0) hash = hash_string(s);
  const hashNodeFunc *p = findFunc(s, hash);
  if (LIKELY(p!=0)) {
    if (UNLIKELY(p->offset)) {
      const char *addr = (const char *)g + (int64)p->data;
      ci = *(const CallInfo **)addr;
      return ci != 0;
    } else {
      ci = (const CallInfo *)p->data;
      return true;
    }
  }
  return get_call_info_builtin(ci, extra, s, hash);
}
Пример #4
0
bool get_call_info_no_eval(const CallInfo *&ci, void *&extra,
                           const char *s, strhash_t hash) {
  extra = NULL;
  return get_call_info_builtin(ci, extra, s, hash);
}