Commit Graph

371 Commits (master)

Author SHA1 Message Date
Daniel Kolesa 3f513180f1 drop prevargs in codegen
since we now have a single, contiguous, unlimited VM stack, this
does not make any sense anymore (it was a limitation of the static
array)
2021-03-28 01:28:31 +01:00
Daniel Kolesa 71f45b2f07 fix up usage of IDENT_FLAG_UNKNOWN 2021-03-28 00:38:41 +01:00
Daniel Kolesa 99f227bfd9 unify arg and non-arg opcodes 2021-03-28 00:19:51 +01:00
Daniel Kolesa d1e131dbf6 don't rely on MAX_ARGUMENTS where not necessary 2021-03-27 23:43:55 +01:00
Daniel Kolesa 54c0f2ae20 remove more dead bits 2021-03-27 00:35:20 +01:00
Daniel Kolesa a24f7c9385 remove leftover dead code 2021-03-27 00:32:27 +01:00
Daniel Kolesa a37eb25d1c move public state methods where they belong 2021-03-27 00:26:59 +01:00
Daniel Kolesa b27d4fa7e6 make p_tstate actually private 2021-03-26 03:05:14 +01:00
Daniel Kolesa bd9a6cbf7c eliminate more future private accesses 2021-03-26 02:59:42 +01:00
Daniel Kolesa 0b2c4c7038 pass thread_state in more places 2021-03-26 02:29:54 +01:00
Daniel Kolesa c854e9d189 move the owner tag inside 2021-03-25 01:55:47 +01:00
Daniel Kolesa 468c3a07d4 get rid of some indirections 2021-03-25 01:52:03 +01:00
Daniel Kolesa d80af7b159 hide internal_state from public state struct 2021-03-25 01:37:42 +01:00
Daniel Kolesa 14cd90116d use the value stack in more places 2021-03-24 23:30:30 +01:00
Daniel Kolesa 4e8c3ee40f move the VM stack off the real stack + std cleanups 2021-03-24 22:38:29 +01:00
Daniel Kolesa 3d37ea22c3 put force_ident and force_code in any_value 2021-03-24 21:01:01 +01:00
Daniel Kolesa 00b8312ad5 move most thread state into an internal structure 2021-03-24 20:33:20 +01:00
Daniel Kolesa 4ded59ce70 launder aligned_storage pointers 2021-03-24 02:42:33 +01:00
Daniel Kolesa d774db675a separate cs_gen.hh, various refactors 2021-03-24 02:21:32 +01:00
Daniel Kolesa 21aec59ad3 rename namespace to cubescript 2021-03-23 23:32:25 +01:00
Daniel Kolesa b9b344cba6 remove cs_ namespace in all API 2021-03-23 23:29:32 +01:00
Daniel Kolesa b3b4624af1 drop cubescript.cc, move parsing stuff from cs_std to cs_parser 2021-03-23 22:17:25 +01:00
Daniel Kolesa 7139370990 move belonging stuff into cs_ident 2021-03-23 21:57:38 +01:00
Daniel Kolesa d06396f88f move more stuff into cs_state.cc 2021-03-23 21:55:19 +01:00
Daniel Kolesa 95e0da1fff move some more stuff, don't use both_libraries() in meson 2021-03-23 02:48:14 +01:00
Daniel Kolesa b5b0d0adf5 move some public state api into cs_state, separate lib_base 2021-03-23 02:43:18 +01:00
Daniel Kolesa 87e141ab36 move public ident interfaces to cs_ident.cc 2021-03-23 02:35:31 +01:00
Daniel Kolesa 4b766a380f drop the util namespace 2021-03-23 02:02:43 +01:00
Daniel Kolesa 4b6c284ea1 separate cs_parser.cc, drop cs_util.cc 2021-03-23 02:00:23 +01:00
Daniel Kolesa 68b66c0b28 move strref implementation to strman 2021-03-23 01:49:29 +01:00
Daniel Kolesa 2cc1b0e271 add cs_std.cc, drop cs_util.hh 2021-03-23 01:46:56 +01:00
Daniel Kolesa f52aeead32 eliminate the strref friend kludge 2021-03-23 01:35:04 +01:00
Daniel Kolesa 6821260c37 separate header/impl for strman 2021-03-23 01:25:47 +01:00
Daniel Kolesa 4588ae2373 separate cs_state, cs_std 2021-03-23 01:11:21 +01:00
Daniel Kolesa 702dca0809 separate ident and error impls into their own files 2021-03-22 22:33:15 +01:00
Daniel Kolesa f9a49ffba7 get rid of emptyblock 2021-03-22 22:01:49 +01:00
Daniel Kolesa 83e92e6881 ditch a bunch of reinterpret_casts 2021-03-22 21:37:13 +01:00
Daniel Kolesa 3d2f115de5 separate bytecode bits into its own file 2021-03-22 21:26:05 +01:00
Daniel Kolesa 63251f0eac add cs_callable to replace std::function
now function data can be allocated with our own allocator as
well, plus we get guarantees on small storage; this type is
move-only, and it's also more memory efficient than std::function,
at least the libstdc++ implementation
2021-03-22 01:01:51 +01:00
Daniel Kolesa f72a39f656 manage bytecode memory using the state allocator
this means *all* heap allocated memory is now handled through
the state's allocator (well, except things using std::function),
which allows for precise memory tracking and control
2021-03-21 19:23:23 +01:00
Daniel Kolesa 666f487a92 don't need full bcode_ref/unref in this case 2021-03-21 18:53:22 +01:00
Daniel Kolesa 3f866baccb strict reference counting for bytecode references 2021-03-21 18:45:59 +01:00
Daniel Kolesa 45bf6ed7ef fix crash on quit where interfaces are destroyed instead of impls 2021-03-21 06:20:56 +01:00
Daniel Kolesa a591384afd use our allocator for more buffers 2021-03-21 06:13:45 +01:00
Daniel Kolesa a5b0ce5d72 drop cs_cmd_internal 2021-03-21 03:07:11 +01:00
Daniel Kolesa 436098cc38 drop the whole cs_alias_internal nonsense 2021-03-21 02:59:37 +01:00
Daniel Kolesa f8eb07ee2b hide implementation details of idents 2021-03-21 02:47:02 +01:00
Daniel Kolesa 3905ff0e9d fix/clean up compileblockstr 2021-03-21 00:00:20 +01:00
Daniel Kolesa be71d3a4b9 rework allocator errors and error message storage buffer 2021-03-20 21:06:26 +01:00
Daniel Kolesa d7c93fa8b9 make format errors internal errors 2021-03-20 19:54:46 +01:00
Daniel Kolesa 2f3d5ea938 further clean up list parser api 2021-03-20 19:34:51 +01:00
Daniel Kolesa 82d366366e drop libostd requirement entirely 2021-03-20 08:23:51 +01:00
Daniel Kolesa cb926a5750 get rid of ostd requirements inside library entirely 2021-03-20 07:24:25 +01:00
Daniel Kolesa 68669413cc get rid of most remaining ostd usage 2021-03-20 06:52:10 +01:00
Daniel Kolesa 10b2a81cec redo (un)escape_string around output iterators 2021-03-20 06:18:31 +01:00
Daniel Kolesa 320fdbaefd use c++20 std::span 2021-03-20 05:41:25 +01:00
Daniel Kolesa 4068c96ec2 remove the auxiliary run_<type> APIs, they are fairly useless now 2021-03-20 05:14:14 +01:00
Daniel Kolesa d626fba537 remove file exec api
this is something each thing will want to do on its own...

