summaryrefslogtreecommitdiffhomepage
path: root/lib/math.c
AgeCommit message (Collapse)Author
2023-07-13docs: various improvementsJo-Philipp Wich
- Switch JSDoc theme to "clean-jsdoc-theme" - Add some custom CSS and JS tweaks to the theme - Use a condensed README.md for the toplevel directory - Include a longer README.md in the documentation portal - Tweak JSDoc annotations for better output results - Register `ucode.mein.io` CNAME Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-07-12math: add JSDoc documentationJo-Philipp Wich
Add JSDoc documentation blocks to all exported math functions. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-11-29math: add isnan() functionJo-Philipp Wich
Add a new `isnan()` convenience function to the math library which can be used to test if a given value is a NaN double. The same test can be realized without the math library by using a function similar to the following one: function isNaN(x) { return x != x; } Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-01-04treewide: rework numeric value handlingJo-Philipp Wich
- Parse integer literals as unsigned numeric values in order to be able to represent the entire unsigned 64bit value range - Stop parsing minus-prefixed integer literals as negative numbers but treat them as separate minus operator followed by a positive integer instead - Only store unsigned numeric constants in bytecode - Rework numeric comparison logic to be able to handle full 64bit unsigned integers - If possible, yield unsigned 64 bit results for additions - Simplify numeric value conversion API - Compile code with -fwrapv for defined signed overflow semantics Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-07-11treewide: harmonize function namingJo-Philipp Wich
- Ensure that most functions follow the subject_verb naming schema - Move type related function from value.c to types.c - Rename value.c to vallist.c Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-07-11treewide: move header files into dedicated directoryJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-07-11treewide: consolidate typedef namingJo-Philipp Wich
Ensure that all custom typedef and vector declaration type names end with a "_t" suffix. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-07-11lib: rename uc_add_proto_functions() to uc_add_functions()Jo-Philipp Wich
The naming is an artifact from before the introduction of the new type system. In the current code, there is nothing special about prototypes, they're simple object values. Also introduce a new singular uc_add_function() convenience macro while we're at it. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-07-11treewide: move ressource type registry into vm instanceJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-04-25treewide: rework internal data type systemJo-Philipp Wich
Instead of relying on json_object values internally, use custom types to represent the different ucode value types which brings a number of advantages compared to the previous approach: - Due to the use of tagged pointers, small integer, string and bool values can be stored directly in the pointer addresses, vastly reducing required heap memory - Ability to create circular data structures such as `let o; o = { test: o };` - Ability to register custom `tostring()` function through prototypes - Initial mark/sweep GC implementation to tear down circular object graphs on VM deinit The change also paves the way for possible future extensions such as constant variables and meta methods for custom ressource types. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-02-17treewide: rewrite ucode interpreterJo-Philipp Wich
Replace the former AST walking interpreter implementation with a single pass bytecode compiler and a corresponding virtual machine. The rewrite lays the groundwork for a couple of improvements with will be subsequently implemented: - Ability to precompile ucode sources into binary byte code - Strippable debug information - Reduced runtime memory usage Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-11-19treewide: rebrand to ucodeJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-19eval: record correct source contexts in call stackJo-Philipp Wich
Also handle calls to C functions. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-11lib: move math functions to new moduleJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>