Rafal Kupiec
a013cee2d1
Properly serve the arrays.
2019-03-28 19:44:03 +01:00
Rafal Kupiec
e4dc9f641e
Invert the logic. Variable needs to be declared.
2019-03-28 19:43:00 +01:00
Rafal Kupiec
9303517b9e
Fix return by reference.
2019-03-26 17:40:28 +01:00
Rafal Kupiec
04c56c9041
Multidimensional array of the same type should not be marked as mixed.
2019-03-25 09:37:40 +01:00
Rafal Kupiec
fa295b9437
It's callback, not callable.
2019-03-24 09:31:19 +01:00
Rafal Kupiec
4f29507c0d
The isset() function always results in true, thus it is useless. If passed as argument variable is not set, the interpreter will throw an error.
2019-03-23 19:51:19 +01:00
Rafal Kupiec
9d7a542aea
The is_null() is useless now, as it always returns FALSE.
2019-03-22 19:29:50 +01:00
Rafal Kupiec
154469f475
Variable cannot be typecasted to NULL.
2019-03-22 18:33:39 +01:00
Rafal Kupiec
9a41f7195d
AerScript does not implement any error control operator.
2019-03-22 17:32:40 +01:00
Rafal Kupiec
65b178932a
Get rid of array() & list() for the new syntax.
2019-03-22 15:54:46 +01:00
Rafal Kupiec
90b5a8797a
Fix a bug allowing to pass an array as argument to the method/closure that takes a scalar.
2019-03-22 08:59:12 +01:00
Rafal Kupiec
7b1ed59f41
Basic check if all methods declared in interface are also defined in class.
2019-03-20 09:24:30 +01:00
Rafal Kupiec
3d23d43040
Enable garbage collector for Program class. This also partially fixes #47 , as from now Program::__destruct() will be called automatically.
2019-03-19 12:52:36 +01:00
Rafal Kupiec
6ca08c9c4a
Fix typo and builtin library.
2019-03-17 19:57:31 +01:00
Rafal Kupiec
55b652c740
Verify that Program::main() returns a value of int or void.
2019-03-17 19:56:07 +01:00
Rafal Kupiec
fe898ec7e7
Update builtin library to follow new syntax.
2019-03-17 19:52:28 +01:00
Rafal Kupiec
9934489ed9
Fix build.
2019-03-17 18:56:17 +01:00
Rafal Kupiec
f3d10dd4bc
Try to exit with code returned by Program::main() only when it is integer value.
2019-03-17 18:49:22 +01:00
Rafal Kupiec
de2b355862
Return 0, when display error message.
2019-03-17 18:47:17 +01:00
Rafal Kupiec
c8985032ef
Verify that return value match the data type of declared method/closure.
2019-03-13 09:36:10 +01:00
Rafal Kupiec
a5ee2d75eb
PH7_VmMemoryError() always breaks script execution.
2019-03-09 13:37:15 +01:00
Rafal Kupiec
b7e3ad9f46
PH7_VmMemoryError() always breaks script execution.
2019-03-09 13:28:04 +01:00
Rafal Kupiec
7eba38a633
Fix segmentation fault when trying to store a value under next index into an array.
2019-03-09 13:25:13 +01:00
Rafal Kupiec
fa0b487cc0
Implement typecasting to resource data type.
2019-02-08 14:06:39 +01:00
Rafal Kupiec
bbdc740388
Finally, do not allow a string variables to act as callback.
2018-12-20 19:37:03 +01:00
Rafal Kupiec
f97e2a8294
Implement typecasting to callback data type.
2018-12-20 18:30:21 +01:00
Rafal Kupiec
d87ce3ad1d
1. Set a proper data type when compiling closure.
...
2. Temporarily allow to call a closure/function if its name is stored in a variable of callback or string type. Ultimately, only callback will be allowed.
2018-12-01 12:53:58 +01:00
Rafal Kupiec
3f9e3b0664
Check for compatible data types on OP_CALL & OP_STORE.
2018-11-28 21:58:41 +01:00
Rafal Kupiec
d65a529d21
Initial support for char data type.
2018-11-26 20:37:51 +01:00
Rafal Kupiec
174ecb2a38
Initial support for void type.
2018-11-23 09:19:37 +01:00
Rafal Kupiec
87db6d6dfd
Allow a method/closure to take compatible mixed variable as argument.
2018-11-18 22:06:40 +01:00
Rafal Kupiec
6f13c347d8
Set the proper type of array.
2018-10-26 19:45:10 +02:00
Rafal Kupiec
c00080e190
Correct comment.
2018-09-24 19:20:23 +02:00
Rafal Kupiec
b5eb268ce1
Do not allow to set a value of different type to the variable.
2018-09-24 19:17:46 +02:00
Rafal Kupiec
5f2f9d9c08
Set proper data type for static variables;
2018-09-24 19:16:44 +02:00
Rafal Kupiec
369cadfcda
Tryeing to call a non-instantiated object should result in an error.
2018-09-24 12:10:19 +02:00
Rafal Kupiec
ae0fde152c
Create a variable only on OP_LOAD.
2018-09-23 17:40:26 +02:00
Rafal Kupiec
514e07c7f3
Fix static variables not containing any value.
2018-09-21 22:18:11 +02:00
Rafal Kupiec
f927667d85
Strictly check for data type of static variable declaration.
2018-09-21 22:06:36 +02:00
Rafal Kupiec
e6e59d299e
Fix method parameters.
2018-09-19 19:27:50 +02:00
Rafal Kupiec
5a6af65cfa
Object of wrong type passed as argument should be generate error.
2018-09-17 22:06:53 +02:00
Rafal Kupiec
82998ffd0f
Silently typecast integer value to float.
...
This is a necessary step, to allow passing integer numbers. Otherwise, every float variable would need a floating point value. In other words, "float $x = 5" is allowed construct. Without this simple change, only accepted
construction was "float $x = 5.0".
2018-09-16 20:02:34 +02:00
Rafal Kupiec
58103ea5fe
Mark method/closure call frame as active.
...
It is impossible to dump the frame during its initialization, as it does not contain all necessary information. Such frame should be skipped. After initialization is done, the frame has to be marked as active just before
evaluating a function body.
2018-09-16 19:52:24 +02:00
Rafal Kupiec
3a16eced8a
Push error if argument type does not match.
2018-09-15 14:13:46 +02:00
Rafal Kupiec
5504579566
Passing an object of different type as expected should result in error.
2018-09-14 22:27:38 +02:00
Rafal Kupiec
faca9b7fb2
Another fix in debug trace.
2018-09-14 22:22:37 +02:00
Rafal Kupiec
ecebbb6094
Use type hinting in standard library.
2018-09-14 08:36:00 +02:00
Rafal Kupiec
58b7ceeae9
Get rid of $GLOBALS completely.
2018-09-11 17:49:20 +02:00
Rafal Kupiec
e383536dc4
Do not store script arguments in $GLOBALS.
2018-09-11 06:47:48 +02:00
Rafal Kupiec
9ebc3dc61a
Extract a list of parameters and pass them to Program::main();
2018-09-10 23:12:08 +02:00
Rafal Kupiec
eb79ed500e
Store float values in an union.
...
Single variable cannot have many values of different types. This also saves some memory, because union allocates memory just for one of its members.
2018-09-07 12:04:51 +02:00
Rafal Kupiec
af1d59dab4
Don't try to get an integer representation of float.
2018-09-07 06:49:50 +02:00
Rafal Kupiec
43a36f070c
Correct comments.
2018-09-06 18:00:34 +02:00
Rafal Kupiec
3887aa69a6
Never disable hash functions.
2018-09-05 21:46:25 +02:00
Rafal Kupiec
00e1c842d5
Never disable builtin functions.
2018-09-05 20:43:39 +02:00
Rafal Kupiec
ea4daa9335
Take last instruction being executed, not necessarily OP_CALL.
2018-09-05 19:45:38 +02:00
Rafal Kupiec
6387026e15
Do not limit the output buffering callbacks.
2018-09-05 18:46:42 +02:00
Rafal Kupiec
11ba0ce738
No need to store output length in VM.
2018-09-05 18:33:53 +02:00
Rafal Kupiec
404f5a2688
No need to store unique ID in VM.
2018-09-05 18:24:34 +02:00
Rafal Kupiec
894dbe47d6
Allow compiler to specify line number, on which instruction has been generated.
...
This also fixes line number on OP_CLASS_INIT and OP_INTERFACE_INIT.
2018-09-05 17:31:06 +02:00
Rafal Kupiec
543176a2f4
Switch VM state to PH7_VM_INCL when including new file.
2018-09-05 13:28:20 +02:00
Rafal Kupiec
d58249cb3f
Use debug trace only if VM is really executing some code.
2018-09-05 13:16:57 +02:00
Rafal Kupiec
d793d3ed70
Rename PH7_VmGenericError() to PH7_VmThrowError()
2018-09-04 08:54:48 +02:00
Rafal Kupiec
758ace0d1a
Shutdown library properly on error.
2018-09-04 08:49:38 +02:00
Rafal Kupiec
dc0a55c8c0
Cleanup old error handler.
2018-09-04 08:38:41 +02:00
Rafal Kupiec
ac73632cb1
Use new error handler.
2018-09-04 08:26:58 +02:00
Rafal Kupiec
d85a517eb0
Rework trigger_error() builtin function.
2018-09-03 19:27:38 +02:00
Rafal Kupiec
0a28e492a7
error_reporting() is useless for Aer.
...
Whole configuration should be done in config file.
2018-09-03 19:11:44 +02:00
Rafal Kupiec
fd4206a227
Remove error_log() builtin function and corresponding PH7_VM_CONFIG_ERR_LOG_HANDLER.
...
It was not fully implemented and such feature should be implemented in separate module or on developers own.
2018-09-03 19:03:05 +02:00
Rafal Kupiec
109f4e981a
Aer does not support custom error handlers.
...
Errors are used only internally to emit notifications about compilation/execution problems. They should not be catched and handled by custom handlers, but properly configured (to be displayed or logged). Instead developers should
use exceptions that can be catched with try-catch block.
2018-09-03 16:43:08 +02:00
Rafal Kupiec
dd35b5b8b4
Uncaught exception message.
2018-09-03 16:29:50 +02:00
Rafal Kupiec
d3d3dcc767
Partially switch to new error reporting.
2018-09-03 16:16:32 +02:00
Rafal Kupiec
0298299169
Extend SEQ field.
2018-09-03 09:36:22 +02:00
Rafal Kupiec
9c4eb59b49
Variable list of arguments for PH7_VmGenericError();
2018-09-03 09:30:23 +02:00
Rafal Kupiec
f176414bce
Release VM and exit automatically, do not rely on VM.
2018-09-03 08:40:18 +02:00
Rafal Kupiec
eea9eee6e5
Implement PH7_VmGenericError();
2018-09-03 08:19:14 +02:00
Rafal Kupiec
a2acf64272
VmExtractDebugTrace() provides information about a kind of call.
...
Both VmExtractDebugTrace() and VmDebugTrace structure should provide information whether it was object call or a static method call.
2018-09-02 20:15:17 +02:00
Rafal Kupiec
d135748bcd
Always iterate through all frames.
2018-09-02 18:53:23 +02:00
Rafal Kupiec
ea7955b6ee
Remove useless VmExtractPeekDebugTrace();
2018-09-02 18:50:00 +02:00
Rafal Kupiec
f89af70ab2
Fix VmExtractDebugTrace();
...
If there is no information about class in the frame (when closure was called), pClassName should point always to NULL.
2018-09-02 18:46:30 +02:00
Rafal Kupiec
3e1d91e909
Add more comments.
2018-09-02 18:45:01 +02:00
Rafal Kupiec
da198fcb44
Implement PH7_VmMemoryError();
2018-09-02 12:27:32 +02:00
Rafal Kupiec
90ab131ce8
Do not append spaces. Instructions names are properly displayed without them.
2018-09-01 20:28:16 +02:00
Rafal Kupiec
8bfaa83b04
Correct typo.
2018-09-01 20:19:10 +02:00
Rafal Kupiec
4dae0bcc9e
Always record last instruction.
2018-09-01 19:56:36 +02:00
Rafal Kupiec
d9db6bbc26
There is no need for global working buffer in VM.
2018-08-31 23:34:35 +02:00
Rafal Kupiec
67ce98d924
Look for executed OP_CALL.
...
Each function contains a list of all instructions inside, thus we should consider only OP_CALL that has already been executed. As the list is browsed from bottom to top, no more checks are necessary. The first match is what we
are looking for.
2018-08-31 08:30:59 +02:00
Rafal Kupiec
838842fa02
Add execution marker to each instruction.
2018-08-31 08:25:48 +02:00
Rafal Kupiec
3e2a5b3be2
Correct field length.
2018-08-30 19:23:06 +02:00
Rafal Kupiec
90a02d8fdd
Add operator ID to the debugging information.
2018-08-30 16:52:09 +02:00
Rafal Kupiec
b6161b0e4b
Fix VM ByteCode debugging.
...
Only executed bytecode should be registered for debugging. In this way we do not register all emitted bytecode and save some memory. What is more, this change registers the bytecode in correct executing order including jumps.
Previously all bytecode generated by compiler has been saved what made the bytecode to be saved in compile, not execute order.
2018-08-30 09:46:40 +02:00
Rafal Kupiec
98d3de2105
Record all instructions in debugging set.
2018-08-29 08:04:19 +02:00
Rafal Kupiec
8f92782fe2
Fix segmentation fault.
2018-08-28 19:07:07 +02:00
Rafal Kupiec
d97c0a6634
Fix VmExtractPeekDebugTrace();
2018-08-28 11:17:32 +02:00
Rafal Kupiec
603672b8e2
PH7 disallows function calls from global scope.
2018-08-28 11:16:34 +02:00
Rafal Kupiec
37c960e313
Fix uninitialized value leading to segmentation fault.
2018-08-27 20:23:08 +02:00
Rafal Kupiec
349bbed774
Allow to enable or disable debugging.
2018-08-27 19:53:24 +02:00
Rafal Kupiec
c8e2dccbeb
Assign Program::main() return value as program exit code.
2018-08-27 19:32:17 +02:00
Rafal Kupiec
6d27069590
Add new file for every chunk.
...
Every chunk should has its own file associated, even if it is [MEMORY]. Otherwise, some false information can be provided by interpreter to developer.
2018-08-27 18:04:45 +02:00
Rafal Kupiec
c9a1971ace
Rewrite debug_backtrace() builtin function.
...
It makes a use of new VmExtractDebugTrace() function. This probably fixes #45 .
2018-08-27 15:47:34 +02:00
Rafal Kupiec
ce621cc49c
Implement VmExtractPeekDebugTrace();
2018-08-27 12:42:02 +02:00
Rafal Kupiec
d0b0a416d0
Allow to dump last frame only.
2018-08-27 12:36:21 +02:00
Rafal Kupiec
8f7b28d46c
Formatting for VM dump.
2018-08-27 12:16:41 +02:00
Rafal Kupiec
fb671ec2d7
Implement VmExtractDebugTrace().
2018-08-27 11:32:21 +02:00
Rafal Kupiec
1403b144d9
Sequence numbers should start from 1.
2018-08-27 09:30:51 +02:00
Rafal Kupiec
782a4df1cf
Formatting, add information about file and line.
2018-08-27 09:17:18 +02:00
Rafal Kupiec
b1f71167d9
Unify memory indicator.
2018-08-27 08:22:05 +02:00
Rafal Kupiec
3f7bac2d85
Associate a filename with VM instructions.
2018-08-27 06:45:53 +02:00
Rafal Kupiec
f552c54992
Better formatting.
2018-08-26 22:10:47 +02:00
Rafal Kupiec
a7bbd55d48
Temporarily enable debugging by default.
2018-08-26 20:09:30 +02:00
Rafal Kupiec
178f3820f6
Enable debugging.
...
This commit introduces ne debug feature. The PH7 Engine limits the VM dump to the global scope. Since Aer Script is fully object-oriented language the dump option contains only information about last call of OP_DONE. This change,
forces the VM to store all instructions set in a global container when debugging is enabled, thus providing information the dump of whole script parse.
2018-08-26 19:59:17 +02:00
Rafal Kupiec
98ee931a04
Correct instruction length.
2018-08-26 18:33:57 +02:00
Rafal Kupiec
4197737ddc
Move structure definitions to header.
2018-08-23 17:08:10 +02:00
Rafal Kupiec
82c18dc109
Do not pop out the processed files.
...
List of procesed files is still needed, as we point to them.
2018-08-23 07:06:33 +02:00
Rafal Kupiec
20c1611902
Implement PH7_VmExtractActiveClass().
...
This function extracts an active class with specified depth, #45 .
2018-08-22 15:33:16 +02:00
Rafal Kupiec
81325b5059
Correct typo.
2018-08-18 21:05:46 +02:00
Rafal Kupiec
2160747479
Make get_included_files() returning full path.
2018-08-18 21:02:23 +02:00
Rafal Kupiec
cbb4a0aa5c
get_included_files() should return a list of included, files.
2018-08-18 20:42:54 +02:00
Rafal Kupiec
4b3279ef01
Correct function description.
2018-08-18 19:32:33 +02:00
Rafal Kupiec
4dbd3ea412
New memory subsystem.
...
This is a new memory subsystem implementing heap calculations as well as new builtin functions:
* get_memory_usage()
* get_memory_peak_usage()
* get_memory_limit()
It also allows to set an upper memory limit, ensuring that processed script will not be able to allocate more memory from OS.
New subsystem is based on work done in 'memory_limit' branch. Big thanks to devnexen!
This finally fixes #25 .
2018-08-18 19:24:38 +02:00
Rafal Kupiec
b5fe36c14b
There is no need for include_once() and require_once()
...
Aer is object-oriented language and the code it includes is executed in the global scope. Global scope can contain only classes and namespaces and they cannot be re-declared. Thus every file can be included just once. We can
leave this to programmer, or take care about it on interpreter side. With this commit, include() and require() builtin functions allows to load file just once. Thanks to that, there is no need for include_once() and
require_once(). Done in scope of #30 .
2018-08-16 16:12:29 +02:00
Rafal Kupiec
039fde099f
Compile Aer code or chunk of code.
2018-08-16 09:34:18 +02:00
Rafal Kupiec
b94a23d580
Get rid of PH7 ident
2018-08-15 20:03:39 +02:00
Rafal Kupiec
7c7a837efb
Correct another bunch of typos.
2018-08-15 19:06:00 +02:00
Rafal Kupiec
71d46e3052
Compiler rework does not allow functions in global scope.
...
These functions will be rewritten in C as a builtin functions in scope of #42 .
2018-08-15 18:56:10 +02:00
Rafal Kupiec
da0b7eb629
Some useless function
2018-08-15 17:34:40 +02:00
Rafal Kupiec
af139b3f0a
Reimplement C-like min() and max() functions.
...
These functions should have C-like implementation and take exactly 2 arguments: integer or float.
Finally, C-implementation will be faster than using PH7 builtin library that needs to be compiled and interpreted.
2018-08-15 17:26:26 +02:00
Rafal Kupiec
8ab67084a0
It is as easy to instantiate the class as to remove this useless functions.
2018-08-15 16:31:28 +02:00
Rafal Kupiec
6f491b398a
Always show compilation errors
2018-08-15 16:01:09 +02:00
Rafal Kupiec
8e87989719
A;ways show compilation errors from evaluated code
2018-08-15 15:41:53 +02:00
Rafal Kupiec
052649e677
Trust builtin library.
...
The builtin library should compile successfully. Otherwise, we want to know about it.
2018-08-15 14:12:44 +02:00
Rafal Kupiec
0e64c7cc6e
Fix builtin library
2018-08-15 14:08:59 +02:00
Rafal Kupiec
ece036b214
Rework the entry point
...
* some functions were not used and have been removed
* some parameters seemed to be useless and have been removed
* code cleanup
2018-08-14 13:45:27 +02:00
Rafal Kupiec
7e3c79d3c5
Functions naming cleanup
2018-08-13 20:16:37 +02:00
Rafal Kupiec
029dd9bfb4
Several changes made:
...
* Do not overload entry point
* Automatically call Program::__construct()
* Automatically call Program::main();
* Fix all tests
2018-08-12 12:52:35 +02:00
Rafal Kupiec
8cbfca2bc9
Do not overload entry point
2018-08-12 12:27:15 +02:00
Rafal Kupiec
3252f54615
Temporarily look for modules in binary/ subdirectory. This will allow us to test modules.
...
Final version should take the full path from configuration.
2018-08-10 08:47:42 +02:00
Rafal Kupiec
8936f6529f
Remove duplicate
2018-08-09 21:32:00 +02:00
Rafal Kupiec
94b29fa238
Remove duplicates
2018-08-09 21:27:24 +02:00
Rafal Kupiec
8f7fc71027
Consider a method with compiled default value associated as a candidate to call. Fixes #37 .
2018-08-08 09:00:24 +02:00
Rafal Kupiec
e15166d940
Temporary fix for master branch
2018-08-08 06:52:15 +02:00
Rafal Kupiec
bca4d1a2fa
Always select an appropriate function to call
...
It does not matter, if we call function, anonymouss function or method. It is important to select appropriate function to call everytime. Otherwise, if function or method is not overloaded it will call it regardless the number
and type of parameters it takes.
type
2018-08-07 19:48:12 +02:00
Rafal Kupiec
34dd052f74
quick typo fix
2018-08-07 19:45:34 +02:00
Rafal Kupiec
370465fe79
We should use %z to match (SyString *) length and to not display trash.
2018-08-07 19:02:28 +02:00
David Carlier
a0fb911d7a
Fix #36 , unrolling through the frames needed to also reset to the initial frame after
2018-08-07 13:55:13 +00:00
Rafal Kupiec
cdc58f2795
Cleanup after 2c37807370
- get rid of global keyword, #29 .
2018-08-07 12:27:21 +02:00
Rafal Kupiec
a4e6962a67
Free dot operator for further usage
2018-08-07 08:13:44 +02:00
Rafal Kupiec
e4ab5974fa
Let the compiler use OP_ADD instead of OP_CAT
2018-08-07 07:47:25 +02:00
Rafal Kupiec
9a56751879
Allow addition operator (+) to concatenate strings.
2018-08-07 06:54:44 +02:00
Rafal Kupiec
4bbdc20174
This commit contains several changes:
...
* print() is now treated as standard function
* get rid of echo() function
* fix test suite
and it fixes #26 .
2018-08-06 17:18:27 +02:00