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
K. Lange
5c8d8942b1
make all classes inherit from object(), add __dir__
2020-12-30 12:28:18 +09:00
K. Lange
f7e3a28408
int/float casts for strings
2020-12-30 11:26:07 +09:00
K. Lange
1ae9828570
export should be able to take multiple arguments; fix resolution bug when export statement does not follow object to be exported
2020-12-30 10:19:52 +09:00
K. Lange
b19fc3a477
Add syntax for list/dict expressions
2020-12-30 09:01:52 +09:00
K. Lange
428c368a75
Support optional arguments by tracking separate arities
2020-12-30 08:00:48 +09:00
K. Lange
430f20566e
allow native functions to be bound as methods with a little work
2020-12-29 20:31:35 +09:00
K. Lange
7dfd853217
More stuff for embedding
2020-12-29 18:51:03 +09:00
K. Lange
eb17af8076
Embed __builtins__ source directly
2020-12-29 18:50:18 +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
c6e5c8c120
once again, completely redo the parsing for indentation so that we can have pretty syntax errors
2020-12-29 15:26:45 +09:00
K. Lange
54c3779938
fix up handling of exceptions in module imports
2020-12-29 13:19:22 +09:00
K. Lange
a0d52a61f2
add an exception mechanism
2020-12-29 11:00:12 +09:00
K. Lange
9a580d6720
Add binding to configure debug tracing at runtime
2020-12-29 08:22:54 +09:00
K Lange
e9261a2f56
change size of integers to long
2020-12-28 16:32:40 +09:00
K Lange
b32dde0431
add % operator
2020-12-28 16:32:27 +09:00
K. Lange
d8d03a2c4c
pause gc around bound native calls
2020-12-28 22:18:30 +09:00
K. Lange
067d8cdb65
fix upvalue storage being completely broken when we move the stack
2020-12-28 22:02:39 +09:00
K. Lange
ae2b00bcfa
int32_t is long int on toaru? I should probably fix that
2020-12-28 21:08:55 +09:00
K. Lange
724e44655d
Make print statement force args to strings
2020-12-28 20:47:16 +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
b3ad2e1f22
Second pass at cleaning up built-ins
2020-12-28 19:26:01 +09:00