Exemplo n.º 1
0
PHP_METHOD(PocketMine_Math_Vector2, add) {

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

	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, "add", NULL, _1, _2);
		zephir_check_call_status();
		RETURN_CCTOR(_0);
	}
	object_init_ex(return_value, pocketmine_math_vector2_ce);
	_3 = zephir_fetch_nproperty_this(this_ptr, SL("x"), PH_NOISY_CC);
	ZEPHIR_INIT_VAR(_4);
	zephir_add_function(_4, _3, x TSRMLS_CC);
	_3 = zephir_fetch_nproperty_this(this_ptr, SL("y"), PH_NOISY_CC);
	ZEPHIR_INIT_VAR(_5);
	zephir_add_function(_5, _3, y TSRMLS_CC);
	ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, _4, _5);
	zephir_check_call_status();
	RETURN_MM();

}
Exemplo n.º 2
0
PHP_METHOD(Test_Fibonnaci, fibonacciFinalRecursive) {

	zephir_fcall_cache_entry *_2 = NULL;
	zval *n_param = NULL, *_0$$6 = NULL, *_1$$6 = NULL, *_3$$6 = NULL;
	int n, ZEPHIR_LAST_CALL_STATUS;

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

	n = zephir_get_intval(n_param);


	if (n == 0) {
		RETURN_MM_LONG(0);
	} else {
		if (n == 1) {
			RETURN_MM_LONG(1);
		} else {
			ZEPHIR_INIT_VAR(_1$$6);
			ZVAL_LONG(_1$$6, (n - 1));
			ZEPHIR_CALL_METHOD(&_0$$6, this_ptr, "fibonaccifinalrecursive", &_2, 36, _1$$6);
			zephir_check_call_status();
			ZEPHIR_INIT_NVAR(_1$$6);
			ZVAL_LONG(_1$$6, (n - 2));
			ZEPHIR_CALL_METHOD(&_3$$6, this_ptr, "fibonaccifinalrecursive", &_2, 36, _1$$6);
			zephir_check_call_status();
			zephir_add_function(return_value, _0$$6, _3$$6);
			RETURN_MM();
		}
	}

}
Exemplo n.º 3
0
PHP_METHOD(Test_Fibonnaci, fibArray) {

	int i = 0, n = 0, k = 0, j = 0;
	zval *fib = NULL, *a = NULL, *b = NULL, *c = NULL, *_0 = NULL;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(fib);
	zephir_create_array(fib, 2, 0 TSRMLS_CC);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, 0);
	zephir_array_fast_append(fib, _0);
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(fib, _0);
	i = 2;
	n = 10;
	while (1) {
		if (!(i < n)) {
			break;
		}
		k = (i - 1);
		j = (i - 2);
		zephir_array_fetch_long(&a, fib, k, PH_NOISY | PH_READONLY, "test/fibonnaci.zep", 51 TSRMLS_CC);
		zephir_array_fetch_long(&b, fib, j, PH_NOISY | PH_READONLY, "test/fibonnaci.zep", 52 TSRMLS_CC);
		ZEPHIR_INIT_NVAR(c);
		zephir_add_function(c, a, b);
		zephir_array_update_long(&fib, i, &c, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
		i++;
	}
	RETURN_CCTOR(fib);

}
Exemplo n.º 4
0
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));

}
Exemplo n.º 5
0
PHP_METHOD(Test_Flow, testWhile11) {

	double c;
	zval *a, *d, *b = NULL, *_0;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &a, &d);

	ZEPHIR_SEPARATE_PARAM(a);


	while (1) {
		if (!(zephir_is_true(a))) {
			break;
		}
		ZEPHIR_CPY_WRT(b, d);
		while (1) {
			if (!(zephir_is_true(b))) {
				break;
			}
			ZEPHIR_SEPARATE(b);
			zephir_decrement(b);
		}
		ZEPHIR_SEPARATE(a);
		zephir_decrement(a);
	}
	ZEPHIR_INIT_VAR(_0);
	zephir_add_function(_0, a, b TSRMLS_CC);
	c = zephir_get_numberval(_0);
	RETURN_MM_DOUBLE(c);

}
Exemplo n.º 6
0
PHP_METHOD(Test_SpectralNorm, Ax) {

	zval *i, *j, *_0, _1;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &i, &j);



	ZEPHIR_INIT_VAR(_0);
	zephir_add_function(_0, i, j TSRMLS_CC);
	ZEPHIR_SINIT_VAR(_1);
	zephir_add_function(&_1, i, j TSRMLS_CC);
	RETURN_MM_LONG((1 / ((((zephir_get_numberval(_0) * (zephir_get_numberval(&_1) + 1)) / 2) + zephir_get_numberval(i)) + 1)));

}
Exemplo n.º 7
0
/**
 * Stops the active profile
 */
