866 Commits

Author SHA1 Message Date
7076a6f3ed Merge branch 'master' of AerScript/Aer into release/v0.1
Some checks failed
The build has failed.
2019-11-02 09:24:55 +01:00
a24e44fbf3 Completely remove this broken threading implementation. Fixes #55.
All checks were successful
The build was successful.
2019-10-28 21:35:16 +01:00
f3972a9ca2 Rename LFB/LFE operators.
All checks were successful
The build was successful.
2019-10-25 23:09:30 +02:00
f323e3cb57 Make a use from PH7_MemObjIsHashmap().
All checks were successful
The build was successful.
2019-09-10 14:12:07 +02:00
426ec932ec Implement MemObjIsHashmap().
All checks were successful
The build was successful.
2019-09-10 10:55:54 +02:00
3aa31a9dfa Make a use from MemObjIsNumeric().
All checks were successful
The build was successful.
2019-09-10 10:10:52 +02:00
f0aba06f4f Allow increment/decrement operations only on numeric operands.
All checks were successful
The build was successful.
2019-09-10 08:03:35 +02:00
18b96064e4 Do not allow to call non-existen array/string index.
All checks were successful
The build was successful.
PHP returns a NULL for each call to non-existen array element, while AerScript design disallows usage of indexes outside the bounds. This fixes one of most serious PHP problems.
2019-09-09 16:55:48 +02:00
91887c0185 Do not try to access non-existen string index.
All checks were successful
The build was successful.
2019-09-07 20:07:46 +02:00
3b9d91f186 Revert 3dcc908788.
All checks were successful
The build was successful.
2019-08-29 14:23:33 +02:00
0fb44bb1ae GitHub Funding.
All checks were successful
The build was successful.
2019-08-23 13:48:56 +02:00
Piotr Likoski
d2335c86b2 Base32::decode() cannot return boolean values.
All checks were successful
The build was successful.
2019-07-12 17:05:27 +02:00
Piotr Likoski
843c2d67d9 I am pretty sure we want to use the number of elements in array in this place, not the actual size of array.
All checks were successful
The build was successful.
The size of a structure is greater than the sum of its parts because of what is called packing. A particular processor has a preferred data size that it works with. Most modern processors' preferred size if 32-bits (4 bytes).
2019-07-12 14:36:56 +02:00
Piotr Likoski
33b0f20573 Check the snprintf() return value.
All checks were successful
The build was successful.
2019-07-12 14:10:09 +02:00
David Carlier
d96dcdf1e0 Little build warning removal
All checks were successful
The build was successful.
2019-07-11 07:17:34 +00:00
a09c6b3fad Fix for index outside the bounds.
All checks were successful
The build was successful.
2019-07-01 21:08:07 +02:00
4d150c2fe3 No way this is working!
All checks were successful
The build was successful.
2019-07-01 21:03:45 +02:00
c94de60c29 Properly implement tests.
All checks were successful
The build was successful.
2019-07-01 20:07:06 +02:00
376b9510a9 Fix typos, formatting.
All checks were successful
The build was successful.
2019-06-30 14:13:35 +02:00
ad49b81b33 Add support for HTTP/2.0 protocol version.
All checks were successful
The build was successful.
2019-06-30 09:51:15 +02:00
4afcbc0815 Extend singleton test.
All checks were successful
The build was successful.
2019-06-29 16:04:15 +02:00
171456beb4 Release all elements in object allocation table.
All checks were successful
The build was successful.
2019-06-29 15:54:05 +02:00
204060fa9d Implement TAU.
All checks were successful
The build was successful.
2019-06-29 14:21:29 +02:00
616b2eeae3 Cleanup the headers a bit.
All checks were successful
The build was successful.
2019-06-29 11:50:01 +02:00
563c10bd20 Do not omit floating point.
All checks were successful
The build was successful.
2019-06-29 11:41:37 +02:00
2e695a9d35 Link dynamically with libC.
All checks were successful
The build was successful.
2019-06-29 11:15:03 +02:00
2ef2b6265c Never disable IO library.
All checks were successful
The build was successful.
2019-06-29 11:10:50 +02:00
a6d89da16b Do not support old libC.
All checks were successful
The build was successful.
2019-06-28 19:43:23 +02:00
48d5088265 Enable the magic number protection.
All checks were successful
The build was successful.
2019-06-27 22:57:08 +02:00
3dcc908788 Enable threading.
All checks were successful
The build was successful.
2019-06-27 20:52:37 +02:00
4881ddf6de Pass compatible pointer type.
All checks were successful
The build was successful.
2019-06-27 20:44:50 +02:00
312fb97db6 Another FS-related bugfix to make compiler happy.
All checks were successful
The build was successful.
2019-06-25 20:25:56 +02:00
0a2f1133d5 Do not use pointer for file path.
All checks were successful
The build was successful.
2019-06-25 20:10:27 +02:00
647454b98d Another signedness correction.
All checks were successful
The build was successful.
2019-06-22 20:45:22 +02:00
72782b147a Do not convert between data pointers and function pointers.
All checks were successful
The build was successful.
2019-06-22 12:35:33 +02:00
edb62ed692 Correct signedness.
All checks were successful
The build was successful.
2019-06-22 12:34:49 +02:00
8b2086402e Fix all compiler warnings in AerScript compiler.
All checks were successful
The build was successful.
2019-06-22 11:59:43 +02:00
8ee2dece06 Test NULL-coalescing operator.
All checks were successful
The build was successful.
2019-06-21 23:53:01 +02:00
dcf37af75e Implement a NULL-coalescing '??' operator.
All checks were successful
The build was successful.
2019-06-21 00:34:41 +02:00
6d964d6113 Add missing declaration for PH7_MemObjIsNull() function.
All checks were successful
The build was successful.
2019-06-21 00:30:35 +02:00
3045bd2d88 Update lexer. Add missing operators.
All checks were successful
The build was successful.
2019-06-20 14:30:49 +02:00
19d0628afc Do not try to duplicate an array when source equals to destination.
All checks were successful
The build was successful.
2019-06-20 13:36:30 +02:00
59811ac742 Completely rely on the compiler.
All checks were successful
The build was successful.
2019-06-20 12:10:02 +02:00
e40dc34026 Pass proper line number from compiler to the virtual machine.
All checks were successful
The build was successful.
2019-06-20 12:07:47 +02:00
c76ae15a7b Disable undefined behavior sanitizer.
All checks were successful
The build was successful.
2019-06-20 00:19:52 +02:00
a1f1d50d25 Allow to use compiler's sanitizer. This fixes #53.
All checks were successful
The build was successful.
2019-06-19 17:38:36 +02:00
ca51e2a5da Add comments.
All checks were successful
The build was successful.
2019-06-19 10:14:01 +02:00
bd24aa0605 Correct more compiler warnings.
All checks were successful
The build was successful.
2019-06-19 09:31:40 +02:00
690213e0c7 Do not use a pointer for temporary value.
All checks were successful
The build was successful.
2019-06-18 13:25:40 +02:00
0be38392bd Correct variable types, to make compiler silent.
All checks were successful
The build was successful.
2019-06-17 14:28:03 +02:00
bffd44a7b4 Get rid of some annoying compiler warnings.
All checks were successful
The build was successful.
2019-06-17 09:51:37 +02:00
173bac16ad Add missing definitions.
All checks were successful
The build was successful.
2019-06-16 19:54:42 +02:00
b3eb2d0139 Include missing header.
All checks were successful
The build was successful.
2019-06-16 08:41:42 +02:00
050a637e88 Add missing declarations.
All checks were successful
The build was successful.
2019-06-16 08:31:43 +02:00
8d0c128d22 Fix comparison of integer expressions of different signedness.
All checks were successful
The build was successful.
2019-06-16 00:37:20 +02:00
c7b6e76d0d Get rid of unused variables/labels/etc.
All checks were successful
The build was successful.
2019-06-16 00:33:03 +02:00
1a91fedb1f Proper SXUNUSED() macro implementation.
All checks were successful
The build was successful.
2019-06-16 00:10:27 +02:00
fffce10ba8 Test for implicitly typed declarations.
All checks were successful
The build was successful.
2019-06-15 23:44:10 +02:00
ace4d56d7f The '-Og' is a better choice than '-O0' for producing debuggable code because some compiler passes that collect debug information are disabled at '-O0'.
All checks were successful
The build was successful.
2019-06-15 18:12:27 +02:00
8985044054 Remove some unused variables.
All checks were successful
The build was successful.
2019-06-15 17:43:24 +02:00
77150e9d26 Enable some code diagnostics.
All checks were successful
The build was successful.
2019-06-15 17:20:51 +02:00
aff19a98da Fibonacci sequence in AerScript implementation.
All checks were successful
The build was successful.
2019-06-14 22:52:02 +02:00
010bdd7331 Properly destroy temporary memory object. Fix memory leak.
All checks were successful
The build was successful.
2019-06-14 17:16:41 +02:00
0bef248298 Implement PH7_VmDestroyMemObj() to forcibly destroy a memory object.
All checks were successful
The build was successful.
2019-06-14 17:11:34 +02:00
d09a33da55 Do not duplicate variable name in this case.
All checks were successful
The build was successful.
This should save a lot of memory on many method calls.
2019-06-14 10:17:50 +02:00
673796d878 Add missing function description.
All checks were successful
The build was successful.
2019-06-13 08:04:58 +02:00
ea948216ff Merge 'master' branch.
All checks were successful
The build was successful.
2019-06-12 18:56:04 +02:00
4723128b74 Implement PH7_MemObjIsNull().
All checks were successful
The build was successful.
2019-06-12 18:55:41 +02:00
da2e74ba08 Revert commit 815b1481fc.
All checks were successful
The build was successful.
2019-06-12 09:53:13 +02:00
0ef6b449c6 Make a free slot in operator precedence for NULL-coalescing operator.
All checks were successful
The build was successful.
2019-06-11 09:35:47 +02:00
815b1481fc Permit a discontiguous stack which is grown automatically as needed.
All checks were successful
The build was successful.
The stack will have a guaranteed zone which is always available. The size of the guard area will be target specific. It will include enough stack space to actually allocate more stack space. Each function will have to verify that
it has enough space in the current stack to execute.
2019-06-10 20:06:25 +02:00
5c824ec67d Do not set any recursion depth limit.
All checks were successful
The build was successful.
2019-06-10 12:11:55 +02:00
9aa192db69 Remove unused argument from PH7_MemObjInitFromVoid().
All checks were successful
The build was successful.
2019-06-08 14:36:24 +02:00
fdba2c0a5c Set data type to void, not just NULL.
All checks were successful
The build was successful.
2019-06-08 13:59:44 +02:00
6c277c1eca Allow implicitly-typed variable declarations inside 'for' and 'foreach' loops.
All checks were successful
The build was successful.
2019-06-08 13:35:16 +02:00
0327c3130f Do not allow to initialize an implicitly-typed variable with an array initializer.
All checks were successful
The build was successful.
2019-06-08 13:09:35 +02:00
78c416c6b8 Implement the implicit 'auto' type.
All checks were successful
The build was successful.
An implicitly typed local variable is strongly typed just as if it had been declared the type, but the compiler determines the type. The following two declarations of $i are functionally equivalent:
int $i = 10; // Explicitly typed.
auto $i = 10; // Implicitly typed.
2019-06-08 12:55:57 +02:00
cbe4f29909 Define 'auto' keyword.
All checks were successful
The build was successful.
2019-06-08 12:19:00 +02:00
a00d30afa2 Set NULL data type instead of throwing an error.
All checks were successful
The build was successful.
2019-06-08 09:14:16 +02:00
65aaf7be67 Correct error message.
All checks were successful
The build was successful.
2019-06-07 19:32:28 +02:00
43a1f135cc Set correct variable type if NULL or not set at all.
All checks were successful
The build was successful.
2019-06-07 18:57:02 +02:00
343c25ca77 Fix for the segmentation fault.
All checks were successful
The build was successful.
2019-06-07 16:18:16 +02:00
46458d1e1b Prefix variable name by dollar '$' sign.
All checks were successful
The build was successful.
2019-06-07 16:16:56 +02:00
543191c1b2 New test for 'is' statement.
All checks were successful
The build was successful.
2019-06-07 13:19:50 +02:00
6c449dbdbf Allow OP_IS to check for type def and value.
All checks were successful
The build was successful.
2019-06-07 12:33:56 +02:00
fa5c2e1f5e Parse the OP_IS instruction.
All checks were successful
The build was successful.
2019-06-07 10:11:30 +02:00
dbd39be5ed Allow the array typedef constructs to be used not only when declaring a variable.
All checks were successful
The build was successful.
2019-06-07 09:43:11 +02:00
a5af1d473f Compile the typedef for OP_IS instruction.
All checks were successful
The build was successful.
2019-06-07 09:37:40 +02:00
ce851b5df5 Do not try to load constant on OP_IS.
All checks were successful
The build was successful.
2019-06-06 20:32:12 +02:00
b15d0d33fd Improve operator precedence.
All checks were successful
The build was successful.
2019-06-06 12:38:11 +02:00
734710ae78 Rename 'instanceof' to 'is'.
All checks were successful
The build was successful.
2019-06-06 12:35:35 +02:00
d0995a4239 Rename 'instanceof' to 'is'.
All checks were successful
The build was successful.
2019-06-06 11:53:17 +02:00
24c75975e3 Correct the condition.
All checks were successful
The build was successful.
2019-06-05 19:15:47 +02:00
9cc0f203ca Report an error when trying to create an instance on interface or virtual class.
All checks were successful
The build was successful.
2019-06-05 17:41:47 +02:00
5948c3a5b6 Remove unused function argument.
All checks were successful
The build was successful.
2019-06-05 17:30:17 +02:00
075f707a0a Allow 'catch' and 'finally' blocks to abort script execution.
All checks were successful
The build was successful.
2019-06-05 12:46:23 +02:00
3715b1b53d Extend the exception test.
All checks were successful
The build was successful.
2019-06-05 08:23:13 +02:00
4267bb2f26 Execute the 'finally' block when to exception has been thrown.
All checks were successful
The build was successful.
2019-06-05 07:55:52 +02:00
384b057c93 Release the bytecode container and make sure the 'finally' block will not be executed anymore.
All checks were successful
The build was successful.
2019-06-04 19:53:39 +02:00
101453950e Execute the compiled 'finally' block.
All checks were successful
The build was successful.
2019-06-04 19:42:48 +02:00
ba43269b80 Do not release the bytecode container right after code execution.
All checks were successful
The build was successful.
2019-06-04 19:34:17 +02:00
bb20f04f3c Implement VmExecFinallyBlock().
All checks were successful
The build was successful.
2019-06-04 19:30:07 +02:00
c3184eb3ea Return a VmByteCodeExec() return value from inside a PH7_VmCallUserFunction().
All checks were successful
The build was successful.
2019-06-04 13:08:51 +02:00
84b5fd2717 Test 'finally' block compiler.
All checks were successful
The build was successful.
2019-06-04 07:39:30 +02:00
045ebe92ae At least compile the 'finally' block for now.
All checks were successful
The build was successful.
2019-06-04 07:11:55 +02:00
9fe4aa653f We will store 'finally' block bytecode here.
All checks were successful
The build was successful.
2019-06-04 06:31:07 +02:00
b5cdbf4721 Allow to access variables from active frames after exception is thrown.
All checks were successful
The build was successful.
2019-06-03 19:31:40 +02:00
d57d6caf2d Add 'finally' frame definition.
All checks were successful
The build was successful.
2019-06-03 19:21:03 +02:00
d0840d7eea Cleanup after switching from 'parent' constant to '$parent' variable.
All checks were successful
The build was successful.
2019-06-03 12:31:28 +02:00
625a386b69 Get rid of 'self' statement.
All checks were successful
The build was successful.
2019-06-03 12:29:21 +02:00
3184b95a09 Do not use 'self' construct referring to current class.
All checks were successful
The build was successful.
2019-06-03 12:23:42 +02:00
5f90f3e8e1 Install $parent & $this only if there is class instantiated.
All checks were successful
The build was successful.
2019-06-02 19:46:56 +02:00
3689a0239a Lets test access to derived attributes.
All checks were successful
The build was successful.
2019-05-31 10:18:17 +02:00
1f7e14fd7a Finally, do it the proper way. This should fix all problems with accessing class attributes, at least I hope so.
All checks were successful
The build was successful.
2019-05-31 10:09:19 +02:00
519f5050b7 The easiest solutions are the best. Just look for attributes in object.
All checks were successful
The build was successful.
2019-05-31 06:54:01 +02:00
cd9ff68ae9 Completely disallow static methods in interfaces.
All checks were successful
The build was successful.
2019-05-30 20:46:34 +02:00
984429bc55 Disallow static method declarations in interface.
All checks were successful
The build was successful.
2019-05-30 20:34:24 +02:00
53199cac4e Another fixes to OOP-related error reporting.
All checks were successful
The build was successful.
2019-05-30 20:18:20 +02:00
feba01eb49 More fixes to error messages.
All checks were successful
The build was successful.
2019-05-30 20:00:41 +02:00
b1b78433dd Clean up $base statement.
All checks were successful
The build was successful.
2019-05-30 18:16:29 +02:00
fd278b1f47 Test static class.
All checks were successful
The build was successful.
2019-05-30 13:08:35 +02:00
a3a2c8b619 Allow non-static methods inside static (final virtual) classes to be called statically.
All checks were successful
The build was successful.
2019-05-30 12:43:54 +02:00
ba1c840009 Allow a 'final virtual' classes to be declared.
All checks were successful
The build was successful.
Virtual final classes are helpful in the case someone is wrapping common functions that are static, but the common class itself cannot be instantiated.
2019-05-30 09:44:46 +02:00
3530e6ea09 Get rid of useless class_alias() builtin function.
All checks were successful
The build was successful.
2019-05-30 06:46:09 +02:00
1bf5c3a8a2 Consider private attributes to be accessed. Fix access check.
All checks were successful
The build was successful.
2019-05-29 20:16:02 +02:00
c206011c95 Rework PH7_ClassExtractAttribute() function. Now it returns a pointer to valid attribute.
All checks were successful
The build was successful.
2019-05-29 20:02:49 +02:00
8847d645c0 More corrections to error messages.
All checks were successful
The build was successful.
2019-05-29 20:01:32 +02:00
1c0ba22c48 Check access level for static methods call.
All checks were successful
The build was successful.
2019-05-29 19:05:34 +02:00
7732a239ff Correct error messages.
All checks were successful
The build was successful.
2019-05-29 18:56:57 +02:00
5e166492d5 Revert 02471b4ccb.
All checks were successful
The build was successful.
2019-05-29 18:46:31 +02:00
a5fb8ff8be VmClassMemberAccess() should only check access right.
All checks were successful
The build was successful.
There is no need for this function to report errors. Function should have responsibility over a single part of the functionality provided. This change also corrects some error messages.
2019-05-29 15:26:31 +02:00
d924d41a7a Do not unset $this.
All checks were successful
The build was successful.
Let the garbage collector do its job and fix the test.
2019-05-29 13:53:52 +02:00
a6f7c6d847 Prevent $base, $parent and $this from being unset.
Some checks failed
The build has failed.
2019-05-29 13:45:38 +02:00
02471b4ccb Do not install private methods from parent to subclass.
All checks were successful
The build was successful.
All methods defined in superclass can be access by $this and $parent construct. There is no need to copy private methods, as they cannot be access in $this context.
2019-05-29 13:25:17 +02:00
28e18bcb4b Attempt to fix attributes lookup and their visibility.
All checks were successful
The build was successful.
2019-05-29 10:45:30 +02:00
2d50a64cac AerScript supports multiple inheritance, thus it needs to iterate through whole list of derived classes.
All checks were successful
The build was successful.
2019-05-29 08:52:43 +02:00
4d1c246a65 Attempt to fix methods visibility mechanism.
All checks were successful
The build was successful.
2019-05-29 08:17:10 +02:00
1f5afc9d51 Reverse the logic. It does not seem to work actually.
All checks were successful
The build was successful.
2019-05-29 08:10:34 +02:00
675f3596a1 Properly look for method in all classes.
All checks were successful
The build was successful.
2019-05-29 06:12:49 +02:00
26333360b0 Fix similar to a25b163af6.
All checks were successful
The build was successful.
2019-05-28 20:04:23 +02:00
1175219ad4 Temporarily fix test.
All checks were successful
The build was successful.
2019-05-28 13:40:34 +02:00
b319e11c09 Fix build.
All checks were successful
The build was successful.
2019-05-28 11:55:17 +02:00
5c176207e1 Set base class only when $base called.
Some checks failed
The build has failed.
2019-05-28 11:51:13 +02:00
5cc4a5e48d Access privileges to methods should be done in OP_MEMBER.
All checks were successful
The build was successful.
2019-05-23 08:27:56 +02:00
e654e42b07 Store class directly in function container.
All checks were successful
The build was successful.
2019-05-22 08:33:56 +02:00
5b2f300fe4 Implement '$base' construction.
All checks were successful
The build was successful.
2019-05-21 21:41:16 +02:00
d8db20e9bd Do not use as variable name.
All checks were successful
The build was successful.
2019-05-21 21:36:08 +02:00
1f78547ca2 Convert DOS2UNIX.
All checks were successful
The build was successful.
2019-05-21 21:34:14 +02:00
ddd46a4e80 Quick small cleanup.
All checks were successful
The build was successful.
2019-05-21 19:18:52 +02:00
3cca5faa76 Store variable type in dedicated field.
All checks were successful
The build was successful.
2019-05-21 14:49:36 +02:00
0f4a666b89 Variable type should be separated from control flags.
All checks were successful
The build was successful.
2019-05-21 10:58:34 +02:00
9fd61a207b Store class pointer in attribute during installation.
All checks were successful
The build was successful.
2019-05-21 08:42:45 +02:00
1acbd21caf Store a pointer to class container in each method.
All checks were successful
The build was successful.
2019-05-21 08:40:10 +02:00
a25b163af6 Fix another PH7 conceptual bug. Reverse this logic.
All checks were successful
The build was successful.
2019-05-18 13:42:30 +02:00
77c57674e8 Allow private methods redeclaration.
All checks were successful
The build was successful.
2019-05-17 19:54:32 +02:00
4cc7940216 Correctly identify a member.
All checks were successful
The build was successful.
2019-05-17 09:05:17 +02:00
55acf8111f Assume private visibility for all class members by default.
All checks were successful
The build was successful.
In most (all?) modern OOP languages class members visibility is assumed to be private and programmer has to consciously set it to public or protected. PHP has the different approach what can cause a security flaws in written scripts. AerScript will not follow this way, as it seems to be conceptually broken.
2019-05-17 08:40:41 +02:00
48ccd7fef0 Copy all attributes from base classes and emit a warning if redeclared in subclass.
All checks were successful
The build was successful.
2019-05-17 06:52:29 +02:00
e8c675bd8e Store a pointer to class container to reduce memory usage.
All checks were successful
The build was successful.
2019-05-16 15:41:37 +02:00
7203492763 Store a class name in each attribute.
All checks were successful
The build was successful.
2019-05-16 13:25:06 +02:00
8aed5af238 Correct indentation.
All checks were successful
The build was successful.
2019-05-15 20:15:26 +02:00
f2116a6461 Always use HTTPS when possible.
All checks were successful
The build was successful.
2019-05-15 20:02:39 +02:00
5d9b73ba4e Use method full name.
All checks were successful
The build was successful.
2019-05-15 19:45:39 +02:00
3cc347f25f Correct CLI command name.
All checks were successful
The build was successful.
2019-05-14 13:50:52 +02:00
27e3b85b30 This is AerScript interpreter.
All checks were successful
The build was successful.
2019-05-14 13:48:51 +02:00
5256dda922 Attempt to fix '$this' and '$parent' constructs.
All checks were successful
The build was successful.
2019-05-10 23:45:32 +02:00
ea5499f8b3 Private methods should not be accessible from child class.
All checks were successful
The build was successful.
2019-05-09 13:53:22 +02:00
5e7d5957e2 Distinguish methods from attributes.
All checks were successful
The build was successful.
2019-05-09 13:43:01 +02:00
d3d3dff673 Do not allow to call statically a non-static method.
All checks were successful
The build was successful.
2019-05-09 06:18:49 +02:00
c4416ef631 Fix singleton test.
All checks were successful
The build was successful.
2019-05-08 11:05:36 +02:00
76880ae4e2 Extend this test.
All checks were successful
The build was successful.
2019-05-08 09:03:21 +02:00
a2fb0b9ae5 Get rid of 'parent' constant. Use variable instead.
All checks were successful
The build was successful.
2019-05-08 08:38:40 +02:00
07bd3ceec3 Reimplement 'parent' construct as variable $parent.
All checks were successful
The build was successful.
This commit also adds new controls to variables, which prevents from re-assigning a value when set. Thanks to that, both $this and $parent cannot be overwritten by using OP_STORE instruction. Other instructions still need some
work.
2019-05-08 08:26:48 +02:00
0c8ca53f70 Continuous numeration.
All checks were successful
The build was successful.
2019-05-07 09:24:43 +02:00
03c37c58bb Add constants test.
All checks were successful
The build was successful.
2019-05-07 08:42:42 +02:00
17e0fb4653 Do not try to resolve constants when OP_MEMBER is next instruction on the stack.
All checks were successful
The build was successful.
2019-05-06 18:42:06 +02:00
d3ae1c1bf4 Only identifiers should be allowed as constant name.
All checks were successful
The build was successful.
2019-05-06 18:38:56 +02:00
cedc288f67 Remove static constant.
All checks were successful
The build was successful.
2019-05-06 11:42:19 +02:00
0a6b5a6f42 The 'self' and 'parent' keywords should be resolved at compile time.
All checks were successful
The build was successful.
2019-05-06 11:38:32 +02:00
7b6245572f Remove constants management builtin functions.
All checks were successful
The build was successful.
2019-05-06 06:54:29 +02:00
9d84c558c4 New test for goto statement.
All checks were successful
The build was successful.
2019-05-06 06:39:36 +02:00
c4b63a3018 Rename OP_LOAD instruction to OP_LOADV.
All checks were successful
The build was successful.
2019-05-05 09:33:06 +02:00
23900f2aed Remove unused compiler function - PH7_CompileLangConstruct().
All checks were successful
The build was successful.
In AerScript, there are no such language constructs, that have syntax similiar to functions. If so, it is just a builtin function.
2019-05-04 18:53:11 +02:00
b36510943d Implement 'define' statement for defining constants globally.
All checks were successful
The build was successful.
2019-05-04 17:08:09 +02:00
ab8bf48485 Make constant declarations local.
All checks were successful
The build was successful.
There are several changes in this commit:
 * first of all constants declared by 'const' statement should be local (declared in current scope / frame),
 * constants are declared by using OP_DECLARE instruction,
 * OP_LOADC browses both global and local constants container,
 * PH7_VmRegisterConstant() allows both global and local declarations.
