PHP_METHOD(PocketMine_Math_Vector2, distance) {

	zephir_nts_static zephir_fcall_cache_entry *_4 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *x, *y = NULL, *_0 = NULL, *_1, *_2, *_3 = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &x, &y);

	if (!y) {
		ZEPHIR_INIT_VAR(y);
		ZVAL_LONG(y, 0);
	}


	if (zephir_instance_of_ev(x, pocketmine_math_vector2_ce TSRMLS_CC)) {
		ZEPHIR_OBS_VAR(_1);
		zephir_read_property(&_1, x, SL("x"), PH_NOISY_CC);
		ZEPHIR_OBS_VAR(_2);
		zephir_read_property(&_2, x, SL("y"), PH_NOISY_CC);
		ZEPHIR_CALL_METHOD(&_0, this_ptr, "distancesquared", NULL, _1, _2);
		zephir_check_call_status();
		ZEPHIR_CALL_FUNCTION(&_3, "sqrt", &_4, _0);
		zephir_check_call_status();
		RETURN_MM_DOUBLE(zephir_get_doubleval(_3));
	}
	ZEPHIR_CALL_METHOD(&_0, this_ptr, "distancesquared", NULL, x, y);
	zephir_check_call_status();
	ZEPHIR_CALL_FUNCTION(&_3, "sqrt", &_4, _0);
	zephir_check_call_status();
	RETURN_MM_DOUBLE(zephir_get_doubleval(_3));

}
Beispiel #2
0
PHP_METHOD(Yb_Std, sizeToBytes) {

	unsigned char _6$$3;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *size_param = NULL, *match = NULL, *_0, *_1 = NULL, *_2, _3, *_4$$3, *_7$$4, *_8$$5, *_9$$6, *_10$$7;
	zval *size = NULL, *unit = NULL, *_5$$3 = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &size_param);

	zephir_get_strval(size, size_param);


	ZEPHIR_INIT_VAR(match);
	ZVAL_NULL(match);
	ZEPHIR_INIT_VAR(_0);
	ZEPHIR_INIT_VAR(_2);
	zephir_fast_strtoupper(_2, size);
	ZEPHIR_SINIT_VAR(_3);
	ZVAL_STRING(&_3, "/^([\\d\\.]+)([KMGT])B?$/", 0);
	zephir_preg_match(_0, &_3, _2, match, 0, 0 , 0  TSRMLS_CC);
	if (zephir_is_true(_0)) {
		ZEPHIR_OBS_VAR(_4$$3);
		zephir_array_fetch_long(&_4$$3, match, 2, PH_NOISY, "yb/std.zep", 17 TSRMLS_CC);
		zephir_get_strval(_5$$3, _4$$3);
		ZEPHIR_CPY_WRT(unit, _5$$3);
		_6$$3 = ZEPHIR_STRING_OFFSET(unit, 0);
		do {
			if (_6$$3 == 'T') {
				ZEPHIR_OBS_VAR(_7$$4);
				zephir_array_fetch_long(&_7$$4, match, 1, PH_NOISY, "yb/std.zep", 20 TSRMLS_CC);
				RETURN_MM_DOUBLE((1099511627776.0 * zephir_get_doubleval(_7$$4)));
			}
			if (_6$$3 == 'G') {
				ZEPHIR_OBS_VAR(_8$$5);
				zephir_array_fetch_long(&_8$$5, match, 1, PH_NOISY, "yb/std.zep", 22 TSRMLS_CC);
				RETURN_MM_DOUBLE((1073741824.0 * zephir_get_doubleval(_8$$5)));
			}
			if (_6$$3 == 'M') {
				ZEPHIR_OBS_VAR(_9$$6);
				zephir_array_fetch_long(&_9$$6, match, 1, PH_NOISY, "yb/std.zep", 24 TSRMLS_CC);
				RETURN_MM_DOUBLE((1048576.0 * zephir_get_doubleval(_9$$6)));
			}
			if (_6$$3 == 'K') {
				ZEPHIR_OBS_VAR(_10$$7);
				zephir_array_fetch_long(&_10$$7, match, 1, PH_NOISY, "yb/std.zep", 26 TSRMLS_CC);
				RETURN_MM_DOUBLE((1024.0 * zephir_get_doubleval(_10$$7)));
			}
		} while(0);

	}
	ZEPHIR_RETURN_CALL_FUNCTION("floatval", NULL, 75, size);
	zephir_check_call_status();
	RETURN_MM();

}
Beispiel #3
0
PHP_METHOD(Test_Compare, isLessDouble) {

	zval *a_param = NULL, *b_param = NULL;
	double a, b;

	zephir_fetch_params(0, 2, 0, &a_param, &b_param);

	a = zephir_get_doubleval(a_param);
	b = zephir_get_doubleval(b_param);


	RETURN_BOOL(a < b);

}
PHP_METHOD(PocketMine_Level_Generator_Noise_Generator, lerp) {

	zval *x_param = NULL, *y_param = NULL, *z_param = NULL;
	double x, y, z;

	zephir_fetch_params(0, 3, 0, &x_param, &y_param, &z_param);

	x = zephir_get_doubleval(x_param);
	y = zephir_get_doubleval(y_param);
	z = zephir_get_doubleval(z_param);


	RETURN_DOUBLE((y + (x * ((z - y)))));

}
PHP_METHOD(PocketMine_Level_Generator_Noise_Generator, noise3D) {

	zephir_fcall_cache_entry *_5 = NULL;
	int i = 0, ZEPHIR_LAST_CALL_STATUS;
	zend_bool normalized;
	zval *x_param = NULL, *y_param = NULL, *z_param = NULL, *normalized_param = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_6, *_7;
	double x, y, z, result = 0, amp = 1, freq = 1, max = 0;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 3, 1, &x_param, &y_param, &z_param, &normalized_param);

	x = zephir_get_doubleval(x_param);
	y = zephir_get_doubleval(y_param);
	z = zephir_get_doubleval(z_param);
	if (!normalized_param) {
		normalized = 0;
	} else {
		normalized = zephir_get_boolval(normalized_param);
	}


	while (1) {
		_0 = zephir_fetch_nproperty_this(this_ptr, SL("octaves"), PH_NOISY_CC);
		if (!(ZEPHIR_GT_LONG(_0, i))) {
			break;
		}
		ZEPHIR_INIT_NVAR(_2);
		ZVAL_DOUBLE(_2, (x * freq));
		ZEPHIR_INIT_NVAR(_3);
		ZVAL_DOUBLE(_3, (y * freq));
		ZEPHIR_INIT_NVAR(_4);
		ZVAL_DOUBLE(_4, (z * freq));
		ZEPHIR_CALL_METHOD(&_1, this_ptr, "getnoise3d", &_5, _2, _3, _4);
		zephir_check_call_status();
		result += (double) (zephir_get_doubleval(_1) * amp);
		max += amp;
		_6 = zephir_fetch_nproperty_this(this_ptr, SL("frequency"), PH_NOISY_CC);
		freq *= zephir_get_numberval(_6);
		_7 = zephir_fetch_nproperty_this(this_ptr, SL("amplitude"), PH_NOISY_CC);
		amp *= zephir_get_numberval(_7);
		i++;
	}
	if (normalized == 1) {
		result = (result / max);
	}
	RETURN_MM_DOUBLE(result);

}
PHP_METHOD(PocketMine_Math_Vector2, dot) {

	zval *v, *_0, *_1, _2, _3, *_4;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &v);



	if (!(zephir_instance_of_ev(v, pocketmine_math_vector2_ce TSRMLS_CC))) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Parameter 'v' must be an instance of 'PocketMine\\Math\\Vector2'", "", 0);
		return;
	}
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("x"), PH_NOISY_CC);
	_1 = zephir_fetch_nproperty_this(v, SL("x"), PH_NOISY_CC);
	ZEPHIR_SINIT_VAR(_2);
	mul_function(&_2, _0, _1 TSRMLS_CC);
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("y"), PH_NOISY_CC);
	_1 = zephir_fetch_nproperty_this(v, SL("y"), PH_NOISY_CC);
	ZEPHIR_SINIT_VAR(_3);
	mul_function(&_3, _0, _1 TSRMLS_CC);
	ZEPHIR_INIT_VAR(_4);
	zephir_add_function(_4, &_2, &_3 TSRMLS_CC);
	RETURN_MM_DOUBLE(zephir_get_doubleval(_4));

}
PHP_METHOD(PocketMine_Math_Vector2, normalize) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *_0 = NULL, *_1 = NULL, *_2 = NULL, *_3;
	double len;

	ZEPHIR_MM_GROW();

	ZEPHIR_CALL_METHOD(&_0, this_ptr, "length",  NULL);
	zephir_check_call_status();
	len = zephir_get_doubleval(_0);
	if (len != 0) {
		ZEPHIR_INIT_VAR(_2);
		ZVAL_DOUBLE(_2, len);
		ZEPHIR_CALL_METHOD(&_1, this_ptr, "divide", NULL, _2);
		zephir_check_call_status();
		RETURN_CCTOR(_1);
	}
	object_init_ex(return_value, pocketmine_math_vector2_ce);
	ZEPHIR_INIT_NVAR(_2);
	ZVAL_LONG(_2, 0);
	ZEPHIR_INIT_VAR(_3);
	ZVAL_LONG(_3, 0);
	ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, _2, _3);
	zephir_check_call_status();
	RETURN_MM();

}
PHP_METHOD(PocketMine_Math_Vector2, length) {

	zephir_nts_static zephir_fcall_cache_entry *_3 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *_0 = NULL, _1, *_2 = NULL;

	ZEPHIR_MM_GROW();

	ZEPHIR_CALL_METHOD(&_0, this_ptr, "lengthsquared",  NULL);
	zephir_check_call_status();
	ZEPHIR_SINIT_VAR(_1);
	ZVAL_DOUBLE(&_1, zephir_get_doubleval(_0));
	ZEPHIR_CALL_FUNCTION(&_2, "sqrt", &_3, &_1);
	zephir_check_call_status();
	RETURN_MM_DOUBLE(zephir_get_doubleval(_2));

}
Beispiel #9
0
PHP_METHOD(Test_Geometry, distanceStatic) {

	zval *x1_param = NULL, *y1_param = NULL, *x2_param = NULL, *y2_param = NULL, *_0;
	double x1, y1, x2, y2;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 4, 0, &x1_param, &y1_param, &x2_param, &y2_param);

	x1 = zephir_get_doubleval(x1_param);
	y1 = zephir_get_doubleval(y1_param);
	x2 = zephir_get_doubleval(x2_param);
	y2 = zephir_get_doubleval(y2_param);


	ZEPHIR_INIT_VAR(_0);
	ZVAL_DOUBLE(_0, ((((x1 - x2)) * ((x1 - x2))) + (((y1 - y2)) * ((y1 - y2)))));
	RETURN_MM_DOUBLE(sqrt(((((x1 - x2)) * ((x1 - x2))) + (((y1 - y2)) * ((y1 - y2))))));

}
PHP_METHOD(PocketMine_Level_Generator_Noise_Generator, fade) {

	zval *x_param = NULL;
	double x;

	zephir_fetch_params(0, 1, 0, &x_param);

	x = zephir_get_doubleval(x_param);


	RETURN_DOUBLE(((double) ((x * x) * x) * (((x * (((x * (double) 6) - (double) (15)))) + (double) (10)))));

}
Beispiel #11
0
PHP_METHOD(Test_Compare, isMoreThenPi) {

	zval *a_param = NULL;
	double a;

	zephir_fetch_params(0, 1, 0, &a_param);

	a = zephir_get_doubleval(a_param);


	RETURN_BOOL(3.14 < a);

}
Beispiel #12
0
PHP_METHOD(Test_Oo_OoParams, setAverage) {

	zval *average_param = NULL;
	double average;

	zephir_fetch_params(0, 1, 0, &average_param);

	average = zephir_get_doubleval(average_param);


	RETURN_DOUBLE(average);

}
PHP_METHOD(PocketMine_Level_Generator_Noise_Generator, setOffset) {

	zval *x_param = NULL, *y_param = NULL, *z_param = NULL, *_0;
	double x, y, z;

	zephir_fetch_params(0, 3, 0, &x_param, &y_param, &z_param);

	x = zephir_get_doubleval(x_param);
	y = zephir_get_doubleval(y_param);
	z = zephir_get_doubleval(z_param);


	ZEPHIR_INIT_ZVAL_NREF(_0);
	ZVAL_DOUBLE(_0, x);
	zephir_update_property_this(this_ptr, SL("offsetX"), _0 TSRMLS_CC);
	ZEPHIR_INIT_ZVAL_NREF(_0);
	ZVAL_DOUBLE(_0, y);
	zephir_update_property_this(this_ptr, SL("offsetY"), _0 TSRMLS_CC);
	ZEPHIR_INIT_ZVAL_NREF(_0);
	ZVAL_DOUBLE(_0, z);
	zephir_update_property_this(this_ptr, SL("offsetZ"), _0 TSRMLS_CC);

}
Beispiel #14
0
PHP_METHOD(Test_Compare, isLessThenPi) {

	zval *a_param = NULL;
	double a;
	zval *this_ptr = getThis();


	zephir_fetch_params(0, 1, 0, &a_param);

	a = zephir_get_doubleval(a_param);


	RETURN_BOOL(a < 3.14);

}
Beispiel #15
0
/**
 * For double parameter
 * @link https://github.com/phalcon/zephir/issues/696
 */
