本文整理了Java中php.runtime.Memory.toLong()
方法的一些代码示例,展示了Memory.toLong()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Memory.toLong()
方法的具体详情如下:
包路径:php.runtime.Memory
类名称:Memory
方法名:toLong
暂无
代码示例来源:origin: jphp-group/jphp
public long[] toLongArray() {
long[] r = new long[size];
int i = 0;
for (Memory e : this) {
r[i] = e.toLong();
i++;
}
return r;
}
代码示例来源:origin: jphp-group/jphp
private static int tryGetChar(Memory value){
if (value.type == Memory.Type.INT){
int val = (int)value.toLong();
if (val > -128 && val <= Character.MAX_CODE_POINT){
if (val < 0)
val += 256;
return val;
}
}
return -1;
}
代码示例来源:origin: jphp-group/jphp
public char toChar(){
switch (type){
case STRING:
String tmp = toString();
if (tmp.isEmpty())
return '\0';
else
return tmp.charAt(0);
default:
return (char)toLong();
}
}
代码示例来源:origin: jphp-group/jphp
@Signature(@Arg("size"))
public Memory truncate(Environment env, Memory... args) throws IOException {
accessFile.setLength(args[0].toLong());
return Memory.NULL;
}
}
代码示例来源:origin: jphp-group/jphp
@Signature({
@Arg(value = "millis", optional = @Optional(value = "0", type = HintType.INT)),
@Arg(value = "nanos", optional = @Optional(value = "0", type = HintType.INT))
})
public Memory join(Environment env, Memory... args) throws InterruptedException {
thread.join(args[0].toLong(), args[1].toInteger());
return Memory.NULL;
}
代码示例来源:origin: jphp-group/jphp
public Memory bitShlRight(long value) {
long l = toLong();
return l < 0 ? _negativeShift() : LongMemory.valueOf(value << l);
}
public Memory bitShlRight(double value){
代码示例来源:origin: jphp-group/jphp
@Immutable
public static Memory abs(Memory value) {
switch (value.type){
case DOUBLE: return new DoubleMemory(Math.abs(value.toDouble()));
case STRING: return abs(value.toNumeric());
default: return LongMemory.valueOf(Math.abs(value.toLong()));
}
}
代码示例来源:origin: jphp-group/jphp
@Immutable
public static double sin(Memory memory){
switch (memory.type){
case DOUBLE: return Math.sin(memory.toDouble());
case STRING: return sin(memory.toNumeric());
default:
return _sin(memory.toLong());
}
}
代码示例来源:origin: jphp-group/jphp
@Override
public boolean smaller(Memory memory) {
switch (memory.type){
case INT: return 0 < ((LongMemory)memory).value;
case DOUBLE: return 0 < ((DoubleMemory)memory).value;
case BOOL: return 0 < memory.toLong();
case NULL: return false;
case REFERENCE: return smaller(memory.toValue());
default:
return smaller(memory.toBoolean());
}
}
代码示例来源:origin: jphp-group/jphp
@Override
public boolean smallerEq(Memory memory) {
switch (memory.type){
case INT: return 0 <= ((LongMemory)memory).value;
case DOUBLE: return 0 <= ((DoubleMemory)memory).value;
case BOOL: return 0 <= memory.toLong();
case NULL: return true;
case REFERENCE: return smallerEq(memory.toValue());
default:
return smallerEq(memory.toBoolean());
}
}
代码示例来源:origin: jphp-group/jphp
protected static Memory _str_replace_impl(Environment env, TraceInfo trace,
Memory search, Memory replace, Memory string,
@Reference Memory _count, boolean isInsensitive) {
String searchText = search.toString();
String replaceText = replace.toString();
String text = string.toString();
AtomicLong count = _count.isUndefined() ? null : new AtomicLong(_count.toLong());
text = StringUtils.replace(text, searchText, replaceText, isInsensitive, count);
if (count != null) _count.assign(count.get());
return StringMemory.valueOf(text);
}
代码示例来源:origin: jphp-group/jphp
public static Memory mul(long o1, Memory value) {
switch (value.type){
case INT: return LongMemory.valueOf(o1 * value.toLong());
case DOUBLE: return DoubleMemory.valueOf(o1 * value.toDouble());
}
return mul(o1, value.toNumeric());
}
public static Memory mul(double o1, Memory value) { return DoubleMemory.valueOf(o1 * value.toDouble()); }
代码示例来源:origin: jphp-group/jphp
@Test
public void testArrayReferenceDefault(){
Memory memory = includeResource("user_function/with_reference_default.php");
Assert.assertEquals(100520, memory.toLong());
}
代码示例来源:origin: jphp-group/jphp
@Override
public Memory minus(Memory memory) {
switch (memory.type){
case INT: return LongMemory.valueOf(1 - ((LongMemory)memory).value);
case DOUBLE: return new DoubleMemory(1 - ((DoubleMemory)memory).value);
case REFERENCE: return minus(memory.toValue());
case BOOL: return LongMemory.valueOf(1 - memory.toLong());
default: return CONST_INT_1.minus(memory.toNumeric());
}
}
代码示例来源:origin: jphp-group/jphp
@Test
public void testAssignMinus(){
Memory memory = run("$x = 10; $x -= 2; return $x", false);
Assert.assertEquals(8, memory.toLong());
}
代码示例来源:origin: jphp-group/jphp
@Test
public void testAssignDiv(){
Memory memory = run("$x = 10; $x /= 2; return $x", false);
Assert.assertEquals(5, memory.toLong());
}
代码示例来源:origin: jphp-group/jphp
@Test
public void testAssignVariable(){
Memory memory = run("$x = 20; return $x", false);
Assert.assertEquals(20, memory.toLong());
Assert.assertTrue(memory instanceof LongMemory);
}
代码示例来源:origin: jphp-group/jphp
@Test
public void testOctalIntegers() {
Memory memory = runDynamic("010");
Assert.assertEquals(8, memory.toLong());
Assert.assertEquals(Memory.Type.INT, memory.type);
}
代码示例来源:origin: jphp-group/jphp
@Test
public void testObjectJsonDecode() {
Memory r = JsonFunctions.json_decode(env, "{\"x\":100, \"y\":500}");
assertTrue(r.instanceOf(StdClass.class));
StdClass stdClass = r.toObject(StdClass.class);
assertEquals(2, stdClass.getProperties().size());
assertEquals(100, stdClass.getProperties().valueOfIndex("x").toLong());
assertEquals(500, stdClass.getProperties().valueOfIndex("y").toLong());
}
代码示例来源:origin: jphp-group/jphp
@Test
public void testValueOfIndex(){
ArrayMemory memory = new ArrayMemory();
assertEquals(Memory.UNDEFINED, memory.valueOfIndex(0));
assertEquals(0, memory.size());
memory.refOfIndex(new DoubleMemory(2)).assign(2);
assertEquals(2, memory.valueOfIndex(2.0).toLong());
}
内容来源于网络,如有侵权,请联系作者删除!