Commit Graph

514 Commits

Author SHA1 Message Date
013fbe22e0 Clean up CLI path arrays 2024-09-09 14:55:04 -04:00
6ea6aadd96 Correctly clean up CLI args that are paths 2024-09-09 14:48:33 -04:00
a306f94557 Add mktemp functionality 2024-09-09 02:43:15 -04:00
13a9304dec Initial working version 2024-09-09 00:22:12 -04:00
711afee405 Fix non-base10 integer literals 2024-09-08 22:12:13 -04:00
a4fff5cb49 Bugfix for default arguments not supporting enclosing types 2024-09-08 21:55:15 -04:00
aeed1992e9 Fix nearly every GCC warning and add __attribute__((pure/const)) where
appropriate
2024-09-08 17:17:15 -04:00
3f16e95127 USAGE and HELP need an underscore prefix so they're not imported into
other files. Also fixed up dependency tool so it works good now
2024-09-07 00:26:30 -04:00
6cc5562791 Support using text in conditionals 2024-09-06 23:01:31 -04:00
11fa4f548c Support 'when' statements as expressions 2024-09-06 14:15:55 -04:00
4b352f89a3 Add Shell dsl type 2024-09-06 11:37:33 -04:00
c075deeab4 Actual fix for incref issue 2024-09-06 04:14:50 -04:00
dc7ee868a6 Speculative fix for some incref issues 2024-09-06 04:11:00 -04:00
e47c45a93b Bugfix for "":join(table.keys) 2024-09-06 03:46:35 -04:00
3444d1652d Add comment 2024-09-05 15:44:49 -04:00
d99f0271ad Revert "Use stack() macro" (actually needs to work this way)
This reverts commit ed36765b42.
2024-09-05 15:43:52 -04:00
ed36765b42 Use stack() macro 2024-09-05 15:35:40 -04:00
04c8fb0362 Replace $Type with Type$info for builtin TypeInfos 2024-09-05 15:31:54 -04:00
391c1b6bde Rename table_t -> Table_t 2024-09-05 14:57:31 -04:00
abe45a3c25 Rename array_t -> Array_t 2024-09-05 14:56:37 -04:00
c82b664db9 Slightly clean up CLI usage error code for no-argument programs 2024-09-05 14:44:52 -04:00
a8be9efcd3 Rework CLI compilation so that all of the argument parsing is written to
the .tm.c file and the runner program is *just* a single function call
to the function that parses args and runs the main function. Also
improved some CLI usage error code
2024-09-05 14:38:37 -04:00
e6aea8c130 Add support for custom HELP for CLI tools 2024-09-05 13:57:48 -04:00
e1d0927744 Fix 'empty' clause for integer iteration 2024-09-05 12:44:01 -04:00
34d98f067e For big or arbitrarily big integers not known to be constant, do full
Int$plus(a,b) logic so it's definitely correct and doesn't error.
2024-09-05 12:41:13 -04:00
e91b53f070 Improve codegen for loops by not adding extra braces and just using the
integer literal for 64-bit ints when iterating over a numeric value
2024-09-05 12:28:28 -04:00
d801681026 Add early outs for (or) and (and) reducers 2024-09-05 11:51:07 -04:00
0d3c8e16bc Add iteration-over-comprehension optimization 2024-09-05 11:23:00 -04:00
e2118b7407 Better enum messaging for CLI arg parsing 2024-09-04 21:33:06 -04:00
453c3610f9 Support parsing enums (without members) 2024-09-04 16:21:27 -04:00
3513b94fc7 Unify parsing code to correctly handle parsing integers and numbers with
a &success boolean. Check for overflow as well.
2024-09-04 16:08:34 -04:00
973b1c55c2 Fix array CLI arguments 2024-09-04 15:30:38 -04:00
e9796e1433 Improve command line parsing (no more cords) 2024-09-04 15:23:23 -04:00
0d098c118b Add automatic --help to print usage 2024-09-04 14:34:24 -04:00
ac507da537 Remove unused code path for >> f := use ./foo.tm 2024-09-04 13:49:41 -04:00
d1b2e9f598 Disallow 'use' statements that aren't top level 2024-09-04 13:48:26 -04:00
f605df8230 Minor codegen cleanup 2024-09-04 13:37:00 -04:00
97a964aa86 Implicit filename for table getting 2024-09-04 05:05:31 -04:00
af15e89303 For arrays, use implicit filename from macro 2024-09-04 05:04:45 -04:00
1092185c84 Improve codegen by making test() even more concise 2024-09-04 05:01:21 -04:00
79c1e8f989 Don't put __SOURCE_FILE__ in header 2024-09-04 03:04:42 -04:00
ec688c11bb Clean up codegen so $Foo"..." comes out as foo$Foo("...") instead of
Text("...")
2024-09-04 00:18:03 -04:00
805082d299 Minor codegen cleanup Texts(...) 2024-09-03 23:35:42 -04:00
f60edfbe7f Improve codegen for doctests a little bit by using __SOURCE_FILE__ macro
and making assignments use (x = 4, &x) syntax instead of ({ x = 4; &x })
2024-09-03 23:32:02 -04:00
e15cb21cd5 Fix up CLI parsing 2024-09-03 21:09:11 -04:00
29a87ff325 Support literal Text("blah") for text that is constant ASCII strings 2024-09-03 14:48:54 -04:00
5feecff9d9 Deprecate Where and change channel API to use a boolean front value 2024-09-03 03:53:36 -04:00
5a78eb61c8 Bugfix for hex escapes adjacent to hex-like characters 2024-09-02 21:54:38 -04:00
620ebeab8d Fixing string methods 2024-09-02 20:22:13 -04:00
337aa911a9 Auto promote to C String from Text 2024-09-02 19:53:09 -04:00
6d7a359f8f Bugfix some text replacement things 2024-09-02 19:49:52 -04:00
80a09e6dba Fix up some integer and print statement stuff 2024-09-02 19:29:43 -04:00
b0a8404bd7 Fix enums/structs 2024-09-02 19:18:21 -04:00
00a3117803 Bugfix 2024-09-02 19:07:51 -04:00
94761d9a5a Fix some stuff 2024-09-02 19:05:06 -04:00
61e482f6f3 Initial WIP first past 2024-09-02 18:47:39 -04:00
a197875214 Bugfix for say() when length is >512, and added back the newline
optional parameter (default=yes)
2024-08-23 12:42:10 -04:00
dceb925573 Bugfix for parsing ints 2024-08-23 11:38:54 -04:00
ad51b208b4 Overhaul of import syntax. Now everything uses use: use foo, `use
./foo.tm`, `use <foo.h>`, `use libfoo.so`
2024-08-22 14:02:48 -04:00
2055439be4 Variables can no longer hold function pointers, only closure_t's. This
makes error reporting easier and prevents issues where some functions
could be assigned, but not others. Also change outputs so Void returns
don't show up when displaying types, now just: `func()`
2024-08-21 00:49:22 -04:00
3c4f477b84 Bugfix some copy-on-write cases for when pointers are automatically
derefenced for method calls
2024-08-20 16:20:41 -04:00
5b945d8fc6 Remove unused parameter and add some docs on arrays 2024-08-20 16:00:58 -04:00
934b843b1c Add .text_content as a field on DSLs instead of a method 2024-08-19 14:29:58 -04:00
ea6f9797be Support DSL constructor working on DSL itself 2024-08-19 13:23:59 -04:00
4e732a718d Restructure things so that DSL constructors do proper escaping 2024-08-19 13:23:02 -04:00
178dca6e88 Clean up codegen for strings that are just a single interpolated value 2024-08-19 13:14:36 -04:00
8c4210ba01 Support demoting int literals 2024-08-19 12:39:45 -04:00
752be14eed Fix some numeric precision issues with how nums are printed 2024-08-19 01:46:37 -04:00
14b4a674e8 Fix precision of compiled numbers 2024-08-19 01:32:27 -04:00
c422806d87 Make sure imported/used modules are initialized properly 2024-08-19 00:52:35 -04:00
8363d53bd2 Update channel API to take a Where parameter 2024-08-18 23:59:13 -04:00
9e07c6adc7 Add Channel:peek() 2024-08-18 23:31:36 -04:00
2e8c949fdc Rename push/pop to give/get, since it's not stack-ordered 2024-08-18 23:24:23 -04:00
7472837ee5 Add array:first(predicate:func(x:&T)->Bool)->@%T? 2024-08-18 22:28:04 -04:00
6f3b2c073a Add enum.tag as a way to do a boolean test for whether a value has a
particular tag or not
2024-08-18 20:58:36 -04:00
967b649da2 Deprecate # operator in favor of .length and fix up some issues 2024-08-18 20:39:57 -04:00
d804b09b02 Added a .length field to arrays/sets/tables, added a .max_size field to
channels, and updated the API
2024-08-18 20:28:39 -04:00
6ef0583868 Fix array indexing 2024-08-18 15:51:19 -04:00
a49870f810 Add primality testing and next_prime()/prev_prime() 2024-08-18 15:22:51 -04:00
da4d07c665 Fix up some bigint logic issues 2024-08-18 12:47:29 -04:00
752ab8212c Split BigIntType out of IntType and switch to using enums for the size
of ints/nums
2024-08-18 11:49:51 -04:00
8b94c2c7f1 Fix array ++= item 2024-08-18 02:58:44 -04:00
d0078ab024 Handle demotion of integers when we know what the expected type ought to
be and it's just a literal.
2024-08-17 23:43:30 -04:00
09c4ff2e43 Disallow accessing type members that start with underscores unless
you're inside the type definition.
2024-08-17 21:03:04 -04:00
20b7793963 Make small integer constants actually constant 2024-08-17 15:17:41 -04:00
2383d73645 Correct the logic to prevent promoting nums to ints automatically 2024-08-17 15:14:45 -04:00
de31398fe4 Add table:get_or_null(key) for tables with non-null pointer values,
which lets get() keep the non-null return type
2024-08-17 15:01:01 -04:00
cbe117a6d3 Allow for top-level or namespace-level variables that are initialized
with non-constant values by the use of an initializer function and
runtime checks for whether the variable is initialized.
2024-08-17 14:41:31 -04:00
a6be5c90ca For cached functions with no arguments, use a static var instead of a
cache table
2024-08-16 01:46:05 -04:00
7c18773011 Bugfix for closures 2024-08-15 13:59:01 -04:00
688f883e16 Add array:find() 2024-08-15 03:01:04 -04:00
66ae30ac29 Add method for array:remove_item(item) and rename
array:remove(index)->array:remove_at(index) to avoid confusion. Also
hook up array:has()
2024-08-15 02:39:35 -04:00
ed1667cb37 Add array:shuffled() and checks for array insertion 2024-08-15 02:17:53 -04:00
eccc4e4721 Add binary search method to arrays 2024-08-15 01:59:42 -04:00
9c2d7c437d Fix up type conversions with ints and nums 2024-08-14 14:57:01 -04:00
e0223a4c20 Support ^ exponentiation for integers 2024-08-13 16:32:00 -04:00
5a0502bdf5 Fix some edge cases 2024-08-13 14:13:02 -04:00
1ce826b9c3 Tweak to codegen for range iteration 2024-08-13 11:35:22 -04:00
81ed38616f Cleanup code gen for Num coercions 2024-08-13 04:24:36 -04:00
eb9e5260a6 Fix channels 2024-08-13 03:27:32 -04:00
9edace28e2 Fix ranges 2024-08-13 03:20:01 -04:00
7365602715 Fixing up more stuff 2024-08-13 03:08:27 -04:00
6f33b93014 Fix min/max 2024-08-13 03:05:56 -04:00
2c4f6536a3 Fix Int->Num promotions 2024-08-13 02:51:10 -04:00
ab7a5e7af6 Proper promotion of ints 2024-08-13 02:45:57 -04:00
aa74180ed1 Fixing up integers 2024-08-13 02:20:48 -04:00
158a1c6ad2 More fixes 2024-08-13 02:09:18 -04:00
d08f795794 Partially working first draft of bigints 2024-08-13 01:30:25 -04:00
c1c889b024 Fix for set.items 2024-08-12 18:00:54 -04:00
ea80fefa05 Bugfix some issues with table keys/values 2024-08-12 17:57:14 -04:00
6aabed4fcc Fix some COW bugs for arrays/tables/sets 2024-08-12 17:44:05 -04:00
d2f4d07585 Support channels with maximum size 2024-08-11 15:04:22 -04:00
2ecb5fe885 Add channels and threads 2024-08-11 14:47:34 -04:00
6d3d104363 Overhaul of operator metamethods 2024-08-10 20:50:15 -04:00
f0e56acc5b Bugfix some issues with mod1 2024-08-10 20:40:41 -04:00
948d6b4c22 Add array:counts() 2024-08-10 16:36:50 -04:00
4265728cbb Add Array:unique() to get a set of unique items 2024-08-10 16:19:36 -04:00
b37bd70b60 For tables, deprecate support for square bracket indexing and .default
values, replacing them with a `:bump()` function for tables with numeric
values. This means that counters can be implemented easily without the
need to mask complexity.
2024-08-10 16:03:41 -04:00
671f81137e Make Num32/Num64 literals explicitly typed to aid in macros using
__typeof
2024-08-10 16:03:00 -04:00
8d3d591312 Add Sets to the language 2024-08-10 15:15:38 -04:00
f78cd6357a Change table removal function to use values instead of references 2024-08-08 13:20:38 -04:00
c045c54309 Add a Range datatype with creation methods like 5:to(10) and
modification methods like `range:by(2)` or `range:reversed()`
2024-08-05 14:40:28 -04:00
7300049867 Switch to TABLE_INCREF 2024-08-04 17:31:33 -04:00
7fd74553f8 More refcount fixes 2024-08-04 17:27:43 -04:00
d7e3d399d6 Fix up some edge cases with refcounting 2024-08-04 17:25:54 -04:00
43501f7bec Minor fix for array refcounting 2024-08-04 17:23:42 -04:00
ff4ea60daf Tweaks to array implementation, including changing how the bits are
allocated, making more explicit checks for refcounts and max values,
optimizations for certain methods, and adding compile-time errors for
arrays that hold items that are too large.
2024-08-04 14:22:58 -04:00
adccc56880 Switch around some of the logic for array:random() and array:shuffle()
to use Int$random() and return values
2024-08-04 13:03:55 -04:00
09204f4ce8 Revert "Fix array:random() to return a random item using correct RNG logic,"
This reverts commit 68b34cf00b.
2024-08-03 17:44:22 -04:00
8357d02992 Make default table removal behavior deterministic, but have caches
explicitly use random eviction.
2024-08-03 17:42:45 -04:00
68b34cf00b Fix array:random() to return a random item using correct RNG logic,
rather than a reference.
2024-08-03 17:33:18 -04:00
99b00530ce Change structs/enums so they allow for field/tag names that are C
keywords
2024-08-03 16:39:04 -04:00
17be975d3a Fix integer random functions so they correctly handle all representable
ranges
2024-08-03 16:23:28 -04:00
167634eaa4 Change array API to take a padded item size instead of a type info in
most cases
2024-08-03 15:33:50 -04:00
16c2e3f590 Incrementally moving towards passing array entry sizes explicitly 2024-08-03 15:06:59 -04:00
2b9bec18a4 Fix for stride overflows in arrays 2024-08-03 14:40:56 -04:00
87785555ec Fix for order of operations issues with enum and function typedef code 2024-07-23 19:46:42 -04:00
7911df8294 Make sure array slicing doesn't require a pointer and disallow automatic
stackifying of values
2024-07-22 13:54:03 -04:00
5b0a841db6 Fix edge case with iterating over array:from(-999) 2024-07-20 17:20:50 -04:00
279cd23143 Micro optimization for iterating over array ranges 2024-07-20 17:13:15 -04:00
fb95bbb1d4 Deprecate array:pairs() and switch iterator functions to use enums 2024-07-20 16:45:13 -04:00
d3f14cf53c Support nested lambda closures 2024-07-14 14:13:23 -04:00
4e6d8162bf Fix issue with bindings inside closures 2024-07-14 13:22:42 -04:00
9fec3a6adb Fix for reductions over iterators like (+) range(5, 10) 2024-07-13 19:58:21 -04:00
39576466a7 Add ReturnType(ret) so we can more accurately track return values for
`if` statements
2024-07-13 18:43:50 -04:00
2e2f68e582 Allow lambdas to have a return statement as the last statement 2024-07-13 18:26:41 -04:00
f64aaf5960 Add array:pairs() 2024-07-13 18:05:14 -04:00
445f79cb70 Add iterator functions 2024-07-13 17:17:58 -04:00
3db57b4d2e Bugfix for unchecked array access 2024-07-10 13:47:15 -04:00
068d0e8563 Add array:to() to split out functionality of array:from() 2024-07-10 13:42:58 -04:00