Commit Graph

129 Commits

Author SHA1 Message Date
K. Lange
a4ba95d5ea basic types not being instances is entirely an implementation detail at this point 2021-01-03 09:37:43 +09:00
K. Lange
fa742d2ff9 redundant statement 2021-01-03 09:32:02 +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
7d8dfa2ffe Add some descriptions of decorators and a note about differences from Python in the README 2021-01-03 09:20:11 +09:00
K. Lange
310cbe4e70 Don't explode when trying to print a null bound method 2021-01-03 09:19:38 +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
31751745cd How did I not catch that earlier... need to _check_, not match, EOL on return statement 2021-01-03 09:15:50 +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
2ab2f6e7eb just stop accepting escape, we don't even need it anyway 2021-01-02 18:05:53 +09:00
K. Lange
5ae4f135bf Build with VM as shared library, as we do in Toaru 2021-01-02 14:51:01 +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
7b506e6190 actually use OP_CALL_LONG 2021-01-02 12:52:12 +09:00
K. Lange
181e598b15 "as its name should imply" 2021-01-02 12:29:30 +09:00
K. Lange
ec9ced2b4a briefly mention character literals in README 2021-01-02 12:24:38 +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
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
a4ba3a3d02 don't clean builtins.c 2021-01-02 09:49:41 +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
fe89d5fae2 inlined function instruction wasn't in dissassembler 2021-01-01 21:13:49 +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
4bde1125b4 (rline) fix minor uninitialized read in word_right 2021-01-01 19:18:19 +09:00
K. Lange
19e1665bc1 why does this keep being terrible 2021-01-01 19:06:30 +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
30613c6354 Actually commit builtins.c to repo so it doesn't need to built normally 2021-01-01 17:25:24 +09:00
K. Lange
b03b0245d7 Actually commit builtins.c to repo so it doesn't need to built normally 2021-01-01 17:25:17 +09:00
K. Lange
288544d4ed fix multiline past in line editor 2021-01-01 17:10:23 +09:00
K. Lange
a9fffce795 bind File.__repr__ 2021-01-01 16:58:57 +09:00
K. Lange
1242f2f10f try to namespace everything 2021-01-01 16:58:13 +09:00
K. Lange
063e69a4fc Hash objects by pointers for now... 2021-01-01 16:23:43 +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
f745f8ec15 Add rudimentary (native) file i/o module 2020-12-31 18:41:17 +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
9a370f00e1 Add continue/break statements 2020-12-31 16:59:51 +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
0031048ff7 Fix missing nil terminator in _builtins_src[] 2020-12-31 13:50:17 +09:00
K. Lange
ede0e6e856 more README sections 2020-12-31 12:26:17 +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