PHP_METHOD(Phalcon_Db_Profiler, stopProfile) {

	zval *finalTime = NULL, *initialTime = NULL, *activeProfile = NULL, *_0, *_1, *_2;
	zend_long ZEPHIR_LAST_CALL_STATUS;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(finalTime);
	zephir_microtime(finalTime, ZEPHIR_GLOBAL(global_true) TSRMLS_CC);
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_activeProfile"), PH_NOISY_CC);
	ZEPHIR_CPY_WRT(activeProfile, _0);
	ZEPHIR_CALL_METHOD(NULL, activeProfile, "setfinaltime", NULL, 0, finalTime);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&initialTime, activeProfile, "getinitialtime", NULL, 0);
	zephir_check_call_status();
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_totalSeconds"), PH_NOISY_CC);
	ZEPHIR_INIT_VAR(_1);
	zephir_sub_function(_1, finalTime, initialTime);
	ZEPHIR_INIT_VAR(_2);
	zephir_add_function(_2, _0, _1);
	zephir_update_property_this(getThis(), SL("_totalSeconds"), _2 TSRMLS_CC);
	zephir_update_property_array_append(this_ptr, SL("_allProfiles"), activeProfile TSRMLS_CC);
	if ((zephir_method_exists_ex(this_ptr, SS("afterendprofile") TSRMLS_CC) == SUCCESS)) {
		ZEPHIR_CALL_METHOD(NULL, this_ptr, "afterendprofile", NULL, 0, activeProfile);
		zephir_check_call_status();
	}
	RETURN_THIS();

}
Exemplo n.º 8
0
PHP_METHOD(Test_Fibonnaci, fibArray) {

	int i, n, k, j;
	zval *fib, *a, *b, *c = NULL, *_0;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(fib);
	array_init_size(fib, 3);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, 0);
	zephir_array_fast_append(fib, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(fib, _0);
	i = 2;
	n = 10;
	while (1) {
		if (!((i < n))) {
			break;
		}
		k = (i - 1);
		j = (i - 2);
		zephir_array_fetch_long(&a, fib, k, PH_NOISY | PH_READONLY TSRMLS_CC);
		zephir_array_fetch_long(&b, fib, j, PH_NOISY | PH_READONLY TSRMLS_CC);
		ZEPHIR_INIT_NVAR(c);
		zephir_add_function(c, a, b TSRMLS_CC);
		zephir_array_update_long(&fib, i, &c, PH_COPY | PH_SEPARATE, "test/fibonnaci.zep", 54);
		i++;
	}
	RETURN_CCTOR(fib);

}
Exemplo n.º 9
0
PHP_METHOD(Test_Fibonnaci, fibonacciFinalRecursive) {

	zval *n_param = NULL, *_0, _1 = zval_used_for_init, *_2;
	int n;

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

		n = zephir_get_intval(n_param);


	if ((n == 0)) {
		RETURN_MM_LONG(0);
	} else {
		if ((n == 1)) {
			RETURN_MM_LONG(1);
		} else {
			ZEPHIR_INIT_VAR(_0);
			ZEPHIR_SINIT_VAR(_1);
			ZVAL_LONG(&_1, (n - 1));
			zephir_call_internal_method_p1(_0, this_ptr, "fibonaccifinalrecursive", ZEND_MN(Test_Fibonnaci_fibonacciFinalRecursive), &_1);
			ZEPHIR_INIT_VAR(_2);
			ZEPHIR_SINIT_NVAR(_1);
			ZVAL_LONG(&_1, (n - 2));
			zephir_call_internal_method_p1(_2, this_ptr, "fibonaccifinalrecursive", ZEND_MN(Test_Fibonnaci_fibonacciFinalRecursive), &_1);
			zephir_add_function(return_value, _0, _2 TSRMLS_CC);
			RETURN_MM();
		}
	}
	ZEPHIR_MM_RESTORE();

}
Exemplo n.º 10
0
PHP_METHOD(Test_Fibonnaci, fibArray2) {

	int i, n;
	zval *fib, *_0, *_1, *_2, *_3 = NULL;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(fib);
	array_init_size(fib, 3);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, 0);
	zephir_array_fast_append(fib, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(fib, _0);
	i = 2;
	n = 10;
	while (1) {
		if (!((i < n))) {
			break;
		}
		zephir_array_fetch_long(&_1, fib, (i - 1), PH_NOISY | PH_READONLY TSRMLS_CC);
		zephir_array_fetch_long(&_2, fib, (i - 2), PH_NOISY | PH_READONLY TSRMLS_CC);
		ZEPHIR_INIT_LNVAR(_3);
		zephir_add_function(_3, _1, _2 TSRMLS_CC);
		zephir_array_update_long(&fib, i, &_3, PH_COPY | PH_SEPARATE, "test/fibonnaci.zep", 67);
		i++;
	}
	RETURN_CCTOR(fib);

}
Exemplo n.º 11
0
PHP_METHOD(Test_Fibonnaci, fibArray2) {

	int i = 0, n = 0;
	zval *fib = NULL, *_0 = NULL, *_1$$3, *_2$$3, *_3$$3 = NULL;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(fib);
	zephir_create_array(fib, 2, 0 TSRMLS_CC);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, 0);
	zephir_array_fast_append(fib, _0);
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(fib, _0);
	i = 2;
	n = 10;
	while (1) {
		if (!(i < n)) {
			break;
		}
		zephir_array_fetch_long(&_1$$3, fib, (i - 1), PH_NOISY | PH_READONLY, "test/fibonnaci.zep", 67 TSRMLS_CC);
		zephir_array_fetch_long(&_2$$3, fib, (i - 2), PH_NOISY | PH_READONLY, "test/fibonnaci.zep", 67 TSRMLS_CC);
		ZEPHIR_INIT_LNVAR(_3$$3);
		zephir_add_function(_3$$3, _1$$3, _2$$3);
		zephir_array_update_long(&fib, i, &_3$$3, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
		i++;
	}
	RETURN_CCTOR(fib);

}
Exemplo n.º 12
0
PHP_METHOD(Test_Mcall, testMethod6) {

	zval *a, *b;

	zephir_fetch_params(0, 2, 0, &a, &b);



	zephir_add_function(return_value, a, b TSRMLS_CC);
	return;

}
Exemplo n.º 13
0
/**
 * Sets the expiration time for this cache item.
 *
 * @param \DateTimeInterface expiration
 *   The point in time after which the item MUST be considered expired.
 *   If null is passed explicitly, a default value MAY be used. If none is set,
 *   the value should be stored permanently or for as long as the
 *   implementation allows.
 *
 * @return \Xpl\Cache\Item The called object.
 */