PHP_METHOD(Test_MethodArgs, methodOptionalDoubleValueWithDefaultStaticConstantAccess) {

	zval *parameter_param = NULL;
	double parameter;

	zephir_fetch_params(0, 0, 1, &parameter_param);

	if (!parameter_param) {
		parameter = 1.32;
	} else {
		parameter = zephir_get_doubleval(parameter_param);
	}


	RETURN_DOUBLE(parameter);

}
Beispiel #16
0
PHP_METHOD(Test_Oo_OoParams, setAverageDefault) {

	zval *average_param = NULL;
	double average;

	zephir_fetch_params(0, 0, 1, &average_param);

	if (!average_param) {
		average = (double) 25;
	} else {
		average = zephir_get_doubleval(average_param);
	}


	RETURN_DOUBLE(average);

}
PHP_METHOD(PocketMine_Math_Vector2, lengthSquared) {

	zval *_0, *_1, _2, _3, *_4;

	ZEPHIR_MM_GROW();

	_0 = zephir_fetch_nproperty_this(this_ptr, SL("x"), PH_NOISY_CC);
	_1 = zephir_fetch_nproperty_this(this_ptr, SL("x"), PH_NOISY_CC);
	ZEPHIR_SINIT_VAR(_2);
	mul_function(&_2, _0, _1 TSRMLS_CC);
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("y"), PH_NOISY_CC);
	_1 = zephir_fetch_nproperty_this(this_ptr, SL("y"), PH_NOISY_CC);
	ZEPHIR_SINIT_VAR(_3);
	mul_function(&_3, _0, _1 TSRMLS_CC);
	ZEPHIR_INIT_VAR(_4);
	zephir_add_function(_4, &_2, &_3 TSRMLS_CC);
	RETURN_MM_DOUBLE(zephir_get_doubleval(_4));

}
PHP_METHOD(PocketMine_Level_Generator_Noise_Generator, floor) {

	zval *x_param = NULL, *_0;
	double x;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &x_param);

	x = zephir_get_doubleval(x_param);


	ZEPHIR_INIT_VAR(_0);
	if (x >= 0) {
		ZVAL_LONG(_0, (long) (x));
	} else {
		ZVAL_LONG(_0, ((long) (x) - 1));
	}
	RETURN_CCTOR(_0);

}
Beispiel #19
0
PHP_METHOD(Test_McallInternal, callFibonacci) {

	zval _3$$3, _4$$3, _5$$3;
	zend_bool _0;
	long i;
	double p;
	zend_long ZEPHIR_LAST_CALL_STATUS, _1, _2;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&_3$$3);
	ZVAL_UNDEF(&_4$$3);
	ZVAL_UNDEF(&_5$$3);

	ZEPHIR_MM_GROW();

	p = (double) (0);
	i = 0;
	_2 = 10000000;
	_1 = 0;
	_0 = 0;
	if (_1 <= _2) {
		while (1) {
			if (_0) {
				_1++;
				if (!(_1 <= _2)) {
					break;
				}
			} else {
				_0 = 1;
			}
			i = _1;
			ZVAL_LONG(&_4$$3, i);
			ZVAL_LONG(&_5$$3, (i + 1));
			ZEPHIR_CALL_INTERNAL_METHOD_P2(&_3$$3, this_ptr, zep_Test_McallInternal_other, &_4$$3, &_5$$3);
			zephir_check_call_status();
			p += zephir_get_doubleval(&_3$$3);
		}
	}
	RETURN_MM_DOUBLE(p);

}
PHP_METHOD(PocketMine_Math_Vector2, distanceSquared) {

	zephir_nts_static zephir_fcall_cache_entry *_5 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *x, *y = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, _3 = zval_used_for_init, _4 = zval_used_for_init, *_6 = NULL, *_7;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &x, &y);

	if (!y) {
		ZEPHIR_INIT_VAR(y);
		ZVAL_LONG(y, 0);
	}


	if (zephir_instance_of_ev(x, pocketmine_math_vector2_ce TSRMLS_CC)) {
		ZEPHIR_OBS_VAR(_1);
		zephir_read_property(&_1, x, SL("x"), PH_NOISY_CC);
		ZEPHIR_OBS_VAR(_2);
		zephir_read_property(&_2, x, SL("y"), PH_NOISY_CC);
		ZEPHIR_CALL_METHOD(&_0, this_ptr, "distancesquared", NULL, _1, _2);
		zephir_check_call_status();
		RETURN_MM_DOUBLE(zephir_get_doubleval(_0));
	}
	ZEPHIR_OBS_NVAR(_1);
	zephir_read_property_this(&_1, this_ptr, SL("x"), PH_NOISY_CC);
	ZEPHIR_SINIT_VAR(_3);
	ZVAL_DOUBLE(&_3, (zephir_get_doubleval(_1) - zephir_get_doubleval(x)));
	ZEPHIR_SINIT_VAR(_4);
	ZVAL_LONG(&_4, 2);
	ZEPHIR_CALL_FUNCTION(&_0, "pow", &_5, &_3, &_4);
	zephir_check_call_status();
	ZEPHIR_OBS_NVAR(_2);
	zephir_read_property_this(&_2, this_ptr, SL("y"), PH_NOISY_CC);
	ZEPHIR_SINIT_NVAR(_3);
	ZVAL_DOUBLE(&_3, (zephir_get_doubleval(_2) - zephir_get_doubleval(y)));
	ZEPHIR_SINIT_NVAR(_4);
	ZVAL_LONG(&_4, 2);
	ZEPHIR_CALL_FUNCTION(&_6, "pow", &_5, &_3, &_4);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(_7);
	zephir_add_function(_7, _0, _6 TSRMLS_CC);
	RETURN_MM_DOUBLE(zephir_get_doubleval(_7));

}
Beispiel #21
0
PHP_METHOD(Yb_Std, bytesToSize) {

	zend_bool _0;
	zval *size;
	int ZEPHIR_LAST_CALL_STATUS;
	zephir_fcall_cache_entry *_4 = NULL;
	long decimal;
	zval *bytes_param = NULL, *decimal_param = NULL, _1$$4 = zval_used_for_init, _2$$4, *_3$$4 = NULL, _5$$5 = zval_used_for_init, _6$$5, *_7$$5 = NULL, _8$$6 = zval_used_for_init, _9$$6, *_10$$6 = NULL, _11$$7 = zval_used_for_init, _12$$7, *_13$$7 = NULL, _14$$8 = zval_used_for_init, _15$$8, *_16$$8 = NULL;
	double bytes;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &bytes_param, &decimal_param);

	bytes = zephir_get_doubleval(bytes_param);
	if (!decimal_param) {
		decimal = 3;
	} else {
		decimal = zephir_get_intval(decimal_param);
	}


	ZEPHIR_INIT_VAR(size);
	ZVAL_STRING(size, "0", 1);
	_0 = decimal < 0;
	if (!(_0)) {
		_0 = decimal > 6;
	}
	if (_0) {
		decimal = 3;
	}
	if (bytes > 1099511627776.0) {
		ZEPHIR_SINIT_VAR(_1$$4);
		ZVAL_STRING(&_1$$4, "%%0.%dfT", 0);
		ZEPHIR_SINIT_VAR(_2$$4);
		ZVAL_LONG(&_2$$4, decimal);
		ZEPHIR_CALL_FUNCTION(&_3$$4, "sprintf", &_4, 1, &_1$$4, &_2$$4);
		zephir_check_call_status();
		ZEPHIR_SINIT_NVAR(_1$$4);
		ZVAL_DOUBLE(&_1$$4, zephir_safe_div_double_long(bytes, 1099511627776.0 TSRMLS_CC));
		ZEPHIR_RETURN_CALL_FUNCTION("sprintf", &_4, 1, _3$$4, &_1$$4);
		zephir_check_call_status();
		RETURN_MM();
	}
	if (bytes > 1073741824.0) {
		ZEPHIR_SINIT_VAR(_5$$5);
		ZVAL_STRING(&_5$$5, "%%0.%dfG", 0);
		ZEPHIR_SINIT_VAR(_6$$5);
		ZVAL_LONG(&_6$$5, decimal);
		ZEPHIR_CALL_FUNCTION(&_7$$5, "sprintf", &_4, 1, &_5$$5, &_6$$5);
		zephir_check_call_status();
		ZEPHIR_SINIT_NVAR(_5$$5);
		ZVAL_DOUBLE(&_5$$5, zephir_safe_div_double_long(bytes, 1073741824.0 TSRMLS_CC));
		ZEPHIR_RETURN_CALL_FUNCTION("sprintf", &_4, 1, _7$$5, &_5$$5);
		zephir_check_call_status();
		RETURN_MM();
	}
	if (bytes > 1048576.0) {
		ZEPHIR_SINIT_VAR(_8$$6);
		ZVAL_STRING(&_8$$6, "%%0.%dfM", 0);
		ZEPHIR_SINIT_VAR(_9$$6);
		ZVAL_LONG(&_9$$6, decimal);
		ZEPHIR_CALL_FUNCTION(&_10$$6, "sprintf", &_4, 1, &_8$$6, &_9$$6);
		zephir_check_call_status();
		ZEPHIR_SINIT_NVAR(_8$$6);
		ZVAL_DOUBLE(&_8$$6, zephir_safe_div_double_long(bytes, 1048576.0 TSRMLS_CC));
		ZEPHIR_RETURN_CALL_FUNCTION("sprintf", &_4, 1, _10$$6, &_8$$6);
		zephir_check_call_status();
		RETURN_MM();
	}
	if (bytes > 1024.0) {
		ZEPHIR_SINIT_VAR(_11$$7);
		ZVAL_STRING(&_11$$7, "%%0.%dfK", 0);
		ZEPHIR_SINIT_VAR(_12$$7);
		ZVAL_LONG(&_12$$7, decimal);
		ZEPHIR_CALL_FUNCTION(&_13$$7, "sprintf", &_4, 1, &_11$$7, &_12$$7);
		zephir_check_call_status();
		ZEPHIR_SINIT_NVAR(_11$$7);
		ZVAL_DOUBLE(&_11$$7, zephir_safe_div_double_long(bytes, 1024.0 TSRMLS_CC));
		ZEPHIR_RETURN_CALL_FUNCTION("sprintf", &_4, 1, _13$$7, &_11$$7);
		zephir_check_call_status();
		RETURN_MM();
	}
	if (bytes > 1.0) {
		ZEPHIR_SINIT_VAR(_14$$8);
		ZVAL_STRING(&_14$$8, "%%0.%dfB", 0);
		ZEPHIR_SINIT_VAR(_15$$8);
		ZVAL_LONG(&_15$$8, decimal);
		ZEPHIR_CALL_FUNCTION(&_16$$8, "sprintf", &_4, 1, &_14$$8, &_15$$8);
		zephir_check_call_status();
		ZEPHIR_SINIT_NVAR(_14$$8);
		ZVAL_DOUBLE(&_14$$8, bytes);
		ZEPHIR_RETURN_CALL_FUNCTION("sprintf", &_4, 1, _16$$8, &_14$$8);
		zephir_check_call_status();
		RETURN_MM();
	}
	RETURN_CTOR(size);

}
Beispiel #22
0
/**
 * We have to cast values manually because parse_ini_file() has a poor implementation.
 *
 * @param mixed ini The array casted by `parse_ini_file`
 */
