Damien George
20f59e182e
py: Make mp_const_empty_bytes globally available.
2014-10-21 21:02:56 +01:00
stijn
2fe4cf7761
Implement kwargs for builtin open() and _io.FileIO
...
This makes open() and _io.FileIO() more CPython compliant.
The mode kwarg is fully iplemented.
The encoding kwarg is allowed but not implemented; mainly to allow
the tests to specify encoding for CPython, see #874
2014-10-21 22:10:01 +03:00
Damien George
21ca2d76a2
py: Partially fix viper multi-comparison; add test for it.
2014-10-19 19:00:51 +01:00
Paul Sokolovsky
1a55b6a787
unix, stmhal: Implement file.readinto() method.
...
Also, usocket.readinto(). Known issue is that .readinto() should be available
only for binary files, but micropython uses single method table for both
binary and text files.
2014-10-18 22:44:07 +03:00
Damien George
b7a4b0f86f
py: Improve stream_read so it doesn't need to alloc 2 bits of heap.
2014-10-17 23:34:06 +01:00
Damien George
391db8669b
py: Add more compiler optimisations for constant if/while conditions.
2014-10-17 17:57:33 +00:00
Damien George
235f9b33c8
py: Simplify compilation of elif blocks.
2014-10-17 17:30:16 +00:00
Damien George
c30595eb1b
py: Add more debug printing code in gc_dump_alloc_table.
2014-10-17 14:12:57 +00:00
Damien George
090c9236e8
py: Fix compiling of nested while/for and exception handler.
...
Addresses issue #912 .
2014-10-17 14:08:49 +00:00
Damien George
37ada236b3
py: Take gc_pool_start out of bss section, to reclaim 1st block of heap.
2014-10-16 21:50:39 +01:00
Paul Sokolovsky
923a8a8320
stream: Handle non-blocking errors in readline() properly.
...
Just like they handled in other read*(). Note that behavior of readline()
in case there's no data when it's called is underspecified in Python lib
spec, implemented to behave as read() - return None.
2014-10-16 12:22:52 +03:00
Paul Sokolovsky
0c7b26c0f8
stream: Return errno value as first arg of OSError exception.
...
This is CPython-compatible convention established yet in acb13886fc
.
2014-10-16 02:58:52 +03:00
Paul Sokolovsky
067ae1269d
objclosure: Fix printing of generator closures.
...
The code previously assumed that only functions can be closed over.
2014-10-16 00:14:01 +03:00
Damien George
9b0b373e5e
py: Fix GC realloc issue, where memory chunks were never shrunk.
...
Previously, a realloc to a smaller memory chunk size would not free the
unused blocks in the tail of the chunk.
2014-10-15 18:24:47 +00:00
Damien George
4859edb95b
py: Fix dummy definition of BEGIN/END_ATOMIC_SECTION.
2014-10-15 17:33:24 +00:00
Paul Sokolovsky
911c00bbc5
modzlibd: Remove, superceded by moduzlib.
2014-10-13 14:13:22 +03:00
Damien George
29f5682621
Merge pull request #904 from pfalcon/moduzlib
...
Module "uzlib" - based on similarly named library
2014-10-12 23:25:24 +01:00
Paul Sokolovsky
34162872b1
moduzlib: Integrate into the system.
2014-10-13 00:07:44 +03:00
Damien George
c14a81662c
py: Add module weak link support.
...
With this patch a port can enable module weak link support and provide
a dict of qstr->module mapping. This mapping is looked up only if an
import fails to find the requested module in the filesystem.
This allows to have the builtin module named, eg, usocket, and provide
a weak link of "socket" to the same module, but this weak link can be
overridden if a file by the name "socket.py" is found in the import
path.
2014-10-12 20:18:40 +01:00
Damien George
3c34d4140d
py: Fix x86 viper code generation, mem8 <-> mem16 for load.
2014-10-12 16:10:25 +00:00
Damien George
91cfd414c0
py: Implement native load for viper.
...
Viper can now do: ptr8(buf)[0], which loads a byte from a buffer using
machine instructions.
2014-10-12 16:59:29 +01:00
Damien George
1ef2348df0
py: Implement and,or,xor native ops for viper.
2014-10-12 14:21:06 +01:00
Paul Sokolovsky
1606607bd4
modure: Make sure that re1.5 compiled in only of modure itself is enabled.
...
This is achieved by including re1.5 *.c files straight from modure.c .
2014-10-12 03:40:20 +03:00
Paul Sokolovsky
c71e045165
modure: Initial module, using re1.5 (which is based on re1 codebase).
...
https://github.com/pfalcon/re1.5
2014-10-11 14:36:32 +03:00
Damien George
9bf5f2857d
py: Add further checks for failed malloc in lexer init functions.
2014-10-09 16:53:37 +01:00
Damien George
a8202762f0
Merge branch 'lexer-crash' of https://github.com/dhylands/micropython into dhylands-lexer-crash
2014-10-09 16:48:55 +01:00
Damien George
4091445612
py: Add #if guard around gc-specific code.
2014-10-09 16:44:43 +01:00
Dave Hylands
e20cbbec73
Make lexer fail gracefully when memory can't be allocated.
2014-10-08 23:17:35 -07:00
Dave Hylands
3556e45711
Allow real memory errors (from locked gc) to be reported with traceback.
2014-10-07 08:07:49 -07:00
Damien George
f32498fe04
py: Extra autodetect for little endianness using __LITTLE_ENDIAN__.
2014-10-06 16:09:31 +00:00
Damien George
9336ee320a
py: Make mp_binary_set_val work on big endian machine.
2014-10-06 15:05:35 +00:00
Damien George
fcdb239815
py: Make int.to_bytes work on big endian machine.
...
Partly addresses issue #856 .
2014-10-06 13:45:34 +00:00
Damien George
a9bcd51dc7
py: Try to autodetect machine endianness when not defined by port.
2014-10-06 13:44:59 +00:00
Damien George
c4d0868df1
py: Implement proper context save/restore for eval/exec; factor code.
...
This has benefits all round: code factoring for parse/compile/execute,
proper context save/restore for exec, allow to sepcify globals/locals
for eval, and reduced ROM usage by >100 bytes on stmhal and unix.
Also, the call to mp_parse_compile_execute is tail call optimised for
the import code, so it doesn't increase stack memory usage.
2014-10-05 20:13:34 +01:00
Damien George
a91ac2011f
py: Make compiler return a proper exception on SyntaxError.
2014-10-05 19:01:34 +01:00
Fabian Vogt
e5268963c6
Implement missing ARM emitter functions for viper
2014-10-04 00:57:21 +02:00
Damien George
00be7a849a
py: Fix unix-cpy to compile with uint->mp_uint_t changes.
2014-10-03 20:05:44 +01:00
Damien George
39dc145478
py: Change [u]int to mp_[u]int_t in qstr.[ch], and some other places.
...
This should pretty much resolve issue #50 .
2014-10-03 19:52:22 +01:00
Damien George
3eaa0c3833
py: Use UINT_FMT instead of %d.
2014-10-03 17:54:25 +00:00
Damien George
42f3de924b
py: Convert [u]int to mp_[u]int_t where appropriate.
...
Addressing issue #50 .
2014-10-03 17:44:14 +00:00
Damien George
8b03d944e2
py: Remove IOError since it's deprecated; use OSError instead.
...
In CPython IOError (and EnvironmentError) is deprecated and aliased to
OSError. All modules that used to raise IOError now raise OSError (or a
derived exception).
In Micro Python we never used IOError (except 1 place, incorrectly) and
so don't need to keep it.
See http://legacy.python.org/dev/peps/pep-3151/ for background.
2014-09-30 13:59:30 +00:00
Damien George
1c6a1dc740
py: Allow x86-64 to mov r16 to rm16 with extended src reg.
...
Fixes bug with x86-64 viper ptr16.
2014-09-29 22:44:18 +01:00
Damien George
dfef4249eb
py: Fix viper store on x86; add tests for viper ptr16.
2014-09-29 21:41:41 +00:00
Damien George
e9dac3b4d0
py: Add casting to viper; add native mem stores to viper.
...
Viper can now do the following:
def store(p:ptr8, c:int):
p[0] = c
This does a store of c to the memory pointed to by p using a machine
instructions inline in the code.
2014-09-29 22:10:41 +01:00
Damien George
3112cde900
py: Implement more binary ops for viper emitter.
...
This included a bit of restructuring of the assembler backends. Note
that the ARM backend is missing a few functions and won't compile.
2014-09-29 19:42:06 +01:00
Damien George
6f81348fa2
py: Allow viper to use ints as direct conditionals in jumps.
...
Allows things like: if 1: ...
2014-09-29 19:42:06 +01:00
Damien George
a7329615eb
py: Fix types, uint -> mp_uint_t.
2014-09-29 19:42:06 +01:00
Damien George
0b610de017
py: Make macro names in assemblers consistent, and tidy up a bit.
2014-09-29 19:42:06 +01:00
Damien George
d66e48662b
py: Add store r8 and store r16 ops to asm_x86 and asm_x64.
2014-09-29 19:42:06 +01:00
Damien George
851f15f34c
py: In asmthumb, clean up unit/int types and ite ops.
2014-09-29 19:42:06 +01:00