Пример #1
0
  /**
   * Evaluates the expression.
   *
   * @param env the calling environment.
   * @return the expression value.
   */
  @Override
  public Value evalCopy(Env env) {
    Value obj = env.getThis();

    if (obj.isNull()) {
      return cannotUseThisError(env);
    }

    return obj.getThisField(env, _name).copy();
  }
Пример #2
0
  /**
   * Evaluates the expression.
   *
   * @param env the calling environment.
   * @return the expression value.
   */
  @Override
  public Value evalArg(Env env, boolean isTop) {
    Value obj = env.getThis();

    if (obj.isNull()) {
      return cannotUseThisError(env);
    }

    return obj.getThisFieldArg(env, _name);
  }
Пример #3
0
  /**
   * Evaluates the expression.
   *
   * @param env the calling environment.
   * @return the expression value.
   */
  @Override
  public void evalUnset(Env env) {
    Value obj = env.getThis();

    if (obj.isNull()) {
      cannotUseThisError(env);
    }

    obj.unsetThisField(_name);
  }
Пример #4
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();

    if (obj.isNull()) {
      cannotUseThisError(env);
    }

    obj.putThisField(env, _name, value);

    return value;
  }
Пример #5
0
  /**
   * Evaluates the expression.
   *
   * @param env the calling environment.
   * @return the expression value.
   */
  @Override
  public Var evalVar(Env env) {
    Value obj = env.getThis();

    if (obj.isNull()) {
      cannotUseThisError(env);

      return new Var();
    }

    return obj.getThisFieldVar(env, _name);
  }
Пример #6
0
  /** Evaluates as an array index assign ($a[index] = value). */
  @Override
  public Value evalArrayAssign(Env env, Value index, Value value) {
    Value obj = env.getThis();

    if (obj.isNull()) {
      cannotUseThisError(env);
    }

    Value fieldVar = obj.getThisFieldVar(env, _name);

    // php/03mm
    return fieldVar.put(index, value);
  }
  /**
   * Evaluates the expression.
   *
   * @param env the calling environment.
   * @return the expression value.
   */
  @Override
  public Value eval(Env env) {
    Value qThis = env.getThis();

    BiancaClass cls = qThis.getBiancaClass();

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

      return NullValue.NULL;
    }

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

    env.pushCall(this, cls, values);

    try {
      return cls.callMethod(env, qThis, _methodName, _hash, values);
    } finally {
      env.popCall();
    }
  }
Пример #8
0
  @Override
  protected int getMarshalingCostImpl(Value argValue) {
    return argValue.toCharMarshalCost();

    /*
    if (argValue.isUnicode() && argValue.length() == 1)
    return Marshal.ONE;
    else if (argValue.isString()
    &&  !argValue.isBinary() && argValue.length() == 1)
    return Marshal.ONE; // php/0ch0
    else if (argValue.isLongConvertible())
    return Marshal.THREE;
    else
    return Marshal.FOUR;
     */
  }
Пример #9
0
  /** Returns the trace. */
  public static Value getTraceAsString(Env env, @This Value obj) {
    Value trace = getTrace(env, obj);

    StringValue sb = new StringValue();
    sb.append("<trace>");

    Iterator<Value> iter = trace.getValueIterator(env);

    while (iter.hasNext()) {
      Value value = iter.next();

      sb = sb.append('\n');
      sb = sb.append(value.get(FILE));
      sb = sb.append(':');
      sb = sb.append(value.get(LINE));
      sb = sb.append(": ");
      sb = sb.append(value.get(FUNCTION));
    }

    return sb;
  }
Пример #10
0
 /** Returns the trace. */
 public static Value getJavaException(Env env, @This Value obj) {
   return obj.getField(env, JAVA_EXCEPTION);
 }
Пример #11
0
 /** Returns the trace. */
 public static Value getTrace(Env env, @This Value obj) {
   return obj.getField(env, TRACE);
 }
Пример #12
0
 @Override
 public Object marshal(Env env, Value value, Class expectedClass) {
   return new Character(value.toChar());
 }