PHP_METHOD(Xpl_Cache_Item, expiresAt) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *expiration, *_0$$3, *_1$$3, *_2$$3, *_3$$5 = NULL, *_4$$5, *_5$$5, *_6$$6, *_7$$6 = NULL, _8$$6, *_9$$6 = NULL;

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



	if (Z_TYPE_P(expiration) == IS_NULL) {
		ZEPHIR_INIT_VAR(_0$$3);
		zephir_time(_0$$3);
		_1$$3 = zephir_fetch_nproperty_this(this_ptr, SL("defaultTtl"), PH_NOISY_CC);
		ZEPHIR_INIT_VAR(_2$$3);
		zephir_add_function(_2$$3, _0$$3, _1$$3);
		zephir_update_property_this(this_ptr, SL("expires"), _2$$3 TSRMLS_CC);
	} else {
		if (zephir_is_instance_of(expiration, SL("DateTimeInterface") TSRMLS_CC)) {
			ZEPHIR_INIT_VAR(_4$$5);
			ZVAL_STRING(_4$$5, "U", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&_3$$5, expiration, "format", NULL, 0, _4$$5);
			zephir_check_temp_parameter(_4$$5);
			zephir_check_call_status();
			ZEPHIR_INIT_ZVAL_NREF(_5$$5);
			ZVAL_LONG(_5$$5, zephir_get_intval(_3$$5));
			zephir_update_property_this(this_ptr, SL("expires"), _5$$5 TSRMLS_CC);
		} else {
			ZEPHIR_INIT_VAR(_6$$6);
			object_init_ex(_6$$6, xpl_cache_invalidargumentexception_ce);
			ZEPHIR_INIT_VAR(_7$$6);
			if (Z_TYPE_P(expiration) == IS_OBJECT) {
				ZEPHIR_INIT_NVAR(_7$$6);
				zephir_get_class(_7$$6, expiration, 0 TSRMLS_CC);
			} else {
				ZEPHIR_INIT_NVAR(_7$$6);
				zephir_gettype(_7$$6, expiration TSRMLS_CC);
			}
			ZEPHIR_SINIT_VAR(_8$$6);
			ZVAL_STRING(&_8$$6, "Expiration date must be null or instance of DateTimeInterface, given: \"%s\".", 0);
			ZEPHIR_CALL_FUNCTION(&_9$$6, "sprintf", NULL, 41, &_8$$6, _7$$6);
			zephir_check_call_status();
			ZEPHIR_CALL_METHOD(NULL, _6$$6, "__construct", NULL, 42, _9$$6);
			zephir_check_call_status();
			zephir_throw_exception_debug(_6$$6, "xpl/cache/item.zep", 147 TSRMLS_CC);
			ZEPHIR_MM_RESTORE();
			return;
		}
	}
	RETURN_THIS();

}
Exemplo n.º 14
0
PHP_METHOD(Test_SpectralNorm, Ax) {

	zval *i, i_sub, *j, j_sub, _0, _1;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&i_sub);
	ZVAL_UNDEF(&j_sub);
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_1);

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &i, &j);



	ZEPHIR_INIT_VAR(&_0);
	zephir_add_function(&_0, i, j);
	ZEPHIR_SINIT_VAR(_1);
	zephir_add_function(&_1, i, j);
	RETURN_MM_DOUBLE(zephir_safe_div_long_double((double) 1, ((zephir_safe_div_long_long((zephir_get_numberval(&_0) * (zephir_get_numberval(&_1) + 1)), 2 TSRMLS_CC) + zephir_get_numberval(i)) + (double) (1)) TSRMLS_CC));

}
Exemplo n.º 15
0
PHP_METHOD(Test_Mcall, testCall9) {

	zval *a, *b, *_0, *_1;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &a, &b);



	ZEPHIR_INIT_VAR(_0);
	zephir_call_method_p2(_0, this_ptr, "testmethod6", a, b);
	ZEPHIR_INIT_VAR(_1);
	zephir_call_method_p2(_1, this_ptr, "testmethod5", a, b);
	zephir_add_function(return_value, _0, _1 TSRMLS_CC);
	RETURN_MM();

}
Exemplo n.º 16
0
/**
 * Sets the bound parameters in the criteria
 * This method replaces all previously set bound parameters
 */