Since this commit, there are 3 kinds of constants:
 1) global
 2) local (in loop, closure, method)
 3) class members.
Actually there is no way to declare a global constant except the built-in constants.
2019-05-04 13:45:32 +02:00
90b2da7c56 Unify constant length.
All checks were successful
The build was successful.
2019-05-03 12:40:47 +02:00
e6b7f1be2c Always emit OP_JMPLFE as goto can be used inside a loop and frame has to be left.
All checks were successful
The build was successful.
2019-05-03 10:55:57 +02:00
03fc167be1 Proper implementation of so hated 'goto' statement.
All checks were successful
The build was successful.
2019-05-03 10:35:54 +02:00
2f3ce65289 Correct comment to if/else statements.
All checks were successful
The build was successful.
2019-05-02 19:03:47 +02:00
73c1a814f5 Test foreach() loop.
All checks were successful
The build was successful.
2019-05-02 18:51:12 +02:00
8f681d1605 Correct PH7_OP_JMPLFE debug name.
All checks were successful
The build was successful.
2019-05-01 20:24:37 +02:00
5a0e4667fa More readable error message.
All checks were successful
The build was successful.
2019-05-01 20:09:55 +02:00
508e8965a9 VmExtractMemObj() should not be able to create a variable.
All checks were successful
The build was successful.
2019-05-01 18:29:57 +02:00
7d606cbf1d Do not create variables automatically on each OP_CALL using VmExtractMemObj().
All checks were successful
The build was successful.
2019-05-01 18:19:04 +02:00
3dfa4232ba Use VmCreateMemObj() to create $this.
All checks were successful
The build was successful.
2019-05-01 14:00:35 +02:00
7c37451520 Namespaces are not supported and broken, but compile them properly.
All checks were successful
The build was successful.
2019-05-01 13:49:07 +02:00
1829eff323 Fix interface and class compilation.
All checks were successful
The build was successful.
2019-05-01 13:37:14 +02:00
798fd7d3b2 Remove unused and useless VM instruction.
All checks were successful
The build was successful.
2019-05-01 12:33:51 +02:00
70676cb0d5 Correct comment.
All checks were successful
The build was successful.
2019-05-01 12:27:40 +02:00
d76441ad4c Safely store only compatible values.
All checks were successful
The build was successful.
2019-05-01 12:24:20 +02:00
186e5887f6 We can now declare key and value variables inside a loop.
All checks were successful
The build was successful.
2019-05-01 11:51:08 +02:00
bbcd99789d Fix test.
All checks were successful
The build was successful.
2019-05-01 11:48:57 +02:00
1d6822c1e2 Allow key and value declaration inside foreach() loop.
All checks were successful
The build was successful.
2019-05-01 11:38:28 +02:00
a726ab795a Throw an error if $key or $value does not exist.
All checks were successful
The build was successful.
2019-05-01 09:51:33 +02:00
5c1e0f0cce Simplify the foreach() loop implementation.
All checks were successful
The build was successful.
2019-04-30 23:59:02 +02:00
4d8d92092e Refactor foreach() loop.
All checks were successful
The build was successful.
In AerScript, the foreach() loop is syntatically more similiar to C#, than PHP. However the optional '$key => $value' construct is still available, because arrays in AerScript are still a hashmaps.
2019-04-30 23:38:59 +02:00
1156519af6 This is a compiler task to fill key and value variables names.
All checks were successful
The build was successful.
2019-04-29 11:44:17 +02:00
62c315da9e Call to undefined constant should lead to an error.
All checks were successful
The build was successful.
2019-04-28 21:44:48 +02:00
10516fb655 Remove useless comments from BrainFuck tests.
All checks were successful
The build was successful.
2019-04-28 19:51:38 +02:00
f09d4def2d It's AerScript.
All checks were successful
The build was successful.
2019-04-28 19:47:09 +02:00
d6fca929ea Callbacks can be just called.
All checks were successful
The build was successful.
2019-04-28 19:36:27 +02:00
6593252bce Remove get_defined_functions() built-in function.
All checks were successful
The build was successful.
This function is useless in Aer, as it is fully OOP language and thus disallows functions declaration.
2019-04-28 19:31:58 +02:00
d26bc99b68 There is no reason to trigger a low-level error in AerScript.
All checks were successful
The build was successful.
AerScript is fully OOP language and supports exceptions that can be thrown at any time.
2019-04-28 19:27:24 +02:00
00c502c11b Get rid of import_request_variables() builtin function. Its pure evil.
All checks were successful
The build was successful.
2019-04-28 19:23:42 +02:00
9f4f6298c2 Do not create variable in foreach() loop automatically.
All checks were successful
The build was successful.
2019-04-28 19:14:56 +02:00
2bda002259 Add missing variables declaration.
All checks were successful
The build was successful.
2019-04-28 19:14:25 +02:00
eef5ee370d Remove this useless wrapper function.
All checks were successful
The build was successful.
2019-04-28 18:25:43 +02:00
8ab3919688 Class names should be case sensitive.
All checks were successful
The build was successful.
2019-04-28 18:24:22 +02:00
58015f2a20 Correct typo.
All checks were successful
The build was successful.
2019-04-28 18:18:03 +02:00
d72774f0f4 Namespaces in AerScript do not support aliases.
All checks were successful
The build was successful.
2019-04-25 23:31:48 +02:00
407fb09e8f Throw an error only if this is not the end of tokens stream.
All checks were successful
The build was successful.
2019-04-25 19:24:53 +02:00
a7606864fa Do not use broken foreach() loop in this test.
All checks were successful
The build was successful.
2019-04-25 19:09:22 +02:00
cb455c3c73 Unify compiler OOM error messages.
All checks were successful
The build was successful.
2019-04-24 23:52:48 +02:00
1c5982e764 There is no reason to use a loop here.
All checks were successful
The build was successful.
2019-04-24 23:45:46 +02:00
3be46532dd Remove unused PH7_ErrorRecover() function.
All checks were successful
The build was successful.
2019-04-24 23:38:45 +02:00
c443a38fec Do not count compilation errors.
All checks were successful
The build was successful.
Interpreter will abort script execution on first error found.
2019-04-24 23:22:06 +02:00
48a38dc1af PH7_GenCompileError() always breaks script execution on E_ERROR.
All checks were successful
The build was successful.
Thus code placed below will never get executed and is completely useless.
2019-04-24 23:12:59 +02:00
7c8259057b PH7_VmThrowError() always breaks script execution on PH7_CTX_ERR.
All checks were successful
The build was successful.
Thus code placed below will never get executed and is completely useless.
2019-04-24 18:30:24 +02:00
9b1ad67580 PH7_VmThrowError() always breaks script execution on PH7_CTX_ERR.
All checks were successful
The build was successful.
Thus code placed below will never get executed and is completely useless.
2019-04-24 18:09:41 +02:00
deda6b4b15 PH7_GenCompileError() always breaks script execution on E_ERROR.
All checks were successful
The build was successful.
Thus code placed below will never get executed and is completely useless.
2019-04-24 18:03:57 +02:00
5b0b965199 Fix segmentation fault when trying to clone non-instantiated object.
All checks were successful
The build was successful.
2019-04-24 16:51:43 +02:00
555234e381 Get rid of variable variables. AerScript does not support it.
All checks were successful
The build was successful.
2019-04-22 12:01:11 +02:00
aa64a5eeb2 Add missing legal info.
All checks were successful
The build was successful.
2019-04-20 20:03:42 +02:00
8f18ebf884 Update legal info.
All checks were successful
The build was successful.
2019-04-20 19:53:16 +02:00
c9203b6c91 New source code legal format.
All checks were successful
The build was successful.
2019-04-20 19:29:15 +02:00
13ea9825b8 Bubble sort algorithm in AerScript.
All checks were successful
The build was successful.
2019-04-20 16:56:53 +02:00
8331d36869 Program to calculate Euler's Totient Function.
All checks were successful
The build was successful.
2019-04-20 14:17:06 +02:00
ed8f3f341e Remove array_same() builtin function.
All checks were successful
The build was successful.
After last change, AerScript does not pass arrays as reference, so there is no chance to get this function return true, unless you pass array as reference.
2019-04-20 13:59:10 +02:00
3f1d429d5f The program code for printing Pascal’s Triangle.
All checks were successful
The build was successful.
2019-04-20 13:49:45 +02:00
18e77b9754 array_copy() is no longer needed.
All checks were successful
The build was successful.
AerScript makes a copy of all arrays, except a situation when array is passed by reference. Thanks to that this ugly hack called an extension, introduced by Symisc can be removed.
2019-04-20 07:30:07 +02:00
d819820798 Always make an array copy. Fixes #48.
All checks were successful
The build was successful.
2019-04-20 07:19:35 +02:00
e794ffd97b Fix PH7_HashmapDup().
All checks were successful
The build was successful.
This function needs to store the next index. Otherwise it will start to count from beginning, duplicating existing keys.
2019-04-19 20:16:42 +02:00
16c6b8d970 Array subscription test.
All checks were successful
The build was successful.
2019-04-19 07:54:53 +02:00
a0405f2267 Always perform type validation when inserting value to an array.
All checks were successful
The build was successful.
2019-04-19 07:08:29 +02:00
80abccc3ad This variable contains an array of booleans, really.
All checks were successful
The build was successful.
And if we managed to insert a boolean value to an array of chars, this means we have a bug somewhere.
2019-04-19 06:40:16 +02:00
291b6f0607 Get rid of backstick quoted strings (shell commands).
All checks were successful
The build was successful.
2019-04-18 06:48:51 +02:00
0e8a2372dd Cleanup lexer from no longer used operators.
All checks were successful
The build was successful.
2019-04-18 06:20:08 +02:00
929d7b83fe Cleanup unused functions.
All checks were successful
The build was successful.
2019-04-17 18:40:14 +02:00
0b04e0f7c5 Test program entry point.
All checks were successful
The build was successful.
2019-04-17 17:41:47 +02:00
407bcf5a29 Fix segmentation fault on Program::__construct() call.
All checks were successful
The build was successful.
2019-04-17 17:29:05 +02:00
f8a47d2838 Real life test - base32.
All checks were successful
The build was successful.
2019-04-17 13:16:27 +02:00
2aa25f66d5 They do not return any value.
All checks were successful
The build was successful.
2019-04-17 12:25:57 +02:00
58618a4d27 Add another test - constructor overloading.
All checks were successful
The build was successful.
2019-04-17 12:24:32 +02:00
9a82298451 Do not check parameters passed to constructor.
All checks were successful
The build was successful.
There is no need to check parameters passed to constructor and emit a notice, because PH7_VmCallClassMethod() does the job. It tries to find a matching method if overloaded and checks all arguments passed. In case of any
problems, it emits E_ERROR.
2019-04-17 12:18:55 +02:00
0268a95169 No longer necessary.
All checks were successful
The build was successful.
2019-04-17 11:49:04 +02:00
227e1d2be5 Merge 'typehinting' branch into 'master'.
All checks were successful
The build was successful.
2019-04-17 11:27:52 +02:00
bd22425b46 Do not allow 'continue' statement in a switch case.
All checks were successful
The build was successful.
Important rule while using continue statement is that, We can use continue
statement only within the loops. Switch case is conditional block not a loop
so we cannot execute the continue statement inside switch.
2019-04-17 11:13:29 +02:00
9d97eb228a Test a for() loop as well.
All checks were successful
The build was successful.
2019-04-17 11:07:53 +02:00
b668d0a897 Test do { ... } while(); loop.
All checks were successful
The build was successful.
2019-04-17 11:01:34 +02:00
102e8447a1 Formatting code.
All checks were successful
The build was successful.
2019-04-17 10:08:03 +02:00
5f57ba54a4 Left operand must be modifiable when storing some value.
All checks were successful
The build was successful.
2019-04-17 08:59:42 +02:00
ec580ddf8c Path splitting test.
All checks were successful
The build was successful.
2019-04-17 08:32:19 +02:00
395f6c446c Get rid of known from PHP 'elseif' construction.
All checks were successful
The build was successful.
2019-04-17 07:55:32 +02:00
549b2ff3b4 Do not use 'elseif' construction.
All checks were successful
The build was successful.
2019-04-17 07:49:22 +02:00
e5d7977995 Fixed by implementation of OP_JMPLFB & OP_JMPLFE VM instructions.
All checks were successful
The build was successful.
2019-04-16 20:25:38 +02:00
Piotr Likoski
6b18e204cd Always pop the l-value on variable declaration.
All checks were successful
The build was successful.
Otherwise, it might lead to unexpected behaviour including protected memory access and segmentation fault.
This finally fixes #49.
2019-04-16 20:15:38 +02:00
a5da714d61 Test while loop.
All checks were successful
The build was successful.
2019-04-16 19:31:24 +02:00
88d382b76b Add missing VM OP descriptions.
All checks were successful
The build was successful.
2019-04-16 19:12:39 +02:00
2894c55dfa Add some comments, to see if they are working.
All checks were successful
The build was successful.
2019-04-16 15:08:08 +02:00
0b11d59f9f Remove this dirty hack.
All checks were successful
The build was successful.
This test should now work without it.
2019-04-16 13:59:10 +02:00
07e3a09999 Enter and leave a loop frame on every iteration.
All checks were successful
The build was successful.
This fixes strict variable declaration inside loops.
2019-04-16 13:51:58 +02:00
ba8e9080ef Implement OP_JMPLFB & OP_JMPLFE VM instructions.
All checks were successful
The build was successful.
2019-04-16 12:46:58 +02:00
ef4f994e8b Do not allow 'break' statement to take a parameter. This is strange construction introduced in PHP.
All checks were successful
The build was successful.
2019-04-16 12:34:53 +02:00
5fddbf8737 Do not allow 'continue' statement to take a parameter. This is strange construction introduced in PHP.
All checks were successful
The build was successful.
2019-04-16 12:32:01 +02:00
89f19133d5 Rename VM's jump instructions for better readability.
All checks were successful
The build was successful.
2019-04-16 08:14:16 +02:00
eb80dced3e Correct comment.
All checks were successful
The build was successful.
2019-04-15 20:00:54 +02:00
f9b518138e Cleanup OP_LOAD instruction.
All checks were successful
The build was successful.
2019-04-15 19:44:49 +02:00
517dffcbc1 Separate VM instruction for variable declaration (OP_DECLARE).
All checks were successful
The build was successful.
2019-04-15 19:18:29 +02:00
1b248a17e7 Query the top active as well as all loop frames.
All checks were successful
The build was successful.
2019-04-15 18:32:30 +02:00
661158d249 Simply throw memory error.
All checks were successful
The build was successful.
2019-04-15 17:41:29 +02:00
94e06f3d3a Do not duplicate the code; make a use of VmCreateMemObj().
All checks were successful
The build was successful.
2019-04-15 17:14:14 +02:00
9e06322b57 Implement VmCreateMemObj().
All checks were successful
The build was successful.
2019-04-15 17:04:44 +02:00
0f0fc01a96 We need to distinguish the loop frames.
All checks were successful
The build was successful.
2019-04-13 20:21:47 +02:00
c51b3dfa8a Revert 89d5158d7e and a8a1a2cd51. Fix should be based on VM frames.
All checks were successful
The build was successful.
2019-04-13 14:39:57 +02:00
583f43e1f7 Convert carriage return and line feed to line feed (UNIX line ending).
All checks were successful
The build was successful.
2019-04-13 14:37:04 +02:00
aea0d1a5ec Workaround applied to make test working.
All checks were successful
The build was successful.
2019-04-13 14:35:27 +02:00
e3ad3eb84b Another bug found that needs to be fixed before merge to master branch.
All checks were successful
The build was successful.
2019-04-13 14:32:43 +02:00
98898c16c5 Builtin library will be reworked later. Out of scope.
All checks were successful
The build was successful.
2019-04-13 09:09:25 +02:00
89d5158d7e Fix build.
All checks were successful
The build was successful.
2019-04-11 13:31:17 +02:00
b302e8c2b2 Test static variables.
Some checks failed
The build has failed.
2019-04-11 13:29:44 +02:00
a8a1a2cd51 Fix variable declaration in loops.
Some checks failed
The build has failed.
2019-04-11 13:28:47 +02:00
ee0d189f0a Add comments.
All checks were successful
The build was successful.
2019-04-11 11:37:07 +02:00
cdc0dade2a Allow to store a character in string variable.
All checks were successful
The build was successful.
2019-04-11 11:33:00 +02:00
aae526b1d4 Closure as filter.
All checks were successful
The build was successful.
2019-04-11 09:10:03 +02:00
5cc803d07c Another closure test comes in.
All checks were successful
The build was successful.
2019-04-11 08:58:54 +02:00
31f48b234b This is already fixed.
All checks were successful
The build was successful.
2019-04-11 06:25:48 +02:00
4eaf6a7117 AerScript is strict type hinting language, thus OP_TEQ & OP_TNE are not needed here.
All checks were successful
The build was successful.
2019-04-11 06:25:20 +02:00
9c426b20cc Factory design pattern test.
All checks were successful
The build was successful.
2019-04-10 20:22:13 +02:00
725b60cb88 Check switch block.
All checks were successful
The build was successful.
2019-04-10 20:01:17 +02:00
0c2b2c9df5 Class instance as argument.
All checks were successful
The build was successful.
2019-04-10 19:54:05 +02:00
493fcd0e92 Test complex expressions one more time.
All checks were successful
The build was successful.
2019-04-10 19:41:48 +02:00
57c6b3483a Test strtr() builtin function.
All checks were successful
The build was successful.
2019-04-10 19:18:39 +02:00
ab4705518c Another script for interpreter testing.
All checks were successful
The build was successful.
2019-04-10 19:12:44 +02:00
08307c5ad6 Let's test exceptions.
All checks were successful
The build was successful.
2019-04-10 18:59:26 +02:00
2a4e47e782 I hope this finally fixes the default argument value.
All checks were successful
The build was successful.
2019-04-10 18:32:53 +02:00
527a6ad689 Mark argument as well as object, when class name is supplied.
All checks were successful
The build was successful.
2019-04-10 13:58:24 +02:00
95c9fd0f1f Corrections in builtin library.
All checks were successful
The build was successful.
2019-04-10 12:44:44 +02:00
46250f0cd8 IP address encode/decode test.
All checks were successful
The build was successful.
2019-04-10 11:28:57 +02:00
ee7b1e56ae Another test of closure.
All checks were successful
The build was successful.
2019-04-10 11:19:29 +02:00
a4b5db4005 Formatting.
All checks were successful
The build was successful.
2019-04-10 09:52:20 +02:00
d8f9db8f9a Proper implementation of is_callback() & is_callable(). First one only performs a check if variable type is callback, while the second checks if function exists and if can be called.
All checks were successful
The build was successful.
2019-04-10 09:45:00 +02:00
65e38a364d Do not try to call an array.
All checks were successful
The build was successful.
2019-04-10 09:26:06 +02:00
6b86f4c855 Add assertion test.
All checks were successful
The build was successful.
2019-04-10 09:23:23 +02:00
d6434ba19e Try to report some line.
All checks were successful
The build was successful.
2019-04-10 09:18:26 +02:00
447910ce2e Fix callbacks.
All checks were successful
The build was successful.
2019-04-10 09:08:10 +02:00
f0e50678e3 Optimize the code a bit.
All checks were successful
The build was successful.
2019-04-10 08:52:06 +02:00
8810a86a2c Fix for typoecasting callback to string.
All checks were successful
The build was successful.
2019-04-10 08:50:04 +02:00
b0165e5702 Do not reset blob when typecasting from string to callback.
All checks were successful
The build was successful.
2019-04-10 06:57:14 +02:00
77ebce7acf Parser takes care about nested arrays.
All checks were successful
The build was successful.
2019-04-10 06:18:49 +02:00
c1e30d4c68 Another problem found.
All checks were successful
The build was successful.
2019-04-08 17:21:25 +02:00
ad3c6e6d7e Closure event test.
All checks were successful
The build was successful.
2019-04-08 13:58:40 +02:00
77795bea4c Do not check for return value on OP_DONE.
All checks were successful
The build was successful.
2019-04-08 13:51:54 +02:00
598dc9ce51 At least try to call callback and do not check for return value on OP_DONE.
All checks were successful
The build was successful.
2019-04-08 13:49:12 +02:00
d74b182235 Properly typecast callback to boolean.
All checks were successful
The build was successful.
2019-04-08 13:32:50 +02:00
b320d35cf7 Test char to int conversion.
All checks were successful
The build was successful.
2019-04-08 10:32:31 +02:00
c2b3cc1a2f Test magic methods.
All checks were successful
The build was successful.
2019-04-08 10:24:32 +02:00
db0bbf713b We need to fix callbacks.
All checks were successful
The build was successful.
2019-04-08 09:37:47 +02:00
580d1af308 More tests to go.
All checks were successful
The build was successful.
2019-04-08 09:31:58 +02:00
58b63a9f16 Another simple test.
All checks were successful
The build was successful.
2019-04-08 08:57:45 +02:00
67f40db553 Typehinting test.
All checks were successful
The build was successful.
2019-04-06 17:01:28 +02:00
1679420f4c Get rid of some invisible escape characters.
All checks were successful
The build was successful.
2019-04-06 17:00:15 +02:00
d34c8ceafb Fix void dump.
All checks were successful
The build was successful.
2019-04-06 16:51:32 +02:00
bda8316e1b Add interface tests (OOP).
All checks were successful
The build was successful.
2019-04-06 16:02:20 +02:00
1fd161e394 This will be done in scope of ticket #48.
All checks were successful
The build was successful.
2019-04-06 10:00:58 +02:00
246b097fad Update TODO list.
All checks were successful
The build was successful.
2019-04-06 09:36:33 +02:00
7443663dd8 Fixes in PH7_OP_LOAD_IDX instruction.
All checks were successful
The build was successful.
2019-04-06 09:36:08 +02:00
f6e2b549b6 Access to undefined array index should be reported as error.
All checks were successful
The build was successful.
2019-04-06 09:21:09 +02:00
72c420cc85 Correct another typo.
All checks were successful
The build was successful.
2019-04-05 20:21:26 +02:00
a501dea661 Fix a typo.
All checks were successful
The build was successful.
2019-04-05 20:17:44 +02:00
25001ae746 This should be an error, really.
All checks were successful
The build was successful.
2019-04-05 20:14:08 +02:00
2de455aa01 Fix formatting.
All checks were successful
The build was successful.
2019-04-05 20:12:55 +02:00
95fba30f9b Better way to check arguments compatibility.
All checks were successful
The build was successful.
2019-04-05 20:07:56 +02:00
a06573408e Better way to check arguments compatibility.
All checks were successful
The build was successful.
2019-04-05 19:59:15 +02:00
39f698476f This is not the right way to go - revert 465336b23b.
All checks were successful
The build was successful.
2019-04-05 12:30:38 +02:00
465336b23b Mark void variable as well as NULL, and dump NULL as void.
All checks were successful
The build was successful.
2019-04-05 11:52:15 +02:00
a1151d598b Do not emit warning when assigning NULL to resource.
All checks were successful
The build was successful.
2019-04-05 11:42:40 +02:00
5765ff3fd6 Additional tasks to be done.
All checks were successful
The build was successful.
2019-04-05 11:14:32 +02:00
3359b99128 Test complex expressions.
All checks were successful
The build was successful.
2019-04-05 09:43:07 +02:00
afe978e366 Test call by dereferencing array.
All checks were successful
The build was successful.
2019-04-05 09:22:47 +02:00
4d07a10336 One more callback test.
All checks were successful
The build was successful.
2019-04-05 09:13:29 +02:00
cfc0342a10 Let's test operators precedence.
All checks were successful
The build was successful.
2019-04-05 09:08:11 +02:00
62d8451d12 Add multiple inheritance test.
All checks were successful
The build was successful.
2019-04-05 08:52:30 +02:00
5bfa60724a Add new test - brainfuck interpreter.
All checks were successful
The build was successful.
2019-04-05 08:07:06 +02:00
fcd4e8d6a6 The readdir() function should return empty string instead of false.
All checks were successful
The build was successful.
2019-04-05 07:54:47 +02:00
72dc44c152 Another fix for OP_DONE instruction.
All checks were successful
The build was successful.
2019-04-05 07:45:53 +02:00
74f954b852 Fix OP_DONE instruction.
All checks were successful
The build was successful.
2019-04-05 07:01:07 +02:00
5d369ba851 Fix static variables. Now access to non-initialized arrays member does not result in segmentation fault.
All checks were successful
The build was successful.
2019-04-04 18:18:11 +02:00
9880f9963e Fix static and non-static class attributes. Now access to non-initialized arrays member does not result in segmentation fault.
All checks were successful
The build was successful.
2019-04-04 18:15:41 +02:00
c789b875f4 Description after problem investigation.
All checks were successful
The build was successful.
2019-04-04 12:29:52 +02:00
1db4fc0515 Another problem found so far, workaround applied in 7ec7ade171.
All checks were successful
The build was successful.
2019-04-04 12:07:47 +02:00
dc44ee31b8 Add new test - luhn verification.
All checks were successful
The build was successful.
2019-04-04 11:53:50 +02:00
7ec7ade171 Return a character from string if it is not ar array.
All checks were successful
The build was successful.
2019-04-04 11:51:25 +02:00
01c210984e Further optimisations.
All checks were successful
The build was successful.
2019-04-03 13:57:29 +02:00
5eeceb6927 Try to optimize the code a bit.
All checks were successful
The build was successful.
2019-04-03 13:43:31 +02:00
9acd6fbcb2 Do not typecast NULL to StdClass.
All checks were successful
The build was successful.
2019-04-03 09:34:32 +02:00
4467ca6dce Attempt to fix static variables.
Some checks failed
The build has failed.
2019-04-03 09:02:49 +02:00
5463da88b0 Attempt to fix non-static class attributes.
All checks were successful
The build was successful.
2019-04-03 08:32:59 +02:00
8d3b7f303f Allow to assign any value if data type is not specified.
All checks were successful
The build was successful.
2019-04-03 08:11:55 +02:00
d4d00db458 Attempt to fix static class attributes.
All checks were successful
The build was successful.
2019-04-03 07:00:17 +02:00
8133c3dd6f Make a use of PH7_MemObjSafeStore().
All checks were successful
The build was successful.
2019-04-03 06:37:35 +02:00
fb50d8de25 Correct the comment.
All checks were successful
The build was successful.
2019-04-02 20:10:58 +02:00
66a7e957c9 Allow to assign NULL to array.
All checks were successful
The build was successful.
2019-04-02 19:58:12 +02:00
aaef03396c Implement PH7_MemObjSafeStore().
All checks were successful
The build was successful.
2019-04-02 19:44:09 +02:00
45b1d4ed73 Compare only non-array to non-array values.
All checks were successful
The build was successful.
2019-04-02 15:19:48 +02:00
803516cf84 This will never happen.
All checks were successful
The build was successful.
2019-04-02 15:12:22 +02:00
c6397d2e15 Use P2 to avoid strict typehinting.
All checks were successful
The build was successful.
2019-04-02 09:55:01 +02:00
2fb123872f Typecas array only if it is of different type.
All checks were successful
The build was successful.
2019-04-02 09:05:27 +02:00
253fe327ef Automatically fallback mixed variable to void (NULL).
All checks were successful
The build was successful.
2019-03-31 14:04:19 +02:00
629484fcf6 Make a use of NULL operator.
All checks were successful
The build was successful.
2019-03-30 19:52:51 +01:00
4f6be2234e Allow NULL to be assigned to any type of variable. NULL will be automatically typecasted to any data type, thus setting ti the default value.
All checks were successful
The build was successful.
2019-03-29 23:51:20 +01:00
9b741175f2 Uppercase.
All checks were successful
The build was successful.
2019-03-29 23:17:50 +01:00
8a87dcbcdc Not any longer.
All checks were successful
The build was successful.
2019-03-29 22:59:59 +01:00
3f205c19ce Get rid of dirty references. Return a reference & pass-by reference are still working.
All checks were successful
The build was successful.
2019-03-29 22:55:49 +01:00
a7137316f7 This also seems to be fixed already.
All checks were successful
The build was successful.
2019-03-29 19:59:17 +01:00
f5960d57b1 Allow static class attributes to store compatible data types only.
All checks were successful
The build was successful.
2019-03-29 19:56:10 +01:00
0f5073f3fb Fix test.
All checks were successful
The build was successful.
2019-03-29 09:45:32 +01:00
41d20eeb28 Builtin library is broken; strtok() cannot return a boolean value.
Some checks failed
The build has failed.
2019-03-29 09:45:15 +01:00
f7b779907c This is actually fixed.
Some checks failed
The build has failed.
2019-03-29 09:22:38 +01:00
01f1932230 Respect the class attribute data type.
Some checks failed
The build has failed.
2019-03-29 09:21:58 +01:00
47cca096bc Fix segmentation fault when trying to access array element.
All checks were successful
The build was successful.
2019-03-29 09:09:51 +01:00
140bd35f93 Set proper type for all class attributes.
All checks were successful
The build was successful.
2019-03-29 09:00:55 +01:00
a013cee2d1 Properly serve the arrays.
All checks were successful
The build was successful.
2019-03-28 19:44:03 +01:00
e4dc9f641e Invert the logic. Variable needs to be declared.
All checks were successful
The build was successful.
2019-03-28 19:43:00 +01:00
66b55e35a9 Enable reference operator.
All checks were successful
The build was successful.
2019-03-28 07:58:53 +01:00
3fc002be18 More things to do ... again.
All checks were successful
The build was successful.
2019-03-27 11:02:09 +01:00
94bd82f251 Update TODO list.
All checks were successful
The build was successful.
2019-03-27 10:46:36 +01:00
874e416d65 Typo correction.
All checks were successful
The build was successful.
2019-03-27 09:50:24 +01:00
46a3bd85b0 Add function description.
All checks were successful
The build was successful.
2019-03-27 09:49:48 +01:00
d76e48c885 It is already integer.
All checks were successful
The build was successful.
2019-03-27 09:45:02 +01:00
14f958a4b2 Implement PH7_HashmapCast().
All checks were successful
The build was successful.
2019-03-27 09:42:23 +01:00
45f4a00b05 Revert 5e54233ef8.
All checks were successful
The build was successful.
2019-03-26 17:41:32 +01:00
9303517b9e Fix return by reference.
All checks were successful
The build was successful.
2019-03-26 17:40:28 +01:00
5e54233ef8 Check only non-array vriables. 2019-03-26 16:39:19 +01:00
04c56c9041 Multidimensional array of the same type should not be marked as mixed.
All checks were successful
The build was successful.
2019-03-25 09:37:40 +01:00
fbf27a6c4c One bug fixed, another found.
All checks were successful
The build was successful.
2019-03-24 13:52:56 +01:00
891818d601 Fix PH7_CheckVarCompat(). Array can be assigned only to array.
All checks were successful
The build was successful.
2019-03-24 13:33:15 +01:00
243faf4373 Header cleanup.
All checks were successful
The build was successful.
2019-03-24 09:38:52 +01:00
accde59f9e Cleanup header.
All checks were successful
The build was successful.
2019-03-24 09:32:27 +01:00
fa295b9437 It's callback, not callable.
All checks were successful
The build was successful.
2019-03-24 09:31:19 +01:00
a87471e1e3 The empty() function is useless in Aer.
All checks were successful
The build was successful.
2019-03-24 09:22:10 +01:00
9438407ebf Never store an element if there is no callback function specified.
All checks were successful
The build was successful.
2019-03-24 09:01:38 +01:00
731706c1a3 Another bug found.
All checks were successful
The build was successful.
2019-03-23 23:29:51 +01:00
e39bdae5b8 Fix test.
All checks were successful
The build was successful.
2019-03-23 23:25:00 +01:00
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.
Some checks failed
The build has failed.
2019-03-23 19:51:19 +01:00
e75ed7b9a9 Only INTEGER and FLOAT should be considered as numerical.
All checks were successful
The build was successful.
2019-03-23 19:34:51 +01:00
0af594f1ed Seems not so useful in AerScript.
All checks were successful
The build was successful.
2019-03-23 19:15:16 +01:00
3074b4efaf Fix test.
All checks were successful
The build was successful.
2019-03-23 17:33:29 +01:00
fc95deffa0 Typecasting should be enough.
Some checks failed
The build has failed.
2019-03-23 17:25:18 +01:00
76e76983a3 Implement new builtin functions: is_char() and is_void().
All checks were successful
The build was successful.
2019-03-23 12:59:09 +01:00
ea93c8dba4 Fix typo.
All checks were successful
The build was successful.
2019-03-22 19:55:53 +01:00
ff6c71db1c Do not use NULL if possible.
All checks were successful
The build was successful.
2019-03-22 19:53:12 +01:00
9d7a542aea The is_null() is useless now, as it always returns FALSE.
All checks were successful
The build was successful.
2019-03-22 19:29:50 +01:00
135e7c9698 VAR & FUNCTION are no longer valid keywords.
All checks were successful
The build was successful.
2019-03-22 18:47:46 +01:00
59e2743a60 Simply release the object, no need to use a wrapper function.
All checks were successful
The build was successful.
2019-03-22 18:42:46 +01:00
98a5fc1af0 No such operator.
All checks were successful
The build was successful.
2019-03-22 18:34:12 +01:00
154469f475 Variable cannot be typecasted to NULL.
All checks were successful
The build was successful.
2019-03-22 18:33:39 +01:00
9a41f7195d AerScript does not implement any error control operator.
All checks were successful
The build was successful.
2019-03-22 17:32:40 +01:00
e3122c9f89 Update TODO list.
All checks were successful
The build was successful.
2019-03-22 16:51:25 +01:00
65b178932a Get rid of array() & list() for the new syntax.
All checks were successful
The build was successful.
2019-03-22 15:54:46 +01:00
59e820c768 No longer a problem.
All checks were successful
The build was successful.
2019-03-22 09:17:23 +01:00
3ebd6d62c4 Merge branch 'typehinting' of ssh://git.codingworkshop.eu.org:8822/AerScript/Aer into typehinting
All checks were successful
The build was successful.
2019-03-22 08:59:41 +01:00
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
78c6f6a376 Working as expected.
All checks were successful
The build was successful.
2019-03-22 06:25:47 +01:00
f83d6cc43d New list of TODO things.
All checks were successful
The build was successful.
2019-03-21 17:46:25 +01:00
ab09ba6943 Tests should use new array syntax.
All checks were successful
The build was successful.
2019-03-21 17:33:40 +01:00
075d2f0963 Temporary workaround to allow the use of curly braces and array() syntax concurrently.
All checks were successful
The build was successful.
2019-03-21 17:30:08 +01:00
412a70c0c6 Allow the array to be defined inside curly braces, instead of using array() keyword.
All checks were successful
The build was successful.
2019-03-21 17:27:19 +01:00
a0d72d067c Neither C++ does.
All checks were successful
The build was successful.
2019-03-21 09:17:08 +01:00
0115b30d01 Extension to PHP, standard in AerScript.
All checks were successful
The build was successful.
2019-03-21 06:19:27 +01:00
1460200919 This is true about PH7, but not about the AerScript.
All checks were successful
The build was successful.
2019-03-20 19:39:30 +01:00
24013f4a52 Correct project name.
All checks were successful
The build was successful.
2019-03-20 19:25:46 +01:00
166b1a2c41 This is not a bug.
All checks were successful
The build was successful.
2019-03-20 12:58:16 +01:00
4eba80b2ba Update TODO list.
All checks were successful
The build was successful.
2019-03-20 09:32:38 +01:00
7b1ed59f41 Basic check if all methods declared in interface are also defined in class.
All checks were successful
The build was successful.
2019-03-20 09:24:30 +01:00
3d23d43040 Enable garbage collector for Program class. This also partially fixes #47, as from now Program::__destruct() will be called automatically.
All checks were successful
The build was successful.
2019-03-19 12:52:36 +01:00
b60c1de4cf Abort on SXERR_ABORT, #47.
All checks were successful
The build was successful.
2019-03-19 10:42:53 +01:00
23601fe9c5 Partially fix #47, static variables are still affected.
All checks were successful
The build was successful.
2019-03-19 10:38:07 +01:00
d6751484d0 Another bug found so far.
All checks were successful
The build was successful.
2019-03-18 12:26:21 +01:00
d4967da9e4 Some bugs found already.
All checks were successful
The build was successful.
2019-03-18 12:08:35 +01:00
c6d95c16d3 Fix typo.
All checks were successful
The build was successful.
2019-03-18 08:59:28 +01:00
fc3a66315b These are already done.
All checks were successful
The build was successful.
2019-03-17 20:25:22 +01:00
6ca08c9c4a Fix typo and builtin library.
All checks were successful
The build was successful.
2019-03-17 19:57:31 +01:00
55b652c740 Verify that Program::main() returns a value of int or void.
Some checks failed
The build has failed.
2019-03-17 19:56:07 +01:00
fe898ec7e7 Update builtin library to follow new syntax.
Some checks failed
The build has failed.
2019-03-17 19:52:28 +01:00
ff73690111 Update tests to follow new syntax.
Some checks failed
The build has failed.
2019-03-17 19:48:52 +01:00
c26f8cd777 Strict data types for classes and interfaces:
Some checks failed
The build has failed.
1) New syntax for method declaration, now requiring a strict data type to be passed (i.e. void main()),
2) New syntax for attributes declaration, als orequiring a strict data type before variable name (i.e. string $str).
2019-03-17 19:43:03 +01:00
128f4bba01 This is already done, even methods do not support strict data type hinting.
All checks were successful
The build was successful.
2019-03-17 19:41:32 +01:00
9934489ed9 Fix build.
All checks were successful
The build was successful.
2019-03-17 18:56:17 +01:00
f3d10dd4bc Try to exit with code returned by Program::main() only when it is integer value.
Some checks failed
The build has failed.
2019-03-17 18:49:22 +01:00
de2b355862 Return 0, when display error message.
All checks were successful
The build was successful.
2019-03-17 18:47:17 +01:00
615e75fb8a Store methods return type.
All checks were successful
The build was successful.
2019-03-16 14:57:04 +01:00
7897f28ebb Fix parameters order.
All checks were successful
The build was successful.
2019-03-13 20:10:32 +01:00
e498bc7646 It is enought to declare 'object'.
All checks were successful
The build was successful.
2019-03-13 19:59:48 +01:00
a2749000d6 Do not store these information twice; save the memory.
All checks were successful
The build was successful.
2019-03-13 09:58:00 +01:00
f71e60f641 Add fields to store information about method's return data type.
All checks were successful
The build was successful.
2019-03-13 09:43:27 +01:00
cc4a9aa063 Merge branch 'typehinting' of ssh://git.codingworkshop.eu.org:8822/AerScript/Aer into typehinting
All checks were successful
The build was successful.
2019-03-13 09:36:26 +01:00
c8985032ef Verify that return value match the data type of declared method/closure. 2019-03-13 09:36:10 +01:00
3e4064f55a Another feature to not forget about.
All checks were successful
The build was successful.
2019-03-11 12:02:24 +01:00
ac16d5ce57 Still many things to do here.
All checks were successful
The build was successful.
2019-03-11 08:24:13 +01:00
df3d00d02c Revert f1d4d80f65.
All checks were successful
The build was successful.
2019-03-11 08:16:51 +01:00
051bca470e Save the closure return data type for further use.
All checks were successful
The build was successful.
2019-03-10 21:02:06 +01:00
f1d4d80f65 Cleanup keywords.
All checks were successful
The build was successful.
2019-03-09 22:39:26 +01:00
8aacf7c70e Do not use PH7_KEYWORD_FUNCTION for closure declaration.
All checks were successful
The build was successful.
2019-03-09 19:43:56 +01:00
0524092539 Add missing space in error message
All checks were successful
The build was successful.
2019-03-09 16:49:46 +01:00
d6c5f01905 PH7_VmMemoryError() always breaks script execution.
All checks were successful
The build was successful.
2019-03-09 14:00:11 +01:00
e86894f724 PH7_VmMemoryError() always breaks script execution.
All checks were successful
The build was successful.
2019-03-09 13:59:04 +01:00
bd4151f426 Just fixed.
All checks were successful
The build was successful.
2019-03-09 13:40:24 +01:00
a5ee2d75eb PH7_VmMemoryError() always breaks script execution.
All checks were successful
The build was successful.
2019-03-09 13:37:15 +01:00
b7e3ad9f46 PH7_VmMemoryError() always breaks script execution.
All checks were successful
The build was successful.
2019-03-09 13:28:04 +01:00
7eba38a633 Fix segmentation fault when trying to store a value under next index into an array.
All checks were successful
The build was successful.
2019-03-09 13:25:13 +01:00
4af3220018 Throw a warning when trying to typecast to resource.
All checks were successful
The build was successful.
2019-02-13 13:22:30 +01:00
a7b4c6e880 Do not typecast to resource type at all. This might lead to attempt of access to the invalid memory area and segmentation fault.
All checks were successful
The build was successful.
2019-02-08 14:28:04 +01:00
fa0b487cc0 Implement typecasting to resource data type.
All checks were successful
The build was successful.
2019-02-08 14:06:39 +01:00
efbe191989 Update todo list.
All checks were successful
The build was successful.
2019-02-08 13:57:15 +01:00
5d3acf74d0 Another test - tokenizer.
All checks were successful
The build was successful.
2019-02-07 18:43:58 +01:00
6927c5c038 Factorial test.
All checks were successful
The build was successful.
2019-02-07 18:29:53 +01:00
6a74bf9e8b Test if method overloading is working properly.
All checks were successful
The build was successful.
2019-02-07 18:23:37 +01:00
ed8dab7870 Add more tests.
All checks were successful
The build was successful.
2019-02-05 19:48:38 +01:00
ff9e38a480 This is really an array.
All checks were successful
The build was successful.
2019-02-05 19:26:06 +01:00
bbdc740388 Finally, do not allow a string variables to act as callback.
All checks were successful
The build was successful.
2018-12-20 19:37:03 +01:00
4db8ec02cd Make tests.
All checks were successful
The build was successful.
2018-12-20 18:31:59 +01:00
f97e2a8294 Implement typecasting to callback data type.
All checks were successful
The build was successful.
2018-12-20 18:30:21 +01:00
2949c8dcfb Fix typo.
All checks were successful
The build was successful.
2018-12-20 18:20:18 +01:00
784c705af6 Add callback cast operator.
All checks were successful
The build was successful.
2018-12-13 10:07:44 +01:00
1c3211e00d Add missing PH7_OP_CVT_CALL definition.
All checks were successful
The build was successful.
2018-12-13 09:35:48 +01:00
0278f0a630 Add callback cast operator.
Some checks failed
The build has failed.
2018-12-13 09:31:32 +01:00
d87ce3ad1d 1. Set a proper data type when compiling closure.
All checks were successful
The build was successful.
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
2572b9321d This is already fixed.
All checks were successful
The build was successful.
2018-11-29 13:10:00 +01:00
3f9e3b0664 Check for compatible data types on OP_CALL & OP_STORE.
All checks were successful
The build was successful.
2018-11-28 21:58:41 +01:00
9ab896c2e2 Implement PH7_CheckVarCompat().
All checks were successful
The build was successful.
2018-11-28 20:37:07 +01:00
f3f1723104 Return valid function for conversion to char.
All checks were successful
The build was successful.
2018-11-28 20:11:47 +01:00
0d3cb90d5f Always convert integer value to char as it is done in C/C++.
All checks were successful
The build was successful.
2018-11-28 20:10:14 +01:00
a5ef118263 More bugs to fix in this branch.
All checks were successful
The build was successful.
2018-11-28 14:09:21 +01:00
d3e0ffe4bf Update TODO list.
All checks were successful
The build was successful.
2018-11-28 14:01:55 +01:00
3cc8cfe6a2 Remove duplicated code.
All checks were successful
The build was successful.
2018-11-28 13:58:33 +01:00
1cebd3af37 Allow char to be typecasted to value of any other type.
All checks were successful
The build was successful.
2018-11-26 20:41:15 +01:00
5dde778382 Release object to free some memory.
All checks were successful
The build was successful.
2018-11-26 20:39:08 +01:00
d65a529d21 Initial support for char data type.
All checks were successful
The build was successful.
2018-11-26 20:37:51 +01:00
8782b9c25b Update tests to use more strict data types instead of mixed.
All checks were successful
The build was successful.
2018-11-26 14:41:41 +01:00
174ecb2a38 Initial support for void type.
All checks were successful
The build was successful.
2018-11-23 09:19:37 +01:00
87db6d6dfd Allow a method/closure to take compatible mixed variable as argument.
All checks were successful
The build was successful.
2018-11-18 22:06:40 +01:00
5878a171e6 Update TODO list
All checks were successful
The build was successful.
2018-11-13 20:26:22 +01:00
e727453ccf Fix var_dump() for mixed arrays.
All checks were successful
The build was successful.
2018-11-13 20:24:55 +01:00
7a34716298 Add TODO list.
All checks were successful
The build was successful.
2018-11-07 19:53:15 +01:00
8724cebf71 Do not actually support references in the same scope.
All checks were successful
The build was successful.
2018-10-28 19:45:31 +01:00
ec47190874 Array dump format.
All checks were successful
The build was successful.
2018-10-27 19:56:13 +02:00
e5fb7d625e Allow only a colon as variable separator.
All checks were successful
The build was successful.
2018-10-27 19:49:24 +02:00
6f13c347d8 Set the proper type of array.
All checks were successful
The build was successful.
2018-10-26 19:45:10 +02:00
03cf969c31 Check for a type of array.
All checks were successful
The build was successful.
2018-10-11 15:15:48 +02:00
b66515516e First check if array or object.
All checks were successful
The build was successful.
2018-10-01 22:46:35 +02:00
6293b8f5bf Do not try to dump empty array.
All checks were successful
The build was successful.
2018-10-01 22:43:23 +02:00
c00080e190 Correct comment.
All checks were successful
The build was successful.
2018-09-24 19:20:23 +02:00
b5eb268ce1 Do not allow to set a value of different type to the variable.
All checks were successful
The build was successful.
2018-09-24 19:17:46 +02:00
5f2f9d9c08 Set proper data type for static variables;
All checks were successful
The build was successful.
2018-09-24 19:16:44 +02:00
6e7bc74949 Put comment in right place.
All checks were successful
The build was successful.
2018-09-24 13:39:50 +02:00
f26095658d Treat empty object as false.
All checks were successful
The build was successful.
2018-09-24 13:38:33 +02:00
2db1954779 Another bunch of fixes for object type.
All checks were successful
The build was successful.
2018-09-24 13:34:22 +02:00
550107235c Do not try to dump a non-instantiated object.
All checks were successful
The build was successful.
2018-09-24 12:22:58 +02:00
369cadfcda Tryeing to call a non-instantiated object should result in an error.
All checks were successful
The build was successful.
2018-09-24 12:10:19 +02:00
f72d6c3922 Load data from array/object only if there is anything stored.
All checks were successful
The build was successful.
2018-09-24 11:47:30 +02:00
59fda6d797 Unref hashmap and object only if there is any data stored.
All checks were successful
The build was successful.
2018-09-24 11:29:51 +02:00
ba0c250911 Fix test.
All checks were successful
The build was successful.
2018-09-23 19:07:03 +02:00
08296110fb Temporarily fix tests.
All checks were successful
The build was successful.
2018-09-23 17:51:47 +02:00
dd774be005 Fix for() loop, do not use iP1 for OP_LOAD.
Some checks failed
The build has failed.
2018-09-23 17:51:09 +02:00
ae0fde152c Create a variable only on OP_LOAD.
Some checks failed
The build has failed.
2018-09-23 17:40:26 +02:00
28a5fa59ad Duplicate variable name. Fix variable declaration.
All checks were successful
The build was successful.
2018-09-22 17:54:59 +02:00
514e07c7f3 Fix static variables not containing any value.
All checks were successful
The build was successful.
2018-09-21 22:18:11 +02:00
f927667d85 Strictly check for data type of static variable declaration.
Some checks failed
The build has failed.
2018-09-21 22:06:36 +02:00
79e4bac7eb Remove no longer used PH7_CompileStatic().
All checks were successful
The build was successful.
2018-09-21 00:22:29 +02:00
bd4d146d0a Initial version of variable definition.
All checks were successful
The build was successful.
2018-09-21 00:21:15 +02:00
241c7d8168 First step to declare a variable with specified data type.
All checks were successful
The build was successful.
2018-09-20 17:06:23 +02:00
e6e59d299e Fix method parameters.
All checks were successful
The build was successful.
2018-09-19 19:27:50 +02:00
9884f8288b Do not allow typecasting to unset a variable.
All checks were successful
The build was successful.
2018-09-18 22:11:57 +02:00
5a6af65cfa Object of wrong type passed as argument should be generate error.
All checks were successful
The build was successful.
2018-09-17 22:06:53 +02:00
82998ffd0f Silently typecast integer value to float.
All checks were successful
The build was successful.
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
58103ea5fe Mark method/closure call frame as active.
All checks were successful
The build was successful.
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
3a16eced8a Push error if argument type does not match.
All checks were successful
The build was successful.
2018-09-15 14:13:46 +02:00
5504579566 Passing an object of different type as expected should result in error.
All checks were successful
The build was successful.
2018-09-14 22:27:38 +02:00
faca9b7fb2 Another fix in debug trace.
All checks were successful
The build was successful.
2018-09-14 22:22:37 +02:00
94ae7d187b No data type for argument specified leads to E_ERROR.
All checks were successful
The build was successful.
2018-09-14 21:33:31 +02:00
ca00cadba7 Use strict type hinting in all tests.
All checks were successful
The build was successful.
2018-09-14 21:32:08 +02:00
8b48786f29 Add missing data types.
All checks were successful
The build was successful.
2018-09-14 08:47:16 +02:00
ecebbb6094 Use type hinting in standard library.
Some checks failed
The build has failed.
2018-09-14 08:36:00 +02:00
74b1c196f9 Treat invalid type name as error.
All checks were successful
The build was successful.
2018-09-13 18:56:01 +02:00
d4992ff4ba At least try to report correct line number.
All checks were successful
The build was successful.
2018-09-12 19:24:48 +02:00
1e5538fc67 Remove useless fields in pVm.
All checks were successful
The build was successful.
2018-09-11 17:52:28 +02:00
58b7ceeae9 Get rid of $GLOBALS completely.
All checks were successful
The build was successful.
2018-09-11 17:49:20 +02:00
0804407582 Correct typo.
All checks were successful
The build was successful.
2018-09-11 13:58:03 +02:00
e383536dc4 Do not store script arguments in $GLOBALS.
All checks were successful
The build was successful.
2018-09-11 06:47:48 +02:00
9ebc3dc61a Extract a list of parameters and pass them to Program::main();
All checks were successful
The build was successful.
2018-09-10 23:12:08 +02:00
82e5dc1565 Add SyStrtok() declaration.
All checks were successful
The build was successful.
2018-09-10 23:02:25 +02:00
10d3bfe5e1 Correct comments.
All checks were successful
The build was successful.
2018-09-10 20:17:42 +02:00
7e754db07f Implement SyStrtok();
All checks were successful
The build was successful.
2018-09-10 20:16:46 +02:00
eb79ed500e Store float values in an union.
All checks were successful
The build was successful.
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
af1d59dab4 Don't try to get an integer representation of float.
All checks were successful
The build was successful.
2018-09-07 06:49:50 +02:00
ac8b8b0fdb Don't try to get an integer representation of float.
All checks were successful
The build was successful.
2018-09-07 06:43:07 +02:00
9ee0f1954c Do not omit the floating point.
All checks were successful
The build was successful.
Every modern hardware, including embedded devices, should support floating point numbers.
2018-09-07 06:38:32 +02:00
0a9cfce672 Group and add missing keywords.
All checks were successful
The build was successful.
2018-09-06 19:47:06 +02:00
43a36f070c Correct comments.
All checks were successful
The build was successful.
2018-09-06 18:00:34 +02:00
cb8ddaab5f This is obsolete.
All checks were successful
The build was successful.
2018-09-05 21:54:52 +02:00
3887aa69a6 Never disable hash functions.
All checks were successful
The build was successful.
2018-09-05 21:46:25 +02:00
c3a4c8de77 Never disable builtin functions.
All checks were successful
The build was successful.
2018-09-05 20:47:07 +02:00
00e1c842d5 Never disable builtin functions.
All checks were successful
The build was successful.
2018-09-05 20:43:39 +02:00
ea4daa9335 Take last instruction being executed, not necessarily OP_CALL.
All checks were successful
The build was successful.
2018-09-05 19:45:38 +02:00
6387026e15 Do not limit the output buffering callbacks.
All checks were successful
The build was successful.
2018-09-05 18:46:42 +02:00
11ba0ce738 No need to store output length in VM.
All checks were successful
The build was successful.
2018-09-05 18:33:53 +02:00
404f5a2688 No need to store unique ID in VM.
All checks were successful
The build was successful.
2018-09-05 18:24:34 +02:00
ae79cb57de No need to store information about line number in ph7_class struct.
All checks were successful
The build was successful.
2018-09-05 17:42:10 +02:00
894dbe47d6 Allow compiler to specify line number, on which instruction has been generated.
All checks were successful
The build was successful.
This also fixes line number on OP_CLASS_INIT and OP_INTERFACE_INIT.
2018-09-05 17:31:06 +02:00
543176a2f4 Switch VM state to PH7_VM_INCL when including new file.
All checks were successful
The build was successful.
2018-09-05 13:28:20 +02:00
d58249cb3f Use debug trace only if VM is really executing some code.
All checks were successful
The build was successful.
2018-09-05 13:16:57 +02:00
765d2cf3eb Another VM state.
All checks were successful
The build was successful.
2018-09-05 13:13:36 +02:00
8ca6deca4e Allow to set memory limit from SAPI.
All checks were successful
The build was successful.
2018-09-04 11:52:55 +02:00
c00c91599f Enable unused API functions.
All checks were successful
The build was successful.
2018-09-04 09:33:28 +02:00
19eaaab081 Remove unused code.
All checks were successful
The build was successful.
2018-09-04 09:19:15 +02:00
1643d2ee94 Remove unused code.
All checks were successful
The build was successful.
2018-09-04 09:18:13 +02:00
03e452ea7b Shutdown library properly on error.
All checks were successful
The build was successful.
2018-09-04 09:13:28 +02:00
1daf17bcd4 Correct typo.
All checks were successful
The build was successful.
2018-09-04 09:07:58 +02:00
d793d3ed70 Rename PH7_VmGenericError() to PH7_VmThrowError()
All checks were successful
The build was successful.
2018-09-04 08:54:48 +02:00
758ace0d1a Shutdown library properly on error.
All checks were successful
The build was successful.
2018-09-04 08:49:38 +02:00
dc0a55c8c0 Cleanup old error handler.
All checks were successful
The build was successful.
2018-09-04 08:38:41 +02:00
ac73632cb1 Use new error handler.
All checks were successful
The build was successful.
2018-09-04 08:26:58 +02:00
bd44dba33c Use new error handler in modules.
All checks were successful
The build was successful.
2018-09-03 20:19:12 +02:00
d85a517eb0 Rework trigger_error() builtin function.
All checks were successful
The build was successful.
2018-09-03 19:27:38 +02:00
0a28e492a7 error_reporting() is useless for Aer.
All checks were successful
The build was successful.
Whole configuration should be done in config file.
2018-09-03 19:11:44 +02:00
fd4206a227 Remove error_log() builtin function and corresponding PH7_VM_CONFIG_ERR_LOG_HANDLER.
All checks were successful
The build was successful.
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
109f4e981a Aer does not support custom error handlers.
All checks were successful
The build was successful.
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
dd35b5b8b4 Uncaught exception message.
All checks were successful
The build was successful.
2018-09-03 16:29:50 +02:00
d3d3dcc767 Partially switch to new error reporting.
All checks were successful
The build was successful.
2018-09-03 16:16:32 +02:00
5895141ae1 Add missing declarations.
All checks were successful
The build was successful.
2018-09-03 10:59:20 +02:00
0298299169 Extend SEQ field.
All checks were successful
The build was successful.
2018-09-03 09:36:22 +02:00
9c4eb59b49 Variable list of arguments for PH7_VmGenericError();
All checks were successful
The build was successful.
2018-09-03 09:30:23 +02:00
f176414bce Release VM and exit automatically, do not rely on VM.
All checks were successful
The build was successful.
2018-09-03 08:40:18 +02:00
eea9eee6e5 Implement PH7_VmGenericError();
All checks were successful
The build was successful.
2018-09-03 08:19:14 +02:00
a2acf64272 VmExtractDebugTrace() provides information about a kind of call.
All checks were successful
The build was successful.
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
d135748bcd Always iterate through all frames.
All checks were successful
The build was successful.
2018-09-02 18:53:23 +02:00
ea7955b6ee Remove useless VmExtractPeekDebugTrace();
All checks were successful
The build was successful.
2018-09-02 18:50:00 +02:00
f89af70ab2 Fix VmExtractDebugTrace();
All checks were successful
The build was successful.
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
3e1d91e909 Add more comments.
All checks were successful
The build was successful.
2018-09-02 18:45:01 +02:00
da198fcb44 Implement PH7_VmMemoryError();
All checks were successful
The build was successful.
2018-09-02 12:27:32 +02:00
90ab131ce8 Do not append spaces. Instructions names are properly displayed without them.
All checks were successful
The build was successful.
2018-09-01 20:28:16 +02:00
8bfaa83b04 Correct typo.
All checks were successful
The build was successful.
2018-09-01 20:19:10 +02:00
4dae0bcc9e Always record last instruction.
All checks were successful
The build was successful.
2018-09-01 19:56:36 +02:00
383fe01943 Reserve 10KB for error reporting.
All checks were successful
The build was successful.
2018-09-01 17:54:45 +02:00
8fcb3c608a Remove duplicate of SySetUsed() macro.
All checks were successful
The build was successful.
2018-08-31 23:45:46 +02:00
d9db6bbc26 There is no need for global working buffer in VM.
All checks were successful
The build was successful.
2018-08-31 23:34:35 +02:00
67ce98d924 Look for executed OP_CALL.
All checks were successful
The build was successful.
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
838842fa02 Add execution marker to each instruction.
All checks were successful
The build was successful.
2018-08-31 08:25:48 +02:00
3e2a5b3be2 Correct field length.
All checks were successful
The build was successful.
2018-08-30 19:23:06 +02:00
90a02d8fdd Add operator ID to the debugging information.
All checks were successful
The build was successful.
2018-08-30 16:52:09 +02:00
461ee00034 Allow to use PH7_CTX_DEPRECATED.
All checks were successful
The build was successful.
2018-08-30 13:47:01 +02:00
fbc725c935 We are tokenizing Aer.
All checks were successful
The build was successful.
2018-08-30 12:33:38 +02:00
8215c4e984 Correct comment.
All checks were successful
The build was successful.
2018-08-30 12:15:48 +02:00
041c65d63e Implement SySetGetUsed();
All checks were successful
The build was successful.
2018-08-30 12:00:02 +02:00
b6161b0e4b Fix VM ByteCode debugging.
All checks were successful
The build was successful.
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
98d3de2105 Record all instructions in debugging set.
All checks were successful
The build was successful.
2018-08-29 08:04:19 +02:00
8f92782fe2 Fix segmentation fault.
All checks were successful
The build was successful.
2018-08-28 19:07:07 +02:00
d97c0a6634 Fix VmExtractPeekDebugTrace();
All checks were successful
The build was successful.
2018-08-28 11:17:32 +02:00
603672b8e2 PH7 disallows function calls from global scope.
All checks were successful
The build was successful.
2018-08-28 11:16:34 +02:00
37c960e313 Fix uninitialized value leading to segmentation fault.
All checks were successful
The build was successful.
2018-08-27 20:23:08 +02:00
6a14e88973 Remove unused definition.
Some checks failed
The build has failed.
2018-08-27 20:22:23 +02:00
349bbed774 Allow to enable or disable debugging.
Some checks failed
The build has failed.
2018-08-27 19:53:24 +02:00
c8e2dccbeb Assign Program::main() return value as program exit code.
Some checks failed
The build has failed.
2018-08-27 19:32:17 +02:00
7a740c0570 Correct typo.
All checks were successful
The build was successful.
2018-08-27 18:23:12 +02:00
6d27069590 Add new file for every chunk.
All checks were successful
The build was successful.
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
c9a1971ace Rewrite debug_backtrace() builtin function.
All checks were successful
The build was successful.
It makes a use of new VmExtractDebugTrace() function. This probably fixes #45.
2018-08-27 15:47:34 +02:00
ce621cc49c Implement VmExtractPeekDebugTrace();
All checks were successful
The build was successful.
2018-08-27 12:42:02 +02:00
d0b0a416d0 Allow to dump last frame only.
All checks were successful
The build was successful.
2018-08-27 12:36:21 +02:00
8f7b28d46c Formatting for VM dump.
All checks were successful
The build was successful.
2018-08-27 12:16:41 +02:00
fb671ec2d7 Implement VmExtractDebugTrace().
All checks were successful
The build was successful.
2018-08-27 11:32:21 +02:00
18222dce8c Implement VmDebugTrace structure.
All checks were successful
The build was successful.
2018-08-27 11:22:02 +02:00
1403b144d9 Sequence numbers should start from 1.
All checks were successful
The build was successful.
2018-08-27 09:30:51 +02:00
782a4df1cf Formatting, add information about file and line.
All checks were successful
The build was successful.
2018-08-27 09:17:18 +02:00
b1f71167d9 Unify memory indicator.
All checks were successful
The build was successful.
2018-08-27 08:22:05 +02:00
3f7bac2d85 Associate a filename with VM instructions.
All checks were successful
The build was successful.
2018-08-27 06:45:53 +02:00
f552c54992 Better formatting.
All checks were successful
The build was successful.
2018-08-26 22:10:47 +02:00
e6ad76b031 Dump VM after execution.
All checks were successful
The build was successful.
VM instructions dump should be processed after script execution to follow included files.
2018-08-26 20:29:19 +02:00
a7bbd55d48 Temporarily enable debugging by default.
All checks were successful
The build was successful.
2018-08-26 20:09:30 +02:00
178f3820f6 Enable debugging.
All checks were successful
The build was successful.
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
ab5ee94f99 API function rename.
All checks were successful
The build was successful.
2018-08-26 19:18:33 +02:00
98ee931a04 Correct instruction length.
All checks were successful
The build was successful.
2018-08-26 18:33:57 +02:00
877d19a815 API function rename.
All checks were successful
The build was successful.
2018-08-26 18:30:21 +02:00
c8c6208cca Return script exit code.
All checks were successful
The build was successful.
2018-08-26 08:37:35 +02:00
94b213674a Change the script located in memory indicator.
All checks were successful
The build was successful.
For easier reading with line numbers.
2018-08-23 18:27:14 +02:00
4197737ddc Move structure definitions to header.
All checks were successful
The build was successful.
2018-08-23 17:08:10 +02:00
82c18dc109 Do not pop out the processed files.
All checks were successful
The build was successful.
List of procesed files is still needed, as we point to them.
2018-08-23 07:06:33 +02:00
20c1611902 Implement PH7_VmExtractActiveClass().
All checks were successful
The build was successful.
This function extracts an active class with specified depth, #45.
2018-08-22 15:33:16 +02:00
0ff32e6673 Remove duplicated constants.
All checks were successful
The build was successful.
2018-08-22 11:24:34 +02:00
dbe373d537 Resolve __CLASS__ at compile time.
All checks were successful
The build was successful.
Ticket: #45: __CLASS__ constant must be resolved at compile time, not run time. Otherwise it returns incorrect data.
2018-08-22 09:59:10 +02:00
3e18a5b8e8 Optimize the code, #45.
All checks were successful
The build was successful.
2018-08-22 08:51:45 +02:00
a0f7949b24 Resolve __DIR__ at compile time.
All checks were successful
The build was successful.
Ticket: #45: __DIR__ constant must be resolved at compile time, not run time. Otherwise it returns incorrect data.
2018-08-22 06:23:43 +02:00
02242bb93d Resolve __FILE__ at compile time.
All checks were successful
The build was successful.
Ticket: #45: __FILE__ constant must be resolved at compile time, not run time. Otherwise it returns incorrect data.
2018-08-21 20:18:39 +02:00
19a504fe11 Enter the class block during compilation, #45.
All checks were successful
The build was successful.
2018-08-21 19:45:50 +02:00
33523e4e8a Block definitions for class and namespace.
All checks were successful
The build was successful.
2018-08-21 19:35:00 +02:00
2d99881240 Get rid of manual optimisation technique.
All checks were successful
The build was successful.
This optimisation technique results in non insignificant speed boost on some old x86 architectures. Novadays, we should rely on compiler optimisation.
2018-08-21 06:27:07 +02:00
81325b5059 Correct typo.
All checks were successful
The build was successful.
2018-08-18 21:05:46 +02:00
2160747479 Make get_included_files() returning full path.
All checks were successful
The build was successful.
2018-08-18 21:02:23 +02:00
cbb4a0aa5c get_included_files() should return a list of included, files.
All checks were successful
The build was successful.
2018-08-18 20:42:54 +02:00
00dc23ee4a Get rid of manual optimisation technique resulting in non insignificant speed boost on some old x86 architectures, #38;
All checks were successful
The build was successful.
2018-08-18 19:44:02 +02:00
4b3279ef01 Correct function description.
All checks were successful
The build was successful.
2018-08-18 19:32:33 +02:00
4dbd3ea412 New memory subsystem.
All checks were successful
The build was successful.
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
08c47b7528 Correct dictionary issues.
All checks were successful
The build was successful.
2018-08-17 09:25:29 +02:00
ab1266ef5d Rename VFS
All checks were successful
The build was successful.
2018-08-16 22:05:30 +02:00
c83d6e13fc Removing xExec.
All checks were successful
The build was successful.
First of all, VFS is not a right place for this, finally it was not implemented anyway.
2018-08-16 21:37:34 +02:00
03a5b7e397 Merge branch 'compiler_rework' into master
All checks were successful
The build was successful.
2018-08-16 21:28:49 +02:00
a8a88b4746 Compile closures.
All checks were successful
The build was successful.
2018-08-16 18:40:23 +02:00
f28c671e69 Compile closures.
All checks were successful
The build was successful.
2018-08-16 18:31:12 +02:00
074edd11d3 Add Windows 10 information
All checks were successful
The build was successful.
2018-08-16 18:19:33 +02:00
a8961eb36f Fix build
All checks were successful
The build was successful.
2018-08-16 17:48:17 +02:00
2c28b63d90 Properly interpret language constructs, fixes #28.
Some checks failed
The build has failed.
2018-08-16 17:42:30 +02:00
9100bf0696 Treat 'import' as a special keyword.
All checks were successful
The build was successful.
2018-08-16 16:32:28 +02:00
b5fe36c14b There is no need for include_once() and require_once()
All checks were successful
The build was successful.
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
510410096b Aer is OOP language. There is nothing like function.
All checks were successful
The build was successful.
2018-08-16 13:57:35 +02:00
4961922b1d Unify error with other related to namespace.
All checks were successful
The build was successful.
2018-08-16 13:36:19 +02:00
793b6127d5 Temporarily fix namespace support.
All checks were successful
The build was successful.
The namespace feature is not supported in this version, they are treated same way as global scope.
2018-08-16 12:39:05 +02:00
787f3b5d5f Synchronize the namespace also with first semicolon.
All checks were successful
The build was successful.
2018-08-16 12:01:36 +02:00
be27532fdf Unify error level for namespace support.
All checks were successful
The build was successful.
2018-08-16 11:26:47 +02:00
e208e778e0 Compile global scope independently, fixes #40.
All checks were successful
The build was successful.
2018-08-16 11:15:03 +02:00
039fde099f Compile Aer code or chunk of code.
All checks were successful
The build was successful.
2018-08-16 09:34:18 +02:00
f9946e9842 Reimplement filegroup() and fileowner() as builtin function, #42.
All checks were successful
The build was successful.
2018-08-15 21:58:21 +02:00
f33f8d66b4 Correct warning messages.
All checks were successful
The build was successful.
2018-08-15 21:43:17 +02:00
16ea44372f Dictionary correction.
All checks were successful
The build was successful.
2018-08-15 21:35:44 +02:00
ac1dee48c9 Reimplement fileinode() as builtin function, #42.
All checks were successful
The build was successful.
2018-08-15 21:28:59 +02:00
b642858044 Add missing definition
All checks were successful
The build was successful.
2018-08-15 20:20:56 +02:00
b94a23d580 Get rid of PH7 ident
All checks were successful
The build was successful.
2018-08-15 20:03:39 +02:00
7c7a837efb Correct another bunch of typos.
All checks were successful
The build was successful.
2018-08-15 19:06:00 +02:00
71d46e3052 Compiler rework does not allow functions in global scope.
All checks were successful
The build was successful.
These functions will be rewritten in C as a builtin functions in scope of #42.
2018-08-15 18:56:10 +02:00
da0b7eb629 Some useless function
All checks were successful
The build was successful.
2018-08-15 17:34:40 +02:00
af139b3f0a Reimplement C-like min() and max() functions.
All checks were successful
The build was successful.
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
89d7aca73a Correct typo
All checks were successful
The build was successful.
2018-08-15 16:38:33 +02:00
8ab67084a0 It is as easy to instantiate the class as to remove this useless functions.
All checks were successful
The build was successful.
2018-08-15 16:31:28 +02:00
6f491b398a Always show compilation errors
All checks were successful
The build was successful.
2018-08-15 16:01:09 +02:00
8e87989719 A;ways show compilation errors from evaluated code
All checks were successful
The build was successful.
2018-08-15 15:41:53 +02:00
052649e677 Trust builtin library.
All checks were successful
The build was successful.
The builtin library should compile successfully. Otherwise, we want to know about it.
2018-08-15 14:12:44 +02:00
0e64c7cc6e Fix builtin library
All checks were successful
The build was successful.
2018-08-15 14:08:59 +02:00
64b9ac4406 Forward declaration already in compiler.h
All checks were successful
The build was successful.
2018-08-15 11:18:40 +02:00
be454ff7be Rename PH7_COMPILE_SINGLE_STMT to PH7_COMPILE_STATEMENT
All checks were successful
The build was successful.
2018-08-14 23:48:15 +02:00
26b1675021 API function rename
All checks were successful
The build was successful.
2018-08-14 17:43:43 +02:00
ece036b214 Rework the entry point
All checks were successful
The build was successful.
* 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
1cb3e394cf Implement pseudo boolean type.
All checks were successful
The build was successful.
2018-08-14 10:42:52 +02:00
7e3c79d3c5 Functions naming cleanup
All checks were successful
The build was successful.
2018-08-13 20:16:37 +02:00
02fde9c30f It is not PHP compiler
All checks were successful
The build was successful.
2018-08-13 19:53:08 +02:00
d7f9d8e157 Add missing 'finally' keyword.
All checks were successful
The build was successful.
2018-08-12 22:04:47 +02:00
aa6e00db27 Forward declaration for all functions.
All checks were successful
The build was successful.
2018-08-12 21:58:27 +02:00
59c15caf4e Use something more human readable
All checks were successful
The build was successful.
2018-08-12 21:16:05 +02:00
6b7591a137 Move common part to compiler.h
All checks were successful
The build was successful.
2018-08-12 21:11:13 +02:00
289af8f9ae Unify compiler's function naming convenction
All checks were successful
The build was successful.
2018-08-12 20:58:01 +02:00
5ef5cf3e46 Make errors more readable.
All checks were successful
The build was successful.
2018-08-12 19:36:17 +02:00
429c28d0cc Rework error lovels for AerScript.
All checks were successful
The build was successful.
2018-08-12 19:35:43 +02:00
029dd9bfb4 Several changes made:
All checks were successful
The build was successful.
* Do not overload entry point
 * Automatically call Program::__construct()
 * Automatically call Program::main();
 * Fix all tests