PHP_METHOD(Phalcon_Config_Adapter_Ini, _cast) {

	zend_bool _5$$5, _6$$5, _8$$5, _9$$5;
	HashTable *_1$$3;
	HashPosition _0$$3;
	zephir_fcall_cache_entry *_4 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *ini, *key = NULL, *val = NULL, **_2$$3, *_3$$4 = NULL, *_7$$5, *_10$$5, *_11$$9, *_12$$9, _13$$9;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &ini);

	ZEPHIR_SEPARATE_PARAM(ini);


	if (Z_TYPE_P(ini) == IS_ARRAY) {
		zephir_is_iterable(ini, &_1$$3, &_0$$3, 1, 0, "phalcon/config/adapter/ini.zep", 134);
		for (
		  ; zephir_hash_get_current_data_ex(_1$$3, (void**) &_2$$3, &_0$$3) == SUCCESS
		  ; zephir_hash_move_forward_ex(_1$$3, &_0$$3)
		) {
			ZEPHIR_GET_HMKEY(key, _1$$3, _0$$3);
			ZEPHIR_GET_HVALUE(val, _2$$3);
			ZEPHIR_CALL_METHOD(&_3$$4, this_ptr, "_cast", &_4, 135, val);
			zephir_check_call_status();
			zephir_array_update_zval(&ini, key, &_3$$4, PH_COPY | PH_SEPARATE);
		}
		zend_hash_destroy(_1$$3);
		FREE_HASHTABLE(_1$$3);
	}
	if (Z_TYPE_P(ini) == IS_STRING) {
		_5$$5 = ZEPHIR_IS_STRING_IDENTICAL(ini, "true");
		if (!(_5$$5)) {
			_5$$5 = ZEPHIR_IS_STRING_IDENTICAL(ini, "yes");
		}
		_6$$5 = _5$$5;
		if (!(_6$$5)) {
			ZEPHIR_INIT_VAR(_7$$5);
			zephir_fast_strtolower(_7$$5, ini);
			_6$$5 = ZEPHIR_IS_STRING_IDENTICAL(_7$$5, "on");
		}
		if (_6$$5) {
			RETURN_MM_BOOL(1);
		}
		_8$$5 = ZEPHIR_IS_STRING_IDENTICAL(ini, "false");
		if (!(_8$$5)) {
			_8$$5 = ZEPHIR_IS_STRING_IDENTICAL(ini, "no");
		}
		_9$$5 = _8$$5;
		if (!(_9$$5)) {
			ZEPHIR_INIT_VAR(_10$$5);
			zephir_fast_strtolower(_10$$5, ini);
			_9$$5 = ZEPHIR_IS_STRING_IDENTICAL(_10$$5, "off");
		}
		if (_9$$5) {
			RETURN_MM_BOOL(0);
		}
		if (ZEPHIR_IS_STRING_IDENTICAL(ini, "null")) {
			RETURN_MM_NULL();
		}
		if (zephir_is_numeric(ini)) {
			ZEPHIR_INIT_VAR(_11$$9);
			ZEPHIR_INIT_VAR(_12$$9);
			ZEPHIR_SINIT_VAR(_13$$9);
			ZVAL_STRING(&_13$$9, "/[.]+/", 0);
			zephir_preg_match(_12$$9, &_13$$9, ini, _11$$9, 0, 0 , 0  TSRMLS_CC);
			if (zephir_is_true(_12$$9)) {
				RETURN_MM_DOUBLE(zephir_get_doubleval(ini));
			} else {
				RETURN_MM_LONG(zephir_get_intval(ini));
			}
		}
	}
	RETVAL_ZVAL(ini, 1, 0);
	RETURN_MM();

}
Beispiel #23
0
/**
 * Internal sanitize wrapper to filter_var
 */