PHP_METHOD(Phalcon_Mvc_Model_Criteria, bind) {

	zend_bool merge;
	zval *bindParams_param = NULL, *merge_param = NULL, *bind = NULL, *_0$$3, *_1$$4, *_2$$6, *_3$$6, *_4$$7, *_5$$8;
	zval *bindParams = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &bindParams_param, &merge_param);

	bindParams = bindParams_param;
	if (!merge_param) {
		merge = 0;
	} else {
		merge = zephir_get_boolval(merge_param);
	}


	if (merge) {
		_0$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC);
		if (zephir_array_isset_string(_0$$3, SS("bind"))) {
			_1$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC);
			ZEPHIR_OBS_VAR(bind);
			zephir_array_fetch_string(&bind, _1$$4, SL("bind"), PH_NOISY, "phalcon/mvc/model/criteria.zep", 106 TSRMLS_CC);
		} else {
			ZEPHIR_INIT_NVAR(bind);
			ZVAL_NULL(bind);
		}
		if (Z_TYPE_P(bind) == IS_ARRAY) {
			ZEPHIR_INIT_VAR(_2$$6);
			zephir_add_function(_2$$6, bind, bindParams);
			ZEPHIR_INIT_VAR(_3$$6);
			ZVAL_STRING(_3$$6, "bind", 1);
			zephir_update_property_array(this_ptr, SL("_params"), _3$$6, _2$$6 TSRMLS_CC);
		} else {
			ZEPHIR_INIT_VAR(_4$$7);
			ZVAL_STRING(_4$$7, "bind", 1);
			zephir_update_property_array(this_ptr, SL("_params"), _4$$7, bindParams TSRMLS_CC);
		}
	} else {
		ZEPHIR_INIT_VAR(_5$$8);
		ZVAL_STRING(_5$$8, "bind", 1);
		zephir_update_property_array(this_ptr, SL("_params"), _5$$8, bindParams TSRMLS_CC);
	}
	RETURN_THIS();

}
Exemplo n.º 17
0
PHP_METHOD(Test_Fibonnaci, fibArray) {

	int i = 0, n = 0, k = 0, j = 0;
	zval fib, a, b, c, _0;
		zval this_zv;
	zval *this_ptr = getThis();
	if (EXPECTED(this_ptr)) {
		ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr));
		this_ptr = &this_zv;
	} else this_ptr = NULL;
	
	ZVAL_UNDEF(&fib);
	ZVAL_UNDEF(&a);
	ZVAL_UNDEF(&b);
	ZVAL_UNDEF(&c);
	ZVAL_UNDEF(&_0);

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(&fib);
	zephir_create_array(&fib, 2, 0 TSRMLS_CC);
	ZEPHIR_INIT_VAR(&_0);
	ZVAL_LONG(&_0, 0);
	zephir_array_fast_append(&fib, &_0);
	ZEPHIR_INIT_NVAR(&_0);
	ZVAL_LONG(&_0, 1);
	zephir_array_fast_append(&fib, &_0);
	i = 2;
	n = 10;
	while (1) {
		if (!(i < n)) {
			break;
		}
		k = (i - 1);
		j = (i - 2);
		zephir_array_fetch_long(&a, &fib, k, PH_NOISY | PH_READONLY, "test/fibonnaci.zep", 51 TSRMLS_CC);
		zephir_array_fetch_long(&b, &fib, j, PH_NOISY | PH_READONLY, "test/fibonnaci.zep", 52 TSRMLS_CC);
		ZEPHIR_INIT_NVAR(&c);
		zephir_add_function(&c, &a, &b);
		zephir_array_update_long(&fib, i, &c, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
		i++;
	}
	RETURN_CCTOR(fib);

}
Exemplo n.º 18
0
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));

}
Exemplo n.º 19
0
PHP_METHOD(Test_Mcall, testCall8) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *a, *b, *_0 = NULL, *_1 = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &a, &b);



	ZEPHIR_CALL_METHOD(&_0, this_ptr, "testmethod5", NULL, a, b);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&_1, this_ptr, "testmethod5", NULL, a, b);
	zephir_check_call_status();
	zephir_add_function(return_value, _0, _1 TSRMLS_CC);
	RETURN_MM();

}
Exemplo n.º 20
0
PHP_METHOD(Test_NativeArray, testArrayAccess6) {

	zval *a, b, *_0, *_1;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(a);
	array_init_size(a, 5);
	add_assoc_long_ex(a, SS("a"), 1);
	add_assoc_long_ex(a, SS("b"), 2);
	add_assoc_long_ex(a, SS("c"), 3);
	zephir_array_fetch_string(&_0, a, SL("a"), PH_NOISY | PH_READONLY TSRMLS_CC);
	zephir_array_fetch_string(&_1, a, SL("b"), PH_NOISY | PH_READONLY TSRMLS_CC);
	ZEPHIR_SINIT_VAR(b);
	zephir_add_function(&b, _0, _1 TSRMLS_CC);
	RETURN_LCTOR(b);

}
Exemplo n.º 21
0
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));

}
Exemplo n.º 22
0
PHP_METHOD(Test_Fibonnaci, fibonacciFinalRecursive) {

	zephir_fcall_cache_entry *_2 = NULL;
	zval *n_param = NULL, _0$$6, _1$$6, _3$$6;
	int n, ZEPHIR_LAST_CALL_STATUS;
		zval this_zv;
	zval *this_ptr = getThis();
	if (EXPECTED(this_ptr)) {
		ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr));
		this_ptr = &this_zv;
	} else this_ptr = NULL;
	
	ZVAL_UNDEF(&_0$$6);
	ZVAL_UNDEF(&_1$$6);
	ZVAL_UNDEF(&_3$$6);

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

	n = zephir_get_intval(n_param);


	if (n == 0) {
		RETURN_MM_LONG(0);
	} else {
		if (n == 1) {
			RETURN_MM_LONG(1);
		} else {
			ZVAL_LONG(&_1$$6, (n - 1));
			ZEPHIR_CALL_METHOD(&_0$$6, this_ptr, "fibonaccifinalrecursive", &_2, 36, &_1$$6);
			zephir_check_call_status();
			ZVAL_LONG(&_1$$6, (n - 2));
			ZEPHIR_CALL_METHOD(&_3$$6, this_ptr, "fibonaccifinalrecursive", &_2, 36, &_1$$6);
			zephir_check_call_status();
			zephir_add_function(return_value, &_0$$6, &_3$$6);
			RETURN_MM();
		}
	}

}
Exemplo n.º 23
0
PHP_METHOD(Test_NativeArray, testArrayAccess6) {

	zval a, b, _0, _1;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&a);
	ZVAL_UNDEF(&b);
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_1);

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(&a);
	zephir_create_array(&a, 3, 0 TSRMLS_CC);
	add_assoc_long_ex(&a, SL("a"), 1);
	add_assoc_long_ex(&a, SL("b"), 2);
	add_assoc_long_ex(&a, SL("c"), 3);
	zephir_array_fetch_string(&_0, &a, SL("a"), PH_NOISY | PH_READONLY, "test/nativearray.zep", 300 TSRMLS_CC);
	zephir_array_fetch_string(&_1, &a, SL("b"), PH_NOISY | PH_READONLY, "test/nativearray.zep", 300 TSRMLS_CC);
	ZEPHIR_INIT_VAR(&b);
	zephir_add_function(&b, &_0, &_1);
	RETURN_CCTOR(&b);

}
Exemplo n.º 24
0
PHP_METHOD(PhalconPlus_Db_Mysql, __construct) {

	zval _9;
	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval name;
	zval *di, di_sub, *name_param = NULL, config, dbConfig, _0, options, _3, _4, _5, _1$$3, _2$$4, _6$$5, _7$$5, _8$$5;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&di_sub);
	ZVAL_UNDEF(&config);
	ZVAL_UNDEF(&dbConfig);
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&options);
	ZVAL_UNDEF(&_3);
	ZVAL_UNDEF(&_4);
	ZVAL_UNDEF(&_5);
	ZVAL_UNDEF(&_1$$3);
	ZVAL_UNDEF(&_2$$4);
	ZVAL_UNDEF(&_6$$5);
	ZVAL_UNDEF(&_7$$5);
	ZVAL_UNDEF(&_8$$5);
	ZVAL_UNDEF(&name);
	ZVAL_UNDEF(&_9);

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &di, &name_param);

	if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) {
		zephir_get_strval(&name, name_param);
	} else {
		ZEPHIR_INIT_VAR(&name);
		ZVAL_EMPTY_STRING(&name);
	}


	ZEPHIR_INIT_VAR(&_0);
	ZVAL_STRING(&_0, "config");
	ZEPHIR_CALL_METHOD(&config, di, "get", NULL, 0, &_0);
	zephir_check_call_status();
	ZEPHIR_OBS_VAR(&dbConfig);
	zephir_read_property_zval(&dbConfig, &config, &name, PH_NOISY_CC);
	zephir_update_property_zval(this_ptr, SL("di"), di);
	zephir_update_property_zval(this_ptr, SL("name"), &name);
	if (zephir_isset_property(&dbConfig, SL("retryTimes"))) {
		zephir_read_property(&_1$$3, &dbConfig, SL("retryTimes"), PH_NOISY_CC | PH_READONLY);
		zephir_update_property_zval(this_ptr, SL("retryTimes"), &_1$$3);
	}
	if (zephir_isset_property(&dbConfig, SL("retryInterval"))) {
		zephir_read_property(&_2$$4, &dbConfig, SL("retryInterval"), PH_NOISY_CC | PH_READONLY);
		zephir_update_property_zval(this_ptr, SL("retryInterval"), &_2$$4);
	}
	ZEPHIR_INIT_VAR(&options);
	zephir_create_array(&options, 3, 0 TSRMLS_CC);
	zephir_read_property(&_3, &dbConfig, SL("charset"), PH_NOISY_CC | PH_READONLY);
	ZEPHIR_INIT_VAR(&_4);
	ZEPHIR_CONCAT_SV(&_4, "SET NAMES ", &_3);
	zephir_array_update_long(&options, 1002, &_4, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY);
	ZEPHIR_OBS_VAR(&_5);
	zephir_read_property(&_5, &dbConfig, SL("timeout"), PH_NOISY_CC);
	zephir_array_update_long(&options, 2, &_5, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY);
	add_index_long(&options, 3, 2);
	if (zephir_isset_property(&dbConfig, SL("options"))) {
		zephir_read_property(&_6$$5, &dbConfig, SL("options"), PH_NOISY_CC | PH_READONLY);
		ZEPHIR_CALL_METHOD(&_7$$5, &_6$$5, "toarray", NULL, 0);
		zephir_check_call_status();
		ZEPHIR_INIT_VAR(&_8$$5);
		zephir_add_function(&_8$$5, &_7$$5, &options);
		zephir_update_property_zval(this_ptr, SL("options"), &_8$$5);
	} else {
		zephir_update_property_zval(this_ptr, SL("options"), &options);
	}
	ZEPHIR_INIT_VAR(&_9);
	zephir_create_array(&_9, 6, 0 TSRMLS_CC);
	ZEPHIR_OBS_NVAR(&_5);
	zephir_read_property(&_5, &dbConfig, SL("host"), PH_NOISY_CC);
	zephir_array_update_string(&_9, SL("host"), &_5, PH_COPY | PH_SEPARATE);
	ZEPHIR_OBS_NVAR(&_5);
	zephir_read_property(&_5, &dbConfig, SL("port"), PH_NOISY_CC);
	zephir_array_update_string(&_9, SL("port"), &_5, PH_COPY | PH_SEPARATE);
	ZEPHIR_OBS_NVAR(&_5);
	zephir_read_property(&_5, &dbConfig, SL("username"), PH_NOISY_CC);
	zephir_array_update_string(&_9, SL("username"), &_5, PH_COPY | PH_SEPARATE);
	ZEPHIR_OBS_NVAR(&_5);
	zephir_read_property(&_5, &dbConfig, SL("password"), PH_NOISY_CC);
	zephir_array_update_string(&_9, SL("password"), &_5, PH_COPY | PH_SEPARATE);
	ZEPHIR_OBS_NVAR(&_5);
	zephir_read_property(&_5, &dbConfig, SL("dbname"), PH_NOISY_CC);
	zephir_array_update_string(&_9, SL("dbname"), &_5, PH_COPY | PH_SEPARATE);
	ZEPHIR_OBS_NVAR(&_5);
	zephir_read_property(&_5, this_ptr, SL("options"), PH_NOISY_CC);
	zephir_array_update_string(&_9, SL("options"), &_5, PH_COPY | PH_SEPARATE);
	zephir_update_property_zval(this_ptr, SL("descriptor"), &_9);
	ZEPHIR_MM_RESTORE();

}
/**
 * Handle the creation of the authorization code.
 *
 * @param string client_id Client identifier related to the authorization code
 * @param string user_id User ID associated with the authorization code
 * @param string redirect_uri An absolute URI to which the authorization server will redirect the
 * user-agent to when the end-user authorization step is completed.
 * @param string scope (optional) Scopes to be stored in space-separated string.
 * @return strin
 *
 * @see http://tools.ietf.org/html/rfc6749#section-4
 * @ingroup oauth2_section_4
 */