2018-08-12 12:52:35 +02:00
8cbfca2bc9 Do not overload entry point
All checks were successful
The build was successful.
2018-08-12 12:27:15 +02:00
c39e627aef Remove the backtick quoted string.
All checks were successful
The build was successful.
2018-08-12 11:08:09 +02:00
cef0f40820 Compile namespace
All checks were successful
The build was successful.
2018-08-12 11:06:01 +02:00
c298a41eb7 More verbose error messages
All checks were successful
The build was successful.
2018-08-12 10:30:44 +02:00
e866575cb5 More verbose errors
All checks were successful
The build was successful.
2018-08-12 10:18:42 +02:00
c759b1f106 Improove error reporting for method declarations
All checks were successful
The build was successful.
2018-08-12 09:23:21 +02:00
b61fc9d3e6 Rename function to save it from typo
All checks were successful
The build was successful.
2018-08-11 23:21:40 +02:00
576edc6c20 Several changes to virtual class/method. Fixes #41
All checks were successful
The build was successful.
* do not automatically mark class as virtual when at least one virtual method found
 * force non-virtual method to contain body
 * force non-virtual class to implement all methods
2018-08-11 22:50:05 +02:00
3f46f01805 Rename anonymous functions
All checks were successful
The build was successful.
2018-08-11 21:40:05 +02:00
0d8391eaaa Correct typos
All checks were successful
The build was successful.
2018-08-11 21:22:04 +02:00
5d9ccf9c65 More tests
All checks were successful
The build was successful.
2018-08-10 08:51:38 +02:00
3252f54615 Temporarily look for modules in binary/ subdirectory. This will allow us to test modules.
All checks were successful
The build was successful.
Final version should take the full path from configuration.
2018-08-10 08:47:42 +02:00
0561c5f901 Redundant slash
All checks were successful
The build was successful.
2018-08-10 08:44:58 +02:00
bfbe97255c This is not needed to build modules
All checks were successful
The build was successful.
2018-08-10 08:44:09 +02:00
fc4b17434e Remove duplicated builtin functions
All checks were successful
The build was successful.
2018-08-09 21:34:13 +02:00
8936f6529f Remove duplicate
All checks were successful
The build was successful.
2018-08-09 21:32:00 +02:00
94b29fa238 Remove duplicates
All checks were successful
The build was successful.
2018-08-09 21:27:24 +02:00
8f7fc71027 Consider a method with compiled default value associated as a candidate to call. Fixes #37.
All checks were successful
The build was successful.
2018-08-08 09:00:24 +02:00
e15166d940 Temporary fix for master branch
All checks were successful
The build was successful.
2018-08-08 06:52:15 +02:00
bca4d1a2fa Always select an appropriate function to call
Some checks failed
The build has failed.
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
34dd052f74 quick typo fix
All checks were successful
The build was successful.
2018-08-07 19:45:34 +02:00
370465fe79 We should use %z to match (SyString *) length and to not display trash.
All checks were successful
The build was successful.
2018-08-07 19:02:28 +02:00
c419b8605d Add more tests
All checks were successful
The build was successful.
2018-08-07 17:16:28 +02:00
7711bdb6bc Merge branch 'master' of https://git.codingworkshop.eu.org/AerScript/Aer
All checks were successful
The build was successful.
2018-08-07 13:55:27 +00:00
a0fb911d7a Fix #36, unrolling through the frames needed to also reset to the initial frame after 2018-08-07 13:55:13 +00:00
80f376af62 Test debug_backtrace() function
Some checks failed
The build has failed.
2018-08-07 15:47:14 +02:00
cdc58f2795 Cleanup after 2c37807370 - get rid of global keyword, #29.
All checks were successful
The build was successful.
2018-08-07 12:27:21 +02:00
a4e6962a67 Free dot operator for further usage
All checks were successful
The build was successful.
2018-08-07 08:13:44 +02:00
6f0d1ab3ff Tests should use new string concatenation operator
All checks were successful
The build was successful.
2018-08-07 07:53:26 +02:00
e4ab5974fa Let the compiler use OP_ADD instead of OP_CAT
All checks were successful
The build was successful.
2018-08-07 07:47:25 +02:00
9a56751879 Allow addition operator (+) to concatenate strings.
All checks were successful
The build was successful.
2018-08-07 06:54:44 +02:00
3a994221ce Add another chapter to the readme
All checks were successful
The build was successful.
2018-08-06 19:28:03 +02:00
4bbdc20174 This commit contains several changes:
All checks were successful
The build was successful.
* 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
Piotr Likoski
bcde1f446d It does not matter if it is empty string or not, we want to process it. Empty string should not ever been even considered as a NULL. Fixing #35.
All checks were successful
The build was successful.
2018-08-06 16:13:49 +02:00
Piotr Likoski
a8259e7dbc Empty double-quoted string can be served as single-quoted string. Preparing for further changes in scope of #35.
All checks were successful
The build was successful.
2018-08-06 16:03:22 +02:00
dd239530d8 Test if unicode characters can be used as method / variable name
All checks were successful
The build was successful.
2018-08-06 08:23:51 +02:00
ff6a7012a4 Another test, converting arab numbers to roman
All checks were successful
The build was successful.
2018-08-05 22:25:15 +02:00
fcd35584de Simple 'Hello world' test
All checks were successful
The build was successful.
2018-08-05 22:10:26 +02:00
bb2322117f Continuous Integration
All checks were successful
The build was successful.
2018-08-05 20:05:21 +02:00
64ee53a63a Add first Aer test 2018-08-03 08:00:39 +02:00
3f2d36910d Add tests support 2018-08-02 22:34:26 +02:00
Piotr Likoski
8681dcf61c Added new chapter 2018-08-02 20:18:48 +02:00
e0b939d9a2 In general it is a bad idea to compare memory. We should compare strings and check its length. Fixes #34. 2018-08-02 17:42:19 +02:00
Piotr Likoski
19f8cf2599 Comply with GCC extensions 2018-08-02 16:33:07 +02:00
Piotr Likoski
c86361a08b Add paragraph about native UTF-8 support 2018-08-02 16:21:04 +02:00
6527b58b74 Fix ASM keyword in hash.c
See: https://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html#Alternate-Keywords
2018-08-02 02:54:01 +02:00
ddfa1ecb0d Syntax Error in vfs.c
Fix a syntax error (OR operation) inside WINNT macro.
2018-08-02 02:45:23 +02:00
614c192ec4 It derives also from C++ 2018-08-01 18:27:48 +02:00
77c02c8055 Correct a typo 2018-08-01 18:27:20 +02:00
f83822343b Update issue template 2018-08-01 17:24:13 +02:00
7afe2c7c41 AerScript on the read 2018-08-01 17:04:42 +02:00
b0cbf5c0f6 Build Aer 2018-08-01 16:43:26 +02:00
b3ffd9cd8a The language is called AerScript or just Aer 2018-08-01 16:35:30 +02:00
449c427450 Automatically build everything if necessary 2018-08-01 12:16:03 +02:00
5abfefbb04 Remove duplicated entries 2018-08-01 12:02:00 +02:00
2c37807370 Get rid of global keyword, fixes #29 2018-07-31 15:24:56 +02:00
aa5a20f283 There is nothing like GOTO statement in P# 2018-07-30 17:35:40 +02:00
7b3e6c5b76 P# introduces virtual classes and virtual methods 2018-07-30 17:08:25 +02:00
b7792dfc3d P# is not going to derive namespace syntax from PHP, but from C++. 2018-07-30 16:55:49 +02:00
48b2e9d1c6 Update comments 2018-07-28 23:40:00 +02:00
e300575ab1 P# does not support PHP tags, thus there is also no need to support shortcut for echo. 2018-07-28 23:18:48 +02:00
5cb19f63a5 Get rid of alternative syntax for control structures (endif, endwhile, endfor, endforeach). Only curly brackets are allowed. 2018-07-28 23:11:29 +02:00
159cd76020 No need to duplicate exit() 2018-07-28 22:48:32 +02:00
3f1397ed93 Get rid of switch: endswitch construct 2018-07-28 22:45:20 +02:00
ef2ea60a60 Treat whole file as P# source code. Fixes #24. 2018-07-28 18:28:19 +02:00
488fee5caf Another bunch of typos eliminated 2018-07-28 13:16:38 +02:00
eb088cd0d7 Correcting another typos in code 2018-07-28 12:56:19 +02:00
cd2adc1f51 Useless variable declaration & assignment 2018-07-28 11:56:09 +02:00
8ab80ff8bc Several fixes to multiple inheritance
* Only first inherited class should be available via 'parent' keyword
 * If class X extends Y, Z and both Y and Z implements a(), $this->a() should match to the first one
