From 61abfff4144cc3f4d6554ec6f23b29492fbef36e Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Fri, 23 Aug 2019 14:17:25 +0900 Subject: [PATCH] v0.0.2 Release --- config.json | 10 ++- ext/config.m4 | 2 +- ext/config.w32 | 2 +- ext/get_inf.c | 11 +++ ext/install | 2 +- ext/php_pocketmine.h | 2 +- ext/pocketmine/math/axisalignedbb.zep.c | 68 +++++++-------- ext/pocketmine/math/voxelraytrace.zep.c | 24 +++--- ext/pocketmine/utils/binary.zep.c | 83 +++++++++---------- ext/pocketmine/utils/binarystream.zep.c | 74 ++++++++--------- .../Pocketmine/math/AxisAlignedBB.zep.php | 0 .../Pocketmine/math/Facing.zep.php | 0 .../Pocketmine/math/Math.zep.php | 0 .../Pocketmine/math/Matrix.zep.php | 0 .../Pocketmine/math/RayTraceResult.zep.php | 0 .../Pocketmine/math/Vector2.zep.php | 0 .../Pocketmine/math/Vector3.zep.php | 0 .../Pocketmine/math/VectorMath.zep.php | 0 .../Pocketmine/math/VoxelRayTrace.zep.php | 0 .../Pocketmine/utils/Binary.zep.php | 4 +- .../utils/BinaryDataException.zep.php | 0 .../Pocketmine/utils/BinaryStream.zep.php | 0 optimizers/GetInfOptimizer.php | 27 ++++++ pocketmine/math/axisalignedbb.zep | 3 - pocketmine/math/voxelraytrace.zep | 5 +- pocketmine/utils/binary.zep | 34 +++----- pocketmine/utils/binarystream.zep | 52 ++++++------ 27 files changed, 215 insertions(+), 188 deletions(-) create mode 100644 ext/get_inf.c rename ide/{0.0.1 => 0.0.2}/Pocketmine/math/AxisAlignedBB.zep.php (100%) rename ide/{0.0.1 => 0.0.2}/Pocketmine/math/Facing.zep.php (100%) rename ide/{0.0.1 => 0.0.2}/Pocketmine/math/Math.zep.php (100%) rename ide/{0.0.1 => 0.0.2}/Pocketmine/math/Matrix.zep.php (100%) rename ide/{0.0.1 => 0.0.2}/Pocketmine/math/RayTraceResult.zep.php (100%) rename ide/{0.0.1 => 0.0.2}/Pocketmine/math/Vector2.zep.php (100%) rename ide/{0.0.1 => 0.0.2}/Pocketmine/math/Vector3.zep.php (100%) rename ide/{0.0.1 => 0.0.2}/Pocketmine/math/VectorMath.zep.php (100%) rename ide/{0.0.1 => 0.0.2}/Pocketmine/math/VoxelRayTrace.zep.php (100%) rename ide/{0.0.1 => 0.0.2}/Pocketmine/utils/Binary.zep.php (99%) rename ide/{0.0.1 => 0.0.2}/Pocketmine/utils/BinaryDataException.zep.php (100%) rename ide/{0.0.1 => 0.0.2}/Pocketmine/utils/BinaryStream.zep.php (100%) create mode 100644 optimizers/GetInfOptimizer.php diff --git a/config.json b/config.json index d02d005..ebe94d1 100644 --- a/config.json +++ b/config.json @@ -3,7 +3,13 @@ "description" : "Extension that implements parts of PocketMine-MP", "name" : "rapidpm", "namespace" : "pocketmine", - "version" : "0.0.1", + "version" : "0.0.2", + "optimizer-dirs": [ + "optimizers" + ], + "extra-sources": [ + "get_inf.c" + ], "optimizations" : { "call-gatherer-pass" : true, "check-invalid-reads" : false, @@ -44,4 +50,4 @@ "unused-variable" : true, "unused-variable-external" : true } - } \ No newline at end of file + } diff --git a/ext/config.m4 b/ext/config.m4 index 75bb521..555ea9d 100644 --- a/ext/config.m4 +++ b/ext/config.m4 @@ -20,7 +20,7 @@ if test "$PHP_POCKETMINE" = "yes"; then pocketmine/math/voxelraytrace.zep.c pocketmine/utils/binary.zep.c pocketmine/utils/binarydataexception.zep.c - pocketmine/utils/binarystream.zep.c " + pocketmine/utils/binarystream.zep.c get_inf.c" PHP_NEW_EXTENSION(pocketmine, $pocketmine_sources, $ext_shared,, ) PHP_SUBST(POCKETMINE_SHARED_LIBADD) diff --git a/ext/config.w32 b/ext/config.w32 index 33fb485..d3703dc 100644 --- a/ext/config.w32 +++ b/ext/config.w32 @@ -9,7 +9,7 @@ if (PHP_POCKETMINE != "no") { ADD_EXTENSION_DEP("pocketmine", "json"); AC_DEFINE("ZEPHIR_USE_PHP_JSON", 1, "Whether PHP json extension is present at compile time"); } - + ADD_SOURCES(configure_module_dirname + "/.", "get_inf.c", "pocketmine"); ADD_SOURCES(configure_module_dirname + "/pocketmine/math", "axisalignedbb.zep.c facing.zep.c math.zep.c matrix.zep.c raytraceresult.zep.c vector2.zep.c vector3.zep.c vectormath.zep.c voxelraytrace.zep.c", "pocketmine"); ADD_SOURCES(configure_module_dirname + "/pocketmine/utils", "binary.zep.c binarydataexception.zep.c binarystream.zep.c", "pocketmine"); ADD_FLAG("CFLAGS_POCKETMINE", "/D ZEPHIR_RELEASE /Oi /Ot /Oy /Ob2 /Gs /GF /Gy /GL"); diff --git a/ext/get_inf.c b/ext/get_inf.c new file mode 100644 index 0000000..a4571fe --- /dev/null +++ b/ext/get_inf.c @@ -0,0 +1,11 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_ext.h" +#include "ext/standard/basic_functions.h" + +double get_inf() { + return php_get_inf(); +} diff --git a/ext/install b/ext/install index 90e36c0..33b5552 100755 --- a/ext/install +++ b/ext/install @@ -1,7 +1,7 @@ #!/usr/bin/env bash export CC="gcc" -export CFLAGS="-O3 -Wall -fvisibility=hidden -flto -DZEPHIR_RELEASE=1" +export CFLAGS="-O2 -Wall -fvisibility=hidden -flto -DZEPHIR_RELEASE=1" phpize_bin=$(which phpize 2> /dev/null) diff --git a/ext/php_pocketmine.h b/ext/php_pocketmine.h index 6e76e4e..59e9c7a 100644 --- a/ext/php_pocketmine.h +++ b/ext/php_pocketmine.h @@ -11,7 +11,7 @@ #include "kernel/globals.h" #define PHP_POCKETMINE_NAME "rapidpm" -#define PHP_POCKETMINE_VERSION "0.0.1" +#define PHP_POCKETMINE_VERSION "0.0.2" #define PHP_POCKETMINE_EXTNAME "pocketmine" #define PHP_POCKETMINE_AUTHOR "Organization" #define PHP_POCKETMINE_ZEPVERSION "0.12.2-b3f17c25" diff --git a/ext/pocketmine/math/axisalignedbb.zep.c b/ext/pocketmine/math/axisalignedbb.zep.c index db7314a..d8acd9b 100644 --- a/ext/pocketmine/math/axisalignedbb.zep.c +++ b/ext/pocketmine/math/axisalignedbb.zep.c @@ -901,11 +901,11 @@ PHP_METHOD(Pocketmine_Math_AxisAlignedBB, calculateXOffset) { zend_bool _2, _7, _10, _13; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *bb, bb_sub, x, *x_param = NULL, x2, x1, _0, _1, _3, _4, _5, _6, _8, _9, _11, _12, _14, _15, _16$$5, _17$$5, _18$$7, _19$$7; + double x; + zval *bb, bb_sub, *x_param = NULL, x2, x1, _0, _1, _3, _4, _5, _6, _8, _9, _11, _12, _14, _15, _16$$5, _17$$5, _18$$7, _19$$7; zval *this_ptr = getThis(); ZVAL_UNDEF(&bb_sub); - ZVAL_UNDEF(&x); ZVAL_UNDEF(&x2); ZVAL_UNDEF(&x1); ZVAL_UNDEF(&_0); @@ -940,7 +940,7 @@ PHP_METHOD(Pocketmine_Math_AxisAlignedBB, calculateXOffset) { _2 = ZEPHIR_GE(&_3, &_4); } if (_2) { - RETURN_CCTOR(&x); + RETURN_MM_DOUBLE(x); } zephir_read_property(&_5, bb, SL("maxZ"), PH_NOISY_CC | PH_READONLY); zephir_read_property(&_6, this_ptr, SL("minZ"), PH_NOISY_CC | PH_READONLY); @@ -951,15 +951,15 @@ PHP_METHOD(Pocketmine_Math_AxisAlignedBB, calculateXOffset) { _7 = ZEPHIR_GE(&_8, &_9); } if (_7) { - RETURN_CCTOR(&x); + RETURN_MM_DOUBLE(x); } - _10 = ZEPHIR_GT_LONG(&x, 0); + _10 = x > 0; if (_10) { zephir_read_property(&_11, bb, SL("maxX"), PH_NOISY_CC | PH_READONLY); zephir_read_property(&_12, this_ptr, SL("minX"), PH_NOISY_CC | PH_READONLY); _10 = ZEPHIR_LE(&_11, &_12); } - _13 = ZEPHIR_LT_LONG(&x, 0); + _13 = x < 0; if (_13) { zephir_read_property(&_14, bb, SL("minX"), PH_NOISY_CC | PH_READONLY); zephir_read_property(&_15, this_ptr, SL("maxX"), PH_NOISY_CC | PH_READONLY); @@ -970,19 +970,19 @@ PHP_METHOD(Pocketmine_Math_AxisAlignedBB, calculateXOffset) { zephir_read_property(&_17$$5, bb, SL("maxX"), PH_NOISY_CC | PH_READONLY); ZEPHIR_INIT_VAR(&x1); zephir_sub_function(&x1, &_16$$5, &_17$$5); - if (ZEPHIR_LT(&x1, &x)) { - ZEPHIR_CPY_WRT(&x, &x1); + if (ZEPHIR_LT_DOUBLE(&x1, x)) { + x = zephir_get_numberval(&x1); } } else if (_13) { zephir_read_property(&_18$$7, this_ptr, SL("maxX"), PH_NOISY_CC | PH_READONLY); zephir_read_property(&_19$$7, bb, SL("minX"), PH_NOISY_CC | PH_READONLY); ZEPHIR_INIT_VAR(&x2); zephir_sub_function(&x2, &_18$$7, &_19$$7); - if (ZEPHIR_GT(&x2, &x)) { - ZEPHIR_CPY_WRT(&x, &x2); + if (ZEPHIR_GT_DOUBLE(&x2, x)) { + x = zephir_get_numberval(&x2); } } - RETURN_CCTOR(&x); + RETURN_MM_DOUBLE(x); } @@ -990,11 +990,11 @@ PHP_METHOD(Pocketmine_Math_AxisAlignedBB, calculateYOffset) { zend_bool _2, _7, _10, _13; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *bb, bb_sub, y, *y_param = NULL, y2, y1, _0, _1, _3, _4, _5, _6, _8, _9, _11, _12, _14, _15, _16$$5, _17$$5, _18$$7, _19$$7; + double y; + zval *bb, bb_sub, *y_param = NULL, y2, y1, _0, _1, _3, _4, _5, _6, _8, _9, _11, _12, _14, _15, _16$$5, _17$$5, _18$$7, _19$$7; zval *this_ptr = getThis(); ZVAL_UNDEF(&bb_sub); - ZVAL_UNDEF(&y); ZVAL_UNDEF(&y2); ZVAL_UNDEF(&y1); ZVAL_UNDEF(&_0); @@ -1029,7 +1029,7 @@ PHP_METHOD(Pocketmine_Math_AxisAlignedBB, calculateYOffset) { _2 = ZEPHIR_GE(&_3, &_4); } if (_2) { - RETURN_CCTOR(&y); + RETURN_MM_DOUBLE(y); } zephir_read_property(&_5, bb, SL("maxZ"), PH_NOISY_CC | PH_READONLY); zephir_read_property(&_6, this_ptr, SL("minZ"), PH_NOISY_CC | PH_READONLY); @@ -1040,15 +1040,15 @@ PHP_METHOD(Pocketmine_Math_AxisAlignedBB, calculateYOffset) { _7 = ZEPHIR_GE(&_8, &_9); } if (_7) { - RETURN_CCTOR(&y); + RETURN_MM_DOUBLE(y); } - _10 = ZEPHIR_GT_LONG(&y, 0); + _10 = y > 0; if (_10) { zephir_read_property(&_11, bb, SL("maxY"), PH_NOISY_CC | PH_READONLY); zephir_read_property(&_12, this_ptr, SL("minY"), PH_NOISY_CC | PH_READONLY); _10 = ZEPHIR_LE(&_11, &_12); } - _13 = ZEPHIR_LT_LONG(&y, 0); + _13 = y < 0; if (_13) { zephir_read_property(&_14, bb, SL("minY"), PH_NOISY_CC | PH_READONLY); zephir_read_property(&_15, this_ptr, SL("maxY"), PH_NOISY_CC | PH_READONLY); @@ -1059,19 +1059,19 @@ PHP_METHOD(Pocketmine_Math_AxisAlignedBB, calculateYOffset) { zephir_read_property(&_17$$5, bb, SL("maxY"), PH_NOISY_CC | PH_READONLY); ZEPHIR_INIT_VAR(&y1); zephir_sub_function(&y1, &_16$$5, &_17$$5); - if (ZEPHIR_LT(&y1, &y)) { - ZEPHIR_CPY_WRT(&y, &y1); + if (ZEPHIR_LT_DOUBLE(&y1, y)) { + y = zephir_get_numberval(&y1); } } else if (_13) { zephir_read_property(&_18$$7, this_ptr, SL("maxY"), PH_NOISY_CC | PH_READONLY); zephir_read_property(&_19$$7, bb, SL("minY"), PH_NOISY_CC | PH_READONLY); ZEPHIR_INIT_VAR(&y2); zephir_sub_function(&y2, &_18$$7, &_19$$7); - if (ZEPHIR_GT(&y2, &y)) { - ZEPHIR_CPY_WRT(&y, &y2); + if (ZEPHIR_GT_DOUBLE(&y2, y)) { + y = zephir_get_numberval(&y2); } } - RETURN_CCTOR(&y); + RETURN_MM_DOUBLE(y); } @@ -1079,11 +1079,11 @@ PHP_METHOD(Pocketmine_Math_AxisAlignedBB, calculateZOffset) { zend_bool _2, _7, _10, _13; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *bb, bb_sub, z, *z_param = NULL, z2, z1, _0, _1, _3, _4, _5, _6, _8, _9, _11, _12, _14, _15, _16$$5, _17$$5, _18$$7, _19$$7; + double z; + zval *bb, bb_sub, *z_param = NULL, z2, z1, _0, _1, _3, _4, _5, _6, _8, _9, _11, _12, _14, _15, _16$$5, _17$$5, _18$$7, _19$$7; zval *this_ptr = getThis(); ZVAL_UNDEF(&bb_sub); - ZVAL_UNDEF(&z); ZVAL_UNDEF(&z2); ZVAL_UNDEF(&z1); ZVAL_UNDEF(&_0); @@ -1118,7 +1118,7 @@ PHP_METHOD(Pocketmine_Math_AxisAlignedBB, calculateZOffset) { _2 = ZEPHIR_GE(&_3, &_4); } if (_2) { - RETURN_CCTOR(&z); + RETURN_MM_DOUBLE(z); } zephir_read_property(&_5, bb, SL("maxY"), PH_NOISY_CC | PH_READONLY); zephir_read_property(&_6, this_ptr, SL("minY"), PH_NOISY_CC | PH_READONLY); @@ -1129,15 +1129,15 @@ PHP_METHOD(Pocketmine_Math_AxisAlignedBB, calculateZOffset) { _7 = ZEPHIR_GE(&_8, &_9); } if (_7) { - RETURN_CCTOR(&z); + RETURN_MM_DOUBLE(z); } - _10 = ZEPHIR_GT_LONG(&z, 0); + _10 = z > 0; if (_10) { zephir_read_property(&_11, bb, SL("maxZ"), PH_NOISY_CC | PH_READONLY); zephir_read_property(&_12, this_ptr, SL("minZ"), PH_NOISY_CC | PH_READONLY); _10 = ZEPHIR_LE(&_11, &_12); } - _13 = ZEPHIR_LT_LONG(&z, 0); + _13 = z < 0; if (_13) { zephir_read_property(&_14, bb, SL("minZ"), PH_NOISY_CC | PH_READONLY); zephir_read_property(&_15, this_ptr, SL("maxZ"), PH_NOISY_CC | PH_READONLY); @@ -1148,19 +1148,19 @@ PHP_METHOD(Pocketmine_Math_AxisAlignedBB, calculateZOffset) { zephir_read_property(&_17$$5, bb, SL("maxZ"), PH_NOISY_CC | PH_READONLY); ZEPHIR_INIT_VAR(&z1); zephir_sub_function(&z1, &_16$$5, &_17$$5); - if (ZEPHIR_LT(&z1, &z)) { - ZEPHIR_CPY_WRT(&z, &z1); + if (ZEPHIR_LT_DOUBLE(&z1, z)) { + z = zephir_get_numberval(&z1); } } else if (_13) { zephir_read_property(&_18$$7, this_ptr, SL("maxZ"), PH_NOISY_CC | PH_READONLY); zephir_read_property(&_19$$7, bb, SL("minZ"), PH_NOISY_CC | PH_READONLY); ZEPHIR_INIT_VAR(&z2); zephir_sub_function(&z2, &_18$$7, &_19$$7); - if (ZEPHIR_GT(&z2, &z)) { - ZEPHIR_CPY_WRT(&z, &z2); + if (ZEPHIR_GT_DOUBLE(&z2, z)) { + z = zephir_get_numberval(&z2); } } - RETURN_CCTOR(&z); + RETURN_MM_DOUBLE(z); } @@ -1693,7 +1693,7 @@ PHP_METHOD(Pocketmine_Math_AxisAlignedBB, calculateIntercept) { zephir_array_fast_append(&_22, &v4); zephir_array_fast_append(&_22, &v5); zephir_array_fast_append(&_22, &v6); - zephir_is_iterable(&_22, 0, "pocketmine/math/axisalignedbb.zep", 575); + zephir_is_iterable(&_22, 0, "pocketmine/math/axisalignedbb.zep", 572); if (Z_TYPE_P(&_22) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_22), _23) { diff --git a/ext/pocketmine/math/voxelraytrace.zep.c b/ext/pocketmine/math/voxelraytrace.zep.c index 8d62670..c891efe 100644 --- a/ext/pocketmine/math/voxelraytrace.zep.c +++ b/ext/pocketmine/math/voxelraytrace.zep.c @@ -291,11 +291,12 @@ PHP_METHOD(Pocketmine_Math_VoxelRayTrace, betweenPoints) { */ PHP_METHOD(Pocketmine_Math_VoxelRayTrace, rayTraceDistanceToBoundary) { - zval s, *s_param = NULL, ds, *ds_param = NULL; + zval *s_param = NULL, *ds_param = NULL, _0$$4, _1; + double s, ds, inf$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&s); - ZVAL_UNDEF(&ds); + ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&_1); zephir_fetch_params_without_memory_grow(2, 0, &s_param, &ds_param); @@ -303,17 +304,20 @@ PHP_METHOD(Pocketmine_Math_VoxelRayTrace, rayTraceDistanceToBoundary) { ds = zephir_get_doubleval(ds_param); - if (ZEPHIR_IS_LONG(&ds, 0)) { - RETURN_DOUBLE(INF); + if (ds == 0) { + inf$$3 = get_inf(); + RETURN_DOUBLE(inf$$3); } - if (ZEPHIR_LT_LONG(&ds, 0)) { - zephir_negate(&s TSRMLS_CC); - zephir_negate(&ds TSRMLS_CC); - if (ZEPHIR_IS_LONG(&s, zephir_floor(&s TSRMLS_CC))) { + if (ds < 0) { + s = -s; + ds = -ds; + ZVAL_DOUBLE(&_0$$4, s); + if (zephir_floor(&_0$$4 TSRMLS_CC) == s) { RETURN_DOUBLE(0.0); } } - RETURN_DOUBLE(zephir_safe_div_double_zval((((double) 1 - ((zephir_get_numberval(&s) - zephir_floor(&s TSRMLS_CC))))), &ds TSRMLS_CC)); + ZVAL_DOUBLE(&_1, s); + RETURN_DOUBLE(zephir_safe_div_double_double((((double) 1 - ((s - zephir_floor(&_1 TSRMLS_CC))))), ds TSRMLS_CC)); } diff --git a/ext/pocketmine/utils/binary.zep.c b/ext/pocketmine/utils/binary.zep.c index 3abdd2a..1e0ffb6 100644 --- a/ext/pocketmine/utils/binary.zep.c +++ b/ext/pocketmine/utils/binary.zep.c @@ -1405,13 +1405,12 @@ PHP_METHOD(Pocketmine_Utils_Binary, writeLLong) { PHP_METHOD(Pocketmine_Utils_Binary, readVarInt) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long offset, ZEPHIR_LAST_CALL_STATUS; - zval *buffer_param = NULL, *offset_param = NULL, temp, raw, _0; + zend_long offset, ZEPHIR_LAST_CALL_STATUS, temp; + zval *buffer_param = NULL, *offset_param = NULL, raw, _0; zval buffer; zval *this_ptr = getThis(); ZVAL_UNDEF(&buffer); - ZVAL_UNDEF(&temp); ZVAL_UNDEF(&raw); ZVAL_UNDEF(&_0); @@ -1425,9 +1424,8 @@ PHP_METHOD(Pocketmine_Utils_Binary, readVarInt) { ZVAL_LONG(&_0, offset); ZEPHIR_CALL_SELF(&raw, "readunsignedvarint", NULL, 0, &buffer, &_0); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&temp); - ZVAL_LONG(&temp, ((((((int) (zephir_get_numberval(&raw)) << 63) >> 63) ^ zephir_get_numberval(&raw))) >> 1)); - RETURN_MM_LONG((((int) (zephir_get_numberval(&temp)) ^ ((int) (zephir_get_numberval(&raw)) & 1)) << 63)); + temp = (((((zephir_get_intval(&raw) << 63) >> 63) ^ zephir_get_intval(&raw))) >> 1); + RETURN_MM_LONG(((temp ^ (zephir_get_intval(&raw) & 1)) << 63)); } @@ -1467,10 +1465,10 @@ PHP_METHOD(Pocketmine_Utils_Binary, readUnsignedVarInt) { } i += 7; if (!(zephir_array_isset_long(buffer, offset))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(pocketmine_utils_binarydataexception_ce, "No bytes left in buffer", "pocketmine/utils/binary.zep", 521); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(pocketmine_utils_binarydataexception_ce, "No bytes left in buffer", "pocketmine/utils/binary.zep", 519); return; } - zephir_array_fetch_long(&_0$$3, buffer, offset, PH_NOISY | PH_READONLY, "pocketmine/utils/binary.zep", 523 TSRMLS_CC); + zephir_array_fetch_long(&_0$$3, buffer, offset, PH_NOISY | PH_READONLY, "pocketmine/utils/binary.zep", 521 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&b$$3, "ord", &_1, 18, &_0$$3); zephir_check_call_status(); offset++; @@ -1479,7 +1477,7 @@ PHP_METHOD(Pocketmine_Utils_Binary, readUnsignedVarInt) { RETURN_MM_LONG(value); } } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(pocketmine_utils_binarydataexception_ce, "VarInt did not terminate after 5 bytes!", "pocketmine/utils/binary.zep", 530); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(pocketmine_utils_binarydataexception_ce, "VarInt did not terminate after 5 bytes!", "pocketmine/utils/binary.zep", 528); return; } @@ -1494,12 +1492,11 @@ PHP_METHOD(Pocketmine_Utils_Binary, readUnsignedVarInt) { PHP_METHOD(Pocketmine_Utils_Binary, writeVarInt) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, _0; - zval v, *v_param = NULL, _1; + zval *v_param = NULL, _0; + zend_long v, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&v); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &v_param); @@ -1507,11 +1504,9 @@ PHP_METHOD(Pocketmine_Utils_Binary, writeVarInt) { v = zephir_get_intval(v_param); - _0 = (((int) (zephir_get_numberval(&v)) << 32) >> 32); - ZEPHIR_INIT_VAR(&v); - ZVAL_LONG(&v, _0); - ZVAL_LONG(&_1, ((((int) (zephir_get_numberval(&v)) << 1) ^ zephir_get_numberval(&v)) >> 31)); - ZEPHIR_RETURN_CALL_SELF("writeunsignedvarint", NULL, 0, &_1); + v = ((v << 32) >> 32); + ZVAL_LONG(&_0, (((v << 1) ^ v) >> 31)); + ZEPHIR_RETURN_CALL_SELF("writeunsignedvarint", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); @@ -1527,19 +1522,20 @@ PHP_METHOD(Pocketmine_Utils_Binary, writeVarInt) { PHP_METHOD(Pocketmine_Utils_Binary, writeUnsignedVarInt) { zend_bool _0; + zval buf; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_5 = NULL; - zval *value_param = NULL, i, buf, _3$$4, _4$$4, _6$$5, _7$$5, _8$$3; + zval *value_param = NULL, i, _3$$4, _4$$4, _6$$5, _7$$5, _8$$3; zend_long value, ZEPHIR_LAST_CALL_STATUS, _1, _2; zval *this_ptr = getThis(); ZVAL_UNDEF(&i); - ZVAL_UNDEF(&buf); ZVAL_UNDEF(&_3$$4); ZVAL_UNDEF(&_4$$4); ZVAL_UNDEF(&_6$$5); ZVAL_UNDEF(&_7$$5); ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&buf); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &value_param); @@ -1575,14 +1571,14 @@ PHP_METHOD(Pocketmine_Utils_Binary, writeUnsignedVarInt) { ZEPHIR_CALL_FUNCTION(&_7$$5, "chr", &_5, 19, &_6$$5); zephir_check_call_status(); zephir_concat_self(&buf, &_7$$5 TSRMLS_CC); - RETURN_CCTOR(&buf); + RETURN_CTOR(&buf); } ZEPHIR_INIT_NVAR(&_8$$3); ZEPHIR_MM_GET_CONSTANT(&_8$$3, "PHP_INT_MAX"); - value = ((value >> (7 & zephir_get_numberval(&_8$$3))) >> 6); + value = ((value >> (7 & zephir_get_intval(&_8$$3))) >> 6); } } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Value too large to be encoded as a VarInt", "pocketmine/utils/binary.zep", 570); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Value too large to be encoded as a VarInt", "pocketmine/utils/binary.zep", 566); return; } @@ -1591,20 +1587,20 @@ PHP_METHOD(Pocketmine_Utils_Binary, writeUnsignedVarInt) { * Reads a 64-bit zigzag-encoded variable-length integer. * * @param string $buffer - * @param int &$offset + * @param int $offset * - * @return int + * @return long */ PHP_METHOD(Pocketmine_Utils_Binary, readVarLong) { + long temp; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long offset, ZEPHIR_LAST_CALL_STATUS; - zval *buffer_param = NULL, *offset_param = NULL, temp, raw, _0; + zval *buffer_param = NULL, *offset_param = NULL, raw, _0; zval buffer; zval *this_ptr = getThis(); ZVAL_UNDEF(&buffer); - ZVAL_UNDEF(&temp); ZVAL_UNDEF(&raw); ZVAL_UNDEF(&_0); @@ -1618,9 +1614,8 @@ PHP_METHOD(Pocketmine_Utils_Binary, readVarLong) { ZVAL_LONG(&_0, offset); ZEPHIR_CALL_SELF(&raw, "readunsignedvarlong", NULL, 0, &buffer, &_0); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&temp); - ZVAL_LONG(&temp, ((((((int) (zephir_get_numberval(&raw)) << 63) >> 63) ^ zephir_get_numberval(&raw))) >> 1)); - RETURN_MM_LONG((((int) (zephir_get_numberval(&temp)) ^ ((int) (zephir_get_numberval(&raw)) & 1)) << 63)); + temp = (((((zephir_get_intval(&raw) << 63) >> 63) ^ zephir_get_intval(&raw))) >> 1); + RETURN_MM_LONG(((temp ^ ((int) (zephir_get_numberval(&raw)) & 1)) << 63)); } @@ -1660,10 +1655,10 @@ PHP_METHOD(Pocketmine_Utils_Binary, readUnsignedVarLong) { } i += 7; if (!(zephir_array_isset_long(buffer, offset))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(pocketmine_utils_binarydataexception_ce, "No bytes left in buffer", "pocketmine/utils/binary.zep", 607); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(pocketmine_utils_binarydataexception_ce, "No bytes left in buffer", "pocketmine/utils/binary.zep", 601); return; } - zephir_array_fetch_long(&_0$$3, buffer, offset, PH_NOISY | PH_READONLY, "pocketmine/utils/binary.zep", 609 TSRMLS_CC); + zephir_array_fetch_long(&_0$$3, buffer, offset, PH_NOISY | PH_READONLY, "pocketmine/utils/binary.zep", 603 TSRMLS_CC); ZEPHIR_CALL_FUNCTION(&b$$3, "ord", &_1, 18, &_0$$3); zephir_check_call_status(); offset++; @@ -1672,7 +1667,7 @@ PHP_METHOD(Pocketmine_Utils_Binary, readUnsignedVarLong) { RETURN_MM_LONG(value); } } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(pocketmine_utils_binarydataexception_ce, "VarLong did not terminate after 10 bytes!", "pocketmine/utils/binary.zep", 616); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(pocketmine_utils_binarydataexception_ce, "VarLong did not terminate after 10 bytes!", "pocketmine/utils/binary.zep", 610); return; } @@ -1716,20 +1711,20 @@ PHP_METHOD(Pocketmine_Utils_Binary, writeVarLong) { PHP_METHOD(Pocketmine_Utils_Binary, writeUnsignedVarLong) { zend_bool _0; + zval buf; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, _1, _2, _9$$3; zephir_fcall_cache_entry *_5 = NULL; - zval value, *value_param = NULL, i, buf, _3$$4, _4$$4, _6$$5, _7$$5, _8$$3; + zval *value_param = NULL, i, _3$$4, _4$$4, _6$$5, _7$$5, _8$$3; + zend_long value, ZEPHIR_LAST_CALL_STATUS, _1, _2; zval *this_ptr = getThis(); - ZVAL_UNDEF(&value); ZVAL_UNDEF(&i); - ZVAL_UNDEF(&buf); ZVAL_UNDEF(&_3$$4); ZVAL_UNDEF(&_4$$4); ZVAL_UNDEF(&_6$$5); ZVAL_UNDEF(&_7$$5); ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&buf); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &value_param); @@ -1754,26 +1749,24 @@ PHP_METHOD(Pocketmine_Utils_Binary, writeUnsignedVarLong) { } ZEPHIR_INIT_NVAR(&i); ZVAL_LONG(&i, _1); - if ((((int) (zephir_get_numberval(&value)) >> 7)) != 0) { - ZVAL_LONG(&_3$$4, ((int) (zephir_get_numberval(&value)) | 0x80)); + if (((value >> 7)) != 0) { + ZVAL_LONG(&_3$$4, (value | 0x80)); ZEPHIR_CALL_FUNCTION(&_4$$4, "chr", &_5, 19, &_3$$4); zephir_check_call_status(); zephir_concat_self(&buf, &_4$$4 TSRMLS_CC); } else { - ZVAL_LONG(&_6$$5, ((int) (zephir_get_numberval(&value)) & 0x7f)); + ZVAL_LONG(&_6$$5, (value & 0x7f)); ZEPHIR_CALL_FUNCTION(&_7$$5, "chr", &_5, 19, &_6$$5); zephir_check_call_status(); zephir_concat_self(&buf, &_7$$5 TSRMLS_CC); - RETURN_CCTOR(&buf); + RETURN_CTOR(&buf); } ZEPHIR_INIT_NVAR(&_8$$3); ZEPHIR_MM_GET_CONSTANT(&_8$$3, "PHP_INT_MAX"); - _9$$3 = (((int) (zephir_get_numberval(&value)) >> (7 & zephir_get_numberval(&_8$$3))) >> 6); - ZEPHIR_INIT_NVAR(&value); - ZVAL_LONG(&value, _9$$3); + value = ((value >> (7 & zephir_get_intval(&_8$$3))) >> 6); } } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Value too large to be encoded as a VarLong", "pocketmine/utils/binary.zep", 655); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Value too large to be encoded as a VarLong", "pocketmine/utils/binary.zep", 647); return; } diff --git a/ext/pocketmine/utils/binarystream.zep.c b/ext/pocketmine/utils/binarystream.zep.c index 0b1edb5..e022a3d 100644 --- a/ext/pocketmine/utils/binarystream.zep.c +++ b/ext/pocketmine/utils/binarystream.zep.c @@ -452,7 +452,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, getShort) { zephir_check_call_status(); ZEPHIR_INIT_VAR(&_2); ZVAL_STRING(&_2, "n"); - ZEPHIR_CALL_FUNCTION(&_3, "\unpack", NULL, 24, &_2, &_0); + ZEPHIR_CALL_FUNCTION(&_3, "unpack", NULL, 20, &_2, &_0); zephir_check_call_status(); zephir_array_fetch_long(&_4, &_3, 1, PH_NOISY | PH_READONLY, "pocketmine/utils/binarystream.zep", 136 TSRMLS_CC); RETURN_CTOR(&_4); @@ -479,7 +479,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, getSignedShort) { zephir_check_call_status(); ZEPHIR_INIT_VAR(&_2); ZVAL_STRING(&_2, "n"); - ZEPHIR_CALL_FUNCTION(&_3, "\unpack", NULL, 24, &_2, &_0); + ZEPHIR_CALL_FUNCTION(&_3, "unpack", NULL, 20, &_2, &_0); zephir_check_call_status(); zephir_array_fetch_long(&_4, &_3, 1, PH_NOISY | PH_READONLY, "pocketmine/utils/binarystream.zep", 141 TSRMLS_CC); RETURN_MM_LONG((((int) (zephir_get_numberval(&_4)) << 48) >> 48)); @@ -506,7 +506,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, putShort) { ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "n"); ZVAL_LONG(&_1, v); - ZEPHIR_CALL_FUNCTION(&_2, "\pack", NULL, 25, &_0, &_1); + ZEPHIR_CALL_FUNCTION(&_2, "pack", NULL, 21, &_0, &_1); zephir_check_call_status(); zephir_update_property_zval(this_ptr, SL("buffer"), &_2); ZEPHIR_MM_RESTORE(); @@ -533,7 +533,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, getLShort) { zephir_check_call_status(); ZEPHIR_INIT_VAR(&_2); ZVAL_STRING(&_2, "v"); - ZEPHIR_CALL_FUNCTION(&_3, "\unpack", NULL, 24, &_2, &_0); + ZEPHIR_CALL_FUNCTION(&_3, "unpack", NULL, 20, &_2, &_0); zephir_check_call_status(); zephir_array_fetch_long(&_4, &_3, 1, PH_NOISY | PH_READONLY, "pocketmine/utils/binarystream.zep", 151 TSRMLS_CC); RETURN_CTOR(&_4); @@ -560,7 +560,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, getSignedLShort) { zephir_check_call_status(); ZEPHIR_INIT_VAR(&_2); ZVAL_STRING(&_2, "v"); - ZEPHIR_CALL_FUNCTION(&_3, "\unpack", NULL, 24, &_2, &_0); + ZEPHIR_CALL_FUNCTION(&_3, "unpack", NULL, 20, &_2, &_0); zephir_check_call_status(); zephir_array_fetch_long(&_4, &_3, 1, PH_NOISY | PH_READONLY, "pocketmine/utils/binarystream.zep", 156 TSRMLS_CC); RETURN_MM_LONG((((int) (zephir_get_numberval(&_4)) << 48) >> 48)); @@ -587,7 +587,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, putLShort) { ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "v"); ZVAL_LONG(&_1, v); - ZEPHIR_CALL_FUNCTION(&_2, "\pack", NULL, 25, &_0, &_1); + ZEPHIR_CALL_FUNCTION(&_2, "pack", NULL, 21, &_0, &_1); zephir_check_call_status(); zephir_update_property_zval(this_ptr, SL("buffer"), &_2); ZEPHIR_MM_RESTORE(); @@ -617,7 +617,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, getTriad) { ZEPHIR_CONCAT_SV(&_2, "\\0", &_0); ZEPHIR_INIT_VAR(&_3); ZVAL_STRING(&_3, "N"); - ZEPHIR_CALL_FUNCTION(&_4, "\unpack", NULL, 24, &_3, &_2); + ZEPHIR_CALL_FUNCTION(&_4, "unpack", NULL, 20, &_3, &_2); zephir_check_call_status(); zephir_array_fetch_long(&_5, &_4, 1, PH_NOISY | PH_READONLY, "pocketmine/utils/binarystream.zep", 166 TSRMLS_CC); RETURN_CTOR(&_5); @@ -627,14 +627,13 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, getTriad) { PHP_METHOD(Pocketmine_Utils_BinaryStream, putTriad) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *v_param = NULL, _0, _1, _2, _3; + zval *v_param = NULL, _0, _1, _2; zend_long v, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &v_param); @@ -645,12 +644,12 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, putTriad) { ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "N"); ZVAL_LONG(&_1, v); - ZEPHIR_CALL_FUNCTION(&_2, "\pack", NULL, 25, &_0, &_1); + ZEPHIR_CALL_FUNCTION(&_2, "pack", NULL, 21, &_0, &_1); zephir_check_call_status(); ZVAL_LONG(&_1, 1); - ZEPHIR_CALL_FUNCTION(&_3, "\substr", NULL, 26, &_2, &_1); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, SL("buffer"), &_3); + ZEPHIR_INIT_NVAR(&_0); + zephir_substr(&_0, &_2, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); + zephir_update_property_zval(this_ptr, SL("buffer"), &_0); ZEPHIR_MM_RESTORE(); } @@ -678,7 +677,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, getLTriad) { ZEPHIR_CONCAT_VS(&_2, &_0, "\\0"); ZEPHIR_INIT_VAR(&_3); ZVAL_STRING(&_3, "V"); - ZEPHIR_CALL_FUNCTION(&_4, "\unpack", NULL, 24, &_3, &_2); + ZEPHIR_CALL_FUNCTION(&_4, "unpack", NULL, 20, &_3, &_2); zephir_check_call_status(); zephir_array_fetch_long(&_5, &_4, 1, PH_NOISY | PH_READONLY, "pocketmine/utils/binarystream.zep", 176 TSRMLS_CC); RETURN_CTOR(&_5); @@ -688,7 +687,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, getLTriad) { PHP_METHOD(Pocketmine_Utils_BinaryStream, putLTriad) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *v_param = NULL, _0, _1, _2, _3, _4; + zval *v_param = NULL, _0, _1, _2, _3; zend_long v, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); @@ -696,7 +695,6 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, putLTriad) { ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &v_param); @@ -707,13 +705,13 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, putLTriad) { ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "V"); ZVAL_LONG(&_1, v); - ZEPHIR_CALL_FUNCTION(&_2, "\pack", NULL, 25, &_0, &_1); + ZEPHIR_CALL_FUNCTION(&_2, "pack", NULL, 21, &_0, &_1); zephir_check_call_status(); ZVAL_LONG(&_1, 0); ZVAL_LONG(&_3, -1); - ZEPHIR_CALL_FUNCTION(&_4, "\substr", NULL, 26, &_2, &_1, &_3); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, SL("buffer"), &_4); + ZEPHIR_INIT_NVAR(&_0); + zephir_substr(&_0, &_2, 0 , -1 , 0); + zephir_update_property_zval(this_ptr, SL("buffer"), &_0); ZEPHIR_MM_RESTORE(); } @@ -738,7 +736,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, getInt) { zephir_check_call_status(); ZEPHIR_INIT_VAR(&_2); ZVAL_STRING(&_2, "N"); - ZEPHIR_CALL_FUNCTION(&_3, "\unpack", NULL, 24, &_2, &_0); + ZEPHIR_CALL_FUNCTION(&_3, "unpack", NULL, 20, &_2, &_0); zephir_check_call_status(); zephir_array_fetch_long(&_4, &_3, 1, PH_NOISY | PH_READONLY, "pocketmine/utils/binarystream.zep", 186 TSRMLS_CC); RETURN_MM_LONG((((int) (zephir_get_numberval(&_4)) << 32) >> 32)); @@ -765,7 +763,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, putInt) { ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "N"); ZVAL_LONG(&_1, v); - ZEPHIR_CALL_FUNCTION(&_2, "\pack", NULL, 25, &_0, &_1); + ZEPHIR_CALL_FUNCTION(&_2, "pack", NULL, 21, &_0, &_1); zephir_check_call_status(); zephir_update_property_zval(this_ptr, SL("buffer"), &_2); ZEPHIR_MM_RESTORE(); @@ -792,7 +790,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, getLInt) { zephir_check_call_status(); ZEPHIR_INIT_VAR(&_2); ZVAL_STRING(&_2, "V"); - ZEPHIR_CALL_FUNCTION(&_3, "\unpack", NULL, 24, &_2, &_0); + ZEPHIR_CALL_FUNCTION(&_3, "unpack", NULL, 20, &_2, &_0); zephir_check_call_status(); zephir_array_fetch_long(&_4, &_3, 1, PH_NOISY | PH_READONLY, "pocketmine/utils/binarystream.zep", 196 TSRMLS_CC); RETURN_MM_LONG((((int) (zephir_get_numberval(&_4)) << 32) >> 32)); @@ -819,7 +817,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, putLInt) { ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "V"); ZVAL_LONG(&_1, v); - ZEPHIR_CALL_FUNCTION(&_2, "\pack", NULL, 25, &_0, &_1); + ZEPHIR_CALL_FUNCTION(&_2, "pack", NULL, 21, &_0, &_1); zephir_check_call_status(); zephir_update_property_zval(this_ptr, SL("buffer"), &_2); ZEPHIR_MM_RESTORE(); @@ -846,7 +844,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, getFloat) { zephir_check_call_status(); ZEPHIR_INIT_VAR(&_2); ZVAL_STRING(&_2, "G"); - ZEPHIR_CALL_FUNCTION(&_3, "\unpack", NULL, 24, &_2, &_0); + ZEPHIR_CALL_FUNCTION(&_3, "unpack", NULL, 20, &_2, &_0); zephir_check_call_status(); zephir_array_fetch_long(&_4, &_3, 1, PH_NOISY | PH_READONLY, "pocketmine/utils/binarystream.zep", 206 TSRMLS_CC); RETURN_CTOR(&_4); @@ -877,11 +875,11 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, getRoundedFloat) { zephir_check_call_status(); ZEPHIR_INIT_VAR(&_2); ZVAL_STRING(&_2, "G"); - ZEPHIR_CALL_FUNCTION(&_3, "\unpack", NULL, 24, &_2, &_0); + ZEPHIR_CALL_FUNCTION(&_3, "unpack", NULL, 20, &_2, &_0); zephir_check_call_status(); zephir_array_fetch_long(&_4, &_3, 1, PH_NOISY | PH_READONLY, "pocketmine/utils/binarystream.zep", 211 TSRMLS_CC); ZVAL_LONG(&_1, accuracy); - ZEPHIR_RETURN_CALL_FUNCTION("\round", NULL, 27, &_4, &_1); + ZEPHIR_RETURN_CALL_FUNCTION("\round", NULL, 24, &_4, &_1); zephir_check_call_status(); RETURN_MM(); @@ -908,7 +906,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, putFloat) { ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "G"); ZVAL_DOUBLE(&_1, v); - ZEPHIR_CALL_FUNCTION(&_2, "\pack", NULL, 25, &_0, &_1); + ZEPHIR_CALL_FUNCTION(&_2, "pack", NULL, 21, &_0, &_1); zephir_check_call_status(); zephir_update_property_zval(this_ptr, SL("buffer"), &_2); ZEPHIR_MM_RESTORE(); @@ -935,7 +933,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, getLFloat) { zephir_check_call_status(); ZEPHIR_INIT_VAR(&_2); ZVAL_STRING(&_2, "g"); - ZEPHIR_CALL_FUNCTION(&_3, "\unpack", NULL, 24, &_2, &_0); + ZEPHIR_CALL_FUNCTION(&_3, "unpack", NULL, 20, &_2, &_0); zephir_check_call_status(); zephir_array_fetch_long(&_4, &_3, 1, PH_NOISY | PH_READONLY, "pocketmine/utils/binarystream.zep", 221 TSRMLS_CC); RETURN_CTOR(&_4); @@ -966,11 +964,11 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, getRoundedLFloat) { zephir_check_call_status(); ZEPHIR_INIT_VAR(&_2); ZVAL_STRING(&_2, "g"); - ZEPHIR_CALL_FUNCTION(&_3, "\unpack", NULL, 24, &_2, &_0); + ZEPHIR_CALL_FUNCTION(&_3, "unpack", NULL, 20, &_2, &_0); zephir_check_call_status(); zephir_array_fetch_long(&_4, &_3, 1, PH_NOISY | PH_READONLY, "pocketmine/utils/binarystream.zep", 226 TSRMLS_CC); ZVAL_LONG(&_1, accuracy); - ZEPHIR_RETURN_CALL_FUNCTION("\round", NULL, 27, &_4, &_1); + ZEPHIR_RETURN_CALL_FUNCTION("\round", NULL, 24, &_4, &_1); zephir_check_call_status(); RETURN_MM(); @@ -997,7 +995,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, putLFloat) { ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "g"); ZVAL_DOUBLE(&_1, v); - ZEPHIR_CALL_FUNCTION(&_2, "\pack", NULL, 25, &_0, &_1); + ZEPHIR_CALL_FUNCTION(&_2, "pack", NULL, 21, &_0, &_1); zephir_check_call_status(); zephir_update_property_zval(this_ptr, SL("buffer"), &_2); ZEPHIR_MM_RESTORE(); @@ -1024,7 +1022,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, getDouble) { zephir_check_call_status(); ZEPHIR_INIT_VAR(&_2); ZVAL_STRING(&_2, "E"); - ZEPHIR_CALL_FUNCTION(&_3, "\unpack", NULL, 24, &_2, &_0); + ZEPHIR_CALL_FUNCTION(&_3, "unpack", NULL, 20, &_2, &_0); zephir_check_call_status(); zephir_array_fetch_long(&_4, &_3, 1, PH_NOISY | PH_READONLY, "pocketmine/utils/binarystream.zep", 236 TSRMLS_CC); RETURN_CTOR(&_4); @@ -1052,7 +1050,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, putDouble) { ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "E"); ZVAL_DOUBLE(&_1, v); - ZEPHIR_CALL_FUNCTION(&_2, "\pack", NULL, 25, &_0, &_1); + ZEPHIR_CALL_FUNCTION(&_2, "pack", NULL, 21, &_0, &_1); zephir_check_call_status(); zephir_update_property_zval(this_ptr, SL("buffer"), &_2); ZEPHIR_MM_RESTORE(); @@ -1079,7 +1077,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, getLDouble) { zephir_check_call_status(); ZEPHIR_INIT_VAR(&_2); ZVAL_STRING(&_2, "e"); - ZEPHIR_CALL_FUNCTION(&_3, "\unpack", NULL, 24, &_2, &_0); + ZEPHIR_CALL_FUNCTION(&_3, "unpack", NULL, 20, &_2, &_0); zephir_check_call_status(); zephir_array_fetch_long(&_4, &_3, 1, PH_NOISY | PH_READONLY, "pocketmine/utils/binarystream.zep", 246 TSRMLS_CC); RETURN_CTOR(&_4); @@ -1107,7 +1105,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, putLDouble) { ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "e"); ZVAL_DOUBLE(&_1, v); - ZEPHIR_CALL_FUNCTION(&_2, "\pack", NULL, 25, &_0, &_1); + ZEPHIR_CALL_FUNCTION(&_2, "pack", NULL, 21, &_0, &_1); zephir_check_call_status(); zephir_update_property_zval(this_ptr, SL("buffer"), &_2); ZEPHIR_MM_RESTORE(); @@ -1164,7 +1162,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, putLong) { ZVAL_STRING(&_0, "NN"); ZVAL_LONG(&_1, (v >> 32)); ZVAL_LONG(&_2, (v & 0xffffffff)); - ZEPHIR_CALL_FUNCTION(&_3, "\pack", NULL, 25, &_0, &_1, &_2); + ZEPHIR_CALL_FUNCTION(&_3, "pack", NULL, 21, &_0, &_1, &_2); zephir_check_call_status(); zephir_update_property_zval(this_ptr, SL("buffer"), &_3); ZEPHIR_MM_RESTORE(); @@ -1221,7 +1219,7 @@ PHP_METHOD(Pocketmine_Utils_BinaryStream, putLLong) { ZVAL_STRING(&_0, "VV"); ZVAL_LONG(&_1, (v & 0xffffffff)); ZVAL_LONG(&_2, (v >> 32)); - ZEPHIR_CALL_FUNCTION(&_3, "\pack", NULL, 25, &_0, &_1, &_2); + ZEPHIR_CALL_FUNCTION(&_3, "pack", NULL, 21, &_0, &_1, &_2); zephir_check_call_status(); zephir_update_property_zval(this_ptr, SL("buffer"), &_3); ZEPHIR_MM_RESTORE(); diff --git a/ide/0.0.1/Pocketmine/math/AxisAlignedBB.zep.php b/ide/0.0.2/Pocketmine/math/AxisAlignedBB.zep.php similarity index 100% rename from ide/0.0.1/Pocketmine/math/AxisAlignedBB.zep.php rename to ide/0.0.2/Pocketmine/math/AxisAlignedBB.zep.php diff --git a/ide/0.0.1/Pocketmine/math/Facing.zep.php b/ide/0.0.2/Pocketmine/math/Facing.zep.php similarity index 100% rename from ide/0.0.1/Pocketmine/math/Facing.zep.php rename to ide/0.0.2/Pocketmine/math/Facing.zep.php diff --git a/ide/0.0.1/Pocketmine/math/Math.zep.php b/ide/0.0.2/Pocketmine/math/Math.zep.php similarity index 100% rename from ide/0.0.1/Pocketmine/math/Math.zep.php rename to ide/0.0.2/Pocketmine/math/Math.zep.php diff --git a/ide/0.0.1/Pocketmine/math/Matrix.zep.php b/ide/0.0.2/Pocketmine/math/Matrix.zep.php similarity index 100% rename from ide/0.0.1/Pocketmine/math/Matrix.zep.php rename to ide/0.0.2/Pocketmine/math/Matrix.zep.php diff --git a/ide/0.0.1/Pocketmine/math/RayTraceResult.zep.php b/ide/0.0.2/Pocketmine/math/RayTraceResult.zep.php similarity index 100% rename from ide/0.0.1/Pocketmine/math/RayTraceResult.zep.php rename to ide/0.0.2/Pocketmine/math/RayTraceResult.zep.php diff --git a/ide/0.0.1/Pocketmine/math/Vector2.zep.php b/ide/0.0.2/Pocketmine/math/Vector2.zep.php similarity index 100% rename from ide/0.0.1/Pocketmine/math/Vector2.zep.php rename to ide/0.0.2/Pocketmine/math/Vector2.zep.php diff --git a/ide/0.0.1/Pocketmine/math/Vector3.zep.php b/ide/0.0.2/Pocketmine/math/Vector3.zep.php similarity index 100% rename from ide/0.0.1/Pocketmine/math/Vector3.zep.php rename to ide/0.0.2/Pocketmine/math/Vector3.zep.php diff --git a/ide/0.0.1/Pocketmine/math/VectorMath.zep.php b/ide/0.0.2/Pocketmine/math/VectorMath.zep.php similarity index 100% rename from ide/0.0.1/Pocketmine/math/VectorMath.zep.php rename to ide/0.0.2/Pocketmine/math/VectorMath.zep.php diff --git a/ide/0.0.1/Pocketmine/math/VoxelRayTrace.zep.php b/ide/0.0.2/Pocketmine/math/VoxelRayTrace.zep.php similarity index 100% rename from ide/0.0.1/Pocketmine/math/VoxelRayTrace.zep.php rename to ide/0.0.2/Pocketmine/math/VoxelRayTrace.zep.php diff --git a/ide/0.0.1/Pocketmine/utils/Binary.zep.php b/ide/0.0.2/Pocketmine/utils/Binary.zep.php similarity index 99% rename from ide/0.0.1/Pocketmine/utils/Binary.zep.php rename to ide/0.0.2/Pocketmine/utils/Binary.zep.php index 2138b3d..14f92c7 100644 --- a/ide/0.0.1/Pocketmine/utils/Binary.zep.php +++ b/ide/0.0.2/Pocketmine/utils/Binary.zep.php @@ -458,11 +458,11 @@ public static function writeUnsignedVarInt(int $value): string {} /** * Reads a 64-bit zigzag-encoded variable-length integer. * - * @param int &$offset + * @param int $offset * * @param string $buffer * @param int $offset - * @return int + * @return long */ public static function readVarLong(string $buffer, int $offset): int {} diff --git a/ide/0.0.1/Pocketmine/utils/BinaryDataException.zep.php b/ide/0.0.2/Pocketmine/utils/BinaryDataException.zep.php similarity index 100% rename from ide/0.0.1/Pocketmine/utils/BinaryDataException.zep.php rename to ide/0.0.2/Pocketmine/utils/BinaryDataException.zep.php diff --git a/ide/0.0.1/Pocketmine/utils/BinaryStream.zep.php b/ide/0.0.2/Pocketmine/utils/BinaryStream.zep.php similarity index 100% rename from ide/0.0.1/Pocketmine/utils/BinaryStream.zep.php rename to ide/0.0.2/Pocketmine/utils/BinaryStream.zep.php diff --git a/optimizers/GetInfOptimizer.php b/optimizers/GetInfOptimizer.php new file mode 100644 index 0000000..06cdb19 --- /dev/null +++ b/optimizers/GetInfOptimizer.php @@ -0,0 +1,27 @@ +processExpectedReturn($context); + + $symbolVariable = $call->getSymbolVariable(); + if (!$symbolVariable->isDouble()) { + throw new CompilerException("Values only can be stored in double variables", $expression); + } + + return new CompiledExpression('double', 'get_inf()', $expression); + } +} diff --git a/pocketmine/math/axisalignedbb.zep b/pocketmine/math/axisalignedbb.zep index 1481990..d17f061 100644 --- a/pocketmine/math/axisalignedbb.zep +++ b/pocketmine/math/axisalignedbb.zep @@ -353,7 +353,6 @@ class AxisAlignedBB public function calculateXOffset( bb, float x) -> float { var x2; - var x; var x1; if bb->maxY <= this->minY || bb->minY >= this->maxY { return x; @@ -378,7 +377,6 @@ class AxisAlignedBB public function calculateYOffset( bb, float y) -> float { var y2; - var y; var y1; if bb->maxX <= this->minX || bb->minX >= this->maxX { return y; @@ -403,7 +401,6 @@ class AxisAlignedBB public function calculateZOffset( bb, float z) -> float { var z2; - var z; var z1; if bb->maxX <= this->minX || bb->minX >= this->maxX { return z; diff --git a/pocketmine/math/voxelraytrace.zep b/pocketmine/math/voxelraytrace.zep index 190d593..bb7a32a 100644 --- a/pocketmine/math/voxelraytrace.zep +++ b/pocketmine/math/voxelraytrace.zep @@ -133,10 +133,9 @@ abstract class VoxelRayTrace */ private static function rayTraceDistanceToBoundary(float s, float ds) -> float { - var ds; - var s; if (ds == 0) { - return INF; + float inf = get_inf(); + return inf; } if (ds < 0) { let s = -s; diff --git a/pocketmine/utils/binary.zep b/pocketmine/utils/binary.zep index d4890e5..9d9df2c 100644 --- a/pocketmine/utils/binary.zep +++ b/pocketmine/utils/binary.zep @@ -494,11 +494,9 @@ class Binary */ public static function readVarInt(string buffer, int offset) -> int { - var temp; - var raw; - let raw = self::readUnsignedVarInt(buffer, offset); - let temp = (raw << 63 >> 63 ^ raw) >> 1; - return temp ^ raw & 1 << 63; + var raw = self::readUnsignedVarInt(buffer, offset); + int temp = ((int) raw << 63 >> 63 ^ (int) raw) >> 1; + return temp ^ (int) raw & 1 << 63; } /** @@ -539,7 +537,6 @@ class Binary */ public static function writeVarInt(int v) -> string { - var v; let v = v << 32 >> 32; return self::writeUnsignedVarInt(v << 1 ^ v >> 31); } @@ -554,9 +551,8 @@ class Binary public static function writeUnsignedVarInt(int value) -> string { var i; - var buf; - let buf = ""; - let value = value & 0xffffffff; + string buf = ""; + int value = value & 0xffffffff; for i in range(0, 4) { if ((value >> 7) !== 0) { let buf .= chr(value | 0x80); @@ -564,7 +560,7 @@ class Binary let buf .= chr(value & 0x7f); return buf; } - let value = value >> 7 & PHP_INT_MAX >> 6; + let value = value >> 7 & (long) PHP_INT_MAX >> 6; //PHP really needs a logical right-shift operator } throw new \InvalidArgumentException("Value too large to be encoded as a VarInt"); @@ -574,16 +570,14 @@ class Binary * Reads a 64-bit zigzag-encoded variable-length integer. * * @param string $buffer - * @param int &$offset + * @param int $offset * - * @return int + * @return long */ - public static function readVarLong(string buffer, int offset) -> int + public static function readVarLong(string buffer, int offset) -> long { - var temp; - var raw; - let raw = self::readUnsignedVarLong(buffer, offset); - let temp = (raw << 63 >> 63 ^ raw) >> 1; + var raw = self::readUnsignedVarLong(buffer, offset); + long temp = ((long) raw << 63 >> 63 ^ (long) raw) >> 1; return temp ^ raw & 1 << 63; } @@ -637,10 +631,8 @@ class Binary */ public static function writeUnsignedVarLong(int value) -> string { - var value; var i; - var buf; - let buf = ""; + string buf = ""; for i in range(0, 9) { if ((value >> 7) !== 0) { let buf .= chr(value | 0x80); @@ -649,7 +641,7 @@ class Binary let buf .= chr(value & 0x7f); return buf; } - let value = value >> 7 & PHP_INT_MAX >> 6; + let value = value >> 7 & (long) PHP_INT_MAX >> 6; //PHP really needs a logical right-shift operator } throw new \InvalidArgumentException("Value too large to be encoded as a VarLong"); diff --git a/pocketmine/utils/binarystream.zep b/pocketmine/utils/binarystream.zep index 8286aba..3db6ea7 100644 --- a/pocketmine/utils/binarystream.zep +++ b/pocketmine/utils/binarystream.zep @@ -133,122 +133,122 @@ class BinaryStream public function getShort() -> int { - return \unpack("n", this->get(2))[1]; + return unpack("n", this->get(2))[1]; } public function getSignedShort() -> int { - return \unpack("n", this->get(2))[1] << 48 >> 48; + return unpack("n", this->get(2))[1] << 48 >> 48; } public function putShort(int v) { - let this->buffer .= \pack("n", v); + let this->buffer .= pack("n", v); } public function getLShort() -> int { - return \unpack("v", this->get(2))[1]; + return unpack("v", this->get(2))[1]; } public function getSignedLShort() -> int { - return \unpack("v", this->get(2))[1] << 48 >> 48; + return unpack("v", this->get(2))[1] << 48 >> 48; } public function putLShort(int v) { - let this->buffer .= \pack("v", v); + let this->buffer .= pack("v", v); } public function getTriad() -> int { - return \unpack("N", "\0" . this->get(3))[1]; + return unpack("N", "\0" . this->get(3))[1]; } public function putTriad(int v) { - let this->buffer .= \substr(\pack("N", v), 1); + let this->buffer .= substr(pack("N", v), 1); } public function getLTriad() -> int { - return \unpack("V", this->get(3) . "\0")[1]; + return unpack("V", this->get(3) . "\0")[1]; } public function putLTriad(int v) { - let this->buffer .= \substr(\pack("V", v), 0, -1); + let this->buffer .= substr(pack("V", v), 0, -1); } public function getInt() -> int { - return \unpack("N", this->get(4))[1] << 32 >> 32; + return unpack("N", this->get(4))[1] << 32 >> 32; } public function putInt(int v) { - let this->buffer .= \pack("N", v); + let this->buffer .= pack("N", v); } public function getLInt() -> int { - return \unpack("V", this->get(4))[1] << 32 >> 32; + return unpack("V", this->get(4))[1] << 32 >> 32; } public function putLInt(int v) { - let this->buffer .= \pack("V", v); + let this->buffer .= pack("V", v); } public function getFloat() -> float { - return \unpack("G", this->get(4))[1]; + return unpack("G", this->get(4))[1]; } public function getRoundedFloat(int accuracy) -> float { - return \round(\unpack("G", this->get(4))[1], accuracy); + return \round(unpack("G", this->get(4))[1], accuracy); } public function putFloat(float v) { - let this->buffer .= \pack("G", v); + let this->buffer .= pack("G", v); } public function getLFloat() -> float { - return \unpack("g", this->get(4))[1]; + return unpack("g", this->get(4))[1]; } public function getRoundedLFloat(int accuracy) -> float { - return \round(\unpack("g", this->get(4))[1], accuracy); + return \round(unpack("g", this->get(4))[1], accuracy); } public function putLFloat(float v) { - let this->buffer .= \pack("g", v); + let this->buffer .= pack("g", v); } public function getDouble() -> float { - return \unpack("E", this->get(8))[1]; + return unpack("E", this->get(8))[1]; } public function putDouble(float v) -> void { - let this->buffer .= \pack("E", v); + let this->buffer .= pack("E", v); } public function getLDouble() -> float { - return \unpack("e", this->get(8))[1]; + return unpack("e", this->get(8))[1]; } public function putLDouble(float v) -> void { - let this->buffer .= \pack("e", v); + let this->buffer .= pack("e", v); } /** @@ -264,7 +264,7 @@ class BinaryStream */ public function putLong(int v) { - let this->buffer .= \pack("NN", v >> 32, v & 0xffffffff); + let this->buffer .= pack("NN", v >> 32, v & 0xffffffff); } /** @@ -280,7 +280,7 @@ class BinaryStream */ public function putLLong(int v) { - let this->buffer .= \pack("VV", v & 0xffffffff, v >> 32); + let this->buffer .= pack("VV", v & 0xffffffff, v >> 32); } /**