PHP_METHOD(Phalcon_Filter, _sanitize) {

	zephir_fcall_cache_entry *_8 = NULL;
	zephir_nts_static zephir_fcall_cache_entry *_7 = NULL, *_9 = NULL, *_11 = NULL, *_12 = NULL, *_14 = NULL;
	zval *_1 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *filter = NULL, *_13;
	zval *value, *filter_param = NULL, *filterObject, *_0, *_2 = NULL, _3 = zval_used_for_init, _4, _5, *_6 = NULL, *_10;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &value, &filter_param);

	if (unlikely(Z_TYPE_P(filter_param) != IS_STRING && Z_TYPE_P(filter_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'filter' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}

	if (likely(Z_TYPE_P(filter_param) == IS_STRING)) {
		zephir_get_strval(filter, filter_param);
	} else {
		ZEPHIR_INIT_VAR(filter);
		ZVAL_EMPTY_STRING(filter);
	}


	ZEPHIR_OBS_VAR(filterObject);
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_filters"), PH_NOISY_CC);
	if (zephir_array_isset_fetch(&filterObject, _0, filter, 0 TSRMLS_CC)) {
		if (zephir_instance_of_ev(filterObject, zend_ce_closure TSRMLS_CC)) {
			ZEPHIR_INIT_VAR(_1);
			zephir_create_array(_1, 1, 0 TSRMLS_CC);
			zephir_array_fast_append(_1, value);
			ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, filterObject, _1);
			zephir_check_call_status();
			RETURN_MM();
		}
		ZEPHIR_RETURN_CALL_METHOD(filterObject, "filter", NULL, value);
		zephir_check_call_status();
		RETURN_MM();
	}
	do {
		if (ZEPHIR_IS_STRING(filter, "email")) {
			ZEPHIR_INIT_VAR(_2);
			ZEPHIR_SINIT_VAR(_3);
			ZVAL_STRING(&_3, "'", 0);
			ZEPHIR_SINIT_VAR(_4);
			ZVAL_STRING(&_4, "", 0);
			zephir_fast_str_replace(&_2, &_3, &_4, value TSRMLS_CC);
			ZEPHIR_SINIT_VAR(_5);
			ZVAL_STRING(&_5, "FILTER_SANITIZE_EMAIL", 0);
			ZEPHIR_CALL_FUNCTION(&_6, "constant", &_7, &_5);
			zephir_check_call_status();
			ZEPHIR_RETURN_CALL_FUNCTION("filter_var", &_8, _2, _6);
			zephir_check_call_status();
			RETURN_MM();
		}
		if (ZEPHIR_IS_STRING(filter, "int")) {
			ZEPHIR_SINIT_NVAR(_3);
			ZVAL_LONG(&_3, 519);
			ZEPHIR_RETURN_CALL_FUNCTION("filter_var", &_8, value, &_3);
			zephir_check_call_status();
			RETURN_MM();
		}
		if (ZEPHIR_IS_STRING(filter, "int!")) {
			RETURN_MM_LONG(zephir_get_intval(value));
		}
		if (ZEPHIR_IS_STRING(filter, "absint")) {
			ZEPHIR_SINIT_NVAR(_3);
			ZVAL_LONG(&_3, zephir_get_intval(value));
			ZEPHIR_RETURN_CALL_FUNCTION("abs", &_9, &_3);
			zephir_check_call_status();
			RETURN_MM();
		}
		if (ZEPHIR_IS_STRING(filter, "string")) {
			ZEPHIR_SINIT_NVAR(_3);
			ZVAL_LONG(&_3, 513);
			ZEPHIR_RETURN_CALL_FUNCTION("filter_var", &_8, value, &_3);
			zephir_check_call_status();
			RETURN_MM();
		}
		if (ZEPHIR_IS_STRING(filter, "float")) {
			ZEPHIR_INIT_NVAR(_1);
			zephir_create_array(_1, 1, 0 TSRMLS_CC);
			add_assoc_long_ex(_1, SS("flags"), 4096);
			ZEPHIR_SINIT_NVAR(_3);
			ZVAL_LONG(&_3, 520);
			ZEPHIR_RETURN_CALL_FUNCTION("filter_var", &_8, value, &_3, _1);
			zephir_check_call_status();
			RETURN_MM();
		}
		if (ZEPHIR_IS_STRING(filter, "float!")) {
			RETURN_MM_DOUBLE(zephir_get_doubleval(value));
		}
		if (ZEPHIR_IS_STRING(filter, "alphanum")) {
			ZEPHIR_INIT_NVAR(_2);
			ZVAL_STRING(_2, "/[^A-Za-z0-9]/", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_INIT_VAR(_10);
			ZVAL_STRING(_10, "", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_RETURN_CALL_FUNCTION("preg_replace", &_11, _2, _10, value);
			zephir_check_temp_parameter(_2);
			zephir_check_temp_parameter(_10);
			zephir_check_call_status();
			RETURN_MM();
		}
		if (ZEPHIR_IS_STRING(filter, "trim")) {
			zephir_fast_trim(return_value, value, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC);
			RETURN_MM();
		}
		if (ZEPHIR_IS_STRING(filter, "striptags")) {
			ZEPHIR_RETURN_CALL_FUNCTION("strip_tags", &_12, value);
			zephir_check_call_status();
			RETURN_MM();
		}
		if (ZEPHIR_IS_STRING(filter, "lower")) {
			if ((zephir_function_exists_ex(SS("mb_strtolower") TSRMLS_CC) == SUCCESS)) {
				ZEPHIR_RETURN_CALL_FUNCTION("mb_strtolower", NULL, value);
				zephir_check_call_status();
				RETURN_MM();
			}
			zephir_fast_strtolower(return_value, value);
			RETURN_MM();
		}
		if (ZEPHIR_IS_STRING(filter, "upper")) {
			if ((zephir_function_exists_ex(SS("mb_strtoupper") TSRMLS_CC) == SUCCESS)) {
				ZEPHIR_RETURN_CALL_FUNCTION("mb_strtoupper", NULL, value);
				zephir_check_call_status();
				RETURN_MM();
			}
			zephir_fast_strtoupper(return_value, value);
			RETURN_MM();
		}
		ZEPHIR_INIT_NVAR(_2);
		object_init_ex(_2, phalcon_filter_exception_ce);
		ZEPHIR_INIT_VAR(_13);
		ZEPHIR_CONCAT_SVS(_13, "Sanitize filter '", filter, "' is not supported");
		ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_14, _13);
		zephir_check_call_status();
		zephir_throw_exception_debug(_2, "phalcon/filter.zep", 214 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	} while(0);

	ZEPHIR_MM_RESTORE();

}
Beispiel #24
0
/**
 * Executes a prepared statement binding. This function uses integer indexes starting from zero
 *
 *<code>
 * $statement = $db->prepare('SELECT * FROM robots WHERE name = :name');
 * $result = $connection->executePrepared($statement, array('name' => 'Voltron'));
 *</code>
 *
 * @param \PDOStatement statement
 * @param array placeholders
 * @param array dataTypes
 * @return \PDOStatement
 */
PHP_METHOD(Phalcon_Db_Adapter_Pdo, executePrepared) {

	zephir_fcall_cache_entry *_4 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zend_bool _3;
	HashTable *_1;
	HashPosition _0;
	zval *placeholders = NULL;
	zval *statement, *placeholders_param = NULL, *dataTypes, *wildcard = NULL, *value = NULL, *type = NULL, *castValue = NULL, *parameter = NULL, **_2;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 3, 0, &statement, &placeholders_param, &dataTypes);

	placeholders = placeholders_param;



	zephir_is_iterable(placeholders, &_1, &_0, 0, 0, "phalcon/db/adapter/pdo.zep", 215);
	for (
	  ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS
	  ; zephir_hash_move_forward_ex(_1, &_0)
	) {
		ZEPHIR_GET_HMKEY(wildcard, _1, _0);
		ZEPHIR_GET_HVALUE(value, _2);
		if (Z_TYPE_P(wildcard) == IS_LONG) {
			ZEPHIR_INIT_NVAR(parameter);
			ZVAL_LONG(parameter, (zephir_get_numberval(wildcard) + 1));
		} else {
			if (Z_TYPE_P(wildcard) == IS_STRING) {
				ZEPHIR_CPY_WRT(parameter, wildcard);
			} else {
				ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid bind parameter (1)", "phalcon/db/adapter/pdo.zep", 188);
				return;
			}
		}
		_3 = Z_TYPE_P(dataTypes) == IS_ARRAY;
		if (_3) {
			ZEPHIR_OBS_NVAR(type);
			_3 = zephir_array_isset_fetch(&type, dataTypes, wildcard, 0 TSRMLS_CC);
		}
		if (_3) {
			if (ZEPHIR_IS_LONG(type, 32)) {
				ZEPHIR_INIT_NVAR(castValue);
				ZVAL_DOUBLE(castValue, zephir_get_doubleval(value));
				ZEPHIR_INIT_NVAR(type);
				ZVAL_LONG(type, 1024);
			} else {
				ZEPHIR_CPY_WRT(castValue, value);
			}
			if (ZEPHIR_IS_LONG(type, 1024)) {
				ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_4, 0, parameter, castValue);
				zephir_check_call_status();
			} else {
				ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_4, 0, parameter, castValue, type);
				zephir_check_call_status();
			}
		} else {
			ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_4, 0, parameter, value);
			zephir_check_call_status();
		}
	}
	ZEPHIR_CALL_METHOD(NULL, statement, "execute", NULL, 0);
	zephir_check_call_status();
	RETVAL_ZVAL(statement, 1, 0);
	RETURN_MM();

}
Beispiel #25
0
PHP_METHOD(Test_Quantum, harmos) {

	zend_bool _13, _16, _32, _35;
	zval *_10 = NULL, *_11 = NULL, *_12 = NULL;
	zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL, *_8 = NULL, *_36 = NULL;
	int i, j, n, ZEPHIR_LAST_CALL_STATUS, _14, _15, _17, _18, _33, _34;
	zval *x_param = NULL, *psr, *psi, *p2, *v, *paramater, *fp = NULL, *tmp, *_0 = NULL, _1 = zval_used_for_init, _2 = zval_used_for_init, *_3 = NULL, *_5 = NULL, *_7 = NULL, *_9 = NULL, *_19, *_20, *_21, *_22, *_23, *_24, *_25, *_26, _27 = zval_used_for_init, *_28, *_29, *_30, *_31;
	double x, dt, dx, k0, item_psr, item_psi;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &x_param);

	x = zephir_get_doubleval(x_param);


	dx = 0.02;
	k0 = (3.0 * 3.14159265358979323846);
	dt = zephir_safe_div_double_long((dx * dx), 4.0 TSRMLS_CC);
	ZEPHIR_INIT_VAR(paramater);
	zephir_create_array(paramater, 4, 0 TSRMLS_CC);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_DOUBLE(_0, dx);
	zephir_array_fast_append(paramater, _0);
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_DOUBLE(_0, k0);
	zephir_array_fast_append(paramater, _0);
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_DOUBLE(_0, dt);
	zephir_array_fast_append(paramater, _0);
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_DOUBLE(_0, x);
	zephir_array_fast_append(paramater, _0);
	i = 0;
	ZEPHIR_INIT_VAR(psr);
	array_init(psr);
	ZEPHIR_INIT_VAR(psi);
	array_init(psi);
	ZEPHIR_INIT_VAR(p2);
	array_init(p2);
	ZEPHIR_INIT_VAR(v);
	array_init(v);
	ZEPHIR_SINIT_VAR(_1);
	ZVAL_STRING(&_1, "harmos.txt", 0);
	ZEPHIR_SINIT_VAR(_2);
	ZVAL_STRING(&_2, "w", 0);
	ZEPHIR_CALL_FUNCTION(&fp, "fopen", NULL, 30, &_1, &_2);
	zephir_check_call_status();
	if (!(zephir_is_true(fp))) {
		RETURN_MM_LONG(1);
	}
	while (1) {
		if (!(i <= 751)) {
			break;
		}
		ZEPHIR_SINIT_NVAR(_1);
		ZVAL_DOUBLE(&_1, (k0 * x));
		ZEPHIR_CALL_FUNCTION(&_3, "sin", &_4, 10, &_1);
		zephir_check_call_status();
		ZEPHIR_SINIT_NVAR(_1);
		ZVAL_DOUBLE(&_1, ((x * x) * 2.0));
		ZEPHIR_CALL_FUNCTION(&_5, "exp", &_6, 1, &_1);
		zephir_check_call_status();
		ZEPHIR_INIT_LNVAR(_7);
		div_function(_7, _3, _5 TSRMLS_CC);
		item_psi = zephir_get_numberval(_7);
		ZEPHIR_SINIT_NVAR(_1);
		ZVAL_DOUBLE(&_1, (k0 * x));
		ZEPHIR_CALL_FUNCTION(&_3, "cos", &_8, 11, &_1);
		zephir_check_call_status();
		ZEPHIR_SINIT_NVAR(_1);
		ZVAL_DOUBLE(&_1, ((x * x) * 2.0));
		ZEPHIR_CALL_FUNCTION(&_5, "exp", &_6, 1, &_1);
		zephir_check_call_status();
		ZEPHIR_INIT_LNVAR(_9);
		div_function(_9, _3, _5 TSRMLS_CC);
		item_psr = zephir_get_numberval(_9);
		ZEPHIR_INIT_NVAR(_10);
		zephir_create_array(_10, 1, 0 TSRMLS_CC);
		ZEPHIR_INIT_NVAR(_0);
		ZVAL_DOUBLE(_0, item_psr);
		zephir_array_fast_append(_10, _0);
		zephir_array_update_long(&psr, i, &_10, PH_COPY | PH_SEPARATE, "test/quantum.zep", 39);
		ZEPHIR_INIT_NVAR(_11);
		zephir_create_array(_11, 1, 0 TSRMLS_CC);
		ZEPHIR_INIT_NVAR(_0);
		ZVAL_DOUBLE(_0, item_psi);
		zephir_array_fast_append(_11, _0);
		zephir_array_update_long(&psi, i, &_11, PH_COPY | PH_SEPARATE, "test/quantum.zep", 40);
		ZEPHIR_INIT_NVAR(_12);
		zephir_create_array(_12, 1, 0 TSRMLS_CC);
		ZEPHIR_INIT_NVAR(_0);
		ZVAL_DOUBLE(_0, (double) ((double) (5.0 * x) * x));
		zephir_array_fast_append(_12, _0);
		zephir_array_update_long(&v, i, &_12, PH_COPY | PH_SEPARATE, "test/quantum.zep", 41);
		x = (x + dx);
		i++;
	}
	i = 1;
	j = 1;
	ZEPHIR_INIT_VAR(tmp);
	zephir_create_array(tmp, 1, 0 TSRMLS_CC);
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_DOUBLE(_0, 2.0);
	zephir_array_fast_append(tmp, _0);
	_15 = 20000;
	_14 = 0;
	_13 = 0;
	if (_14 <= _15) {
		while (1) {
			if (_13) {
				_14++;
				if (!(_14 <= _15)) {
					break;
				}
			} else {
				_13 = 1;
			}
			n = _14;
			_18 = (751 - 1);
			_17 = 1;
			_16 = 0;
			if (_17 <= _18) {
				while (1) {
					if (_16) {
						_17++;
						if (!(_17 <= _18)) {
							break;
						}
					} else {
						_16 = 1;
					}
					i = _17;
					zephir_array_fetch_long(&_19, psr, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 50 TSRMLS_CC);
					zephir_array_fetch_long(&_20, _19, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 50 TSRMLS_CC);
					zephir_array_fetch_long(&_21, paramater, 2, PH_NOISY | PH_READONLY, "test/quantum.zep", 50 TSRMLS_CC);
					zephir_array_fetch_long(&_22, psi, (i + 1), PH_NOISY | PH_READONLY, "test/quantum.zep", 50 TSRMLS_CC);
					zephir_array_fetch_long(&_23, _22, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 50 TSRMLS_CC);
					zephir_array_fetch_long(&_24, psi, (i - 1), PH_NOISY | PH_READONLY, "test/quantum.zep", 50 TSRMLS_CC);
					zephir_array_fetch_long(&_25, _24, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_1);
					zephir_add_function_ex(&_1, _23, _25 TSRMLS_CC);
					zephir_array_fetch_long(&_23, tmp, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC);
					zephir_array_fetch_long(&_25, psi, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC);
					zephir_array_fetch_long(&_26, _25, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_2);
					mul_function(&_2, _23, _26 TSRMLS_CC);
					ZEPHIR_INIT_LNVAR(_7);
					sub_function(_7, &_1, &_2 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_1);
					mul_function(&_1, _21, _7 TSRMLS_CC);
					zephir_array_fetch_long(&_21, paramater, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC);
					zephir_array_fetch_long(&_23, paramater, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC);
					ZEPHIR_INIT_LNVAR(_7);
					mul_function(_7, _21, _23 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_2);
					div_function(&_2, &_1, _7 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_1);
					sub_function(&_1, _20, &_2 TSRMLS_CC);
					zephir_array_fetch_long(&_20, paramater, 2, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC);
					zephir_array_fetch_long(&_21, v, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC);
					zephir_array_fetch_long(&_23, _21, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_2);
					mul_function(&_2, _20, _23 TSRMLS_CC);
					zephir_array_fetch_long(&_20, psi, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC);
					zephir_array_fetch_long(&_23, _20, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 51 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_27);
					mul_function(&_27, &_2, _23 TSRMLS_CC);
					ZEPHIR_INIT_LNVAR(_7);
					zephir_add_function_ex(_7, &_1, &_27 TSRMLS_CC);
					zephir_array_update_multi(&psr, &_7 TSRMLS_CC, SL("ll"), 2, i, 1);
					zephir_array_fetch_long(&_23, psr, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC);
					zephir_array_fetch_long(&_26, _23, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC);
					zephir_array_fetch_long(&_28, psr, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC);
					zephir_array_fetch_long(&_29, _28, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_1);
					mul_function(&_1, _26, _29 TSRMLS_CC);
					zephir_array_fetch_long(&_26, psi, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC);
					zephir_array_fetch_long(&_29, _26, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC);
					zephir_array_fetch_long(&_30, psi, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC);
					zephir_array_fetch_long(&_31, _30, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 53 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_2);
					mul_function(&_2, _29, _31 TSRMLS_CC);
					ZEPHIR_INIT_LNVAR(_7);
					zephir_add_function_ex(_7, &_1, &_2 TSRMLS_CC);
					zephir_array_update_long(&p2, i, &_7, PH_COPY | PH_SEPARATE, "test/quantum.zep", 53);
				}
			}
			_34 = (751 - 1);
			_33 = 1;
			_32 = 0;
			if (_33 <= _34) {
				while (1) {
					if (_32) {
						_33++;
						if (!(_33 <= _34)) {
							break;
						}
					} else {
						_32 = 1;
					}
					j = _33;
					ZEPHIR_INIT_NVAR(_0);
					ZVAL_LONG(_0, 0);
					zephir_array_update_multi(&psr, &_0 TSRMLS_CC, SL("ll"), 2, 0, 1);
					ZEPHIR_INIT_NVAR(_0);
					ZVAL_LONG(_0, 0);
					zephir_array_update_multi(&psr, &_0 TSRMLS_CC, SL("ll"), 2, 751, 1);
					zephir_array_fetch_long(&_19, psi, j, PH_NOISY | PH_READONLY, "test/quantum.zep", 58 TSRMLS_CC);
					zephir_array_fetch_long(&_20, _19, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 58 TSRMLS_CC);
					zephir_array_fetch_long(&_21, paramater, 2, PH_NOISY | PH_READONLY, "test/quantum.zep", 58 TSRMLS_CC);
					zephir_array_fetch_long(&_22, psr, (j + 1), PH_NOISY | PH_READONLY, "test/quantum.zep", 58 TSRMLS_CC);
					zephir_array_fetch_long(&_23, _22, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 58 TSRMLS_CC);
					zephir_array_fetch_long(&_24, psr, (j - 1), PH_NOISY | PH_READONLY, "test/quantum.zep", 58 TSRMLS_CC);
					zephir_array_fetch_long(&_25, _24, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_1);
					zephir_add_function_ex(&_1, _23, _25 TSRMLS_CC);
					zephir_array_fetch_long(&_23, tmp, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC);
					zephir_array_fetch_long(&_25, psr, j, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC);
					zephir_array_fetch_long(&_26, _25, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_2);
					mul_function(&_2, _23, _26 TSRMLS_CC);
					ZEPHIR_INIT_LNVAR(_9);
					sub_function(_9, &_1, &_2 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_1);
					mul_function(&_1, _21, _9 TSRMLS_CC);
					zephir_array_fetch_long(&_21, paramater, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC);
					zephir_array_fetch_long(&_23, paramater, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC);
					ZEPHIR_INIT_LNVAR(_9);
					mul_function(_9, _21, _23 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_2);
					div_function(&_2, &_1, _9 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_1);
					zephir_add_function_ex(&_1, _20, &_2 TSRMLS_CC);
					zephir_array_fetch_long(&_20, paramater, 2, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC);
					zephir_array_fetch_long(&_21, v, j, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC);
					zephir_array_fetch_long(&_23, _21, 0, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_2);
					mul_function(&_2, _20, _23 TSRMLS_CC);
					zephir_array_fetch_long(&_20, psr, j, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC);
					zephir_array_fetch_long(&_23, _20, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 59 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_27);
					mul_function(&_27, &_2, _23 TSRMLS_CC);
					ZEPHIR_INIT_LNVAR(_9);
					sub_function(_9, &_1, &_27 TSRMLS_CC);
					zephir_array_update_multi(&psi, &_9 TSRMLS_CC, SL("ll"), 2, j, 1);
				}
			}
			_35 = n == 0;
			if (!(_35)) {
				_35 = zephir_safe_mod_long_long(n, 2000 TSRMLS_CC) == 0;
			}
			if (_35) {
				i = 1;
				while (1) {
					if (!(i < (751 - 1))) {
						break;
					}
					zephir_array_fetch_long(&_19, p2, i, PH_NOISY | PH_READONLY, "test/quantum.zep", 67 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_1);
					ZVAL_STRING(&_1, "%16.8lf %16.8lf %16.8lf \n", 0);
					ZEPHIR_SINIT_NVAR(_2);
					ZVAL_DOUBLE(&_2, ((double) i * dx));
					ZEPHIR_SINIT_NVAR(_27);
					ZVAL_DOUBLE(&_27, ((double) n * dt));
					ZEPHIR_CALL_FUNCTION(NULL, "fprintf", &_36, 57, fp, &_1, &_2, &_27, _19);
					zephir_check_call_status();
					i = (i + 10);
				}
				ZEPHIR_SINIT_NVAR(_1);
				ZVAL_STRING(&_1, "\n", 0);
				ZEPHIR_CALL_FUNCTION(NULL, "fprintf", &_36, 57, fp, &_1);
				zephir_check_call_status();
			}
			j = 1;
			while (1) {
				if (!(j < (751 - 1))) {
					break;
				}
				zephir_array_fetch_long(&_19, psi, j, PH_NOISY | PH_READONLY, "test/quantum.zep", 76 TSRMLS_CC);
				zephir_array_fetch_long(&_20, _19, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 76 TSRMLS_CC);
				zephir_array_update_multi(&psi, &_20 TSRMLS_CC, SL("ll"), 2, j, 0);
				zephir_array_fetch_long(&_20, psr, j, PH_NOISY | PH_READONLY, "test/quantum.zep", 77 TSRMLS_CC);
				zephir_array_fetch_long(&_21, _20, 1, PH_NOISY | PH_READONLY, "test/quantum.zep", 77 TSRMLS_CC);
				zephir_array_update_multi(&psr, &_21 TSRMLS_CC, SL("ll"), 2, j, 0);
				j++;
			}
		}
	}
	RETURN_MM_BOOL(1);

}
Beispiel #26
0
/**
 * @return mixed
 */