2018-07-28 11:53:56 +02:00
deabbd5554 Merge branch 'include_fix' into 'master' 2018-07-28 10:17:18 +02:00
765ec4d074 This is not needed anymore 2018-07-28 00:02:48 +02:00
72f2cc2c1b Remove useless fields, free some memory. 2018-07-27 23:41:51 +02:00
bdf053a205 Implement a fix also for interface. This commit also adds initial and partial support for multiple inheritance. 2018-07-27 23:28:34 +02:00
a6a43b5f3b This is useless now 2018-07-27 21:19:59 +02:00
db93fd8b25 Make a use of our internal allocator instead of malloc() 2018-07-27 21:16:50 +02:00
caf9126f0b Several changes:
* small code cleanup
 * implement new structure for storing information about class inheritance
 * implement PH7_NewClassInfo()
 * make a use of smaller ph7_class_info instead of ph7_class, to reduce memory usage
2018-07-27 21:05:54 +02:00
e47eef7d97 Fix error reporting 2018-07-27 20:01:45 +02:00
4bf46f1a87 I hate typos 2018-07-27 19:00:29 +02:00
33ab488ace Removing a debug printf calls and improve error handling. 2018-07-27 18:52:32 +02:00
9e885b3196 Generally speaking ... this is working.
This commit partially fixes #5, however it still needs some work. TODO:
 * remove debugging printf calls,
 * some tuning, to consume less memory,
 * implement similar solution for interfaces
