Damien George
a11ceca807
Change int to uint for n_args in function with variable arguments.
11 years ago
Damien George
136b149e41
py: Add full traceback to exception printing.
11 years ago
Damien George
cbd2f7482c
py: Add module/function/class name to exceptions.
Exceptions know source file, line and block name.
Also tidy up some debug printing functions and provide a global
flag to enable/disable them.
11 years ago
Damien George
e02b2d4391
py: Temporary fix for bug where not enough VM state is allocated.
11 years ago
Damien George
ebde0b8a09
Tiny optimisation in objlist.c; a new test for inheritance.
11 years ago
Damien George
932bf1c48f
py: Fix VM/runtime unpack sequence bug, Issue #193 .
11 years ago
Paul Sokolovsky
a2715c05c6
Add objarray.h .
11 years ago
Damien George
08335004cf
Add source file name and line number to error messages.
Byte code has a map from byte-code offset to source-code line number,
used to give better error messages.
11 years ago
Damien George
f49ba1bd9c
Improve method lookup in mp_obj_class_lookup.
Now searches both locals_dict and methods. Partly addresses Issue #145 .
11 years ago
Paul Sokolovsky
427905cedd
Add skeleton implementation of array.array and bytearray.
So far, only storage, initialization, repr() and buffer protocol is
implemented - alredy suitable for passing binary data around.
11 years ago
Damien George
1d6fc94c16
Implement framework for class-defined built-in operators.
Now working for class-defined methods: __getitem__, __setitem__,
__add__, __sub__. Easy to add others.
11 years ago
Paul Sokolovsky
d26b379eec
int: Add value accessors: mp_obj_int_get() & mp_obj_int_get_checked().
mp_obj_int_get() can be used when just full resolution of C machine_int_t
is required (returns truncated value of long int). mp_obj_int_get_checked()
will throw exception if Python int value not representable in machine_int_t.
11 years ago
Damien George
20006dbba9
Make VM stack grow upwards, and so no reversed args arrays.
Change state layout in VM so the stack starts at state[0] and grows
upwards. Locals are at the top end of the state and number downwards.
This cleans up a lot of the interface connecting the VM to C: now all
functions that take an array of Micro Python objects are in order (ie no
longer in reverse).
Also clean up C API with keyword arguments (call_n and call_n_kw
replaced with single call method that takes keyword arguments). And now
make_new takes keyword arguments.
emitnative.c has not yet been changed to comply with the new order of
stack layout.
11 years ago
Paul Sokolovsky
6d8edf6acf
Add store_item() virtual method to type to implement container[index] = val.
11 years ago
Paul Sokolovsky
166bb40fb2
Add OverflowError and use it for small int overflow instead of assert.
11 years ago
Paul Sokolovsky
a9f5abd48c
Implement LOAD_CONST_INT (by dispatching to int object implementation).
11 years ago
Paul Sokolovsky
966879cf59
Add long int implementation using C long long type, enable for unix port.
11 years ago
Paul Sokolovsky
10744dd816
Add empty (false) value testing for strings, tuples, lists, dicts.
11 years ago
Paul Sokolovsky
dcac88095b
Add empty "micropython" module to allow more seamless CPython portability.
Implicit "micropython" module contains (at least) codegeneration decorators.
Make it explicit, so an app could have "import micropython". On MicroPython,
that will be no-op. On CPython, that will give a chance to have a module
with placeholder decorators.
11 years ago
Paul Sokolovsky
a671f891dd
Make file.read() and file.read(-1) call out to file.readall().
Per Python3 io module semantics.
11 years ago
Paul Sokolovsky
323c09e881
Do not assume that vstr buf is the same after it was extended.
11 years ago
Paul Sokolovsky
f2b796e7c7
str.format: Don't assume that '}' immediately follows '{', skip insides.
That at least makes stuff like "{:x}".format(1) to produce not completely
broken output.
11 years ago
Damien George
b99d9ea258
Add errno=0 before call.
11 years ago
Damien George
613eb25545
stm: Fix print methods with new kind argument.
11 years ago
Damien George
d02c6d8962
Implement eval.
11 years ago
Paul Sokolovsky
9953ca432b
Add unbuffered readline() implementation for Raw I/O files.
11 years ago
Damien George
e2fb2baaa4
Implement repr.
11 years ago
Damien George
9528cd66d7
Convert parse errors to exceptions.
Parser no longer prints an error, but instead returns an exception ID
and message.
11 years ago
xyb
3e4ed25138
add more tests and remove debug code
11 years ago
xyb
3270fb4be6
int() test passed
11 years ago
John R. Lenton
fca456bc3c
added filter()
11 years ago
John R. Lenton
39b174e00a
Added map
11 years ago
Paul Sokolovsky
36c4499d36
Implement str() and repr() builtin functions.
11 years ago
Paul Sokolovsky
76d982ef34
type->print(): Distinguish str() and repr() variety by passing extra param.
11 years ago
John R. Lenton
9daa78943e
added enumerate()
11 years ago
Damien George
0f59203e37
Tidy up.
11 years ago
Paul Sokolovsky
8bc96471f0
Implement "is" and "is not" operators.
So far, don't work for strings as expected.
11 years ago
Paul Sokolovsky
ddf2178d83
Refactor exception objects to have better impl of Python-side interface.
This implements internal args tuple of arguments, while still keeping
object useful for reporting C-side errors.
Further elaboration is needed.
11 years ago
Paul Sokolovsky
8eec8bcad9
Add objtuple.h to allow embedding of tuples inside other objects.
This is useful because tuple is closest analog of C static array.
11 years ago
xyb
82e61bdc24
support int(str, basbase)
11 years ago
xyb
c178ea471e
Implemented int(str) in UNIX
11 years ago
Paul Sokolovsky
5225450b9f
Add generic impl of stream .readall() method. Use one for unix io.FileIO.
11 years ago
Paul Sokolovsky
5d2499c638
Add "buffer management" and "shrink" API calls to vstr.
vstr is initially intended to deal with arbitrary-length strings. By
providing a bit lower-level API calls, it will be also useful to deal
with arbitrary-length I/O buffers (the difference from strings is that
buffers are filled from "outside", via I/O).
Another issue, especially aggravated by I/O buffer use, is alloc size
vs actual size length. If allocated 1Mb for buffer, but actually
read 1 byte, we don't want to keep rest of 1Mb be locked by this I/O
result, but rather return it to heap ASAP ("shrink" buffer before passing
it to qstr_from_str_take()).
11 years ago
Paul Sokolovsky
ca318bba0d
mp_obj_equal(): Compare small and long ints properly.
By dispatching to long int methods.
11 years ago
Paul Sokolovsky
76a90f2f60
Move mp_obj_int_t definition to objint.h, to reuse in long int impls.
11 years ago
John R. Lenton
88cb1e60e0
Made sorted() raise an exception instead of aborting when given no arguments; moved around some things in objfun.c as a consequence
11 years ago
John R. Lenton
2ded68db77
Cleaned up sorted() as per Damien's suggestions.
11 years ago
Damien George
f62d33aa1d
Consolidate rt_make_function_[0123] to rt_make_function_n.
11 years ago
Damien George
2300537c79
Cleanup built-ins, and fix some compiler warnings/errors.
11 years ago
Dave Hylands
44332ec9ea
Initialize is_kw for dynamically allocated mp_obj_fun_native_t ojects.
This should fix issue #171
11 years ago