PHP_METHOD(OAuth2_ResponseType_AuthorizationCode, createAuthorizationCode) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *client_id_param = NULL, *user_id_param = NULL, *redirect_uri_param = NULL, *scope_param = NULL, *code = NULL, *_0, *_1 = NULL, *_2, *_3, *_4;
	zval *client_id = NULL, *user_id = NULL, *redirect_uri = NULL, *scope = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 3, 1, &client_id_param, &user_id_param, &redirect_uri_param, &scope_param);

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

	if (likely(Z_TYPE_P(client_id_param) == IS_STRING)) {
		zephir_get_strval(client_id, client_id_param);
	} else {
		ZEPHIR_INIT_VAR(client_id);
		ZVAL_EMPTY_STRING(client_id);
	}
	if (unlikely(Z_TYPE_P(user_id_param) != IS_STRING && Z_TYPE_P(user_id_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'user_id' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}

	if (likely(Z_TYPE_P(user_id_param) == IS_STRING)) {
		zephir_get_strval(user_id, user_id_param);
	} else {
		ZEPHIR_INIT_VAR(user_id);
		ZVAL_EMPTY_STRING(user_id);
	}
	if (unlikely(Z_TYPE_P(redirect_uri_param) != IS_STRING && Z_TYPE_P(redirect_uri_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'redirect_uri' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}

	if (likely(Z_TYPE_P(redirect_uri_param) == IS_STRING)) {
		zephir_get_strval(redirect_uri, redirect_uri_param);
	} else {
		ZEPHIR_INIT_VAR(redirect_uri);
		ZVAL_EMPTY_STRING(redirect_uri);
	}
	if (!scope_param) {
		ZEPHIR_INIT_VAR(scope);
		ZVAL_EMPTY_STRING(scope);
	} else {
	if (unlikely(Z_TYPE_P(scope_param) != IS_STRING && Z_TYPE_P(scope_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'scope' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}

	if (likely(Z_TYPE_P(scope_param) == IS_STRING)) {
		zephir_get_strval(scope, scope_param);
	} else {
		ZEPHIR_INIT_VAR(scope);
		ZVAL_EMPTY_STRING(scope);
	}
	}


	ZEPHIR_CALL_METHOD(&code, this_ptr, "generateauthorizationcode", NULL);
	zephir_check_call_status();
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("storage"), PH_NOISY_CC);
	ZEPHIR_CALL_FUNCTION(&_1, "time", NULL);
	zephir_check_call_status();
	_2 = zephir_fetch_nproperty_this(this_ptr, SL("config"), PH_NOISY_CC);
	zephir_array_fetch_string(&_3, _2, SL("auth_code_lifetime"), PH_NOISY | PH_READONLY, "oauth2/responsetype/authorizationcode.zep", 64 TSRMLS_CC);
	ZEPHIR_INIT_VAR(_4);
	zephir_add_function(_4, _1, _3 TSRMLS_CC);
	ZEPHIR_CALL_METHOD(NULL, _0, "setauthorizationcode", NULL, code, client_id, user_id, redirect_uri, _4, scope);
	zephir_check_call_status();
	RETURN_CCTOR(code);

}
Exemplo n.º 26
0
/**
 * Sets the expiration time for this cache item.
 *
 * @param int|\DateInterval time
 *   The period of time from the present after which the item MUST be considered
 *   expired. An integer parameter is understood to be the time in seconds until
 *   expiration. If null is passed explicitly, a default value MAY be used.
 *   If none is set, the value should be stored permanently or for as long as the
 *   implementation allows.
 *
 * @return \Xpl\Cache\Item
 *   The called object.
 */
PHP_METHOD(Xpl_Cache_Item, expiresAfter) {

	zend_class_entry *_6$$7;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *time, *_0$$3, *_1$$3, *_2$$3, *_3$$5, *_4$$5, *_5$$7 = NULL, *_7$$7, *_8$$7 = NULL, *_9$$7 = NULL, *_10$$7 = NULL, *_11$$8, *_12$$8 = NULL, _13$$8, *_14$$8 = NULL;

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



	if (Z_TYPE_P(time) == IS_NULL) {
		ZEPHIR_INIT_VAR(_0$$3);
		zephir_time(_0$$3);
		_1$$3 = zephir_fetch_nproperty_this(this_ptr, SL("defaultTtl"), PH_NOISY_CC);
		ZEPHIR_INIT_VAR(_2$$3);
		zephir_add_function(_2$$3, _0$$3, _1$$3);
		zephir_update_property_this(this_ptr, SL("expires"), _2$$3 TSRMLS_CC);
	} else {
		if (Z_TYPE_P(time) == IS_LONG) {
			ZEPHIR_INIT_VAR(_3$$5);
			zephir_time(_3$$5);
			ZEPHIR_INIT_VAR(_4$$5);
			zephir_add_function(_4$$5, _3$$5, time);
			zephir_update_property_this(this_ptr, SL("expires"), _4$$5 TSRMLS_CC);
		} else {
			if (zephir_instance_of_ev(time, zephir_get_internal_ce(SS("dateinterval") TSRMLS_CC) TSRMLS_CC)) {
					_6$$7 = zend_fetch_class(SL("DateTime"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
				ZEPHIR_INIT_VAR(_7$$7);
				zephir_time(_7$$7);
				ZEPHIR_INIT_VAR(_8$$7);
				ZVAL_STRING(_8$$7, "U", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_CE_STATIC(&_5$$7, _6$$7, "createfromformat", NULL, 0, _8$$7, _7$$7);
				zephir_check_temp_parameter(_8$$7);
				zephir_check_call_status();
				ZEPHIR_CALL_METHOD(&_9$$7, _5$$7, "add", NULL, 0, time);
				zephir_check_call_status();
				ZEPHIR_INIT_NVAR(_8$$7);
				ZVAL_STRING(_8$$7, "U", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(&_10$$7, _9$$7, "format", NULL, 0, _8$$7);
				zephir_check_temp_parameter(_8$$7);
				zephir_check_call_status();
				zephir_update_property_this(this_ptr, SL("expires"), _10$$7 TSRMLS_CC);
			} else {
				ZEPHIR_INIT_VAR(_11$$8);
				object_init_ex(_11$$8, xpl_cache_invalidargumentexception_ce);
				ZEPHIR_INIT_VAR(_12$$8);
				if (Z_TYPE_P(time) == IS_OBJECT) {
					ZEPHIR_INIT_NVAR(_12$$8);
					zephir_get_class(_12$$8, time, 0 TSRMLS_CC);
				} else {
					ZEPHIR_INIT_NVAR(_12$$8);
					zephir_gettype(_12$$8, time TSRMLS_CC);
				}
				ZEPHIR_SINIT_VAR(_13$$8);
				ZVAL_STRING(&_13$$8, "Expiration date must be integer, DateInterval or null, given: \"%s\".", 0);
				ZEPHIR_CALL_FUNCTION(&_14$$8, "sprintf", NULL, 41, &_13$$8, _12$$8);
				zephir_check_call_status();
				ZEPHIR_CALL_METHOD(NULL, _11$$8, "__construct", NULL, 42, _14$$8);
				zephir_check_call_status();
				zephir_throw_exception_debug(_11$$8, "xpl/cache/item.zep", 181 TSRMLS_CC);
				ZEPHIR_MM_RESTORE();
				return;
			}
		}
	}
	RETURN_THIS();

}
Exemplo n.º 27
0
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();

}
Exemplo n.º 28
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);

}