Automatically call entry point #39

Закрыто
открыта 2018-08-08 11:21:33 +02:00 belliash · комментариев: 2
belliash прокомментировал(а) 2018-08-08 11:21:33 +02:00
Владелец

Actually all our test scripts contain "new Main();" in order to call for an entry point. This should be invoked automatically by the Interpreter from the PH7_VmByteCodeExec() function.

It should look for a main class, instantiate it, call its constructor if exists. Also it should pass argv as a parameter to the entry point. Some mechanism needs to be implemented to do that. There are two ways:

  1. PH7_VmCallClassMethod() will take one more argument saying that it should NOT check for parameters count and we will pass argv everytime, regardless any argument have been passed to the script or not. Otherwise, Interpreter will throw error.
  2. We have to check how many parameters does entry point take. If it take one parameter, pass argv. If does not take any arguments, do not pass it. if takes more arguments, throw error.

Additionally in scope of this ticket, I would like to discuss:

  1. Which way should we choose to solve above described problem?
  2. Should the entry class be called Main? Or maybe we should rename it to sth else (eg. Program)?
  3. Should we try to launch only constructor, or maybe there should be another method implemented (eg. main())? Thus we could do some pre-tasks in constructor, before Main::main() or Program::main() would be called? This could be resolved respectively

to:

$main = new Main();

or

$main = new Main();
$main->main();
Actually all our test scripts contain "__new Main();__" in order to call for an entry point. This should be invoked automatically by the Interpreter from the PH7_VmByteCodeExec() function. It should look for a main class, instantiate it, call its constructor if exists. Also it should pass argv as a parameter to the entry point. Some mechanism needs to be implemented to do that. There are two ways: 1. PH7_VmCallClassMethod() will take one more argument saying that it should NOT check for parameters count and we will pass argv everytime, regardless any argument have been passed to the script or not. Otherwise, Interpreter will throw error. 2. We have to check how many parameters does entry point take. If it take one parameter, pass argv. If does not take any arguments, do not pass it. if takes more arguments, throw error. Additionally in scope of this ticket, I would like to discuss: 1. Which way should we choose to solve above described problem? 2. Should the entry class be called Main? Or maybe we should rename it to sth else (eg. Program)? 3. Should we try to launch only constructor, or maybe there should be another method implemented (eg. main())? Thus we could do some pre-tasks in constructor, before Main::main() or Program::main() would be called? This could be resolved respectively to: $main = new Main(); or $main = new Main(); $main->main();
belliash добавил(а) метку
aerscript
2018-08-08 11:21:33 +02:00
belliash добавил(а) метку
question
2018-08-08 12:04:14 +02:00
belliash назначил(а) на себя 2018-08-11 21:09:22 +02:00
belliash прокомментировал(а) 2018-08-11 21:09:40 +02:00
Автор
Владелец

Will be done in compiler_rework branch.

Will be done in compiler_rework branch.
belliash прокомментировал(а) 2018-08-12 12:58:55 +02:00
Автор
Владелец

Implemented with 029dd9bfb4 in compiler_rework branch.

Implemented with 029dd9bfb4 in compiler_rework branch.
belliash закрыл(а) эту задачу 2018-08-12 12:58:55 +02:00
Войдите, чтобы присоединиться к обсуждению.
Нет этапа
Нет назначенных лиц
1 участников
Уведомления
Срок выполнения
Срок действия недействителен или находится за пределами допустимого диапазона. Пожалуйста, используйте формат 'гггг-мм-дд'.

Срок выполнения не установлен.

Зависимости

Зависимостей нет.

Ссылка: aerscript/Aer#39
Описание отсутствует.