Commit Graph

206 Commits

Author SHA1 Message Date
K. Lange
84765c1f4d Update test for change in dict ordering 2021-04-14 22:32:51 +09:00
K. Lange
40836cba21 Implement Python 3 division semantics 2021-04-02 16:02:05 +09:00
K. Lange
dc361af48b Fix incorrect binding of classmethod when called on instance of subclass 2021-04-02 12:25:07 +09:00
K. Lange
002412ecf8 Initial support for async/await 2021-03-31 19:27:13 +09:00
K. Lange
f4ea799d42 Fix generator not being popped from stack on 'yield from' 2021-03-31 19:09:06 +09:00
K. Lange
729220568e Try swapping args to __eq__ on NotImplemented 2021-03-30 17:00:23 +09:00
K. Lange
70d5f1b2b7 Implement NotImplemented, fallback operators
Adds 'NOTIMPL' as a new primitive value, available from
__builtins__.NotImplemented. Adds support for inverse /
reflected overrides for binary operators. Adds opcodes
for LESS_EQUAL and GREATER_EQUAL.
2021-03-30 16:42:29 +09:00
K. Lange
006119cc1e Support arguments to super(), support outside of classes 2021-03-30 14:18:39 +09:00
K. Lange
7a81724595 Unify more format strings 2021-03-26 12:17:14 +09:00
K. Lange
41c77de753 Implement overridable hashing and speed up property access 2021-03-25 19:49:18 +09:00
HarJIT
5c2de206b9
Codecs package (#4)
Codecs package

Co-authored-by: HarJIT <harjit@harjit.moe>
2021-03-24 04:53:02 -07:00
K Lange
2ed8e65c89 Rework KrkValue to use NaN-boxing 2021-03-24 20:49:44 +09:00
K. Lange
b5c22f77c5 Preallocate table space for krk_dict_of 2021-03-23 20:26:39 +09:00
K. Lange
6f92af28a2 Update test/day7.krk to not just be a test of list.pop 2021-03-23 12:50:04 +09:00
K. Lange
a63aef6b92 Try to make builds smaller
... by:
    - Normalizing some exception strings.
    - Putting the 'dis' module behind -DDEBUG.
2021-03-22 18:09:25 +09:00
K Lange
c68eb093e8 Fix broken stack handling in and make map,enumerate,filter object inits 2021-03-21 16:47:13 +09:00
K. Lange
a25315de92 Implement chained comparison operators 2021-03-21 12:41:54 +09:00
K. Lange
d0ea1278a6 ... and update test 2021-03-21 11:31:07 +09:00
K. Lange
1a569e36f6 README changed, update the test 2021-03-20 16:09:48 +09:00
K. Lange
cb809dd0fe 'yield' as an expression with a value; 'yield from' 2021-03-20 12:07:46 +09:00
K. Lange
2d3e7ca3d3 Fix bad pop on bare except-finally 2021-03-19 11:39:49 +09:00
K. Lange
46dada92fc Support multiple context managers in a 'with' statement 2021-03-18 21:25:19 +09:00
K. Lange
ee731257dd Support calling exit handlers for with: statements on exception 2021-03-18 20:41:11 +09:00
K. Lange
8aed1368ea Implement 'finally' 2021-03-18 19:52:30 +09:00
K. Lange
6c29be4dcf Fix up multiple assignment targets so we have some hope of nesting 2021-03-16 19:28:00 +09:00
K Lange
708ba0a481 Fix up some weird stuff with parens 2021-03-13 23:37:09 +09:00
K. Lange
b09f7b1131 Multiple arbitrary assignment 2021-03-13 20:17:45 +09:00
K Lange
9ea28e77f1 Add class and module member annotations 2021-03-13 14:22:32 +09:00
K Lange
49ee777c50 Type annotations. 2021-03-11 20:44:39 +09:00
K Lange
f655ca7f61 Fix up function, object repring and add __qualname__ to functions 2021-03-11 19:05:21 +09:00
K. Lange
6b3f8de63b Implement general __get__/__set__ descriptors
property objects are no longer a special case and have been simplified
old-style native properties can probably all be removed as well, but, todo
2021-03-10 20:24:12 +09:00
K. Lange
c9aa17e119 Rename __get__, __set__ to match Python's __getitem__, __setitem__ and make room for future addition of descriptors 2021-03-10 14:24:22 +09:00
K. Lange
05f7d9537a Add tests related to recent class method changes 2021-03-09 23:00:47 +09:00
K. Lange
84b7a37fab Remove the distinction between a class's 'fields' and 'methods' and implement actual method resolution 2021-03-09 22:35:40 +09:00
K. Lange
5dfbf8ec17 Various cleanups 2021-03-08 16:36:12 +09:00
K. Lange
1809ebf99e Okay quite a bit was wrong with that, but now it's right 2021-03-06 18:00:14 +09:00
K. Lange
35b4032de3 Support chained 'for's in generator expressions 2021-03-06 15:32:30 +09:00
K. Lange
0f6b74ff5b Generator expressions as direct function arguments 2021-03-06 11:19:34 +09:00
K. Lange
e97e42afc9 Replace tuple comprehensions with generator expressions 2021-03-06 11:13:49 +09:00
K. Lange
7aa4d3ce99 yield keyword; generator functions 2021-03-04 18:09:07 +09:00
K. Lange
4b7cf2ec27 Fix operator precedence for unary 'not' 2021-03-01 14:56:40 +09:00
K. Lange
a65f2dcf81 Add 'assert' statement 2021-03-01 11:55:51 +09:00
K. Lange
00fce076fe Add __qualname__ to classes 2021-02-25 10:03:52 +09:00
K. Lange
bc856ac063 Ongoing documentation improvements 2021-02-25 08:50:37 +09:00
K Lange
8e1f5f0565 repr classes as <class 'module.Class'> like Python
- We were using "<type ...>" like Python2 does for built-ins?
  But even Python 2 called user classes "<class ...>" - Python 3
  calls both built-ins and user classes "class".
- Check if there's a __module__ name and use that as well, now
  we look even more like Python!
2021-02-24 22:50:51 +09:00
K. Lange
6fee62f341 Fix parsing of nested ternary 2021-02-22 13:51:45 +09:00
K Lange
379e1846a9 Stringify floats with more digits 2021-02-20 21:48:47 +09:00
K. Lange
c5b04d55b1 Natively support @classmethod since we intentionally broke using @property for it 2021-02-20 16:04:26 +09:00
K. Lange
9bbb0a1d6e Overhaul exceptions with tracebacks; 'except Type...' 2021-02-18 11:04:59 +09:00
K. Lange
649b452714 That changes some test results intentionally 2021-02-18 08:45:07 +09:00
K. Lange
34e7eb4e57 Embed os, dir, time, fileio modules in core; only 'math' is still a separate shared library 2021-02-15 16:27:50 +09:00
K. Lange
4a9e3981fc Add object.__hash__() 2021-02-14 15:04:09 +09:00
K. Lange
e0adfcdc80 Remove str-nonstr concatenation / implicit coercion 2021-02-14 08:25:53 +09:00
K. Lange
6b6597d57d Add experimental bytecode marshal tool 2021-02-12 15:53:47 +09:00
K. Lange
a3b577e239 Add one actual and three skipped thread tests to the test suite 2021-02-11 15:31:37 +09:00
K Lange
8b53ac09b7 Our tuple packing is pretty slow, but some shifts and ors are pretty good 2021-02-11 05:27:06 +09:00
K. Lange
4233234406 Quick little demo of threads fighting over a dict (and still working) 2021-02-10 19:06:25 +09:00
K. Lange
09ce6c46a9 Wrap table accesses in locks, should be good for dicts, field assignments? 2021-02-10 18:19:10 +09:00
K. Lange
43d1e86a2a Wrap some things in readers-writer locks and now more stuff doesn't break 2021-02-10 10:20:56 +09:00
K. Lange
345b021936 Eliminate forced uses of GC pausing and fix up some more thread stuff; still need locks on collections 2021-02-09 23:13:45 +09:00
K. Lange
6f95124bcd Threading
Don't be deceived by its size: this commit is mostly a bunch of
sed replacements to move thread state out of "vm" and introduce
a thread-local "KrkThreadState" object to hold stack pointers and
call frames for individual threads.

Threading support is incomplete and there's almost definitely a
bunch of really easy ways to break everything just by allocating
objects, but really simple stuff like carefully modifying a
a list of ints should work okay.

The README has been rewritten to remove code samples, which have
moved to the Wiki (as has the section on integrating with C).

Some other stuff has also moved around because the threading changes
necessitated a major API break anyway, so I also took the time to
fix some ABI issues.
2021-02-09 18:51:09 +09:00
K. Lange
d550c1be6b I need to get rid of this README-reading test... 2021-02-08 17:38:11 +09:00
K. Lange
f5d9a6b806 sets do not have stable ordering, so stop trying to print them in tests 2021-02-08 09:36:30 +09:00
K. Lange
e7a8d0b8e5 Attach code object for class to the resulting class object 2021-02-05 20:34:18 +09:00
K. Lange
f4216ed3a1 Implement set literals, comprehensions 2021-02-05 20:23:28 +09:00
K. Lange
19e5beba05 Implement class decorators and move class definitions into pseudo-functions 2021-02-05 19:54:46 +09:00
K. Lange
689cee075e C-ify set(), mostly the same as it was originally written 2021-02-05 16:09:29 +09:00
K. Lange
0b6b6468a6 Prune actual file paths from test/testPackageImports.krk 2021-01-31 11:13:39 +09:00
K. Lange
67460145fa Add a test for everything we fix... 2021-01-31 09:57:15 +09:00
K. Lange
50e4902170 Hacky implementation of @staticmethod, @property, mb even @classmethod 2021-01-23 19:38:45 +09:00
K. Lange
824cbc59eb And update the test changed from that... 2021-01-23 13:34:09 +09:00
K. Lange
8ec3cfe07d Optimizations for f-strings 2021-01-22 08:38:36 +09:00
K. Lange
c0ef3a0917 Do that thing Python does when repr'ing strings where it picks between single and double quote 2021-01-21 18:52:53 +09:00
K. Lange
d6169a2c12 Support unpacking iterables in multiple assignments 2021-01-19 22:49:36 +09:00
K. Lange
85e7c667b4 C-ify some more collection methods 2021-01-19 22:27:05 +09:00
K. Lange
895eb367ee Support comprehensions for dicts, tuples. 2021-01-19 21:06:52 +09:00
K. Lange
851d3df8cd Add more operators. 2021-01-19 19:29:29 +09:00
K. Lange
ef7fb215b2 Add a module that does simple Kuroko syntax highlighting with flexible outputs 2021-01-18 20:45:26 +09:00
K. Lange
abfaa50bee Implement module packages 2021-01-17 22:01:58 +09:00
K. Lange
f97d8cd562 Fix a bad indentation handling for if/try. 2021-01-17 16:52:38 +09:00
K. Lange
7e11fcb920 Try to help the compiler with branch prediction hints 2021-01-16 22:47:52 +09:00
K. Lange
648ed8c85f Add something original for once 2021-01-15 19:31:00 +09:00
K. Lange
1abc8529cb Put some actual tuple unpacks in a test 2021-01-15 09:53:29 +09:00
K. Lange
d44f080260 oops, leaked a pointer in a test 2021-01-14 23:19:59 +09:00
K. Lange
5568665ad6 Unverified implementation for __getattr__ 2021-01-14 23:16:13 +09:00
K. Lange
13bbc3ae2d Change 'let' semantics to do unpacking; support unpacking more things 2021-01-14 21:16:48 +09:00
K. Lange
d2d1c98a1e Add 'del' statement. 2021-01-14 16:08:25 +09:00
K Lange
1f189ed82c Fixup string iteration for unicode strings 2021-01-12 20:11:52 +09:00
K. Lange
10f3c16e40 Major overhaul of strings to support Unicode 2021-01-12 19:23:14 +09:00
K. Lange
dc56d7b2ea Normalize __add__ for strings, but keep the shortcut around 2021-01-11 21:46:24 +09:00
K. Lange
5517162a93 Add json module 2021-01-11 19:02:51 +09:00
K. Lange
b00fcc0c0a Call override functions for various operators if available 2021-01-11 17:48:32 +09:00
K. Lange
eb27158173 Class fields and access to class member methods 2021-01-11 16:31:34 +09:00
K. Lange
991ed99e78 Add a basic collections module 2021-01-11 14:08:05 +09:00
K. Lange
ff7dcbb92a Support 'return' from within a 'with' block 2021-01-10 23:39:05 +09:00
K. Lange
78c5503341 list.pop() is really useful 2021-01-10 20:49:01 +09:00
K. Lange
35570e7ee9 Support complex argument expansion in C functions 2021-01-10 18:49:52 +09:00
K. Lange
3532f24c75 Rewrite complex argument processor because that old stack-juggling version was awful 2021-01-10 18:23:28 +09:00
K. Lange
84302652a8 move test 2021-01-10 11:00:14 +09:00
K. Lange
997e1a8d2a length should determine truthiness where relevent 2021-01-09 13:58:46 +09:00