/**
   * 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();
    }
  }
示例#2
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());
  }
示例#3
0
 protected static Value wrapJava(Env env, QuercusClass cls, SimpleXMLElement element) {
   if (!"SimpleXMLElement".equals(cls.getName()))
     return new ObjectExtJavaValue(cls, element, cls.getJavaClassDef());
   else return new JavaValue(env, element, cls.getJavaClassDef());
 }