Commit Graph

210 Commits

Author SHA1 Message Date
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
K. Lange
656942f612 Cleanup and useful builtins 2021-01-09 10:12:50 +09:00
K Lange
2bd0d93596 Add kuroko.argv 2021-01-08 19:05:11 +09:00
K. Lange
070b4bc356 Add tuple unpacking and 'if' conditions to list comprehensions 2021-01-08 18:00:49 +09:00
K. Lange
fc05327c42 Support unpacking tuples in for ... in ... loops. 2021-01-08 17:42:57 +09:00
K. Lange
8f9c1a4c1d Switch C-style loops to semicolons before I regret having used commas 2021-01-08 17:14:42 +09:00
K. Lange
3735b9c16b Raise KeyboardInterrupt on ^C 2021-01-08 16:40:43 +09:00
K. Lange
f21a959b14 Add instructions for static builds 2021-01-08 12:12:44 +09:00
K. Lange
cdd3272d0e Accept tabs as being equivalent to eight spaces, but no mixing on a single line 2021-01-08 07:05:33 +09:00
K Lange
a1fbaecabd Readme and doc updates 2021-01-07 22:45:52 +09:00
K. Lange
9eb5fb1cad Add ternary (a) if (cond) else (b) 2021-01-07 14:04:42 +09:00
K. Lange
ecb5f1e4ec Attach __doc__ to modules, default to None (but still set) if missing 2021-01-07 11:30:10 +09:00
K. Lange
8a1de6c4d2 Assign __main__ as name of executed scripts 2021-01-07 10:58:04 +09:00
K. Lange
fbf4dda818 Fix tracking what should be 'global' through function calls? 2021-01-07 10:39:09 +09:00
K. Lange
902d2222b5 Make modules work like in Python. TODO: module class for better repring 2021-01-07 09:50:58 +09:00
K. Lange
7073505c6b fix test that includes pointer values in output 2021-01-06 19:07:22 +09:00
K. Lange
b4e4da667f Add test for upvalue bug resolved yesterday 2021-01-06 14:51:07 +09:00
K. Lange
a4a4da70df Fixup more kwargs stuff, need to pop values for defaults 2021-01-05 19:01:26 +09:00
K. Lange
181e378628 Add class name to method __repr__ 2021-01-05 15:36:09 +09:00
K Lange
ff8ed02ebd Make print() a function before it's too late 2021-01-04 23:34:10 +09:00
K. Lange
d87fd9b1bd Commit results of test cases as of now (not sure if they're all correctly) 2021-01-04 21:50:20 +09:00
K. Lange
bc12529e75 Fix some test cases for expect testing 2021-01-04 21:44:16 +09:00
K. Lange
e5a1756543 Remove some tests that make too much output 2021-01-04 21:43:51 +09:00
K. Lange
feeaa30d11 Fix missing comma in test case for whitespace eating 2021-01-04 21:23:55 +09:00
K. Lange
5c1d8f24b6 more AOC test cases 2021-01-04 20:27:32 +09:00
K. Lange
f4cbf2ec38 this is now a late AOC2020 repo 2021-01-04 20:10:39 +09:00
K. Lange
6195649458 More test scripts 2021-01-04 19:59:11 +09:00
K. Lange
f1ebada908 Add string iterators 2021-01-04 19:34:56 +09:00
K. Lange
7b8df5d4da More test files 2021-01-04 19:07:46 +09:00
K. Lange
3fd9bfecde Demonstrate how Python's default args behavior can be emulated 2021-01-04 10:02:44 +09:00
K. Lange
90a4dd678d Ignore line feeds and indentation in some contexts 2021-01-04 09:49:56 +09:00
K. Lange
7dfa32f471 Fix some exceptional edge cases 2021-01-03 18:26:55 +09:00
K. Lange
2ee154ecf7 Add argument expansions... 2021-01-03 18:13:17 +09:00
K. Lange
36716e3508 Support * and ** in function signatures for collections of additional arguments and keyword args 2021-01-03 16:02:50 +09:00
K. Lange
8ad29f7891 Ditch character literals and add single, triple strings 2021-01-03 14:09:45 +09:00
K. Lange
76e70b79d0 Add default argument values.
Unlike in Python, I'm taking the approach of evaluating these at function
call time rather than definition time. Assigning things like empty lists/dicts
to default arguments has always been a ridiculous thing in Python, and I don't
want to make that mistake. I'm pretty sure Python only continues to do that
because it was something they didn't want to break for backwards compatibility
reasons even in Python 3.
2021-01-03 12:32:04 +09:00
K. Lange
e46d753999 Basic support for keyword arguments when calling functions. 2021-01-03 12:09:41 +09:00
K. Lange
0966a21c7a Move sleep, uname to Pythonic module names 2021-01-03 09:49:19 +09:00
K. Lange
93af369b8c Quietly pretend we didn't just do that different from Python for no reason 2021-01-03 09:29:09 +09:00
K. Lange
b676df69da Add method decorators
This required a new approach for handling function arguments.

Methods remain the same: the callee object is on the stack and positioned
to be "argument 0". Non-methods have changed so that "argument 0" is the
first argument, with the function still remaining before that. When a
non-method is called, we track this fact so that we can continue to restore
the stack to the correct height to get rid of the function. This allows
a method decorator to be defined exactly like it would be in Python

def methodDecorator(func):
    def wrappedMethod(instance, someOtherArg):
        print "Do something with the arg:", someOtherArg
        func(instance)

class Foo():
    @methodDecorator
    def func():
        print "I only take an implicit self:", self

let f = Foo()
f.func("but that other arg is needed")
2021-01-03 08:43:32 +09:00
K. Lange
1de1fbc150 Basic non-method decorator support? 2021-01-02 21:58:24 +09:00
K. Lange
542e219192 Redefine list comprehension and add infix in 2021-01-02 19:46:21 +09:00
K. Lange
7b506e6190 actually use OP_CALL_LONG 2021-01-02 12:52:12 +09:00
K. Lange
9211b04fc1 Add 'else if'; don't do Python's elif thing, I don't like that. 2021-01-02 12:13:01 +09:00
K. Lange
ae2e2be15d do something more straightforward and useful for methods on non-objects 2021-01-01 16:02:16 +09:00
K. Lange
9a370f00e1 Add continue/break statements 2020-12-31 16:59:51 +09:00
K. Lange
0b2c9df58f shove list comprehensions into their own fake call frames because everything is terrible 2020-12-30 22:30:09 +09:00
K. Lange
33f7561076 List comprehensions, and several gc+scoping fixes along the way 2020-12-30 21:57:13 +09:00
K. Lange
a5928b18c9 bite the bullet and rename length() to __len__() 2020-12-30 15:50:26 +09:00
K. Lange
b0c2772937 switch some type conversions to bound methods 2020-12-29 16:40:42 +09:00
K. Lange
2c18402d40 escape sequences in strings 2020-12-29 16:26:00 +09:00
K. Lange
a0d52a61f2 add an exception mechanism 2020-12-29 11:00:12 +09:00
K. Lange
ba73f5a32a move stray test into test/ 2020-12-29 08:25:36 +09:00
K. Lange
0f7bc84ad3 for loops must open a new scope around their blocks as well or they won't pop locals before the loop finishes 2020-12-29 08:23:18 +09:00
K Lange
e9261a2f56 change size of integers to long 2020-12-28 16:32:40 +09:00
K. Lange
3ba8025eeb lots of fixups so we can create dicts from the vm 2020-12-28 20:38:26 +09:00
K. Lange
cdcbf6cf54 First pass at module/builtin cleanup 2020-12-28 19:01:28 +09:00