Commit Graph

393 Commits

Author SHA1 Message Date
Stephen Chung
612ecc4ebc Move StaticVec definition to lib.rs. 2020-10-10 13:41:55 +08:00
Stephen Chung
7ede299aae Allow expressions in constants. 2020-10-09 11:15:25 +08:00
Stephen Chung
1272eeb81a Add/remove #[inline] attributes. 2020-10-08 22:25:50 +08:00
Stephen Chung
b2d603ec06 Refine Add/AddAssign for AST and Module. 2020-10-07 23:25:08 +08:00
Stephen Chung
d7bfe13b3e Add convenient functions and operators for Module and module resolvers. 2020-10-07 15:40:36 +08:00
Stephen Chung
1523981e4e Add AST::combine and AST::combine_filtered. 2020-10-07 12:11:25 +08:00
Stephen Chung
ae1157a140 Remove Expr::get_constant_str and change Expr::get_constant_value not to panic. 2020-10-06 22:09:26 +08:00
Stephen Chung
1e13e6be5f Doc formatting. 2020-10-03 18:49:11 +08:00
Stephen Chung
a72f70846f Make merged namespace more efficient. 2020-10-02 23:14:33 +08:00
Stephen Chung
08ca90a136 Use ImmutableString for import alias. 2020-10-02 18:52:18 +08:00
Stephen Chung
e8d5f78f88 Simplify code. 2020-10-01 23:31:27 +08:00
Stephen Chung
03dce86328 Support Dynamic as function default return value. 2020-09-26 16:27:38 +08:00
Stephen Chung
c4ec93080e New FileModuleResolver. 2020-09-24 22:50:28 +08:00
Stephen Chung
b8aeaa84de Add functions to iterate script function definitions. 2020-09-24 16:10:25 +08:00
J Henry Waugh
c8dffff515 Fix clippy::perf lint errors 2020-09-20 13:07:46 -05:00
Stephen Chung
d1ab9a2848 Fix bug on unary function hashes. 2020-09-11 22:09:09 +08:00
Stephen Chung
a72f797da1 Merge branch 'plugins' into plugins_dev 2020-08-23 17:54:37 +08:00
Stephen Chung
7cd345b128 Fix bug in closure capture for no_object. 2020-08-23 17:46:39 +08:00
Stephen Chung
3042e3d9db Merge branch 'master' into plugins_dev 2020-08-22 22:51:41 +08:00
Stephen Chung
0ece75aba3 Allow module access in closures. 2020-08-22 22:44:24 +08:00
Stephen Chung
0b04d05afe Do not parse closures when allow_anonymous_fn is false. 2020-08-22 11:08:27 +08:00
Stephen Chung
08977e2a62 Use combine_flatten for plugin modules. 2020-08-21 21:48:45 +08:00
Stephen Chung
564d3bc339 Add more closure tests. 2020-08-09 22:12:50 +08:00
Ilya Lakhin
39ee74112c no-closure feature issue fixed 2020-08-09 18:42:33 +07:00
Ilya Lakhin
20cff87e14 False-positive capturing prevention bug fix 2020-08-09 18:35:29 +07:00
Stephen Chung
da3cce58d3 Minor refactor. 2020-08-08 22:59:05 +08:00
Ilya Lakhin
45d021c7ef Function names capturing as external variables bug 2020-08-08 17:55:58 +07:00
Stephen Chung
ffe52bf437 Allow omitting the alias in import statement. 2020-08-05 23:23:53 +08:00
Stephen Chung
ae11dbbefe Fix feature flags. 2020-08-05 22:53:01 +08:00
Stephen Chung
2aa08c0dd9 get_constant_value for FnPointer. 2020-08-03 23:12:42 +08:00
Stephen Chung
4079164bfd Implement closures. 2020-08-03 12:10:20 +08:00
Stephen Chung
60891e694f Streamline code and feature gates. 2020-07-31 22:30:23 +08:00
Ilya Lakhin
89f75bbf0c Merge remote-tracking branch 'schungx/closures' into closures 2020-07-31 13:05:16 +07:00
Ilya Lakhin
060dd33046 Shared Dynamic tests and fixes in Engine; Also fixed a bug in Parser variable capturing 2020-07-31 10:47:22 +07:00
Ilya Lakhin
aa87a7f5ef Fixes in Engine to properly interpret Shared Dynamic 2020-07-31 10:47:22 +07:00
Stephen Chung
a7ff207636 Use Scope::flatten_clone for capturing. 2020-07-30 23:29:30 +08:00
Stephen Chung
98b294c699 Implement capturing. 2020-07-30 18:18:28 +08:00
Stephen Chung
691e04292f Put externals in ScriptFnDef. 2020-07-30 13:28:06 +08:00
Stephen Chung
721c578407 Use HashMap for externals. 2020-07-29 23:34:48 +08:00
Stephen Chung
1465ba2315 Refactor auto-currying. 2020-07-29 22:43:50 +08:00
Stephen Chung
a5a3bbd399
Merge pull request #19 from Eliah-Lakhin/closures
Autocurry feature
2020-07-29 21:24:43 +08:00
Ilya Lakhin
8fc16b40e6 Code style issues fixed 2020-07-29 20:17:18 +07:00
Ilya Lakhin
a856a8bbcb max_expr_depth bug fix 2020-07-29 19:04:33 +07:00
Ilya Lakhin
48356abc83 Autocurry fixes and test 2020-07-29 18:52:54 +07:00
Ilya Lakhin
8e51988b66 A prototype of a new feature to automatically curry of external scope variables 2020-07-29 16:56:32 +07:00
Stephen Chung
afbcd0fc0b Replace StaticVec with SmallVec. 2020-07-29 16:10:06 +08:00
Stephen Chung
b63ff56e09 Make sure we keep the starting position of each statement (for future uses). 2020-07-28 10:26:20 +08:00
Stephen Chung
a3a167424b Allow Rust functions in FnPtr::call_dynamic. 2020-07-27 12:52:32 +08:00
Stephen Chung
ec5082c328 Better handling of reserved keywords. 2020-07-26 22:25:30 +08:00
Stephen Chung
6b600704a3 Avoid warnings. 2020-07-26 15:53:22 +08:00
Stephen Chung
c825de6f77 Mark internal data structures with [INTERNALS]. 2020-07-25 16:05:08 +08:00
Stephen Chung
284e58e8a1 Improve documentation on internal types. 2020-07-25 15:52:27 +08:00
Stephen Chung
a58207aaa9 Change ScriptFnDef to use ImmutableString. 2020-07-25 14:06:13 +08:00
Stephen Chung
abf66850f6 Enable custom syntax without internals. 2020-07-22 17:05:13 +08:00
Stephen Chung
e6c3f8134d Avoid copying property name for map property access. 2020-07-21 20:59:12 +08:00
Stephen Chung
a5fa8322e9 Avoid pulling in std for no-std. 2020-07-20 20:23:35 +08:00
Stephen Chung
cf36dc5a57 Support for anonymous functions. 2020-07-19 17:14:55 +08:00
Stephen Chung
2f33edb762 FIx no_std. 2020-07-19 09:10:22 +08:00
Stephen Chung
3ae7cf4018 Improve treatment of disabled symbols and custom symbols. 2020-07-17 14:50:23 +08:00
Stephen Chung
d119e13b79 Allow binding of this pointer in FnPtr calls. 2020-07-17 10:18:07 +08:00
Stephen Chung
16fbfbb606 Enable call in function-call style. 2020-07-16 12:09:31 +08:00
Stephen Chung
2a8d63fd5f Refine custom syntax. 2020-07-11 15:09:17 +08:00
Stephen Chung
ebffbf0f98 Refine docs and add custom syntax. 2020-07-10 22:01:47 +08:00
Stephen Chung
99164ebceb Add custom syntax. 2020-07-09 19:54:28 +08:00
Stephen Chung
2b3f10f2c5 Define functions anywhere during parsing. 2020-07-06 22:57:50 +08:00
Stephen Chung
3e45d5d9a5 Refine docs and API. 2020-07-06 13:01:57 +08:00
Stephen Chung
ea86888638 Add new &Module parameter to native functions. 2020-07-06 12:04:02 +08:00
Stephen Chung
495d202af4 Add new AST API. 2020-07-06 10:02:54 +08:00
Stephen Chung
e390dd73e6 Add custom operators. 2020-07-05 17:41:45 +08:00
Stephen Chung
936a3ff44a Add feature to disable symbols. 2020-07-05 15:23:51 +08:00
Stephen Chung
368b4a480b Reformat code. 2020-07-04 22:53:00 +08:00
Stephen Chung
2b2deba5e0 Remove serde from default feature. 2020-07-03 22:48:33 +08:00
Stephen Chung
78c94daf46 Add ser::to_dynamic. 2020-07-03 22:42:56 +08:00
Stephen Chung
760c13d36e Fix features. 2020-07-01 22:21:43 +08:00
Stephen Chung
e614790897 Enable function pointers even under no_function. 2020-06-30 18:34:58 +08:00
Stephen Chung
d6a08be223 Refactor. 2020-06-29 23:55:28 +08:00
Stephen Chung
527d41d0e3 No modules in scope. 2020-06-28 15:49:24 +08:00
Stephen Chung
aac04a5e53 Remove modules from Scope and use separate stack. 2020-06-27 23:56:24 +08:00
Stephen Chung
175c3ccaec OOP support. 2020-06-26 10:39:18 +08:00
Stephen Chung
58c198776f Code cleanup. 2020-06-25 11:07:46 +08:00
Stephen Chung
54c5c139f9 Add internals feature. 2020-06-23 10:43:24 +08:00
Stephen Chung
7cc1a3f5dc Change Map keys to ImmutableString to facilitate fast keys(). 2020-06-21 16:37:05 +08:00
Stephen Chung
1adf3cc39a Support for trailing commas. 2020-06-16 22:14:46 +08:00
Stephen Chung
0c6a939c66 Better convert LexError to ParseError. 2020-06-14 16:56:36 +08:00
Stephen Chung
bb691a0313 Add maximum data size limits. 2020-06-14 14:25:47 +08:00
Stephen Chung
6cc27eb9f4 Better error messages. 2020-06-11 23:21:39 +08:00
Stephen Chung
d92613eaf6 Fix parse positions. 2020-06-11 23:08:00 +08:00
Stephen Chung
8f55a15ab0 Collect parse settings into struct type. 2020-06-11 22:03:47 +08:00
Stephen Chung
0ac3a7d8b4 Use type alias TokenStream. 2020-06-11 18:13:33 +08:00
Stephen Chung
56eb659d5a Unify all functions into CallableFunction type, remove FunctionsLib. 2020-06-05 15:14:42 +08:00
Stephen Chung
ec6e3daabb Refactor. 2020-06-03 10:44:36 +08:00
Stephen Chung
b8b12055b9 Disable if-expression when parsing expressions. 2020-06-01 13:26:20 +08:00
Stephen Chung
6d190096fd Fix bug with bracket postfix when no_index. 2020-06-01 13:03:01 +08:00
Stephen Chung
cec6748ac6 Remove no_module gates to prepare for plugins. 2020-06-01 10:58:14 +08:00
Stephen Chung
5f727335a6 Add type info. 2020-05-31 12:36:42 +08:00
Stephen Chung
c9de37e8d1 Hash functions only once via custom hasher. 2020-05-31 00:02:23 +08:00
Stephen Chung
acd0f6b56b != defaults to true for different parameter types. 2020-05-30 13:49:40 +08:00
Stephen Chung
2bcc51cc45 Fix bug in index expressions. 2020-05-30 10:27:48 +08:00
Stephen Chung
854634afa0 Allow native overriding implementation of assignment operators. 2020-05-27 13:22:10 +08:00
Stephen Chung
b34d5fe3a1 Complete ImmutableString. 2020-05-26 14:14:03 +08:00
Stephen Chung
95e67c48bd Optimize op-assignment statement. 2020-05-25 20:14:31 +08:00
Stephen Chung
99ea2b33c9 Use immutable strings. 2020-05-25 13:44:28 +08:00
Stephen Chung
0374311cf6 Optimize hot path of operators calling. 2020-05-24 16:40:00 +08:00
Stephen Chung
d56634cac7 Complete built-in operators. 2020-05-24 00:29:06 +08:00
Stephen Chung
b49e1e199a Build-in certain common operators. 2020-05-23 18:59:28 +08:00
Stephen Chung
e224550861 Move boxing of ParseError into ParseErrorType. 2020-05-22 18:28:13 +08:00
Stephen Chung
4a1fd66b9f Reduce Rc/Arc wrapping for functions. 2020-05-19 22:25:57 +08:00
Stephen Chung
ab76a69b12 Avoid repeating empty TypeId's when calculating hash. 2020-05-19 20:07:51 +08:00
Stephen Chung
1824dced69 Limit expression/statement nesting depths. 2020-05-18 19:32:22 +08:00
Stephen Chung
8b5550eeb6 Complete StaticVec implementation. 2020-05-17 22:19:49 +08:00
Stephen Chung
a2c50879fe Fix dropping issues with StaticVec and use it everywhere. 2020-05-17 00:24:07 +08:00
Stephen Chung
cabceb7498 Better handling of errors during function calls. 2020-05-13 21:58:38 +08:00
Stephen Chung
996a54279c Pre-calculate property getter/setter function names. 2020-05-13 10:19:18 +08:00
Stephen Chung
ec67879759 Derive more standard traits. 2020-05-12 18:48:25 +08:00
Stephen Chung
2e28967565 Fix bug with wrong method call hash. 2020-05-12 10:20:29 +08:00
Stephen Chung
33c9be7efc Reformat. 2020-05-11 23:48:50 +08:00
Stephen Chung
4a8710a4a9 Create NativeCallable trait. 2020-05-11 13:36:50 +08:00
Stephen Chung
8aa0e2ceb4 Use StaticVec to avoid most allocations with function arguments. 2020-05-10 21:25:47 +08:00
Stephen Chung
80debbc432 Refactor. 2020-05-10 00:19:13 +08:00
Stephen Chung
a7bfac21bd Reducing boxing and sizes of Expr/Stmt. 2020-05-09 21:46:38 +08:00
Stephen Chung
79f39bd702 Pre-calculate function call hashes. 2020-05-09 16:15:50 +08:00
Stephen Chung
0d20137d6c Implement private modifier for functions. 2020-05-09 11:29:30 +08:00
Stephen Chung
d1de84fdd2 Add comments and fix documentation. 2020-05-09 10:00:59 +08:00
Stephen Chung
e50fcc385f Pre-calculate index for module-qualified calls. 2020-05-08 22:38:56 +08:00
Stephen Chung
eb52bfa28a Add export statement. 2020-05-08 16:49:24 +08:00
Stephen Chung
89d75b1b11 Fix compilation errors for no_module. 2020-05-08 14:50:48 +08:00
Stephen Chung
e6fabe58cc Unify function hash calculations, pre-hash module-qualified function calls. 2020-05-08 11:34:56 +08:00
Stephen Chung
5f12391ec6 Use hashed lookup for module-qualified functions and variables. 2020-05-08 00:19:08 +08:00
Stephen Chung
f3c0609377 Catch more assignment errors at parse time. 2020-05-07 12:25:09 +08:00
Stephen Chung
e966f5d49e Fix bug with let statement without expression. 2020-05-06 22:54:34 +08:00
Stephen Chung
d75a8bc6cd Make sure all features compile correctly. 2020-05-06 19:45:17 +08:00
Stephen Chung
88fec57394 Make module_resolver optional and remove NullModuleResolver. 2020-05-06 16:09:44 +08:00
Stephen Chung
aae9e43109 Implement module-qualified functions. 2020-05-05 17:51:40 +08:00
Stephen Chung
38e717a838 Build Module type plus engine hooks. 2020-05-05 15:00:10 +08:00
Stephen Chung
c03b162b7e Refactor code base and split into more module files. 2020-05-05 12:24:13 +08:00
Stephen Chung
143861747d Rename sub-scope/SubScope to module. 2020-05-05 10:39:12 +08:00
Stephen Chung
64036f69ca Refine modules. 2020-05-04 23:07:42 +08:00
Stephen Chung
2bdd174f16 Add import statement. 2020-05-04 19:36:58 +08:00
Stephen Chung
ead9716f6d Add namespacing syntax. 2020-05-04 17:43:54 +08:00
jhwgh1968
7011e4068f Start on namespaces 2020-05-03 12:19:01 -05:00
Stephen Chung
d83b829810 Avoid copying arguments for function calls. 2020-05-03 16:54:24 +08:00
Stephen Chung
c7c7fe3dfc Reduce size of Expr and Stmt by Boxing strings. 2020-05-01 17:32:39 +08:00
Stephen Chung
21c3edb31e Streamline. 2020-04-29 16:11:54 +08:00
Stephen Chung
304c658f89 Use scope offset for variable access. 2020-04-28 23:05:03 +08:00
Stephen Chung
9ad9dd52ab Reduce unnecessary Cow's in Expr. 2020-04-28 19:39:36 +08:00
Stephen Chung
f5c7d7cd0d Reduce memory footprint of Target. 2020-04-26 19:37:32 +08:00
Stephen Chung
33d3e34908 Deep linking for dot/index chains. 2020-04-26 18:04:07 +08:00
Stephen Chung
5aaaa7be3b Simplify parsing by expecting the tokens stream will never be exhausted. 2020-04-23 13:24:24 +08:00
Stephen Chung
fbfea60903 Disallow assignments in expressions. 2020-04-22 17:37:06 +08:00
Stephen Chung
c69647d9fd Change Dynamic::from_xxx to From<xxx> impl. 2020-04-22 12:12:13 +08:00