Exemple #1
0
void Parser::onStaticMember(Token &out, Token &className, Token &name) {
  out.reset();
  TempExpressionListPtr texp = name->getExp<TempExpressionList>();
  ArrayElementExpressionPtr arr = name->getExp<ArrayElementExpression>();
  if (!arr && texp) {
    arr = texp->getLast()->unsafe_cast<ArrayElementExpression>();
  }
  NamePtr cn = procStaticClassName(className, false);
  if (arr) {
    arr->sinkStaticMember(this, cn);
    out->exp() = name->exp();
  } else {
    NamePtr n;
    VariableExpressionPtr var = name->getExp<VariableExpression>();
    if (var) {
      n = var->getName();
      ASSERT(n);
      out->exp() = NEW_EXP(StaticMember, cn, n);
    } else {
      ASSERT(texp);
      var = texp->getLast()->unsafe_cast<VariableExpression>();
      ASSERT(var);
      n = var->getName();
      ASSERT(n);
      out->exp() = NEW_EXP(StaticMember, cn, n);
      texp->setLast(out->exp());
      out->exp() = texp;
    }
  }
}
Exemple #2
0
void Parser::onStaticMember(Token &out, Token &className, Token &name) {
  out.reset();
  ArrayElementExpressionPtr arr = name->getExp<ArrayElementExpression>();
  NamePtr cn = procStaticClassName(className, false);
  if (arr) {
    arr->sinkStaticMember(this, cn);
    out->exp() = name->exp();
  } else {
    NamePtr n;
    VariableExpressionPtr var = name->getExp<VariableExpression>();
    if (var) {
      n = var->getName();
    }
    ASSERT(n);
    out->exp() = NEW_EXP(StaticMember, cn, n);
  }
}
void ArrayElementExpression::sinkStaticMember(Parser *parser,
                                              const NamePtr &className) {
  ArrayElementExpressionPtr arr = m_arr->unsafe_cast<ArrayElementExpression>();
  if (arr) {
    arr->sinkStaticMember(parser, className);
    return;
  }

  VariableExpressionPtr var = m_arr->unsafe_cast<VariableExpression>();
  if (var) {
    m_arr =
      StaticMemberExpressionPtr(new StaticMemberExpression(parser,
                                                           className,
                                                           var->getName()));
    return;
  }
  ASSERT(false);
}
Exemple #4
0
void Parser::onStaticMember(Token &out, Token &className, Token &name) {
  out.reset();
  ArrayElementExpressionPtr arr = name->getExp<ArrayElementExpression>();
  string cn = className.getText();
  if (haveClass()) {
    if (cn == "self") {
      cn = peekClass()->name();
    } else if (cn == "parent") {
      cn = peekClass()->parent();
    }
  }
  if (arr) {
    arr->sinkStaticMember(this, cn);
    out->exp() = name->exp();
  } else {
    NamePtr n;
    VariableExpressionPtr var = name->getExp<VariableExpression>();
    if (var) {
      n = var->getName();
    }
    ASSERT(n);
    out->exp() = NEW_EXP(StaticMember, cn, n);
  }
}