PHP_METHOD(Lynx_Annotation_RegexDocParser, parseValue) {

	int ZEPHIR_LAST_CALL_STATUS;
	zephir_nts_static zephir_fcall_cache_entry *_14 = NULL;
	HashTable *_11;
	HashPosition _10;
	zend_bool _3, _15, _20;
	zval *value, *val = NULL, *vals, *v = NULL, _0, _1, *_2, _4, *_5, _6 = zval_used_for_init, _7 = zval_used_for_init, *_8 = NULL, _9 = zval_used_for_init, **_12, *_13 = NULL, *_16, _17, _18, *_19, _21, *_22, _23, _24, *_25 = NULL, *_26;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &value);



	ZEPHIR_INIT_VAR(val);
	zephir_fast_trim(val, value, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC);
	ZEPHIR_SINIT_VAR(_0);
	ZVAL_LONG(&_0, 0);
	ZEPHIR_SINIT_VAR(_1);
	ZVAL_LONG(&_1, 1);
	ZEPHIR_INIT_VAR(_2);
	zephir_substr(_2, val, 0 , 1 , 0);
	_3 = ZEPHIR_IS_STRING(_2, "[");
	if (_3) {
		ZEPHIR_SINIT_VAR(_4);
		ZVAL_LONG(&_4, -1);
		ZEPHIR_INIT_VAR(_5);
		zephir_substr(_5, val, -1 , 0, ZEPHIR_SUBSTR_NO_LENGTH);
		_3 = ZEPHIR_IS_STRING(_5, "]");
	}
	if (_3) {
		ZEPHIR_INIT_VAR(vals);
		ZEPHIR_SINIT_VAR(_6);
		ZVAL_LONG(&_6, 1);
		ZEPHIR_SINIT_VAR(_7);
		ZVAL_LONG(&_7, -1);
		ZEPHIR_INIT_VAR(_8);
		zephir_substr(_8, val, 1 , -1 , 0);
		ZEPHIR_SINIT_VAR(_9);
		ZVAL_LONG(&_9, ',');
		zephir_fast_explode(vals, &_9, _8, LONG_MAX TSRMLS_CC);
		ZEPHIR_INIT_NVAR(val);
		array_init(val);
		zephir_is_iterable(vals, &_11, &_10, 0, 0, "lynx/Annotation/RegexDocParser.zep", 89);
		for (
		  ; zephir_hash_get_current_data_ex(_11, (void**) &_12, &_10) == SUCCESS
		  ; zephir_hash_move_forward_ex(_11, &_10)
		) {
			ZEPHIR_GET_HVALUE(v, _12);
			ZEPHIR_CALL_SELF(&_13, "parsevalue", &_14, v);
			zephir_check_call_status();
			zephir_array_append(&val, _13, PH_SEPARATE, "lynx/Annotation/RegexDocParser.zep", 86);
		}
		RETURN_CCTOR(val);
	} else {
		ZEPHIR_SINIT_NVAR(_6);
		ZVAL_LONG(&_6, 0);
		ZEPHIR_SINIT_NVAR(_7);
		ZVAL_LONG(&_7, 1);
		ZEPHIR_INIT_NVAR(_8);
		zephir_substr(_8, val, 0 , 1 , 0);
		_15 = ZEPHIR_IS_STRING(_8, "{");
		if (_15) {
			ZEPHIR_SINIT_NVAR(_9);
			ZVAL_LONG(&_9, -1);
			ZEPHIR_INIT_VAR(_16);
			zephir_substr(_16, val, -1 , 0, ZEPHIR_SUBSTR_NO_LENGTH);
			_15 = ZEPHIR_IS_STRING(_16, "}");
		}
		if (_15) {
			zephir_json_decode(return_value, &(return_value), val, 0  TSRMLS_CC);
			RETURN_MM();
		} else {
			ZEPHIR_SINIT_VAR(_17);
			ZVAL_LONG(&_17, 0);
			ZEPHIR_SINIT_VAR(_18);
			ZVAL_LONG(&_18, 1);
			ZEPHIR_INIT_VAR(_19);
			zephir_substr(_19, val, 0 , 1 , 0);
			_20 = ZEPHIR_IS_STRING(_19, "\"");
			if (_20) {
				ZEPHIR_SINIT_VAR(_21);
				ZVAL_LONG(&_21, -1);
				ZEPHIR_INIT_VAR(_22);
				zephir_substr(_22, val, -1 , 0, ZEPHIR_SUBSTR_NO_LENGTH);
				_20 = ZEPHIR_IS_STRING(_22, "\"");
			}
			if (_20) {
				ZEPHIR_SINIT_VAR(_23);
				ZVAL_LONG(&_23, 1);
				ZEPHIR_SINIT_VAR(_24);
				ZVAL_LONG(&_24, -1);
				ZEPHIR_INIT_VAR(_25);
				zephir_substr(_25, val, 1 , -1 , 0);
				ZEPHIR_CPY_WRT(val, _25);
				ZEPHIR_RETURN_CALL_SELF("parsevalue", &_14, val);
				zephir_check_call_status();
				RETURN_MM();
			} else {
				ZEPHIR_INIT_NVAR(_25);
				zephir_fast_strtolower(_25, val);
				if (ZEPHIR_IS_STRING(_25, "true")) {
					RETURN_MM_BOOL(1);
				} else {
					ZEPHIR_INIT_VAR(_26);
					zephir_fast_strtolower(_26, val);
					if (ZEPHIR_IS_STRING(_26, "false")) {
						RETURN_MM_BOOL(0);
					} else {
						if (zephir_is_numeric(val)) {
							if (zephir_get_doubleval(val) == zephir_get_intval(val)) {
								RETURN_MM_LONG(zephir_get_intval(val));
							} else {
								RETURN_MM_DOUBLE(zephir_get_doubleval(val));
							}
						}
					}
				}
			}
		}
	}
	RETURN_CCTOR(val);

}
Beispiel #27
0
/**
 * Executes a prepared statement binding. This function uses integer indexes starting from zero
 *
 *<code>
 * use Phalcon\Db\Column;
 *
 * $statement = $db->prepare('SELECT * FROM robots WHERE name = :name');
 * $result = $connection->executePrepared($statement, ['name' => 'Voltron'], ['name' => Column::BIND_PARAM_INT]);
 *</code>
 *
 * @param \PDOStatement statement
 * @param array placeholders
 * @param array dataTypes
 * @return \PDOStatement
 */
