/** * 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(); }
/** * 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); }
/** * 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); }
/** * 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; }
/** * 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); }
/** 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(); } }
@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; */ }
/** 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; }
/** Returns the trace. */ public static Value getJavaException(Env env, @This Value obj) { return obj.getField(env, JAVA_EXCEPTION); }
/** Returns the trace. */ public static Value getTrace(Env env, @This Value obj) { return obj.getField(env, TRACE); }
@Override public Object marshal(Env env, Value value, Class expectedClass) { return new Character(value.toChar()); }