Commit Graph

97 Commits

Author SHA1 Message Date
K. Lange
b93429d6a6 Oops, fix strings; simplify bytecode around getters/setters; use this approach for slicing 2021-01-04 18:10:55 +09:00
K. Lange
49b7eb2941 Super speedy getters and setters 2021-01-04 17:47:53 +09:00
K. Lange
fb9d0163ef Some more objects 2021-01-04 17:29:06 +09:00
K. Lange
66533d5c23 C-ify a bunch of basic builtin functions 2021-01-04 16:21:59 +09:00
K. Lange
eb383e7663 Support __call__ on instances 2021-01-04 16:21:27 +09:00
K. Lange
a1f29ee399 Fixup dirObject which we broke with __inrepr 2021-01-04 16:20:50 +09:00
K. Lange
9941889f54 str.__contains__ 2021-01-04 14:03:19 +09:00
K. Lange
2f5b7ef262 Add str.split() 2021-01-04 12:47:57 +09:00
K. Lange
d1c2d3f234 Add str.join() 2021-01-04 12:01:50 +09:00
K. Lange
b25f2e6c73 Implement str.format() 2021-01-04 11:29:33 +09:00
K. Lange
b8c89c0550 add ValueError to builtin exceptions 2021-01-04 11:27:33 +09:00
K. Lange
0a0c5885e4 Fix cached imports not pushing module to stack 2021-01-04 07:38:44 +09:00
K. Lange
edbb4f06e5 Try to catch some bad attempts to expand garbage 2021-01-03 22:36:24 +09:00
K. Lange
a903fd0a3e We can probably support this well enough, but just throw an error for now. 2021-01-03 18:38:27 +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
0a042e7a38 Kinda shoddily support keyword args in native functions by shoving them on the end and setting a flag you can opt in to seeing 2021-01-03 16:23:22 +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
a86884247a Catch instances where method decorators didn't return anything and we tried to call a null method. 2021-01-03 09:19:18 +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
542e219192 Redefine list comprehension and add infix in 2021-01-02 19:46:21 +09:00
K. Lange
cbdd60d768 Do some simple recursion avoidence and improve reprs in lists/dicts 2021-01-02 14:28:37 +09:00
K. Lange
355dcb3705 add globals() function 2021-01-02 13:58:16 +09:00
K. Lange
b1b747b234 Some improvements to debug output before I move on to a marshalling format 2021-01-02 13:42:07 +09:00
K. Lange
c5df6bd8cf fix the __dir__ which we broke internalizing lists because we renamed the internal object to __list 2021-01-02 12:24:25 +09:00
K. Lange
6164c3ebf4 General code cleanup. 2021-01-02 12:21:11 +09:00
K. Lange
4cb692842c actually print an error when the interpreter is unable to open a file 2021-01-02 07:47:00 +09:00
K. Lange
6e4ff9f791 .. and fix uname() 2021-01-01 21:07:42 +09:00
K. Lange
b42844f842 Fully internalize list+dict core methods and implement invokes for getters/setters 2021-01-01 20:52:18 +09:00
K. Lange
2677c7aca7 Make sure that's still returning something 2021-01-01 17:47:30 +09:00
K. Lange
77fbff0e69 Disable set_tracing if debug flags aren't enabled 2021-01-01 17:38:09 +09:00
K. Lange
3823d5f69e Hide dumpStack() behind ifdef 2021-01-01 17:35:12 +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
8e5ace5112 Make classes for base types and exceptions 2021-01-01 12:04:58 +09:00
K. Lange
1dca833d6f add assignment shortcut operators (probably not worth using until optimizations are in place) 2021-01-01 10:42:16 +09:00
K. Lange
58132eedf8 Add binary operators 2021-01-01 08:55:39 +09:00
K. Lange
4df8cd8673 Docs, and also make negative indexes work as expected for strings at least... 2020-12-31 18:40:38 +09:00
K. Lange
2b3a5cec60 String slicing, and general syntax support 2020-12-31 18:32:37 +09:00
K. Lange
aa3674dd32 implement shared object module support 2020-12-31 15:48:39 +09:00
K. Lange
c2e5eeceb7 Internal binding functions should look at the stack from the top, not the bottom; they may run with stuff on the stack... 2020-12-31 14:46:02 +09:00
K. Lange
764f9144f8 Add __base__, isinstance(), and track superclass in the VM and not just implicitly by super() calls. 2020-12-31 09:15:53 +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
f7e1c0da0d Add docstrings, __doc__, and help() 2020-12-30 16:59:21 +09:00
K. Lange
a5928b18c9 bite the bullet and rename length() to __len__() 2020-12-30 15:50:26 +09:00
K Lange
9fd9d81afe eliminate arbitrary size restrictions where possible 2020-12-29 06:33:16 +09:00