本文整理了Java中php.runtime.Memory.isString()
方法的一些代码示例,展示了Memory.isString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Memory.isString()
方法的具体详情如下:
包路径:php.runtime.Memory
类名称:Memory
方法名:isString
暂无
代码示例来源:origin: jphp-group/jphp
@Immutable
public static boolean is_string(Memory memory) {
return memory.isString();
}
代码示例来源:origin: jphp-group/jphp
@Override
public boolean isString() {
return getValue().isString();
}
代码示例来源:origin: jphp-group/jphp
@Override
public Memory bitXor(Memory memory) {
if(memory.isString())
return OperatorUtils.binaryXor(this, memory);
else
return super.bitXor(memory);
}
代码示例来源:origin: jphp-group/jphp
@Override
public Memory bitAnd(Memory memory) {
if(memory.isString())
return OperatorUtils.binaryAnd(this, memory);
else
return super.bitAnd(memory);
}
代码示例来源:origin: jphp-group/jphp
@Override
public Memory bitOr(Memory memory) {
if(memory.isString())
return OperatorUtils.binaryOr(this, memory);
else
return super.bitOr(memory);
}
代码示例来源:origin: jphp-group/jphp
@Immutable
public static Memory stristr(String haystack, Memory needleV) {
String needleLower;
if (needleV.isString()) {
needleLower = needleV.toString().toLowerCase();
} else {
char lower = Character.toLowerCase((char) needleV.toLong());
needleLower = String.valueOf(lower);
}
String haystackLower = haystack.toLowerCase();
int i = haystackLower.indexOf(needleLower);
if (i >= 0) {
return new StringMemory(haystack.substring(i));
} else {
return Memory.FALSE;
}
}
代码示例来源:origin: jphp-group/jphp
public Memory setConfigValue(String name, Memory value) {
value = value.toValue();
if (!value.isString())
value = new StringMemory(value.toString()); // fix capability with zend php
ConfigChangeHandler handler = configurationHandler.get(name);
if (handler != null)
handler.onChange(this, value);
return configuration.put(name, value);
}
代码示例来源:origin: jphp-group/jphp
@Override
public int read() throws IOException {
Memory result = stream.read(env, Memory.CONST_INT_1);
return result.isString() ? result.getBinaryBytes(env.getDefaultCharset())[0] & 0xFF : -1;
}
代码示例来源:origin: jphp-group/jphp
@Override
public int read(byte[] b, int off, int len) throws IOException {
Memory result = stream.read(env, LongMemory.valueOf(len));
if (!result.isString())
return -1;
byte[] copy = result.getBinaryBytes(env.getDefaultCharset());
System.arraycopy(copy, 0, b, off, copy.length);
return copy.length;
}
代码示例来源:origin: jphp-group/jphp
@Immutable
public static Memory strripos(Environment env, TraceInfo trace, String haystack, Memory needleV, Memory offsetV) {
String needle;
if (needleV.isString()) {
needle = needleV.toString();
} else {
needle = String.valueOf((char) needleV.toInteger());
}
int offset;
if (offsetV == null) {
offset = haystack.length();
} else {
offset = offsetV.toInteger();
if (haystack.length() < offset) {
env.warning(trace, "strripos(): offset cannot exceed string length");
return Memory.FALSE;
}
}
haystack = haystack.toLowerCase();
needle = needle.toLowerCase();
int pos = haystack.lastIndexOf(needle, offset);
if (pos < 0) {
return Memory.FALSE;
} else {
return LongMemory.valueOf(pos);
}
}
代码示例来源:origin: jphp-group/jphp
@Signature
public Memory __toString(Environment env, Memory... args) throws Throwable {
Memory memory = env.invokeMethod(this, "readFully");
if (memory.isString()) {
return memory;
} else {
return StringMemory.valueOf(memory.toString());
}
}
代码示例来源:origin: jphp-group/jphp
if (needle.isString()) {
search = needle.toString();
if (search.length() == 1) {
代码示例来源:origin: jphp-group/jphp
if (key.isString()){
printer.write('"');
printer.write(key.toString());
代码示例来源:origin: jphp-group/jphp
@Signature(@Arg(value = "group", optional = @Reflection.Optional("null")))
public Memory group(Environment env, Memory... args) {
Memory group = args[0];
if (group.isNull())
return StringMemory.valueOf(matcher.group());
else {
if (group.isString() || group.isObject()) {
Memory longMemory = StringMemory.toLong(group.toString(), false);
if (longMemory == null) {
return StringMemory.valueOf(matcher.group(group.toString()));
}
}
return StringMemory.valueOf(matcher.group(group.toInteger()));
}
}
代码示例来源:origin: jphp-group/jphp
try {
Memory result = entity.methodMagicToString.invokeDynamic(value, env, env.trace(), (Memory[]) null);
if (!result.isString()) {
env.error(
ErrorType.E_RECOVERABLE_ERROR, "Method %s must return a string value",
代码示例来源:origin: jphp-group/jphp
public static Memory get_class_methods(Environment env, TraceInfo trace, Memory value) {
ClassEntity entity;
if (value.isString()) {
entity = env.fetchClass(value.toString(), true);
} else if (value.isObject()) {
entity = value.toValue(ObjectMemory.class).getReflection();
} else {
env.warning(
trace, "get_class_methods(): Argument 1 must be string or object, %s given",
value.getRealType().toString()
);
return Memory.NULL;
}
if (entity == null)
return Memory.NULL;
ClassEntity context = env.getLastClassOnStack();
ArrayMemory result = new ArrayMemory();
for (MethodEntity el : entity.getMethods().values()) {
if (el.canAccess(env, context) == 0)
result.refOfPush().assign(el.getName());
}
return result.toConstant();
}
代码示例来源:origin: jphp-group/jphp
@Override
public Memory refOfIndex(TraceInfo trace, Memory index) {
needArray();
switch (getValue().type){
case STRING:
if (index.isString()){
int _index = -1;
Memory tmp = StringMemory.toLong(index.toString());
if (tmp != null)
_index = tmp.toInteger();
return CharMemory.valueOf(this, (StringMemory)this.getValue(), _index);
} else
return CharMemory.valueOf(this, (StringMemory)this.getValue(), (int)index.toNumeric().toLong());
default: return getValue().refOfIndex(trace, index);
}
}
代码示例来源:origin: jphp-group/jphp
@Override
public void write(GetVarExprToken getVar, boolean returnValue) {
if (!methodStatement.isDynamicLocal())
throw new ExpressionStmtCompiler.UnsupportedTokenException(getVar);
Memory result = expr.writeExpression(getVar.getName(), true, true, false);
if (result != null && result.isString()){
String name = result.toString();
LocalVariable variable = method.getLocalVariable(name);
if (variable != null){
if (returnValue)
expr.writeVarLoad(variable);
return;
}
}
expr.writePushLocal();
expr.writeExpression(getVar.getName(), true, false);
expr.writePopBoxing();
expr.writeSysDynamicCall(Memory.class, "refOfIndex", Memory.class, Memory.class);
if (!returnValue)
expr.writePopAll(1);
}
}
代码示例来源:origin: jphp-group/jphp
@Test
public void testMethods(){
Memory memory;
memory = runDynamic("class A { function b() { return 'foobar'; } } return new A()->b();", false);
Assert.assertTrue(memory.isString());
Assert.assertEquals("foobar", memory.toString());
memory = runDynamic("class A { static function b() { return 100500; } } return A::b();", false);
Assert.assertEquals(100500, memory.toLong());
memory = runDynamic("class A { static function b() { return 100500; } } return new A->b();", false);
Assert.assertEquals(100500, memory.toLong());
}
代码示例来源:origin: jphp-group/jphp
public static Memory get_class_vars(Environment env, TraceInfo trace, Memory value) {
ClassEntity entity;
if (value.isString()) {
entity = env.fetchClass(value.toString(), true);
} else if (value.isObject()) {
entity = value.toValue(ObjectMemory.class).getReflection();
} else {
env.warning(
trace, "get_class_vars(): Argument 1 must be string or object, %s given",
value.getRealType().toString()
);
return Memory.NULL;
}
if (entity == null)
return Memory.NULL;
ClassEntity context = env.getLastClassOnStack();
ArrayMemory result = new ArrayMemory();
for (PropertyEntity el : entity.getProperties()) {
if (el.canAccess(env, context) == 0)
result.refOfIndex(el.getName()).assign(el.getDefaultValue(env));
}
for (PropertyEntity el : entity.getStaticProperties()) {
if (el.canAccess(env, context) == 0)
result.refOfIndex(el.getName()).assign(el.getDefaultValue(env));
}
return result.toConstant();
}
内容来源于网络,如有侵权,请联系作者删除!