but add a new set of calls that take code source for debug info
2021-03-20 05:10:19 +01:00
Daniel Kolesa 55d5397f4f implement move behavior for cs_value
this prevents things from going horribly wrong when people
do move the values (since the implicit implementations don't
take care of handling the refcounts)
2021-03-20 04:49:47 +01:00
Daniel Kolesa 5648c1a757 use string_view everywhere that returns or takes a string 2021-03-20 04:10:27 +01:00
Daniel Kolesa 70d7e15ed5 eliminate cs_vector/cs_map, use our allocator for all state 2021-03-19 23:05:19 +01:00
Daniel Kolesa ac1af69d96 move cs_valbuf/charbuf before cs_shared_state 2021-03-19 22:54:22 +01:00
Daniel Kolesa f41462deaf move cs_allocator out of cs_shared_state 2021-03-19 22:53:42 +01:00
Daniel Kolesa b81e419db6 get rid of cs_vector in most places 2021-03-19 22:49:52 +01:00
Daniel Kolesa 0ca8561d5d add cs_valbuf 2021-03-19 22:40:11 +01:00
Daniel Kolesa 2e725771e4 eliminate remaining cs_string 2021-03-19 22:35:39 +01:00
Daniel Kolesa fece7ce769 get rid of most remaining cs_string 2021-03-19 22:32:28 +01:00
Daniel Kolesa 4e5e0f5de8 get rid of cs_string in codegen 2021-03-19 22:25:38 +01:00
Daniel Kolesa b27f8dee91 use state's allocator to manage cs_strman resources 2021-03-19 03:10:02 +01:00
Daniel Kolesa 47b87ab936 get rid of cs_string in lib_list 2021-03-19 02:55:59 +01:00
Daniel Kolesa e74d8b5bef get rid of cs_string in lib_str 2021-03-19 02:50:48 +01:00
Daniel Kolesa 5ee7e27839 add cs_charbuf (mutable buffer controlled by our allocator)
also use it in a few places
2021-03-19 02:44:29 +01:00
Daniel Kolesa 5a4cccf194 move strref impl to cs_util 2021-03-19 02:28:30 +01:00
Daniel Kolesa 08212df80f move shared state into cs_util 2021-03-19 02:27:36 +01:00
Daniel Kolesa 126d6ab2b6 use a stolen buffer for strupper/lower 2021-03-19 01:31:34 +01:00
Daniel Kolesa b42da1e56f add custom buffer allocation into string manager 2021-03-19 01:00:11 +01:00
Daniel Kolesa af1a85fb91 get rid of public format_int/float (use cs_value) 2021-03-19 00:34:12 +01:00
Daniel Kolesa 26bcc43578 get rid of tvals_concat in favor of simpler api 2021-03-19 00:31:18 +01:00
Daniel Kolesa 64d9c0e749 make intstr/floatstr internal to cs_value 2021-03-19 00:12:47 +01:00
Daniel Kolesa b534a6d9af get rid of some unnecessary string allocs 2021-03-19 00:01:57 +01:00
Daniel Kolesa d3ec4a47dd ditch cs_string from public headers + style fix 2021-03-18 23:56:25 +01:00
Daniel Kolesa 9d0494a9da replace list_parser with a simpler api 2021-03-18 23:53:16 +01:00
Daniel Kolesa 704f9217f7 unify enum style 2021-03-18 20:55:14 +01:00
Daniel Kolesa 7023e09049 don't use memcpy for non-trivial structures 2021-03-18 01:37:38 +01:00
Daniel Kolesa 6ed9ae1235 get rid of standard i/o inside vm 2021-03-18 00:03:30 +01:00
Daniel Kolesa fb8668a508 use more stringrefs 2021-03-17 23:32:38 +01:00
Daniel Kolesa 7eaf3679a4 get rid of cs_value::get_strr 2021-03-17 21:59:37 +01:00
Daniel Kolesa 2f5bb697eb use string refs more instead of allocated strings 2021-03-17 21:46:37 +01:00
Daniel Kolesa 8b7f36319d eliminate length field in cs_value 2021-03-17 21:16:25 +01:00
Daniel Kolesa e3cff816c7 reduce copying strings around (ensure refs are not erased) 2021-03-17 21:00:19 +01:00
Daniel Kolesa 64130a12bf remove handling of constants from codegen, bytecode and cs_value
also drop move semantics on cs_value
2021-03-17 20:41:08 +01:00
Daniel Kolesa 8def7ce85c intern all strings in cs_value 2021-03-17 02:47:34 +01:00
Daniel Kolesa c004db42c6 refactor cs_value and related structures to contain state
this will allow us to intern strings inside cs_value
2021-03-17 01:26:30 +01:00
Daniel Kolesa dcae5b30b2 initial implementation of unique/interned string manager 2021-03-16 00:45:09 +01:00
Daniel Kolesa e58c69bc99 mesonize libcubescript 2018-10-28 02:56:00 +02:00
Daniel Kolesa 8805594bc2 style fixes 2018-04-27 23:53:55 +02:00
Daniel Kolesa fb78b4acdd initial support for "threads" 2018-04-26 19:23:11 +02:00
Daniel Kolesa 07666c7564 naming consistency 2018-04-25 01:49:58 +02:00
Daniel Kolesa d12e7f67ee gcc warning fixes 2017-11-06 01:07:53 +01:00
Daniel Kolesa efdc82324e fix includes 2017-06-20 21:21:39 +02:00
Daniel Kolesa d01349886a remove slice_until 2017-06-15 20:44:09 +02:00
Daniel Kolesa 8d62c09f88 fix build 2017-04-23 15:34:45 +02:00
Daniel Kolesa f0f6dc437f fix build 2017-04-17 17:13:14 +02:00
Daniel Kolesa d744c6b1c6 remove dependency on types.hh 2017-04-04 00:28:56 +02:00
Daniel Kolesa 5b1baafdb3 fixes 2017-04-01 01:06:36 +02:00
Daniel Kolesa 73d1b142d1 fixes 2017-03-31 03:34:09 +02:00
Daniel Kolesa 6b17c4594f remove slice_until 2017-03-31 03:18:26 +02:00
Daniel Kolesa 70ef1ff486 stuff 2017-03-31 03:10:36 +02:00
Daniel Kolesa 7294580ccf use range_put_all 2017-02-19 18:13:51 +01:00
Daniel Kolesa 5c2c441925 fix build 2017-02-19 16:44:16 +01:00
Daniel Kolesa 73699bd1cf use std::min, max, clamp 2017-02-18 17:49:01 +01:00
Daniel Kolesa e87b1b566c use appender_range directly 2017-02-18 17:28:43 +01:00
Daniel Kolesa 14436d6aa0 fix build 2017-02-16 20:51:03 +01:00
Daniel Kolesa 8343979e03 fix build after style update 2017-02-16 19:07:22 +01:00
Daniel Kolesa 74edc2821d fix build 2017-02-15 19:41:12 +01:00
Daniel Kolesa 3c093ce8ad compile fix 2017-02-14 18:33:45 +01:00
Daniel Kolesa 9b4ea3e765 replace removed PointerRange 2017-02-14 17:41:15 +01:00
Daniel Kolesa efe4ee523a fix build 2017-02-13 23:32:15 +01:00
Daniel Kolesa 41eb8b211f begin naming scheme rework 2017-02-13 18:11:19 +01:00
Daniel Kolesa 140ccf08c6 add cs_internal_error exception and use it for unrecoverable unlikely errors 2017-02-12 22:52:43 +01:00
Daniel Kolesa 6e67ce8574 clean up pointerrange constructor 2017-02-09 22:54:09 +01:00
Daniel Kolesa fda734a868 ostd fixes 2017-02-09 21:27:57 +01:00
Daniel Kolesa 2536179500 use standard type traits 2017-02-09 20:59:14 +01:00
Daniel Kolesa 2241bcf4b8 use std math overloads 2017-02-08 01:14:15 +01:00
Daniel Kolesa 896ab4aba2 update according to ostd 2017-02-08 01:07:35 +01:00
Daniel Kolesa 0dd69fedea remove memory.hh includes 2017-02-01 20:20:57 +01:00
Daniel Kolesa d88e9de11a use unordered_map 2017-01-31 19:28:34 +01:00
Daniel Kolesa 58bf658409 update according to ostd 2017-01-30 19:38:11 +01:00
Daniel Kolesa 8dc423dcaa update according to ostd 2017-01-30 01:18:55 +01:00
Daniel Kolesa f1d2bbc8b7 update according to ostd 2017-01-29 15:56:38 +01:00
Daniel Kolesa 3bdb0c4d7b update according to ostd 2017-01-29 15:17:43 +01:00
Daniel Kolesa 01899074fd update for ostd 2017-01-28 23:04:10 +01:00
Daniel Kolesa 8e31583612 use uint32_t 2017-01-25 02:10:17 +01:00
Daniel Kolesa 1c5c0939e1 use size_t 2017-01-25 02:09:50 +01:00
Daniel Kolesa d14c8f8593 update to latest ostd 2017-01-25 01:57:33 +01:00
Daniel Kolesa 57478f6866 move to std::vector 2017-01-25 01:18:29 +01:00
Daniel Kolesa 7be2ee5a08 remove multi-item parse 2016-11-18 15:17:50 +01:00
Daniel Kolesa 79b1a031ca use new ostd features 2016-11-15 22:54:05 +01:00
Daniel Kolesa ed65356dbe automagically figure out CsInt minimum and add some extra assertions 2016-11-12 19:15:28 +01:00
Daniel Kolesa 58b8f3ba54 make some types not configurable 2016-11-11 22:19:51 +01:00
Daniel Kolesa 128a961869 simpler char-to-hexdigit conversion func (can assume because of isxdigit) 2016-11-08 23:12:02 +01:00
Daniel Kolesa 4f7c05a60d clean up ListParser api 2016-11-07 23:33:53 +01:00
Daniel Kolesa da37ff51d1 rename to get_element 2016-11-06 23:48:50 +01:00
Daniel Kolesa 049cbd0035 make input private in listparser 2016-10-27 00:49:16 +02:00
Daniel Kolesa 78df1ca95d move element() out to header 2016-10-26 23:02:48 +02:00
Daniel Kolesa 6fcdbe7ac1 non-allocating element() variant on ListParser 2016-10-24 02:52:25 +02:00
Daniel Kolesa 1a08b018c6 remove list_index, add parse() that takes number of items 2016-10-24 02:45:15 +02:00
Daniel Kolesa 4d830b08ad sublist fix 2016-10-24 02:38:52 +02:00
Daniel Kolesa 61135fb79b remove list_length and instead add a method 2016-10-24 02:33:04 +02:00
Daniel Kolesa ed106d7e11 remove list_explode 2016-10-23 19:32:24 +02:00
Daniel Kolesa b5568456a5 forgot some exports 2016-10-22 19:34:52 +02:00
Daniel Kolesa b3e31c1d25 use Size for linenum 2016-10-15 21:15:19 +02:00
Daniel Kolesa f124126b32 use str parse util for blockstrs 2016-10-12 02:05:55 +02:00
Daniel Kolesa 5fe766aaeb use the new util in parser 2016-10-11 21:23:04 +02:00
Daniel Kolesa 0a88a10d99 add a line-counting parse_string to util 2016-10-11 21:15:23 +02:00
Daniel Kolesa 27affb1057 expose string parse 2016-10-10 20:14:16 +02:00
Daniel Kolesa 7f1c6b03a8 don't copy where not necessary 2016-10-04 20:30:13 +02:00
Daniel Kolesa c4471b71bf unexpose allocator related stuff from public API 2016-10-03 19:23:15 +02:00
Daniel Kolesa 4353bb7904 move allocator into shared state 2016-10-02 13:56:55 +02:00
Daniel Kolesa 5d70e2c80f simplify parser error handling (and allow for wider usage of line infos) 2016-09-29 21:21:21 +02:00
Daniel Kolesa cd515a4cff expose word parsing into API and unify with parser 2016-09-29 20:57:47 +02:00
Daniel Kolesa 9995fcf2e1 str parse cleanup 2016-09-26 02:27:33 +02:00
Daniel Kolesa 15e692f755 save state within ListParser and throw errors on unfinished strings in lists 2016-09-25 15:26:38 +02:00
Daniel Kolesa ccf24e95f5 line breaking in strings without inserting newlines 2016-09-24 03:31:56 +02:00
Daniel Kolesa 64b12b442b remove a jump 2016-09-23 21:06:44 +02:00
Daniel Kolesa 3a0cd8d378 exception-proof rundepth 2016-09-23 21:04:52 +02:00
Daniel Kolesa 1cdcc438cc debug fix 2016-09-23 20:18:01 +02:00
Daniel Kolesa de98b808ef allow breaking statements into multiple lines with \ 2016-09-23 20:04:29 +02:00
Daniel Kolesa 604fd4e000 proper line infos at parse time 2016-09-22 01:44:35 +02:00
Daniel Kolesa 0f10c3e303 safer next_char() 2016-09-22 01:19:29 +02:00
Daniel Kolesa 1c9f9c8f9f safe lexing with unterminated strings 2016-09-22 01:15:51 +02:00
Daniel Kolesa b3110c30b9 use ConstCharRange for source 2016-09-22 01:12:32 +02:00
Daniel Kolesa 5527025d5c more cleanups 2016-09-22 00:42:34 +02:00
Daniel Kolesa 9bfb599f64 fixes 2016-09-22 00:40:33 +02:00
Daniel Kolesa 73f770552c clean up parser a bit 2016-09-22 00:36:21 +02:00
Daniel Kolesa 33c6479539 move ListParser utils out of the way 2016-09-21 21:02:13 +02:00
Daniel Kolesa 918ca216a3 recursive parseword 2016-09-21 20:48:56 +02:00
Daniel Kolesa 1b25b64ae5 force strings to be finished 2016-09-20 22:33:02 +02:00
Daniel Kolesa 43e272c7e0 more parser cleanups 2016-09-20 22:24:56 +02:00
Daniel Kolesa 6f706dea86 properly get rid of cutstring/cutword 2016-09-20 22:11:40 +02:00
Daniel Kolesa 814b2824e9 match ostd api 2016-09-18 19:31:19 +02:00
Daniel Kolesa b57fcd082b split up statement parser a bit 2016-09-17 22:32:32 +02:00
Daniel Kolesa 62d4afccd2 remove set_mstr 2016-09-15 23:09:52 +02:00
Daniel Kolesa 1846fee1a0 clean up string lib 2016-09-15 23:04:32 +02:00
Daniel Kolesa 4bbe2ca6df clean up list sort 2016-09-15 22:45:28 +02:00
Daniel Kolesa cf21ba0a86 list lib cleanup 2016-09-15 22:34:52 +02:00
Daniel Kolesa 845232605d remove the out stream and re-do the var printing system 2016-09-15 21:59:11 +02:00
Daniel Kolesa 192ce615d8 remove get_err/set_err 2016-09-15 21:27:14 +02:00
Daniel Kolesa f12197bbe5 throw CsErrorException where appropriate (robust error handling everywhere) 2016-09-15 21:15:54 +02:00
Daniel Kolesa 377e9d7702 throw out of the VM on errors 2016-09-15 20:55:58 +02:00
Daniel Kolesa 214ecf8ad2 fix multi-operand cmp bug 2016-09-15 19:21:06 +02:00
Daniel Kolesa c97e56d7b7 fix doargs segv 2016-09-15 04:30:37 +02:00
Daniel Kolesa 38c17d1911 implement break/continue in bytecode 2016-09-15 02:12:22 +02:00
Daniel Kolesa b05bc51b14 reduce the instruction number by merging some instructions 2016-09-15 02:02:54 +02:00
Daniel Kolesa b0917ade03 use type inference for shorter command funcs 2016-09-15 00:42:19 +02:00
Daniel Kolesa c5772f0720 add loop control (break and continue) 2016-09-14 23:24:13 +02:00
Daniel Kolesa b20eb94a9e alloc error stack using CsState 2016-09-14 21:46:47 +02:00
Daniel Kolesa e7f3213588 custom allocf support 2016-09-14 21:33:32 +02:00
Daniel Kolesa e41c3c03a1 use exceptions to throw errors 2016-09-14 00:14:21 +02:00
Daniel Kolesa 4510e53916 use normal exception handling to handle errors C++-side, also guarantee valid pointer from alloc 2016-09-13 23:47:06 +02:00