Commit Graph

237 Commits

Author SHA1 Message Date
Stephen Chung
cb6171ebcd Merge branch 'constants' 2020-03-14 14:33:56 +08:00
Stephen Chung
b3a22d942a Allow AST optimization based on external Scope. 2020-03-14 14:30:44 +08:00
Stephen Chung
d5adee2209 Allow chained assignments. 2020-03-14 11:51:45 +08:00
Stephen Chung
e5ed2f4be5 Update api.rs 2020-03-13 23:09:45 +08:00
Stephen Chung
c7a6777b70
Merge branch 'master' into master 2020-03-13 18:27:53 +08:00
Stephen Chung
9844ae8665 Add constants. 2020-03-13 18:12:41 +08:00
Jarkko Kuukkanen
6c72e3c48b
Change filename to path for clarity 2020-03-13 12:07:51 +02:00
Jarkko Kuukkanen
8c1c37666d
Make every file evaluation use PathBuf instead of str 2020-03-13 11:53:14 +02:00
Stephen Chung
2a181e5aab FIX - fix minus/negative number conflict. 2020-03-13 16:54:00 +08:00
Stephen Chung
9bd66c7db3 Minor improvements to the optimizer. 2020-03-12 23:46:52 +08:00
Stephen Chung
55dcd2f0f4 Fix call_fn calls with only one argument. 2020-03-12 15:30:42 +08:00
Stephen Chung
560da5fdc6 Allow call_fn with only one parameter; consume can retain functions, eval cannot. 2020-03-12 14:54:14 +08:00
Stephen Chung
e24d3a7ade Allow overloading of script functions. 2020-03-12 13:02:13 +08:00
Stephen Chung
1765d302b9 Minor refactor. 2020-03-12 12:40:28 +08:00
Stephen Chung
66edd28fb3 Do not optimize AST for dump_ast. 2020-03-12 12:39:33 +08:00
Stephen Chung
0d1a240292 Expand range function to cover all integer types. 2020-03-12 12:32:26 +08:00
Stephen Chung
a02c0cfaa0 More optimizations. 2020-03-11 23:43:10 +08:00
Stephen Chung
952932f64c Reduce cloning. 2020-03-11 23:43:04 +08:00
Stephen Chung
7c4d22d98a Add no_function feature to disable script-defined functions. 2020-03-11 13:28:12 +08:00
Stephen Chung
047f064cd1 Add dump_ast function for debugging. 2020-03-11 11:39:15 +08:00
Stephen Chung
880bce1114 General cleanup. 2020-03-11 11:03:18 +08:00
Stephen Chung
708c285a0a Add only_i32 and only_i64 features. 2020-03-10 23:06:20 +08:00
Stephen Chung
e22aaca5c1 Make sure all tests run with all features. 2020-03-10 19:48:47 +08:00
Stephen Chung
cc772c6e2a Add no_float feature to disable floating-point. 2020-03-10 18:32:01 +08:00
Stephen Chung
52b5732bcb Add no_inidex feature to disable arrays and indexing. 2020-03-10 17:10:33 +08:00
Stephen Chung
f3bcb2a10d Simplify call_fn API, no need to pass &mut references. 2020-03-10 14:09:05 +08:00
Stephen Chung
2d80ee2f18 Refine optimizer. 2020-03-10 11:22:41 +08:00
Stephen Chung
feaad4e0da Group use of std under one root. 2020-03-10 10:07:44 +08:00
Stephen Chung
bae9946291 Allow engine to retain functions across runs. 2020-03-10 09:30:12 +08:00
Stephen Chung
55e7af7b04 Add AST optimizer. 2020-03-09 21:57:07 +08:00
Stephen Chung
c467ffd58d Comment out optimizer for successful build. 2020-03-09 21:52:43 +08:00
Stephen Chung
5b5fd162be Use ? operator in tests. 2020-03-09 21:09:53 +08:00
Stephen Chung
1ca9db4379 Fix i64.powi() to i64.pos() 2020-03-09 14:15:32 +08:00
Stephen Chung
b9d562eba4 Add standard math functions and make power functions checked. 2020-03-09 11:42:10 +08:00
Stephen Chung
e54fb54da2 Catch indexing errors at compile time. 2020-03-09 10:41:17 +08:00
Stephen Chung
01d04f717b Natively handle negative numbers in tokenizer instead of the neg() function. 2020-03-09 10:10:19 +08:00
Stephen Chung
c5b40783ef Add unchecked feature to remove arithmetic operations checking. 2020-03-08 23:14:18 +08:00
Stephen Chung
b1b25d3043 Add fallible functions support and replace most arithmetic operations with checked versions. 2020-03-08 22:47:13 +08:00
Stephen Chung
3e7adc2e51 More comments in code. 2020-03-08 19:54:02 +08:00
Stephen Chung
daa581bac7 Add append to strings. 2020-03-08 09:19:04 +08:00
Stephen Chung
a264abffa4 Allow arbitrary number of indexing in dot getter chain. 2020-03-07 23:57:01 +08:00
Stephen Chung
eed7bef974 Allow chaining of indexing (one level) and dotting. 2020-03-07 22:50:46 +08:00
Stephen Chung
df6950f8f7 Fix arrayindexed property access. 2020-03-07 20:55:03 +08:00
Stephen Chung
d055638e83 Properly detect invalid assignment LHS at compile time. 2020-03-07 17:32:15 +08:00
Stephen Chung
a8be700b9f Simplify op-assignment. 2020-03-07 13:39:28 +08:00
Stephen Chung
22cb69a16b Allow block expressions. 2020-03-07 10:39:00 +08:00
Stephen Chung
473e40e8a4 Catch more invalid LHS for assignments. 2020-03-07 10:16:20 +08:00
Stephen Chung
024133ae2d Avoid string copying. 2020-03-07 10:15:42 +08:00
Stephen Chung
ea82ee81d6 Fix call_fn to take &ast instead of ast. 2020-03-07 00:29:45 +08:00
Stephen Chung
c917aa0a5a Code cleanup. 2020-03-06 23:49:52 +08:00
Stephen Chung
d2296ab33b Allow dot operator on function results; change debug print info for function registration. 2020-03-06 21:08:51 +08:00
Stephen Chung
07e396b3f5 Allow chaining of array indexing operations. 2020-03-06 10:50:52 +08:00
Stephen Chung
d8ec7ed141 Rephrase error messages. 2020-03-06 10:50:20 +08:00
Stephen Chung
c7801e1d7e Fix off-by-one error message on indexing. 2020-03-06 09:55:00 +08:00
Stephen Chung
3d3b939ba6 Simplify code, document logic, refactor and better error messages. 2020-03-06 01:05:02 +08:00
Stephen Chung
883f08c026 Enable more indexing expressions. 2020-03-05 20:28:03 +08:00
Stephen Chung
c9395049e2 Remove no-std feature and rename stdlib to no_stdlib. 2020-03-05 10:18:46 +08:00
Stephen Chung
347f6d607a Add no-std and stdlib features. 2020-03-04 23:44:32 +08:00
Stephen Chung
ba2aac4960 General code cleanup. 2020-03-04 23:06:05 +08:00
Stephen Chung
bb56a7a843 Code refactor, bug fixes, code docs. 2020-03-04 22:00:01 +08:00
Stephen Chung
b4d56accd4 Reverse commit fa13588f69. Limit input script size not meaningful. 2020-03-04 09:33:35 +08:00
Stephen Chung
b421c8ac50 Minor refactor. 2020-03-03 23:31:29 +08:00
Stephen Chung
3af421ae5f Fix problems with script-defined functions. 2020-03-03 23:31:16 +08:00
Stephen Chung
01bee6e16e Accept up to 20 parameters in functions. 2020-03-03 23:17:42 +08:00
Stephen Chung
71a3c79915 Fix number parsing. 2020-03-03 21:39:25 +08:00
Stephen Chung
9f80bf03c4 Add throw. 2020-03-03 18:15:20 +08:00
Stephen Chung
e2cb111e4b Add type_of function. 2020-03-03 17:28:38 +08:00
Stephen Chung
71ec23e621 Minor code refactoring. 2020-03-03 16:24:03 +08:00
Stephen Chung
95d0b2e620 Better error messages for function definitions. 2020-03-03 16:23:55 +08:00
Stephen Chung
a1591ae45b Better API for Scope. 2020-03-03 15:20:20 +08:00
Stephen Chung
fa13588f69 Limit script size to avoid overflowing positions. 2020-03-03 13:30:46 +08:00
Stephen Chung
366188234b Pretty-print common type names. 2020-03-02 23:16:19 +08:00
Stephen Chung
a4a9102fc5 Add remaining integer types. 2020-03-02 22:32:08 +08:00
Stephen Chung
0e96e1080c Comprehensive error line number/character position during evaluation. 2020-03-02 22:13:14 +08:00
Stephen Chung
0707fad1ca Refactor tests. 2020-03-02 22:11:56 +08:00
Stephen Chung
ed8d2ac20f Add else if control flow. 2020-03-02 17:04:56 +08:00
Stephen Chung
cc87214750 Simplify code. 2020-03-02 17:04:45 +08:00
Stephen Chung
103c62fb43 Include io::Error in file API's. 2020-03-02 16:29:50 +08:00
Stephen Chung
adaa65f953 Allow script functions to override built-in functions. 2020-03-02 15:19:41 +08:00
Stephen Chung
a5e09295f8 Allow comparisons between different types (returning false). 2020-03-02 14:28:42 +08:00
Stephen Chung
22a505b57b Short-curcuit boolean operators. 2020-03-02 12:08:03 +08:00
Stephen Chung
bedfe55005 Minor code refactoring. 2020-03-02 00:11:00 +08:00
Stephen Chung
a64b01692b Use impl Fn style. 2020-03-01 19:26:57 +08:00
Stephen Chung
b152ed88f0 Move built-in functions into separate module. 2020-03-01 17:37:47 +08:00
Stephen Chung
e93fd7d3fe Properly handle char types. 2020-03-01 13:30:22 +08:00
Stephen Chung
5f135353c0 Change precedence to i8. 2020-02-29 21:18:48 +08:00
Stephen Chung
17f0001b11 Fix string handling - error for unterminated strings. 2020-02-29 21:10:31 +08:00
Stephen Chung
4b3cf95871 Simplify position handling. 2020-02-29 20:12:10 +08:00
Stephen Chung
c9daab3754 Simplify code by removing redirections. 2020-02-29 17:10:51 +08:00
Stephen Chung
8723eedca9 Rename RegisterBoxFn to RegisterDynamicFn. 2020-02-28 23:38:39 +08:00
Stephen Chung
8128c0cf24 Add pad and truncate array functions. 2020-02-25 16:23:59 +08:00
Stephen Chung
80a9abada6 Introduce to_int and to_float conersion functions. 2020-02-25 15:02:50 +08:00
Stephen Chung
51abc4a2c1 Simplify API by introducing the Dynamic and Array type aliases. 2020-02-25 15:02:27 +08:00
Stephen Chung
60a7d51537 Allow override of print and debug. 2020-02-25 10:40:48 +08:00
Stephen Chung
e4e471fd20 Add line/position in compilation errors; Add compile to AST; FIx infinite loop in close parens. 2020-02-24 23:25:52 +08:00
Stephen Chung
b3247204c6 Include filename in ErrorCantOpenScriptFile. 2020-02-24 11:06:33 +08:00
Stephen Chung
157aa2be94 Add for statement and range function; New register_box_fn for functions returning Box<dyn Any> (which should not be boxed again); Register standard utility functions in library (e.g. print, string concat). 2020-02-23 22:48:46 +08:00
Stephen Chung
b2747b076e Add bouncs check to array index access. 2020-02-23 14:09:40 +08:00
Stephen Chung
829621a3d4 Trap array out-of-bound index access error. 2020-02-23 13:59:50 +08:00
timfish
4217e96d19 Remove unused enums and simplify test assertions 2019-10-09 12:06:32 +01:00