PHP_METHOD(Phalcon_Db_Adapter_Pdo, executePrepared) {

	zval *_6$$13 = NULL;
	zend_bool _3$$3;
	HashTable *_1, *_9$$22, *_14$$28;
	HashPosition _0, _8$$22, _13$$28;
	int ZEPHIR_LAST_CALL_STATUS;
	zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL;
	zval *placeholders = NULL;
	zval *statement, *placeholders_param = NULL, *dataTypes, *wildcard = NULL, *value = NULL, *type = NULL, *castValue = NULL, *parameter = NULL, *position = NULL, *itemValue = NULL, **_2, _4$$12 = zval_used_for_init, **_10$$22, *_11$$24 = NULL, *_12$$25 = NULL, **_15$$28, *_16$$29 = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 3, 0, &statement, &placeholders_param, &dataTypes);

	placeholders = placeholders_param;


	zephir_is_iterable(placeholders, &_1, &_0, 0, 0, "phalcon/db/adapter/pdo.zep", 273);
	for (
	  ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS
	  ; zephir_hash_move_forward_ex(_1, &_0)
	) {
		ZEPHIR_GET_HMKEY(wildcard, _1, _0);
		ZEPHIR_GET_HVALUE(value, _2);
		if (Z_TYPE_P(wildcard) == IS_LONG) {
			ZEPHIR_INIT_NVAR(parameter);
			ZVAL_LONG(parameter, (zephir_get_numberval(wildcard) + 1));
		} else if (Z_TYPE_P(wildcard) == IS_STRING) {
			ZEPHIR_CPY_WRT(parameter, wildcard);
		} else {
			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid bind parameter (1)", "phalcon/db/adapter/pdo.zep", 200);
			return;
		}
		_3$$3 = Z_TYPE_P(dataTypes) == IS_ARRAY;
		if (_3$$3) {
			ZEPHIR_OBS_NVAR(type);
			_3$$3 = zephir_array_isset_fetch(&type, dataTypes, wildcard, 0 TSRMLS_CC);
		}
		if (_3$$3) {
			if (ZEPHIR_IS_LONG(type, 32)) {
				ZEPHIR_INIT_NVAR(castValue);
				ZVAL_DOUBLE(castValue, zephir_get_doubleval(value));
				ZEPHIR_INIT_NVAR(type);
				ZVAL_LONG(type, 1024);
			} else {
				if (ZEPHIR_GLOBAL(db).force_casting) {
					if (Z_TYPE_P(value) != IS_ARRAY) {
						do {
							if (ZEPHIR_IS_LONG(type, 1)) {
								ZEPHIR_SINIT_NVAR(_4$$12);
								ZVAL_LONG(&_4$$12, 10);
								ZEPHIR_CALL_FUNCTION(&castValue, "intval", &_5, 26, value, &_4$$12);
								zephir_check_call_status();
								break;
							}
							if (ZEPHIR_IS_LONG(type, 2)) {
								zephir_get_strval(_6$$13, value);
								ZEPHIR_CPY_WRT(castValue, _6$$13);
								break;
							}
							if (ZEPHIR_IS_LONG(type, 0)) {
								ZEPHIR_INIT_NVAR(castValue);
								ZVAL_NULL(castValue);
								break;
							}
							if (ZEPHIR_IS_LONG(type, 5)) {
								ZEPHIR_INIT_NVAR(castValue);
								ZVAL_BOOL(castValue, zephir_get_boolval(value));
								break;
							}
							ZEPHIR_CPY_WRT(castValue, value);
							break;
						} while(0);

					} else {
						ZEPHIR_CPY_WRT(castValue, value);
					}
				} else {
					ZEPHIR_CPY_WRT(castValue, value);
				}
			}
			if (Z_TYPE_P(castValue) != IS_ARRAY) {
				if (ZEPHIR_IS_LONG(type, 1024)) {
					ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_7, 0, parameter, castValue);
					zephir_check_call_status();
				} else {
					ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_7, 0, parameter, castValue, type);
					zephir_check_call_status();
				}
			} else {
				zephir_is_iterable(castValue, &_9$$22, &_8$$22, 0, 0, "phalcon/db/adapter/pdo.zep", 261);
				for (
				  ; zephir_hash_get_current_data_ex(_9$$22, (void**) &_10$$22, &_8$$22) == SUCCESS
				  ; zephir_hash_move_forward_ex(_9$$22, &_8$$22)
				) {
					ZEPHIR_GET_HMKEY(position, _9$$22, _8$$22);
					ZEPHIR_GET_HVALUE(itemValue, _10$$22);
					if (ZEPHIR_IS_LONG(type, 1024)) {
						ZEPHIR_INIT_LNVAR(_11$$24);
						ZEPHIR_CONCAT_VV(_11$$24, parameter, position);
						ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_7, 0, _11$$24, itemValue);
						zephir_check_call_status();
					} else {
						ZEPHIR_INIT_LNVAR(_12$$25);
						ZEPHIR_CONCAT_VV(_12$$25, parameter, position);
						ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_7, 0, _12$$25, itemValue, type);
						zephir_check_call_status();
					}
				}
			}
		} else {
			if (Z_TYPE_P(value) != IS_ARRAY) {
				ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_7, 0, parameter, value);
				zephir_check_call_status();
			} else {
				zephir_is_iterable(value, &_14$$28, &_13$$28, 0, 0, "phalcon/db/adapter/pdo.zep", 269);
				for (
				  ; zephir_hash_get_current_data_ex(_14$$28, (void**) &_15$$28, &_13$$28) == SUCCESS
				  ; zephir_hash_move_forward_ex(_14$$28, &_13$$28)
				) {
					ZEPHIR_GET_HMKEY(position, _14$$28, _13$$28);
					ZEPHIR_GET_HVALUE(itemValue, _15$$28);
					ZEPHIR_INIT_LNVAR(_16$$29);
					ZEPHIR_CONCAT_VV(_16$$29, parameter, position);
					ZEPHIR_CALL_METHOD(NULL, statement, "bindvalue", &_7, 0, _16$$29, itemValue);
					zephir_check_call_status();
				}
			}
		}
	}
	ZEPHIR_CALL_METHOD(NULL, statement, "execute", NULL, 0);
	zephir_check_call_status();
	RETVAL_ZVAL(statement, 1, 0);
	RETURN_MM();

}
PHP_METHOD(Pdm_Db_Adapter_AbstractPdo, bindStatmentParameters) {

	zephir_fcall_cache_entry *_4 = NULL, *_5 = NULL, *_7 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	HashTable *_1;
	HashPosition _0;
	zend_bool hasBindParams, hasBindTypes, _3;
	zval *statement, *bindParams = NULL, *bindTypes = NULL, *wildcard = NULL, *value = NULL, *parameter = NULL, *type = NULL, *castValue = NULL, **_2, *_6 = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 2, &statement, &bindParams, &bindTypes);

	if (!bindParams) {
		ZEPHIR_INIT_VAR(bindParams);
		array_init(bindParams);
	}
	if (!bindTypes) {
		ZEPHIR_INIT_VAR(bindTypes);
		array_init(bindTypes);
	} else {
		ZEPHIR_SEPARATE_PARAM(bindTypes);
	}


	if (!(zephir_instance_of_ev(statement, zephir_get_internal_ce(SS("pdostatement") TSRMLS_CC) TSRMLS_CC))) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Parameter 'statement' must be an instance of 'PDOStatement'", "", 0);
		return;
	}
	if (Z_TYPE_P(bindTypes) != IS_ARRAY) {
		ZEPHIR_INIT_NVAR(bindTypes);
		array_init(bindTypes);
	}
	if (zephir_fast_count_int(bindParams TSRMLS_CC) > 0) {
		hasBindParams = 1;
	} else {
		hasBindParams = 0;
	}
	if (zephir_fast_count_int(bindTypes TSRMLS_CC) > 0) {
		hasBindTypes = 1;
	} else {
		hasBindTypes = 0;
	}
	zephir_is_iterable(bindParams, &_1, &_0, 0, 0);
	for (
	  ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS
	  ; zephir_hash_move_forward_ex(_1, &_0)
	) {
		ZEPHIR_GET_HMKEY(wildcard, _1, _0);
		ZEPHIR_GET_HVALUE(value, _2);
		if (Z_TYPE_P(wildcard) == IS_LONG) {
			ZEPHIR_INIT_NVAR(parameter);
			ZVAL_LONG(parameter, (zephir_get_numberval(wildcard) + 1));
		} else {
			if (Z_TYPE_P(wildcard) == IS_STRING) {
				ZEPHIR_CPY_WRT(parameter, wildcard);
			} else {
				ZEPHIR_THROW_EXCEPTION_DEBUG_STR(pdm_db_adapter_exception_ce, "Invalid bind parameter (1)", "pdm/db/adapter/abstractpdo.zep", 126);
				return;
			}
		}
		_3 = hasBindParams;
		if (_3) {
			_3 = hasBindTypes;
		}
		if (_3) {
			ZEPHIR_OBS_NVAR(type);
			if (!(zephir_array_isset_fetch(&type, bindTypes, wildcard, 0 TSRMLS_CC))) {
				ZEPHIR_INIT_NVAR(type);
				ZVAL_LONG(type, 2);
			}
			if (ZEPHIR_IS_LONG(type, 32)) {
				ZEPHIR_INIT_NVAR(castValue);
				ZVAL_DOUBLE(castValue, zephir_get_doubleval(value));
				ZEPHIR_INIT_NVAR(type);
				ZVAL_LONG(type, 1024);
			} else {
				ZEPHIR_CPY_WRT(castValue, value);
			}
			if (ZEPHIR_IS_LONG(type, 1024)) {
				Z_SET_ISREF_P(castValue);
				ZEPHIR_CALL_METHOD(NULL, statement, "bindparam", &_4, parameter, castValue);
				zephir_check_call_status();
				Z_UNSET_ISREF_P(castValue);
			} else {
				Z_SET_ISREF_P(castValue);
				ZEPHIR_CALL_METHOD(NULL, statement, "bindparam", &_5, parameter, castValue, type);
				zephir_check_call_status();
				Z_UNSET_ISREF_P(castValue);
			}
		} else {
			ZEPHIR_INIT_NVAR(_6);
			ZVAL_LONG(_6, 2);
			Z_SET_ISREF_P(value);
			ZEPHIR_CALL_METHOD(NULL, statement, "bindparam", &_7, parameter, value, _6);
			zephir_check_call_status();
			Z_UNSET_ISREF_P(value);
		}
	}
	RETURN_CCTOR(statement);

}
PHP_METHOD(PocketMine_Level_Generator_Noise_Generator, grad) {

	zend_bool _2;
	double x, y, z, u, v;
	zval *hash_param = NULL, *x_param = NULL, *y_param = NULL, *z_param = NULL, *_0, *_1, *_3, *_4;
	int hash;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 4, 0, &hash_param, &x_param, &y_param, &z_param);

	hash = zephir_get_intval(hash_param);
	x = zephir_get_doubleval(x_param);
	y = zephir_get_doubleval(y_param);
	z = zephir_get_doubleval(z_param);


	hash = (hash & 15);
	ZEPHIR_INIT_VAR(_0);
	if (hash < 8) {
		ZEPHIR_INIT_BNVAR(_0);
		ZVAL_DOUBLE(_0, x);
	} else {
		ZEPHIR_INIT_BNVAR(_0);
		ZVAL_DOUBLE(_0, y);
	}
	u = zephir_get_numberval(_0);
	ZEPHIR_INIT_VAR(_1);
	if (hash < 4) {
		ZEPHIR_INIT_BNVAR(_1);
		ZVAL_DOUBLE(_1, y);
	} else {
		_2 = hash == 12;
		if (!(_2)) {
			_2 = hash == 14;
		}
		if (_2) {
			ZEPHIR_INIT_BNVAR(_1);
			ZVAL_DOUBLE(_1, x);
		} else {
			ZEPHIR_INIT_BNVAR(_1);
			ZVAL_DOUBLE(_1, z);
		}
	}
	v = zephir_get_numberval(_1);
	ZEPHIR_INIT_VAR(_3);
	if (((hash & 1)) == 0) {
		ZEPHIR_INIT_BNVAR(_3);
		ZVAL_DOUBLE(_3, u);
	} else {
		ZEPHIR_INIT_BNVAR(_3);
		ZVAL_DOUBLE(_3, -u);
	}
	ZEPHIR_INIT_VAR(_4);
	if (((hash & 2)) == 0) {
		ZEPHIR_INIT_BNVAR(_4);
		ZVAL_DOUBLE(_4, v);
	} else {
		ZEPHIR_INIT_BNVAR(_4);
		ZVAL_DOUBLE(_4, -v);
	}
	zephir_add_function(return_value, _3, _4 TSRMLS_CC);
	RETURN_MM();

}
Beispiel #30
0
PHP_METHOD(Test_Quantum, Harmos) {

	zend_bool _14, _17, _33, _36;
	zval *_11 = NULL, *_12 = NULL, *_13 = NULL;
	zephir_nts_static zephir_fcall_cache_entry *_3 = NULL, *_5 = NULL, *_7 = NULL, *_9 = NULL, *_37 = NULL;
	int i, j, n, ZEPHIR_LAST_CALL_STATUS, _15, _16, _18, _19, _34, _35;
	zval *x_param = NULL, *psr, *psi, *p2, *v, *paramater, *fp = NULL, *_0 = NULL, _1 = zval_used_for_init, _2 = zval_used_for_init, *_4 = NULL, *_6 = NULL, *_8 = NULL, *_10 = NULL, *tmp, *_20, *_21, *_22, *_23, *_24, *_25, *_26, *_27, _28 = zval_used_for_init, *_29, *_30, *_31, *_32;
	double x, dt, dx, k0, item_psr, item_psi;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &x_param);

	x = zephir_get_doubleval(x_param);


	dx = 0.02;
	k0 = (3.0 * 3.14159265358979323846);
	dt = ((dx * dx) / 4.0);
	ZEPHIR_INIT_VAR(paramater);
	array_init_size(paramater, 7);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_DOUBLE(_0, dx);
	zephir_array_fast_append(paramater, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_DOUBLE(_0, k0);
	zephir_array_fast_append(paramater, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_DOUBLE(_0, dt);
	zephir_array_fast_append(paramater, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_DOUBLE(_0, x);
	zephir_array_fast_append(paramater, _0);
	i = 0;
	ZEPHIR_INIT_VAR(psr);
	array_init(psr);
	ZEPHIR_INIT_VAR(psi);
	array_init(psi);
	ZEPHIR_INIT_VAR(p2);
	array_init(p2);
	ZEPHIR_INIT_VAR(v);
	array_init(v);
	ZEPHIR_SINIT_VAR(_1);
	ZVAL_STRING(&_1, "harmos.txt", 0);
	ZEPHIR_SINIT_VAR(_2);
	ZVAL_STRING(&_2, "w", 0);
	ZEPHIR_CALL_FUNCTION(&fp, "fopen", &_3, &_1, &_2);
	zephir_check_call_status();
	if (!(zephir_is_true(fp))) {
		RETURN_MM_LONG(1);
	}
	while (1) {
		if (!(i <= 751)) {
			break;
		}
		ZEPHIR_SINIT_NVAR(_1);
		ZVAL_DOUBLE(&_1, (k0 * x));
		ZEPHIR_CALL_FUNCTION(&_4, "sin", &_5, &_1);
		zephir_check_call_status();
		ZEPHIR_SINIT_NVAR(_1);
		ZVAL_DOUBLE(&_1, ((x * x) * 2.0));
		ZEPHIR_CALL_FUNCTION(&_6, "exp", &_7, &_1);
		zephir_check_call_status();
		ZEPHIR_INIT_LNVAR(_8);
		div_function(_8, _4, _6 TSRMLS_CC);
		item_psi = zephir_get_numberval(_8);
		ZEPHIR_SINIT_NVAR(_1);
		ZVAL_DOUBLE(&_1, (k0 * x));
		ZEPHIR_CALL_FUNCTION(&_4, "cos", &_9, &_1);
		zephir_check_call_status();
		ZEPHIR_SINIT_NVAR(_1);
		ZVAL_DOUBLE(&_1, ((x * x) * 2.0));
		ZEPHIR_CALL_FUNCTION(&_6, "exp", &_7, &_1);
		zephir_check_call_status();
		ZEPHIR_INIT_LNVAR(_10);
		div_function(_10, _4, _6 TSRMLS_CC);
		item_psr = zephir_get_numberval(_10);
		ZEPHIR_INIT_NVAR(_11);
		array_init_size(_11, 2);
		ZEPHIR_INIT_NVAR(_0);
		ZVAL_DOUBLE(_0, item_psr);
		zephir_array_fast_append(_11, _0);
		zephir_array_update_long(&psr, i, &_11, PH_COPY | PH_SEPARATE, "test/quantum.zep", 38);
		ZEPHIR_INIT_NVAR(_12);
		array_init_size(_12, 2);
		ZEPHIR_INIT_NVAR(_0);
		ZVAL_DOUBLE(_0, item_psi);
		zephir_array_fast_append(_12, _0);
		zephir_array_update_long(&psi, i, &_12, PH_COPY | PH_SEPARATE, "test/quantum.zep", 39);
		ZEPHIR_INIT_NVAR(_13);
		array_init_size(_13, 2);
		ZEPHIR_INIT_NVAR(_0);
		ZVAL_DOUBLE(_0, (double) ((double) (5.0 * x) * x));
		zephir_array_fast_append(_13, _0);
		zephir_array_update_long(&v, i, &_13, PH_COPY | PH_SEPARATE, "test/quantum.zep", 40);
		x = (x + dx);
		i++;
	}
	i = 1;
	j = 1;
	ZEPHIR_INIT_VAR(tmp);
	array_init_size(tmp, 2);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_DOUBLE(_0, 2.0);
	zephir_array_fast_append(tmp, _0);
	_16 = 20000;
	_15 = 0;
	_14 = 0;
	if (_15 <= _16) {
		while (1) {
			if (_14) {
				_15++;
				if (!(_15 <= _16)) {
					break;
				}
			} else {
				_14 = 1;
			}
			n = _15;
			_19 = (751 - 1);
			_18 = 1;
			_17 = 0;
			if (_18 <= _19) {
				while (1) {
					if (_17) {
						_18++;
						if (!(_18 <= _19)) {
							break;
						}
					} else {
						_17 = 1;
					}
					i = _18;
					zephir_array_fetch_long(&_20, psr, i, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_21, _20, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_22, paramater, 2, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_23, psi, (i + 1), PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_24, _23, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_25, psi, (i - 1), PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_26, _25, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_1);
					zephir_add_function(&_1, _24, _26 TSRMLS_CC);
					zephir_array_fetch_long(&_24, tmp, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_26, psi, i, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_27, _26, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_2);
					mul_function(&_2, _24, _27 TSRMLS_CC);
					ZEPHIR_INIT_LNVAR(_8);
					zephir_sub_function(_8, &_1, &_2 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_1);
					mul_function(&_1, _22, _8 TSRMLS_CC);
					zephir_array_fetch_long(&_22, paramater, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_24, paramater, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
					ZEPHIR_INIT_LNVAR(_8);
					mul_function(_8, _22, _24 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_2);
					div_function(&_2, &_1, _8 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_1);
					zephir_sub_function(&_1, _21, &_2 TSRMLS_CC);
					zephir_array_fetch_long(&_21, paramater, 2, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_22, v, i, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_24, _22, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_2);
					mul_function(&_2, _21, _24 TSRMLS_CC);
					zephir_array_fetch_long(&_21, psi, i, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_24, _21, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_28);
					mul_function(&_28, &_2, _24 TSRMLS_CC);
					ZEPHIR_INIT_LNVAR(_8);
					zephir_add_function(_8, &_1, &_28 TSRMLS_CC);
					zephir_array_update_multi(&psr, &_8 TSRMLS_CC, SL("ll"), 2, i, 1);
					zephir_array_fetch_long(&_24, psr, i, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_27, _24, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_29, psr, i, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_30, _29, 1, PH_NOISY | PH_READONLY TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_1);
					mul_function(&_1, _27, _30 TSRMLS_CC);
					zephir_array_fetch_long(&_27, psi, i, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_30, _27, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_31, psi, i, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_32, _31, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_2);
					mul_function(&_2, _30, _32 TSRMLS_CC);
					ZEPHIR_INIT_LNVAR(_8);
					zephir_add_function(_8, &_1, &_2 TSRMLS_CC);
					zephir_array_update_long(&p2, i, &_8, PH_COPY | PH_SEPARATE, "test/quantum.zep", 53);
				}
			}
			_35 = (751 - 1);
			_34 = 1;
			_33 = 0;
			if (_34 <= _35) {
				while (1) {
					if (_33) {
						_34++;
						if (!(_34 <= _35)) {
							break;
						}
					} else {
						_33 = 1;
					}
					j = _34;
					ZEPHIR_INIT_NVAR(_0);
					ZVAL_LONG(_0, 0);
					zephir_array_update_multi(&psr, &_0 TSRMLS_CC, SL("ll"), 2, 0, 1);
					ZEPHIR_INIT_NVAR(_0);
					ZVAL_LONG(_0, 0);
					zephir_array_update_multi(&psr, &_0 TSRMLS_CC, SL("ll"), 2, 751, 1);
					zephir_array_fetch_long(&_20, psi, j, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_21, _20, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_22, paramater, 2, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_23, psr, (j + 1), PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_24, _23, 1, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_25, psr, (j - 1), PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_26, _25, 1, PH_NOISY | PH_READONLY TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_1);
					zephir_add_function(&_1, _24, _26 TSRMLS_CC);
					zephir_array_fetch_long(&_24, tmp, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_26, psr, j, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_27, _26, 1, PH_NOISY | PH_READONLY TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_2);
					mul_function(&_2, _24, _27 TSRMLS_CC);
					ZEPHIR_INIT_LNVAR(_10);
					zephir_sub_function(_10, &_1, &_2 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_1);
					mul_function(&_1, _22, _10 TSRMLS_CC);
					zephir_array_fetch_long(&_22, paramater, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_24, paramater, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
					ZEPHIR_INIT_LNVAR(_10);
					mul_function(_10, _22, _24 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_2);
					div_function(&_2, &_1, _10 TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_1);
					zephir_add_function(&_1, _21, &_2 TSRMLS_CC);
					zephir_array_fetch_long(&_21, paramater, 2, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_22, v, j, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_24, _22, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_2);
					mul_function(&_2, _21, _24 TSRMLS_CC);
					zephir_array_fetch_long(&_21, psr, j, PH_NOISY | PH_READONLY TSRMLS_CC);
					zephir_array_fetch_long(&_24, _21, 1, PH_NOISY | PH_READONLY TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_28);
					mul_function(&_28, &_2, _24 TSRMLS_CC);
					ZEPHIR_INIT_LNVAR(_10);
					zephir_sub_function(_10, &_1, &_28 TSRMLS_CC);
					zephir_array_update_multi(&psi, &_10 TSRMLS_CC, SL("ll"), 2, j, 1);
				}
			}
			_36 = n == 0;
			if (!(_36)) {
				_36 = (n % 2000) == 0;
			}
			if (_36) {
				i = 1;
				while (1) {
					if (!(i < (751 - 1))) {
						break;
					}
					zephir_array_fetch_long(&_20, p2, i, PH_NOISY | PH_READONLY TSRMLS_CC);
					ZEPHIR_SINIT_NVAR(_1);
					ZVAL_STRING(&_1, "%16.8lf %16.8lf %16.8lf \n", 0);
					ZEPHIR_SINIT_NVAR(_2);
					ZVAL_DOUBLE(&_2, ((double) i * dx));
					ZEPHIR_SINIT_NVAR(_28);
					ZVAL_DOUBLE(&_28, ((double) n * dt));
					ZEPHIR_CALL_FUNCTION(NULL, "fprintf", &_37, fp, &_1, &_2, &_28, _20);
					zephir_check_call_status();
					i = (i + 10);
				}
				ZEPHIR_SINIT_NVAR(_1);
				ZVAL_STRING(&_1, "\n", 0);
				ZEPHIR_CALL_FUNCTION(NULL, "fprintf", &_37, fp, &_1);
				zephir_check_call_status();
			}
			j = 1;
			while (1) {
				if (!(j < (751 - 1))) {
					break;
				}
				zephir_array_fetch_long(&_20, psi, j, PH_NOISY | PH_READONLY TSRMLS_CC);
				zephir_array_fetch_long(&_21, _20, 1, PH_NOISY | PH_READONLY TSRMLS_CC);
				zephir_array_update_multi(&psi, &_21 TSRMLS_CC, SL("ll"), 2, j, 0);
				zephir_array_fetch_long(&_21, psr, j, PH_NOISY | PH_READONLY TSRMLS_CC);
				zephir_array_fetch_long(&_22, _21, 1, PH_NOISY | PH_READONLY TSRMLS_CC);
				zephir_array_update_multi(&psr, &_22 TSRMLS_CC, SL("ll"), 2, j, 0);
				j++;
			}
		}
	}
	RETURN_MM_BOOL(1);

}