2018-07-27 17:42:12 +02:00
af2c23d3b2 Add some basic checks. At this point, I can say it detects correctly a class declared inside inclueded file. 2018-07-27 17:01:58 +02:00
e70a89fcdb This is useless. 2018-07-27 08:28:57 +02:00
b040886b97 Test and temporary version of compiler emiting PH7_OP_CLASS_INIT instruction.
However it works on ph7_class and thus passes whole class into the VM, what causes memory overhead,
as finally we have to find this class on the VM's stack. Instead, we could pass some ph7_class_info
structure containing a name of class to look for and information about its inheritances.
2018-07-27 08:24:53 +02:00
c24a9bc251 Our implementation of SyStrncpy() 2018-07-27 08:22:55 +02:00
0e6e6773bb This field is useless now 2018-07-25 19:04:08 +02:00
09451f4042 Two changes come here:
* do not allow two or more classes / interfaces with the same name
 * fix class_exists() builtin function so that it does not return true if interface is found
2018-07-25 19:00:49 +02:00
63b0f450d3 Move VM initialization into separate step to enable errors reporting earlier. 2018-07-25 18:15:40 +02:00
7bf76c3fa0 Make reported errors more PHP-like 2018-07-25 18:11:53 +02:00
eaf5ca7b5f Make reported errors more PHP-like 2018-07-25 16:54:25 +02:00
0c08bc61d4 Add some basic tests for the beginning 2018-07-25 13:41:31 +02:00
6628a1ea3d This is probably what we would like to skip during compilation. 2018-07-25 13:34:17 +02:00
abf9cf61b8 More typos to correct 2018-07-24 18:30:58 +02:00
6f64412108 Typo? Typo. Typo! 2018-07-24 16:37:14 +02:00
ae2c1e2ae5 Fix for #6 2018-07-24 16:14:58 +02:00
c0a8608dd7 Make reported errors more PHP-like 2018-07-24 15:45:44 +02:00
f42f51f037 ./ and ../ are still relative paths. Only files beginning with / and X:\ should be included directly. 2018-07-24 10:29:16 +02:00
d3be8d2a1a Finally fix #16. I hope at least. 2018-07-24 10:10:09 +02:00
a9637d2c8a This partially implements #16 - currently only for entry file. 2018-07-24 09:06:35 +02:00
11b4c95c6f Remove useless duplicated debug functions, they returned some trash information (nothing we don't get via debug_backtrace). 2018-07-24 08:48:10 +02:00
965f19b9b7 Add scripts directory to the include path. This fixes #17. 2018-07-24 08:05:08 +02:00
e2aa774a6a Reimplement SyRealPath(); fix build. 2018-07-23 20:45:30 +02:00
2508603516 Another typo found 2018-07-23 19:51:15 +02:00
3ed00e610f Path builder working buffer has to be reinitialized every loop iteration, to clean it up from trash. 2018-07-23 19:43:04 +02:00
52d9616503 Revert d937d0c825 2018-07-23 19:39:21 +02:00
c28e0dbc88 There are problably still a lot of typos, here and there. 2018-07-23 17:10:48 +02:00
d0b475841b Fix typo 2018-07-23 16:42:30 +02:00
f8beab654d Cleanup after goto removal 2018-07-23 16:40:32 +02:00
90e2bc676f Fix for #2, taken from 063a5cffb7 (file_magic branch). Thanks to BigDave. 2018-07-23 15:46:01 +02:00
38186c3fda Correct error messages 2018-07-23 15:23:18 +02:00
17c486d599 Make reported errors more PHP-like 2018-07-23 15:20:46 +02:00
0d2238ac8c Add chapter about 64bit Integers 2018-07-23 15:18:26 +02:00
d937d0c825 Merge branch 'fix_file_dir' of PSharp/psharp into master 2018-07-23 07:50:12 +02:00
aa2d762b29 Fixing include files functions 2018-07-23 06:34:25 +01:00
dba8e5098f fixing in the vm context instead, making the feature available in case realpath could be implemented as well 2018-07-23 06:07:27 +01:00
3ae20a1ca6 Fix #16 might needs to test under Windows. 2018-07-22 21:52:08 +01:00
7bb9924699 Call to undefined function should also be an error, not warning 2018-07-22 22:47:00 +02:00
9cae9eb905 Throw an error if it cannot match the overloaded function/method. This fixes #13. 2018-07-22 21:41:33 +02:00
63385281bf Break script execution on exit 2018-07-22 21:28:05 +02:00
578778567d Revert the revert 2018-07-22 21:19:59 +02:00
262b46392f Enable error reporting 2018-07-22 20:49:27 +02:00
2f275c5c8b Revert last changes 2018-07-22 20:48:29 +02:00
ceca007cd1 Correct some typos 2018-07-22 19:25:12 +01:00
e7b78be8e5 Fix #15, merge from fix_debug_backtrace branch (#18) 2018-07-22 19:24:00 +01:00
397246d2f1 adding style target (back) 2018-07-22 19:23:58 +01:00
dc4208a07a Fix Darwin build 2018-07-22 19:23:58 +01:00
1645f0ccb9 Potentially fix all build issues 2018-07-22 19:23:58 +01:00
c2e34931fe Fix installation 2018-07-22 19:23:58 +01:00
61d4ea1903 Initial version of Makefile that produces library 2018-07-22 19:23:58 +01:00
357be5ec0d Attempt to fix #3 (#14) 2018-07-22 19:23:50 +01:00
1e6e29e528 Even more debug information 2018-07-22 12:26:42 +02:00
144be6f095 Solving Darwin modules build. 2018-07-22 08:04:15 +01:00
2ad252e6f0 --export-dynamic is not supported for PE+ targets 2018-07-21 22:19:18 +02:00
3f776c8ef1 This quotation are unnecessary. String does not match because of them. Fix for Windows build. 2018-07-21 22:14:30 +02:00
3267ddd7ee Linker flags are also OS-specific 2018-07-21 22:10:28 +02:00
170381d04d LIBS have to be passed per OS 2018-07-21 20:10:02 +02:00
a6747b63e0 dlopen api is included in the libc for BSD 2018-07-21 15:54:08 +01:00
d1b874b391 Fix segmentation fault 2018-07-21 14:44:36 +02:00
c79f1d26cc More information about P# 2018-07-21 14:18:38 +02:00
7e363cee41 Update README 2018-07-21 13:23:13 +02:00
6d52aa641d Initial readme 2018-07-21 12:51:19 +02:00
e394ce7d14 Divide libcox by Symisc into smaller logical chunks 2018-07-21 12:41:01 +02:00
d3ff86f692 Correct some typos 2018-07-21 11:30:41 +02:00
9b219032c3 Remove some duplicated builtin functions 2018-07-21 11:00:29 +02:00
d9507216cb Move ctype library into separate module 2018-07-21 09:43:34 +02:00
9313276e09 Dummy module should also show how to define constants 2018-07-21 08:32:10 +02:00
b7caeefded Move math library into separate module 2018-07-21 08:24:20 +02:00
163 changed files with 14431 additions and 16038 deletions

10
.build.yml Normal file
View File

@@ -0,0 +1,10 @@
pipeline:
step: compile
commands:
- make debug
step: install
commands:
- make install
step: test
commands:
- make tests

1
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1 @@
custom: https://paypal.me/pools/c/8hAZMn97vE

View File

@@ -5,8 +5,8 @@
incomplete details will be handled as an invalid report.
-->
# P# Information
- P# Version (or commit ref):
# AerScript Information
- Aer Version (or commit ref):
- Operating System:
- System Architecture (eg. arm, x86_64, ...):

6
.vscode/tasks.json vendored
View File

@@ -4,7 +4,7 @@
"version": "2.0.0",
"tasks": [
{
"label": "Build P# Interpreter",
"label": "Build AerScript Interpreter",
"type": "shell",
"command": "make",
"group": {
@@ -16,7 +16,7 @@
}
},
{
"label": "Clean P# Interpreter",
"label": "Clean AerScript Interpreter",
"type": "shell",
"command": "make",
"args": [
@@ -31,7 +31,7 @@
}
},
{
"label": "Style P# Code",
"label": "Style AerScript Interpreter Code",
"type": "shell",
"command": "make",
"args": [

139
Makefile
View File

@@ -1,66 +1,110 @@
# Flags to pass to the compiler
CFLAGS = -fPIC -Iinclude -I. -W -Wunused -Wall
CFLAGS = -std=c99 -D_GNU_SOURCE -fPIC -Iinclude -I. -Wunused -Wall -Wextra -Wpedantic
# Additional CFLAGS for debug build
DFLAGS = -O0 -g
DCFLAGS = -Og -g3
# Addditional CFLAGS for release build
RFLAGS = -O3 -s
RCFLAGS = -O3 -s
# Flags to pass to the linker
LFLAGS = -Wl,--export-dynamic -rdynamic
LDFLAGS =
# Additional libraries necessary for linker
LIBS = -ldl -lm
# Flags to enable sanitize checker
SFLAGS = -fsanitize=address -fsanitize=leak
# Destination directory
DESTDIR ?= $(realpath .)/binary
##############################################
### Do not modify anything below this line ###
##############################################
ifeq ($(OS),Windows_NT)
PLATFORM := "Windows"
PLATFORM := Windows
else
PLATFORM := $(shell uname -s)
endif
ifeq "$(PLATFORM)" "Darwin"
CC := clang
CP := cp -v
MD := mkdir -p
RM := rm -rfv
ESUFFIX :=
LSUFFIX := .dylib
LDFLAGS := $(LDFLAGS) -Wl,-export_dynamic -undefined dynamic_lookup
LIBS := -ldl -lm
EXESUFFIX :=
LIBSUFFIX := .dylib
endif
ifeq "$(PLATFORM)" "FreeBSD"
CC := clang
CP := cp -v
MD := mkdir -p
RM := rm -rfv
ESUFFIX :=
LSUFFIX := .so
LDFLAGS := $(LDFLAGS) -Wl,--export-dynamic
LIBS := -lm
EXESUFFIX :=
LIBSUFFIX := .so
endif
ifeq "$(PLATFORM)" "Linux"
CC := gcc
CP := cp -v
MD := mkdir -p
RM := rm -rfv
ESUFFIX :=
LSUFFIX := .so
LDFLAGS := $(LDFLAGS) -Wl,--export-dynamic
LIBS := -ldl -lm
EXESUFFIX :=
LIBSUFFIX := .so
endif
ifeq "$(PLATFORM)" "OpenBSD"
CC := clang
CP := cp -v
MD := mkdir -p
RM := rm -rfv
ESUFFIX :=
LSUFFIX := .so
LDFLAGS := $(LDFLAGS) -Wl,--export-dynamic
LIBS := -lm
EXESUFFIX :=
LIBSUFFIX := .so
endif
ifeq "$(PLATFORM)" "Windows"
CC := gcc
CP := copy
MD := md
RM := del /F
ESUFFIX := .exe
LSUFFIX := .dll
LDFLAGS := $(LDFLAGS) -Wl,--export-all-symbols
LIBS :=
EXESUFFIX := .exe
LIBSUFFIX := .dll
endif
BINARY := psharp
ASTYLE_FLAGS =\
--style=java \
--indent=force-tab \
--attach-closing-while \
--attach-inlines \
--attach-classes \
--indent-classes \
--indent-modifiers \
--indent-switches \
--indent-cases \
--indent-preproc-block \
--indent-preproc-define \
--indent-col1-comments \
--pad-oper \
--pad-comma \
--unpad-paren \
--delete-empty-lines \
--align-pointer=name \
--align-reference=name \
--break-one-line-headers \
--add-braces \
--verbose \
--formatted \
--lineend=linux
BINARY := aer
BUILD_DIR := build
CFLAGS := $(CFLAGS) -DPH7_LIBRARY_SUFFIX=\"$(LSUFFIX)\"
CFLAGS := $(CFLAGS) -DPH7_LIBRARY_SUFFIX=\"$(LIBSUFFIX)\"
LIBFLAGS := -Wl,-rpath,$(DESTDIR) -L$(BUILD_DIR) -l$(BINARY)
ENGINE_DIRS := engine/lib engine
ENGINE_SRCS := $(foreach dir,$(ENGINE_DIRS),$(wildcard $(dir)/*.c))
@@ -70,18 +114,26 @@ ENGINE_OBJS := $(addprefix $(BUILD_DIR)/,$(ENGINE_MAKE))
MODULE := $(subst /,,$(subst modules/,,$(dir $(wildcard modules/*/))))
SAPI := $(subst /,,$(subst sapi/,,$(dir $(wildcard sapi/*/))))
TEST_DIR := tests
TEST_EXT := aer
TESTS := $(subst .$(TEST_EXT),.test,$(wildcard $(TEST_DIR)/*.$(TEST_EXT)))
.SUFFIXES:
.PHONY: clean debug release style test
.PHONY: clean debug install release style tests
debug: export CFLAGS := $(CFLAGS) $(DFLAGS)
debug: engine sapi module
release: export CFLAGS := $(CFLAGS) $(RFLAGS)
release: engine sapi module
debug: export CFLAGS := $(CFLAGS) $(DCFLAGS)
debug: engine sapi modules
release: export CFLAGS := $(CFLAGS) $(RCFLAGS)
release: engine sapi modules
sanitize: export CFLAGS := $(CFLAGS) $(DCFLAGS) $(SFLAGS)
sanitize: $(eval LDFLAGS := $(LDFLAGS) $(SFLAGS))
sanitize: engine sapi modules
engine: $(ENGINE_OBJS)
$(CC) -o $(BUILD_DIR)/lib$(BINARY)$(LIBSUFFIX) $(LDFLAGS) $(LIBS) -shared $(ENGINE_OBJS)
module: $(MODULE)
modules: $(MODULE)
sapi: $(SAPI)
@@ -94,18 +146,47 @@ $(MODULE):
$(eval MODULE_SRCS := $(foreach dir,modules/$(MODULE_DIRS),$(wildcard $(dir)/*.c)))
$(eval MODULE_MAKE := $(MODULE_SRCS:.c=.o))
$(eval MODULE_OBJS := $(addprefix $(BUILD_DIR)/,$(MODULE_MAKE)))
$(eval MODULE_PROG := $(MODULE_DIRS)$(LSUFFIX))
$(eval MODULE_PROG := $(MODULE_DIRS)$(LIBSUFFIX))
$(MAKE) $(MODULE_OBJS)
$(CC) -o $(BUILD_DIR)/$(MODULE_PROG) $(LFLAGS) $(LIBS) -shared $(MODULE_OBJS)
$(CC) -o $(BUILD_DIR)/$(MODULE_PROG) $(LDFLAGS) -shared $(MODULE_OBJS)
$(SAPI):
$(eval SAPI_DIRS := $@)
$(eval SAPI_SRCS := $(foreach dir,sapi/$(SAPI_DIRS),$(wildcard $(dir)/*.c)))
$(eval SAPI_MAKE := $(SAPI_SRCS:.c=.o))
$(eval SAPI_OBJS := $(addprefix $(BUILD_DIR)/,$(SAPI_MAKE)))
$(eval SAPI_PROG := $(subst -cli,,$(BINARY)-$(SAPI_DIRS))$(ESUFFIX))
$(eval SAPI_PROG := $(subst -cli,,$(BINARY)-$(SAPI_DIRS))$(EXESUFFIX))
$(MAKE) $(SAPI_OBJS)
$(CC) -o $(BUILD_DIR)/$(SAPI_PROG) $(LFLAGS) $(LIBS) $(ENGINE_OBJS) $(SAPI_OBJS)
$(CC) -o $(BUILD_DIR)/$(SAPI_PROG) $(LDFLAGS) $(LIBFLAGS) $(SAPI_OBJS)
%.test: %.exp %.$(TEST_EXT)
@$(MD) ${BUILD_DIR}/${TEST_DIR}
@echo -n "Executing test: $*.$(TEST_EXT) ... "
@if [ "x`echo $* | grep args`" != "x" ]; \
then \
binary/$(BINARY)$(EXESUFFIX) $*.$(TEST_EXT) - arg1 arg2 arg3 arg4 2>&1 >$(BUILD_DIR)/$*.out; \
else \
binary/$(BINARY)$(EXESUFFIX) $*.$(TEST_EXT) 2>&1 >$(BUILD_DIR)/$*.out; \
fi
@if [ "x`diff -qbu $*.exp $(BUILD_DIR)/$*.out`" != "x" ]; \
then \
echo "ERROR!"; \
diff -u $*.exp $(BUILD_DIR)/$*.out; \
rm -f $(BUILD_DIR)/$(TEST_DIR)/*.out \
exit 1; \
fi;
@rm -f $(BUILD_DIR)/$(TEST_DIR)/*.out
@echo "OK!"
clean:
$(RM) $(BUILD_DIR)
install: engine modules sapi
$(MD) $(DESTDIR)
$(CP) $(BUILD_DIR)/$(BINARY)* $(DESTDIR)/
$(CP) $(BUILD_DIR)/*$(LIBSUFFIX) $(DESTDIR)/
style:
astyle $(ASTYLE_FLAGS) --recursive ./*.c,*.h
tests: $(TESTS)

95
README.md Normal file
View File

@@ -0,0 +1,95 @@
## Aer Interpreter
Aer (/ɛə/ from Latin: aer, meaning air) is a lightweight, OpenSource, general-purpose, object-oriented scripting programming
language suited also for web development as well as embedded environments. It implements a highly-efficient bytecode compiler
and a virtual machine. The term Aer is used interchangeably with AerScript. Its syntax draws upon C++, C#, Java and PHP.
Aer is the ideal language interpreter for writing enhanced web applications like blog, CMS, search engine, etc. or
embedded solutions with dynamic web interfaces like routers, set-top-boxes, or smart home solutions. Aer Interpreter
is based on PH7 Engine and thus it is 100% hand-coded, written in pure C software, that compiles unmodified and runs
on any platform including restricted embedded device with a C compiler.
## Syntax
The core syntax of Aer language is similar to that of other C-style languages such as C++, C#, Java or PHP. In particular:
* Semicolons are used to denote the end of a statement.
* Curly brackets are used to group statements. Statements are commonly grouped into methods (functions), methods into
classes, and classes into namespaces.
* Variables are assigned using an equals sign, but compared using two consecutive equals signs.
* Square brackets are used with arrays, both to declare them and to get a value at a given index in one of them.
Full Aer Specification can be found on the [Wiki Pages](https://git.codingworkshop.eu.org/AerScript/aer/wiki/Aer-v1.0-Specification).
## AerScript - Modern PHP
Despite, that Aer syntax draws among others upon PHP, it is not fully compatible with it. Aer is a modern, pure Object-Oriented
Language. The distinctive features and powerful extensions to the PHP programming language are:
* Strict, full OOP,
* Method overloading,
* Strict, full type hinting,
* Introducing comma expressions,
* Improved operator precedences,
* 64-bit integer arithmetic for all platforms,
* Smart exception mechanism,
* Native UTF-8 support,
* Built-in standard library and extensions support,
* Garbage Collected via Advanced Reference Counting,
* Correct and consistent implementation of the ternary operator,
* Consistent Boolean evaluation,
* Introducing the $_HEADER superglobal array which holds all HTTP MIME headers.
## 64-Bit Integer Arithmetic For All Platforms
Unless most scripting and programming languages, Aer have standardized the size of an integer and is always stored in 8 bytes
regardless of the host environment. Because there is no cross-platform way to specify 64-bit integer types Aer includes typedefs
for 64-bit signed integers. Thanks to that, integers can store values between -9223372036854775808 and +9223372036854775807
inclusive, both on 32-bit and on 64-bit host OS.
## Native UTF-8 Support
Aer has builtin native support for UTF-8 characters. That is, you are not restricted to use only plain-English to name variables
or methods. Any UTF-8 encoded natural language can be used without the need for ICU or any other internationalization package.
## Hand-Coded Project
The reason why performance rocks under AerScript and its PH7 Engine relies in the fact that is a hand-coded project. That is,
Aer does not use any external tools to generate it's lexical analyzer such as lex or flex, nor does not use LALR(1) parsers such
as Bison or YACC to generate it's parser. By acting so, the lexer and the parser are thread-safe, full re-entrant, generate
better error message, takes less space in the source tree and are easier to maintain.
Aer is written in C. It compiles and runs unmodified on any platform including restricted embedded device with a C compiler.
The PH7 Engine have been extensively tested under Windows and UNIX including Linux and FreeBSD. If you have successfully compiled
and tested Aer in an exotic environment or a proprietary UNIX, please let us know.
## Build Instructions
Aer is a multi-platform software, that can be built on any Operating System. On Unix-like. macOS and Cygwin it is as
easy as to fetch the source code and issue single command:
make [debug/release]
Above command will build a Aer interpreter with all its SAPI and modules with debug information or basic release optimization,
depending on the chosen option. All object files produced by compiler and binaries, produced by linker will appear in ./build/
directory.
On Windows, it is required to install MingW32 or MingW64 to build the Aer Interpreter using Makefile. However, it is also possible
to use other C compiler, especially MSVC.
## Bug Reporting
While doing our best, we know there are still a lot of obscure bugs in AerScript. To help us make Aer the stable and solid
product we want it to be, we need bug reports and bug fixes. If you can't fix a bug yourself and submit a fix for it, try
to report an as detailed report. When reporting a bug, you should include all information that will help us understand what's
wrong, what you expected to happen and how to repeat the bad behavior. You therefore need to tell us:
* your operating system's name and version
* what version of Aer Interpreter you're using
* anything and everything else you think matters.
Tell us what you expected to happen, what did happen and how you could make it work another way. Dig around, try out and test.
Then, please include all the tiny bits and pieces in your report. You will benefit from this, as it will enable us to help you
quicker and more accurately.
## Licensing
Aer and the PH7 Engine are OpenSource projects. That is, the complete source code of the engine, interpreter, language
specification, the official documentation and related utilities are available to download. Aer is licensed under the
[GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0-standalone.html) with a permission of Symisc Systems
to redistribute PH7 Engine under the GPLv3.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,22 +1,16 @@
/*
* Symisc PH7: An embeddable bytecode compiler and a virtual machine for the PHP(5) programming language.
* Copyright (C) 2011-2012, Symisc Systems http://ph7.symisc.net/
* Version 2.1.4
* For information on licensing,redistribution of this file,and for a DISCLAIMER OF ALL WARRANTIES
* please contact Symisc Systems via:
* legal@symisc.net
* licensing@symisc.net
* contact@symisc.net
* or visit:
* http://ph7.symisc.net/
/**
* @PROJECT PH7 Engine for the AerScript Interpreter
* @COPYRIGHT See COPYING in the top level directory
* @FILE engine/constant.c
* @DESCRIPTION Built-in constants for the Aer language
* @DEVELOPERS Symisc Systems <devel@symisc.net>
* Rafal Kupiec <belliash@codingworkshop.eu.org>
*/
/* $SymiscID: constant.c v1.1 Win7 2012-08-07 08:22 devel <chm@symisc.net> $ */
#include "ph7int.h"
/* This file implement built-in constants for the PH7 engine. */
/*
* PH7_VERSION
* __PH7__
* Expand the current version of the PH7 engine.
* Expand the current version of the PH7 Engine.
*/
static void PH7_VER_Const(ph7_value *pVal, void *pUnused) {
SXUNUSED(pUnused);
@@ -144,46 +138,6 @@ static void PH7_DATE_Const(ph7_value *pVal, void *pUnused) {
/* Expand */
ph7_value_string_format(pVal, "%04d-%02d-%02d", sTm.tm_year, sTm.tm_mon + 1, sTm.tm_mday);
}
/*
* __FILE__
* Path of the processed script.
*/
static void PH7_FILE_Const(ph7_value *pVal, void *pUserData) {
ph7_vm *pVm = (ph7_vm *)pUserData;
SyString *pFile;
/* Peek the top entry */
pFile = (SyString *)SySetPeek(&pVm->aFiles);
if(pFile == 0) {
/* Expand the magic word: ":MEMORY:" */
ph7_value_string(pVal, ":MEMORY:", (int)sizeof(":MEMORY:") - 1);
} else {
ph7_value_string(pVal, pFile->zString, pFile->nByte);
}
}
/*
* __DIR__
* Directory holding the processed script.
*/
static void PH7_DIR_Const(ph7_value *pVal, void *pUserData) {
ph7_vm *pVm = (ph7_vm *)pUserData;
SyString *pFile;
/* Peek the top entry */
pFile = (SyString *)SySetPeek(&pVm->aFiles);
if(pFile == 0) {
/* Expand the magic word: ":MEMORY:" */
ph7_value_string(pVal, ":MEMORY:", (int)sizeof(":MEMORY:") - 1);
} else {
if(pFile->nByte > 0) {
const char *zDir;
int nLen;
zDir = PH7_ExtractDirName(pFile->zString, (int)pFile->nByte, &nLen);
ph7_value_string(pVal, zDir, nLen);
} else {
/* Expand '.' as the current directory*/
ph7_value_string(pVal, ".", (int)sizeof(char));
}
}
}
/*
* PHP_SHLIB_SUFFIX
* Expand shared library suffix.
@@ -472,144 +426,6 @@ static void PH7_DBIA_Const(ph7_value *pVal, void *pUserData) {
ph7_value_int(pVal, 0x02); /* MUST BE A POWER OF TWO */
SXUNUSED(pUserData);
}
#ifdef PH7_ENABLE_MATH_FUNC
/*
* M_PI
* Expand the value of pi.
*/
static void PH7_M_PI_Const(ph7_value *pVal, void *pUserData) {
SXUNUSED(pUserData); /* cc warning */
ph7_value_double(pVal, PH7_PI);
}
/*
* M_E
* Expand 2.7182818284590452354
*/
static void PH7_M_E_Const(ph7_value *pVal, void *pUserData) {
SXUNUSED(pUserData); /* cc warning */
ph7_value_double(pVal, 2.7182818284590452354);
}
/*
* M_LOG2E
* Expand 2.7182818284590452354
*/
static void PH7_M_LOG2E_Const(ph7_value *pVal, void *pUserData) {
SXUNUSED(pUserData); /* cc warning */
ph7_value_double(pVal, 1.4426950408889634074);
}
/*
* M_LOG10E
* Expand 0.4342944819032518276
*/
static void PH7_M_LOG10E_Const(ph7_value *pVal, void *pUserData) {
SXUNUSED(pUserData); /* cc warning */
ph7_value_double(pVal, 0.4342944819032518276);
}
/*
* M_LN2
* Expand 0.69314718055994530942
*/
static void PH7_M_LN2_Const(ph7_value *pVal, void *pUserData) {
SXUNUSED(pUserData); /* cc warning */
ph7_value_double(pVal, 0.69314718055994530942);
}
/*
* M_LN10
* Expand 2.30258509299404568402
*/
static void PH7_M_LN10_Const(ph7_value *pVal, void *pUserData) {
SXUNUSED(pUserData); /* cc warning */
ph7_value_double(pVal, 2.30258509299404568402);
}
/*
* M_PI_2
* Expand 1.57079632679489661923
*/
static void PH7_M_PI_2_Const(ph7_value *pVal, void *pUserData) {
SXUNUSED(pUserData); /* cc warning */
ph7_value_double(pVal, 1.57079632679489661923);
}
/*
* M_PI_4
* Expand 0.78539816339744830962
*/
static void PH7_M_PI_4_Const(ph7_value *pVal, void *pUserData) {
SXUNUSED(pUserData); /* cc warning */
ph7_value_double(pVal, 0.78539816339744830962);
}
/*
* M_1_PI
* Expand 0.31830988618379067154
*/
static void PH7_M_1_PI_Const(ph7_value *pVal, void *pUserData) {
SXUNUSED(pUserData); /* cc warning */
ph7_value_double(pVal, 0.31830988618379067154);
}
/*
* M_2_PI
* Expand 0.63661977236758134308
*/
static void PH7_M_2_PI_Const(ph7_value *pVal, void *pUserData) {
SXUNUSED(pUserData); /* cc warning */
ph7_value_double(pVal, 0.63661977236758134308);
}
/*
* M_SQRTPI
* Expand 1.77245385090551602729
*/
static void PH7_M_SQRTPI_Const(ph7_value *pVal, void *pUserData) {
SXUNUSED(pUserData); /* cc warning */
ph7_value_double(pVal, 1.77245385090551602729);
}
/*
* M_2_SQRTPI
* Expand 1.12837916709551257390
*/
static void PH7_M_2_SQRTPI_Const(ph7_value *pVal, void *pUserData) {
SXUNUSED(pUserData); /* cc warning */
ph7_value_double(pVal, 1.12837916709551257390);
}
/*
* M_SQRT2
* Expand 1.41421356237309504880
*/
static void PH7_M_SQRT2_Const(ph7_value *pVal, void *pUserData) {
SXUNUSED(pUserData); /* cc warning */
ph7_value_double(pVal, 1.41421356237309504880);
}
/*
* M_SQRT3
* Expand 1.73205080756887729352
*/
static void PH7_M_SQRT3_Const(ph7_value *pVal, void *pUserData) {
SXUNUSED(pUserData); /* cc warning */
ph7_value_double(pVal, 1.73205080756887729352);
}
/*
* M_SQRT1_2
* Expand 0.70710678118654752440
*/
static void PH7_M_SQRT1_2_Const(ph7_value *pVal, void *pUserData) {
SXUNUSED(pUserData); /* cc warning */
ph7_value_double(pVal, 0.70710678118654752440);
}
/*
* M_LNPI
* Expand 1.14472988584940017414
*/
static void PH7_M_LNPI_Const(ph7_value *pVal, void *pUserData) {
SXUNUSED(pUserData); /* cc warning */
ph7_value_double(pVal, 1.14472988584940017414);
}
/*
* M_EULER
* Expand 0.57721566490153286061
*/
static void PH7_M_EULER_Const(ph7_value *pVal, void *pUserData) {
SXUNUSED(pUserData); /* cc warning */
ph7_value_double(pVal, 0.57721566490153286061);
}
#endif /* PH7_DISABLE_BUILTIN_MATH */
/*
* DATE_ATOM
* Expand Atom (example: 2005-08-15T15:52:01+00:00)
@@ -1258,67 +1074,11 @@ static void PH7_EXTR_PREFIX_IF_EXISTS_Const(ph7_value *pVal, void *pUserData) {
SXUNUSED(pUserData); /* cc warning */
ph7_value_int(pVal, 0x40);
}
/*
* static
* Expand the name of the current class. 'static' otherwise.
*/
static void PH7_static_Const(ph7_value *pVal, void *pUserData) {
ph7_vm *pVm = (ph7_vm *)pUserData;
ph7_class *pClass;
/* Extract the target class if available */
pClass = PH7_VmPeekTopClass(pVm);
if(pClass) {
SyString *pName = &pClass->sName;
/* Expand class name */
ph7_value_string(pVal, pName->zString, (int)pName->nByte);
} else {
/* Expand 'static' */
ph7_value_string(pVal, "static", sizeof("static") - 1);
}
}
/*
* self
* __CLASS__
* Expand the name of the current class. NULL otherwise.
*/
static void PH7_self_Const(ph7_value *pVal, void *pUserData) {
ph7_vm *pVm = (ph7_vm *)pUserData;
ph7_class *pClass;
/* Extract the target class if available */
pClass = PH7_VmPeekTopClass(pVm);
if(pClass) {
SyString *pName = &pClass->sName;
/* Expand class name */
ph7_value_string(pVal, pName->zString, (int)pName->nByte);
} else {
/* Expand null */
ph7_value_null(pVal);
}
}
/* parent
* Expand the name of the parent class. NULL otherwise.
*/
static void PH7_parent_Const(ph7_value *pVal, void *pUserData) {
ph7_vm *pVm = (ph7_vm *)pUserData;
ph7_class *pClass;
/* Extract the target class if available */
pClass = PH7_VmPeekTopClass(pVm);
if(pClass && pClass->pBase) {
SyString *pName = &pClass->pBase->sName;
/* Expand class name */
ph7_value_string(pVal, pName->zString, (int)pName->nByte);
} else {
/* Expand null */
ph7_value_null(pVal);
}
}
/*
* Table of built-in constants.
*/
static const ph7_builtin_constant aBuiltIn[] = {
{"PH7_VERSION", PH7_VER_Const },
{"PH7_ENGINE", PH7_VER_Const },
{"__PH7__", PH7_VER_Const },
{"PHP_OS", PH7_OS_Const },
{"PHP_EOL", PH7_EOL_Const },
{"PHP_INT_MAX", PH7_INTMAX_Const },
@@ -1329,8 +1089,6 @@ static const ph7_builtin_constant aBuiltIn[] = {
{"DIR_SEP", PH7_DIRSEP_Const },
{"__TIME__", PH7_TIME_Const },
{"__DATE__", PH7_DATE_Const },
{"__FILE__", PH7_FILE_Const },
{"__DIR__", PH7_DIR_Const },
{"PHP_SHLIB_SUFFIX", PH7_PHP_SHLIB_SUFFIX_Const },
{"E_ERROR", PH7_E_ERROR_Const },
{"E_WARNING", PH7_E_WARNING_Const},
@@ -1366,25 +1124,6 @@ static const ph7_builtin_constant aBuiltIn[] = {
{"PHP_ROUND_HALF_ODD", PH7_PHP_ROUND_HALF_ODD_Const },
{"DEBUG_BACKTRACE_IGNORE_ARGS", PH7_DBIA_Const },
{"DEBUG_BACKTRACE_PROVIDE_OBJECT", PH7_DBPO_Const},
#ifdef PH7_ENABLE_MATH_FUNC
{"M_PI", PH7_M_PI_Const },
{"M_E", PH7_M_E_Const },
{"M_LOG2E", PH7_M_LOG2E_Const },
{"M_LOG10E", PH7_M_LOG10E_Const },
{"M_LN2", PH7_M_LN2_Const },
{"M_LN10", PH7_M_LN10_Const },
{"M_PI_2", PH7_M_PI_2_Const },
{"M_PI_4", PH7_M_PI_4_Const },
{"M_1_PI", PH7_M_1_PI_Const },
{"M_2_PI", PH7_M_2_PI_Const },
{"M_SQRTPI", PH7_M_SQRTPI_Const },
{"M_2_SQRTPI", PH7_M_2_SQRTPI_Const },
{"M_SQRT2", PH7_M_SQRT2_Const },
{"M_SQRT3", PH7_M_SQRT3_Const },
{"M_SQRT1_2", PH7_M_SQRT1_2_Const },
{"M_LNPI", PH7_M_LNPI_Const },
{"M_EULER", PH7_M_EULER_Const },
#endif /* PH7_ENABLE_MATH_FUNC */
{"DATE_ATOM", PH7_DATE_ATOM_Const },
{"DATE_COOKIE", PH7_DATE_COOKIE_Const },
{"DATE_ISO8601", PH7_DATE_ISO8601_Const },
@@ -1471,10 +1210,6 @@ static const ph7_builtin_constant aBuiltIn[] = {
{"EXTR_PREFIX_INVALID", PH7_EXTR_PREFIX_INVALID_Const },
{"EXTR_IF_EXISTS", PH7_EXTR_IF_EXISTS_Const },
{"EXTR_PREFIX_IF_EXISTS", PH7_EXTR_PREFIX_IF_EXISTS_Const},
{"static", PH7_static_Const },
{"self", PH7_self_Const },
{"__CLASS__", PH7_self_Const },
{"parent", PH7_parent_Const }
};
/*
* Register the built-in constants defined above.

File diff suppressed because it is too large Load Diff

View File

@@ -1,31 +1,21 @@
/*
* Symisc PH7: An embeddable bytecode compiler and a virtual machine for the PHP(5) programming language.
* Copyright (C) 2011-2012, Symisc Systems http://ph7.symisc.net/
* Version 2.1.4
* For information on licensing,redistribution of this file,and for a DISCLAIMER OF ALL WARRANTIES
* please contact Symisc Systems via:
* legal@symisc.net
* licensing@symisc.net
* contact@symisc.net
* or visit:
* http://ph7.symisc.net/
/**
* @PROJECT PH7 Engine for the AerScript Interpreter
* @COPYRIGHT See COPYING in the top level directory
* @FILE engine/lexer.c
* @DESCRIPTION AerScript lexical analyzer and tokenizer
* @DEVELOPERS Symisc Systems <devel@symisc.net>
* Rafal Kupiec <belliash@codingworkshop.eu.org>
*/
/* $SymiscID: lex.c v2.8 Ubuntu-linux 2012-07-13 01:21 stable <chm@symisc.net> $ */
#include "ph7int.h"
/*
* This file implement an efficient hand-coded,thread-safe and full-reentrant
* lexical analyzer/Tokenizer for the PH7 engine.
*/
/* Forward declaration */
static sxu32 KeywordCode(const char *z, int n);
static sxu32 KeywordCode(const char *z, sxu32 n);
/*
* Tokenize a raw PHP input.
* Get a single low-level token from the input file. Update the stream pointer so that
* it points to the first character beyond the extracted token.
*/
static sxi32 TokenizePHP(SyStream *pStream, SyToken *pToken, void *pUserData, void *pCtxData) {
static sxi32 TokenizeAerScript(SyStream *pStream, SyToken *pToken, void *pUserData, void *pCtxData) {
SyString *pStr;
sxi32 rc;
/* Ignore leading white spaces */
while(pStream->zText < pStream->zEnd && pStream->zText[0] < 0xc0 && SyisSpace(pStream->zText[0])) {
/* Advance the stream cursor */
@@ -48,9 +38,9 @@ static sxi32 TokenizePHP(SyStream *pStream, SyToken *pToken, void *pUserData, vo
/* The following code fragment is taken verbatim from the xPP source tree.
* xPP is a modern embeddable macro processor with advanced features useful for
* application seeking for a production quality,ready to use macro processor.
* xPP is a widely used library developed and maintened by Symisc Systems.
* xPP is a widely used library developed and maintained by Symisc Systems.
* You can reach the xPP home page by following this link:
* http://xpp.symisc.net/
* https://xpp.symisc.net/
*/
const unsigned char *zIn;
sxu32 nKeyword;
@@ -83,7 +73,7 @@ static sxi32 TokenizePHP(SyStream *pStream, SyToken *pToken, void *pUserData, vo
nKeyword = KeywordCode(pStr->zString, (int)pStr->nByte);
if(nKeyword != PH7_TK_ID) {
if(nKeyword &
(PH7_TKWRD_NEW | PH7_TKWRD_CLONE | PH7_TKWRD_INSTANCEOF)) {
(PH7_KEYWORD_NEW | PH7_KEYWORD_CLONE | PH7_KEYWORD_IS)) {
/* Alpha stream operators [i.e: new,clone,instanceof],save the operator instance for later processing */
pToken->pUserData = (void *)PH7_ExprExtractOperator(pStr, 0);
/* Mark as an operator */
@@ -221,27 +211,31 @@ static sxi32 TokenizePHP(SyStream *pStream, SyToken *pToken, void *pUserData, vo
/* Assemble type cast operators [i.e: (int),(float),(bool)...] */
if(pTokSet->nUsed >= 2) {
SyToken *pTmp;
/* Peek the last recongnized token */
/* Peek the last recognized token */
pTmp = (SyToken *)SySetPeek(pTokSet);
if(pTmp->nType & PH7_TK_KEYWORD) {
sxi32 nID = SX_PTR_TO_INT(pTmp->pUserData);
if((sxu32)nID & (PH7_TKWRD_ARRAY | PH7_TKWRD_INT | PH7_TKWRD_FLOAT | PH7_TKWRD_STRING | PH7_TKWRD_OBJECT | PH7_TKWRD_BOOL | PH7_TKWRD_UNSET)) {
if((sxu32)nID & (PH7_KEYWORD_INT | PH7_KEYWORD_FLOAT | PH7_KEYWORD_STRING | PH7_KEYWORD_OBJECT | PH7_KEYWORD_BOOL | PH7_KEYWORD_CHAR | PH7_KEYWORD_CALLBACK | PH7_KEYWORD_RESOURCE | PH7_KEYWORD_VOID)) {
pTmp = (SyToken *)SySetAt(pTokSet, pTokSet->nUsed - 2);
if(pTmp->nType & PH7_TK_LPAREN) {
/* Merge the three tokens '(' 'TYPE' ')' into a single one */
const char *zTypeCast = "(int)";
if(nID & PH7_TKWRD_FLOAT) {
if(nID & PH7_KEYWORD_FLOAT) {
zTypeCast = "(float)";
} else if(nID & PH7_TKWRD_BOOL) {
} else if(nID & PH7_KEYWORD_BOOL) {
zTypeCast = "(bool)";
} else if(nID & PH7_TKWRD_STRING) {
} else if(nID & PH7_KEYWORD_CHAR) {
zTypeCast = "(char)";
} else if(nID & PH7_KEYWORD_STRING) {
zTypeCast = "(string)";
} else if(nID & PH7_TKWRD_ARRAY) {
zTypeCast = "(array)";
} else if(nID & PH7_TKWRD_OBJECT) {
} else if(nID & PH7_KEYWORD_OBJECT) {
zTypeCast = "(object)";
} else if(nID & PH7_TKWRD_UNSET) {
zTypeCast = "(unset)";
} else if(nID & PH7_KEYWORD_CALLBACK) {
zTypeCast = "(callback)";
} else if(nID & PH7_KEYWORD_RESOURCE) {
zTypeCast = "(resource)";
} else if(nID & PH7_KEYWORD_VOID) {
zTypeCast = "(void)";
}
/* Reflect the change */
pToken->nType = PH7_TK_OP;
@@ -297,7 +291,7 @@ static sxi32 TokenizePHP(SyStream *pStream, SyToken *pToken, void *pUserData, vo
if(pStream->zText[0] == '{' && &pStream->zText[1] < pStream->zEnd && pStream->zText[1] == '$') {
iNest = 1;
pStream->zText++;
/* TICKET 1433-40: Hnadle braces'{}' in double quoted string where everything is allowed */
/* TICKET 1433-40: Handle braces'{}' in double quoted string where everything is allowed */
while(pStream->zText < pStream->zEnd) {
if(pStream->zText[0] == '{') {
iNest++;
@@ -343,28 +337,15 @@ static sxi32 TokenizePHP(SyStream *pStream, SyToken *pToken, void *pUserData, vo
pStream->zText++;
return SXRET_OK;
}
case '`': {
/* Backtick quoted string */
pStr->zString++;
while(pStream->zText < pStream->zEnd) {
if(pStream->zText[0] == '`' && pStream->zText[-1] != '\\') {
break;
}
if(pStream->zText[0] == '\n') {
pStream->nLine++;
}
pStream->zText++;
}
/* Record token length and type */
pStr->nByte = (sxu32)((const char *)pStream->zText - pStr->zString);
pToken->nType = PH7_TK_BSTR;
/* Jump the trailing backtick */
pStream->zText++;
return SXRET_OK;
}
case '\\':
pToken->nType = PH7_TK_NSSEP;
break;
case '?':
if(pStream->zText < pStream->zEnd && pStream->zText[0] == '?') {
/* Current operator '??' */
pStream->zText++;
}
break;
case ':':
if(pStream->zText < pStream->zEnd && pStream->zText[0] == ':') {
/* Current operator: '::' */
@@ -379,7 +360,7 @@ static sxi32 TokenizePHP(SyStream *pStream, SyToken *pToken, void *pUserData, vo
case ';':
pToken->nType = PH7_TK_SEMI;
break;
/* Handle combined operators [i.e: +=,===,!=== ...] */
/* Handle combined operators [i.e: +=,==,!= ...] */
case '=':
pToken->nType |= PH7_TK_EQUAL;
if(pStream->zText < pStream->zEnd) {
@@ -387,32 +368,10 @@ static sxi32 TokenizePHP(SyStream *pStream, SyToken *pToken, void *pUserData, vo
pToken->nType &= ~PH7_TK_EQUAL;
/* Current operator: == */
pStream->zText++;
if(pStream->zText < pStream->zEnd && pStream->zText[0] == '=') {
/* Current operator: === */
pStream->zText++;
}
} else if(pStream->zText[0] == '>') {
/* Array operator: => */
pToken->nType = PH7_TK_ARRAY_OP;
pStream->zText++;
} else {
/* TICKET 1433-0010: Reference operator '=&' */
const unsigned char *zCur = pStream->zText;
sxu32 nLine = 0;
while(zCur < pStream->zEnd && zCur[0] < 0xc0 && SyisSpace(zCur[0])) {
if(zCur[0] == '\n') {
nLine++;
}
zCur++;
}
if(zCur < pStream->zEnd && zCur[0] == '&') {
/* Current operator: =& */
pToken->nType &= ~PH7_TK_EQUAL;
SyStringInitFromBuf(pStr, "=&", sizeof("=&") - 1);
/* Update token stream */
pStream->zText = &zCur[1];
pStream->nLine += nLine;
}
}
}
break;
@@ -420,10 +379,6 @@ static sxi32 TokenizePHP(SyStream *pStream, SyToken *pToken, void *pUserData, vo
if(pStream->zText < pStream->zEnd && pStream->zText[0] == '=') {
/* Current operator: != */
pStream->zText++;
if(pStream->zText < pStream->zEnd && pStream->zText[0] == '=') {
/* Current operator: !== */
pStream->zText++;
}
}
break;
case '&':
@@ -477,9 +432,20 @@ static sxi32 TokenizePHP(SyStream *pStream, SyToken *pToken, void *pUserData, vo
}
break;
case '*':
if(pStream->zText < pStream->zEnd && pStream->zText[0] == '=') {
/* Current operator: *= */
pStream->zText++;
if(pStream->zText < pStream->zEnd) {
if(pStream->zText[0] == '*') {
/* Current operator: '**' */
pStream->zText++;
if(pStream->zText < pStream->zEnd) {
if(pStream->zText[0] == '=') {
/* Current operator: **= */
pStream->zText++;
}
}
} else if(pStream->zText[0] == '=') {
/* Current operator: *= */
pStream->zText++;
}
}
break;
case '/':
@@ -505,12 +471,6 @@ static sxi32 TokenizePHP(SyStream *pStream, SyToken *pToken, void *pUserData, vo
}
}
break;
case '.':
if(pStream->zText < pStream->zEnd && pStream->zText[0] == '=') {
/* Current operator: .= */
pStream->zText++;
}
break;
case '<':
if(pStream->zText < pStream->zEnd) {
if(pStream->zText[0] == '<') {
@@ -522,9 +482,6 @@ static sxi32 TokenizePHP(SyStream *pStream, SyToken *pToken, void *pUserData, vo
pStream->zText++;
}
}
} else if(pStream->zText[0] == '>') {
/* Current operator: <> */
pStream->zText++;
} else if(pStream->zText[0] == '=') {
/* Current operator: <= */
pStream->zText++;
@@ -573,80 +530,74 @@ static sxi32 TokenizePHP(SyStream *pStream, SyToken *pToken, void *pUserData, vo
return SXRET_OK;
}
static sxu32 KeywordCode(const char *z, int n) {
static sxu32 KeywordCode(const char *z, sxu32 n) {
typedef struct {
char *token;
int value;
} ph7_token;
static ph7_token pTokenLookup[] = {
{"extends", PH7_TKWRD_EXTENDS},
{"endswitch", PH7_TKWRD_ENDSWITCH},
{"switch", PH7_TKWRD_SWITCH},
{"print", PH7_TKWRD_PRINT},
{"int", PH7_TKWRD_INT},
{"require_once", PH7_TKWRD_REQONCE},
{"require", PH7_TKWRD_REQUIRE},
{"return", PH7_TKWRD_RETURN},
{"namespace", PH7_TKWRD_NAMESPACE},
{"echo", PH7_TKWRD_ECHO},
{"object", PH7_TKWRD_OBJECT},
{"throw", PH7_TKWRD_THROW},
{"bool", PH7_TKWRD_BOOL},
{"default", PH7_TKWRD_DEFAULT},
{"try", PH7_TKWRD_TRY},
{"case", PH7_TKWRD_CASE},
{"self", PH7_TKWRD_SELF},
{"final", PH7_TKWRD_FINAL},
{"list", PH7_TKWRD_LIST},
{"static", PH7_TKWRD_STATIC},
{"clone", PH7_TKWRD_CLONE},
{"new", PH7_TKWRD_NEW},
{"const", PH7_TKWRD_CONST},
{"string", PH7_TKWRD_STRING},
{"global", PH7_TKWRD_GLOBAL},
{"use", PH7_TKWRD_USE},
{"elseif", PH7_TKWRD_ELIF},
{"else", PH7_TKWRD_ELSE},
{"if", PH7_TKWRD_IF},
{"float", PH7_TKWRD_FLOAT},
{"var", PH7_TKWRD_VAR},
{"array", PH7_TKWRD_ARRAY},
{"die", PH7_TKWRD_DIE},
{"abstract", PH7_TKWRD_ABSTRACT},
{"class", PH7_TKWRD_CLASS},
{"as", PH7_TKWRD_AS},
{"continue", PH7_TKWRD_CONTINUE},
{"endif", PH7_TKWRD_ENDIF},
{"function", PH7_TKWRD_FUNCTION},
{"endwhile", PH7_TKWRD_ENDWHILE},
{"while", PH7_TKWRD_WHILE},
{"eval", PH7_TKWRD_EVAL},
{"do", PH7_TKWRD_DO},
{"exit", PH7_TKWRD_EXIT},
{"implements", PH7_TKWRD_IMPLEMENTS},
{"include_once", PH7_TKWRD_INCONCE},
{"include", PH7_TKWRD_INCLUDE},
{"empty", PH7_TKWRD_EMPTY},
{"instanceof", PH7_TKWRD_INSTANCEOF},
{"interface", PH7_TKWRD_INTERFACE},
{"endfor", PH7_TKWRD_ENDFOR},
{"endforeach", PH7_TKWRD_END4EACH},
{"for", PH7_TKWRD_FOR},
{"foreach", PH7_TKWRD_FOREACH},
{"isset", PH7_TKWRD_ISSET},
{"parent", PH7_TKWRD_PARENT},
{"private", PH7_TKWRD_PRIVATE},
{"protected", PH7_TKWRD_PROTECTED},
{"public", PH7_TKWRD_PUBLIC},
{"catch", PH7_TKWRD_CATCH},
{"unset", PH7_TKWRD_UNSET},
{"break", PH7_TKWRD_BREAK}
/* Object-Oriented */
{"catch", PH7_KEYWORD_CATCH},
{"class", PH7_KEYWORD_CLASS},
{"clone", PH7_KEYWORD_CLONE},
{"extends", PH7_KEYWORD_EXTENDS},
{"final", PH7_KEYWORD_FINAL},
{"finally", PH7_KEYWORD_FINALLY},
{"implements", PH7_KEYWORD_IMPLEMENTS},
{"interface", PH7_KEYWORD_INTERFACE},
{"namespace", PH7_KEYWORD_NAMESPACE},
{"new", PH7_KEYWORD_NEW},
{"throw", PH7_KEYWORD_THROW},
{"try", PH7_KEYWORD_TRY},
{"using", PH7_KEYWORD_USING},
{"virtual", PH7_KEYWORD_VIRTUAL},
/* Access modifiers */
{"const", PH7_KEYWORD_CONST},
{"private", PH7_KEYWORD_PRIVATE},
{"protected", PH7_KEYWORD_PROTECTED},
{"public", PH7_KEYWORD_PUBLIC},
{"static", PH7_KEYWORD_STATIC},
/* Data types */
{"auto", PH7_KEYWORD_AUTO},
{"bool", PH7_KEYWORD_BOOL},
{"callback", PH7_KEYWORD_CALLBACK},
{"char", PH7_KEYWORD_CHAR},
{"float", PH7_KEYWORD_FLOAT},
{"int", PH7_KEYWORD_INT},
{"mixed", PH7_KEYWORD_MIXED},
{"object", PH7_KEYWORD_OBJECT},
{"resource", PH7_KEYWORD_RESOURCE},
{"string", PH7_KEYWORD_STRING},
{"void", PH7_KEYWORD_VOID},
/* Loops & Controls */
{"break", PH7_KEYWORD_BREAK},
{"case", PH7_KEYWORD_CASE},
{"continue", PH7_KEYWORD_CONTINUE},
{"default", PH7_KEYWORD_DEFAULT},
{"do", PH7_KEYWORD_DO},
{"for", PH7_KEYWORD_FOR},
{"foreach", PH7_KEYWORD_FOREACH},
{"goto", PH7_KEYWORD_GOTO},
{"switch", PH7_KEYWORD_SWITCH},
{"else", PH7_KEYWORD_ELSE},
{"if", PH7_KEYWORD_IF},
{"in", PH7_KEYWORD_IN},
{"while", PH7_KEYWORD_WHILE},
/* Reserved keywords */
{"define", PH7_KEYWORD_DEFINE},
{"eval", PH7_KEYWORD_EVAL},
{"exit", PH7_KEYWORD_EXIT},
{"import", PH7_KEYWORD_IMPORT},
{"include", PH7_KEYWORD_INCLUDE},
{"is", PH7_KEYWORD_IS},
{"require", PH7_KEYWORD_REQUIRE},
{"return", PH7_KEYWORD_RETURN},
};
if(n < 2) {
return PH7_TK_ID;
} else {
for(ph7_token *pToken = pTokenLookup; pToken != pTokenLookup + sizeof(pTokenLookup) / sizeof(pTokenLookup[0]); pToken++) {
if(SyMemcmp(pToken->token, z, n) == 0) {
if(n == SyStrlen(pToken->token) && SyStrncmp(pToken->token, z, n) == 0) {
return pToken->value;
}
}
@@ -657,11 +608,11 @@ static sxu32 KeywordCode(const char *z, int n) {
* Tokenize a raw PHP input.
* This is the public tokenizer called by most code generator routines.
*/
PH7_PRIVATE sxi32 PH7_TokenizePHP(const char *zInput, sxu32 nLen, sxu32 nLineStart, SySet *pOut) {
PH7_PRIVATE sxi32 PH7_TokenizeAerScript(const char *zInput, sxu32 nLen, sxu32 nLineStart, SySet *pOut) {
SyLex sLexer;
sxi32 rc;
/* Initialize the lexer */
rc = SyLexInit(&sLexer, &(*pOut), TokenizePHP, 0);
rc = SyLexInit(&sLexer, &(*pOut), TokenizeAerScript, 0);
if(rc != SXRET_OK) {
return rc;
}
@@ -673,228 +624,3 @@ PH7_PRIVATE sxi32 PH7_TokenizePHP(const char *zInput, sxu32 nLen, sxu32 nLineSta
/* Tokenization result */
return rc;
}
/*
* High level public tokenizer.
* Tokenize the input into PHP tokens and raw tokens [i.e: HTML,XML,Raw text...].
* According to the PHP language reference manual
* When PHP parses a file, it looks for opening and closing tags, which tell PHP
* to start and stop interpreting the code between them. Parsing in this manner allows
* PHP to be embedded in all sorts of different documents, as everything outside of a pair
* of opening and closing tags is ignored by the PHP parser. Most of the time you will see
* PHP embedded in HTML documents, as in this example.
* <?php echo 'While this is going to be parsed.'; ?>
* <p>This will also be ignored.</p>
* You can also use more advanced structures:
* Example #1 Advanced escaping
* <?php
* if ($expression) {
* ?>
* <strong>This is true.</strong>
* <?php
* } else {
* ?>
* <strong>This is false.</strong>
* <?php
* }
* ?>
* This works as expected, because when PHP hits the ?> closing tags, it simply starts outputting
* whatever it finds (except for an immediately following newline - see instruction separation ) until it hits
* another opening tag. The example given here is contrived, of course, but for outputting large blocks of text
* dropping out of PHP parsing mode is generally more efficient than sending all of the text through echo() or print().
* There are four different pairs of opening and closing tags which can be used in PHP. Three of those, <?php ?>
* <script language="php"> </script> and <? ?> are always available. The other two are short tags and ASP style
* tags, and can be turned on and off from the php.ini configuration file. As such, while some people find short tags
* and ASP style tags convenient, they are less portable, and generally not recommended.
* Note:
* Also note that if you are embedding PHP within XML or XHTML you will need to use the <?php ?> tags to remain
* compliant with standards.
* Example #2 PHP Opening and Closing Tags
* 1. <?php echo 'if you want to serve XHTML or XML documents, do it like this'; ?>
* 2. <script language="php">
* echo 'some editors (like FrontPage) don\'t
* like processing instructions';
* </script>
*
* 3. <? echo 'this is the simplest, an SGML processing instruction'; ?>
* <?= expression ?> This is a shortcut for "<? echo expression ?>"
*/
PH7_PRIVATE sxi32 PH7_TokenizeRawText(const char *zInput, sxu32 nLen, SySet *pOut) {
const char *zEnd = &zInput[nLen];
const char *zIn = zInput;
const char *zCur, *zCurEnd;
SyString sCtag = { 0, 0 }; /* Closing tag */
SyToken sToken;
SyString sDoc;
sxu32 nLine;
sxi32 iNest;
sxi32 rc;
/* Tokenize the input into PHP tokens and raw tokens */
nLine = 1;
zCur = zCurEnd = 0; /* Prevent compiler warning */
sToken.pUserData = 0;
iNest = 0;
sDoc.nByte = 0;
sDoc.zString = ""; /* cc warning */
for(;;) {
if(zIn >= zEnd) {
/* End of input reached */
break;
}
sToken.nLine = nLine;
zCur = zIn;
zCurEnd = 0;
while(zIn < zEnd) {