/**
   * Evaluates the expression.
   *
   * @param env the calling environment.
   * @return the expression value.
   */
  @Override
  public Value eval(Env env) {
    Value qThis = env.getThis();

    QuercusClass cls = qThis.getQuercusClass();

    if (cls == null) {
      env.error(L.l("no calling class found"), getLocation());

      return NullValue.NULL;
    }

    StringValue methodName = _methodName.evalStringValue(env);
    int hash = methodName.hashCodeCaseInsensitive();

    Value[] values = evalArgs(env, _args);

    env.pushCall(this, cls, values);

    try {
      env.checkTimeout();

      return cls.callMethod(env, qThis, methodName, hash, values);
    } finally {
      env.popCall();
    }
  }
Ejemplo n.º 2
0
  /**
   * Evaluates the expression.
   *
   * @param env the calling environment.
   * @return the expression value.
   */
  @Override
  public Var evalVar(Env env) {
    // quercus/0d1k
    Value value = env.getThis();

    return value.getThisFieldVar(env, _nameExpr.evalStringValue(env));
  }
Ejemplo n.º 3
0
  /**
   * Evaluates the expression.
   *
   * @param env the calling environment.
   * @return the expression value.
   */
  @Override
  public Value evalAssignRef(Env env, Value value) {
    Value obj = env.getThis();

    obj.putThisField(env, _nameExpr.evalStringValue(env), value);

    return value;
  }
Ejemplo n.º 4
0
  /** Evaluates as an array index assign ($a[index] = &value). */
  @Override
  public Value evalArrayAssignRef(Env env, Expr indexExpr, Expr valueExpr) {
    Value obj = env.getThis();

    StringValue name = _nameExpr.evalStringValue(env);

    Value fieldVar = obj.getThisFieldArray(env, name);
    Value index = indexExpr.eval(env);

    Value value = valueExpr.evalRef(env);

    // php/03mn
    return fieldVar.putThisFieldArray(env, obj, name, index, value);
  }
Ejemplo n.º 5
0
  /**
   * Evaluates the expression.
   *
   * @param env the calling environment.
   * @param ctx
   * @return the expression value.
   */
  @Override
  @Nonnull
  protected V<? extends ValueOrVar> _eval(Env env, FeatureExpr ctx) {
    QuercusClass cl = env.findClass(_className);

    if (cl == null) {
      env.error(L.l("no matching class {0}", _className), getLocation());
    }

    // qa/0954 - static calls pass the current $this
    Value qThis = env.getThis();

    StringValue methodName = _nameExpr.evalStringValue(env, ctx).getOne();

    V<? extends ValueOrVar>[] args = evalArgs(env, _args, ctx);
    int hash = methodName.hashCodeCaseInsensitive();

    return cl.callStaticMethod(env, ctx, qThis, methodName, hash, args).map((a) -> a.toValue());
  }
Ejemplo n.º 6
0
  /**
   * Evaluates the expression.
   *
   * @param env the calling environment.
   * @return the expression value.
   */
  @Override
  public Value eval(Env env) {
    Value obj = env.getThis();

    return obj.getThisField(env, _nameExpr.evalStringValue(env));
  }
Ejemplo n.º 7
0
  /**
   * Evaluates the expression.
   *
   * @param env the calling environment.
   * @return the expression value.
   */
  @Override
  public Value evalArg(Env env, boolean isTop) {
    Value value = env.getThis();

    return value.getThisFieldArg(env, _nameExpr.evalStringValue(env));
  }
Ejemplo n.º 8
0
  /**
   * Evaluates the expression.
   *
   * @param env the calling environment.
   * @return the expression value.
   */
  public void evalUnset(Env env) {
    Value obj = env.getThis();

    obj.unsetThisField(_nameExpr.evalStringValue(env));
  }
Ejemplo n.º 9
0
  /**
   * Evaluates the expression, creating an object if the field is unset.
   *
   * @param env the calling environment.
   * @return the expression value.
   */
  public Value evalObject(Env env) {
    Value obj = env.getThis();

    return obj.getThisFieldObject(env, _nameExpr.evalStringValue(env));
  }
Ejemplo n.º 10
0
  /**
   * Evaluates the expression, creating an array if the field is unset.
   *
   * @param env the calling environment.
   * @return the expression value.
   */
  public Value evalArray(Env env) {
    Value obj = env.getThis();

    return obj.getThisFieldArray(env, _nameExpr.evalStringValue(env));
  }