예제 #1
0
파일: Post.java 프로젝트: hofmeister/Webi
  private static void put(ArrayValue array, Value key, Value value, boolean addSlashes) {
    if (addSlashes && value.isString()) {
      value = StringModule.addslashes(value.toStringValue());
    }

    if (key == null) array.put(value);
    else array.put(key, value);
  }
예제 #2
0
  public BinaryStream fopen(Env env, StringValue path, StringValue mode, LongValue options) {
    boolean useIncludePath = (options.toLong() & StreamModule.STREAM_USE_PATH) != 0;

    Value pathComponent = UrlModule.parse_url(env, path, UrlModule.PHP_URL_PATH);

    if (!pathComponent.isset()) {
      log.info(L.l("no path component found in '{0}'", path.toString()));
      return null;
    }

    return ZlibModule.gzopen(
        env, pathComponent.toStringValue(env), mode.toString(), useIncludePath);
  }
예제 #3
0
 public void setValue(Interpreter interpreter, final Value targetValue) {
   if (this.getBaseType().equals(DataTypes.ANY_TYPE)
       || this.getBaseType().equals(targetValue.getType())) {
     this.content = targetValue;
     this.expression = null;
   } else if (this.getBaseType().equals(DataTypes.TYPE_STRICT_STRING)
       || this.getBaseType().equals(DataTypes.TYPE_STRING)) {
     this.content = targetValue.toStringValue();
     this.expression = null;
   } else if (this.getBaseType().equals(DataTypes.TYPE_INT)
       && targetValue.getType().equals(DataTypes.TYPE_FLOAT)) {
     this.content = targetValue.toIntValue();
     this.expression = null;
   } else if (this.getBaseType().equals(DataTypes.TYPE_FLOAT)
       && targetValue.getType().equals(DataTypes.TYPE_INT)) {
     this.content = targetValue.toFloatValue();
     this.expression = null;
   } else {
     throw new ScriptException(
         "Internal error: Cannot assign " + targetValue.getType() + " to " + this.getType());
   }
 }
예제 #4
0
  public void aset(final int index, final Value val, final Interpreter interpreter) {
    RecordType type = (RecordType) this.type;
    int size = type.fieldCount();
    if (index < 0 || index >= size) {
      throw interpreter.runtimeException("Internal error: field index out of bounds");
    }

    Value[] array = (Value[]) this.content;

    if (array[index].getType().equals(val.getType())) {
      array[index] = val;
    } else if (array[index].getType().equals(DataTypes.TYPE_STRING)) {
      array[index] = val.toStringValue();
    } else if (array[index].getType().equals(DataTypes.TYPE_INT)
        && val.getType().equals(DataTypes.TYPE_FLOAT)) {
      array[index] = val.toIntValue();
    } else if (array[index].getType().equals(DataTypes.TYPE_FLOAT)
        && val.getType().equals(DataTypes.TYPE_INT)) {
      array[index] = val.toFloatValue();
    } else {
      throw interpreter.runtimeException(
          "Internal error: Cannot assign " + val.getType() + " to " + array[index].getType());
    }
  }
예제 #5
0
 @Test
 public void testToStringValue() {
   assertEquals("-123", mNegativeValue.toStringValue().toString());
   assertEquals("0", mZeroValue.toStringValue().toString());
   assertEquals("123", mPositiveValue.toStringValue().toString());
 }