Commit Graph

2096 Commits

Author SHA1 Message Date
Damien George
b0edec61ac stmhal: Improve handling of out-of-memory in REPL.
Addresses issue #558, but it's likely that other out-of-memory errors
could crash the pyboard.  Reason is that qstrs use m_new and can raise
an exception within the parser.
2014-05-10 17:48:46 +01:00
Damien George
e1199ecf10 py, lexer: Add allocation policy config; return NULL if can't allocate. 2014-05-10 17:48:01 +01:00
Damien George
1b82e9af5c py: Improve handling of memory error in parser.
Parser shouldn't raise exceptions, so needs to check when memory
allocation fails.  This patch does that for the initial set up of the
parser state.

Also, we now put the parser object on the stack.  It's small enough to
go there instead of on the heap.

This partially addresses issue #558.
2014-05-10 17:36:41 +01:00
Paul Sokolovsky
ad6178bb08 builtinimport: Fix broken namespace imports due to dup vstr_cut_tail_bytes(). 2014-05-10 19:00:03 +03:00
Paul Sokolovsky
f9589d2f23 builtinimport: Fix comment orphaned by one of previous commits. 2014-05-10 18:46:02 +03:00
Paul Sokolovsky
deaeaac469 modsys: Enable sys.exit() per port after all. 2014-05-10 17:26:47 +03:00
Paul Sokolovsky
37b0f33545 objset: Add frozenset tests, skippable if frozenset not available. 2014-05-10 16:56:21 +03:00
Paul Sokolovsky
43d4a6fa31 run-tests: Add support for skipping tests.
MicrpPython test should print single "SKIP" line for test to be skipped.
2014-05-10 16:56:21 +03:00
Paul Sokolovsky
0f14fdea0c stmhal: Implement draft version of sys.exit(). 2014-05-10 16:56:21 +03:00
Paul Sokolovsky
d99e9083cb modsys, unix: Add sys.exit(), should be implemented by a port. 2014-05-10 16:56:21 +03:00
Paul Sokolovsky
d80e2476c7 py: Disable frozenset by default, enable on unix.
Takes 416 text bytes on x86.
2014-05-10 16:56:20 +03:00
Paul Sokolovsky
b181b581aa objset: Give up and implement frozenset.
Tired of patching CPython stdlib for it.
2014-05-10 16:56:20 +03:00
Paul Sokolovsky
d86020ac4f objtype: Don't treat inheritance from "object" as from native type.
"object" type in MicroPython currently doesn't implement any methods, and
hopefully, we'll try to stay like that for as long as possible. Even if we
have to add something eventually, look up from there might be handled in
adhoc manner, as last resort (that's not compliant with Python3 MRO, but
we're already non-compliant). Hence: 1) no need to spend type trying to
lookup anything in object; 2) no need to allocate subobject when explicitly
inheriting from object; 3) and having multiple bases inheriting from object
is not a case of incompatible multiple inheritance.
2014-05-10 16:56:20 +03:00
Damien George
d0a5bf34f7 py: Tidy up returning NULL which should be MP_OBJ_NOT_SUPPORTED. 2014-05-10 13:55:11 +01:00
Damien George
2bb179e124 bare-arm: Change output file from flash.elf to firmware.elf. 2014-05-10 13:45:47 +01:00
Damien George
ccc85ea0da py: Combine native emitters to 1 glue function; distinguish viper.
This patch simplifies the glue between native emitter and runtime,
and handles viper code like inline assember: return values are
converted to Python objects.

Fixes issue #531.
2014-05-10 13:40:46 +01:00
Damien George
04b7cc4df0 stmhal: Fix setting of RTC: was BCD now BIN encoded.
Addresses issue #592.
2014-05-10 11:56:58 +01:00
Damien George
c17fd70de9 stm: Reorder mpconfig.h header inclusion to get stm building. 2014-05-10 10:38:38 +01:00
Damien George
3417bc2f25 py: Rename byte_code to bytecode everywhere.
bytecode is the more widely used.  See issue #590.
2014-05-10 10:36:38 +01:00
Paul Sokolovsky
6e8085b425 py: Fix base "detection" for int('0<hexdigit>', 16). 2014-05-10 04:45:15 +03:00
Paul Sokolovsky
7b0f9a7d9b bytes: Implement comparison and other binary operations.
Should support everything supported by strings.
2014-05-10 04:45:02 +03:00
Paul Sokolovsky
070c78af5d runtime0.h: Group binary ops by fives.
So one has some chance to convert numeric op code into symbol.
2014-05-10 04:44:55 +03:00
Paul Sokolovsky
affa870cc2 Merge pull request #575 from stinos/windows-modtime
Add modtime implementation for mingw
2014-05-09 22:09:10 +03:00
stijn
5ed284a15e windows: Add modtime implementation 2014-05-09 13:58:15 +02:00
Damien George
d25cba4f64 Merge branch 'pfalcon-README-features-overview' 2014-05-09 12:01:15 +01:00
Damien George
65114ca015 README: Add articles, and update doc for deploying firmware. 2014-05-09 12:00:23 +01:00
Paul Sokolovsky
ad79ecdf96 README: Add short overview of Python features supported.
Also, "upgrade" project to "early beta", and elaborate pyboard description.
2014-05-09 04:15:24 +03:00
Damien George
8c1c7488b2 Add gc.enable, gc.disable; remove pyb.gc. 2014-05-08 23:04:49 +01:00
Damien George
d6cbbc51ab stmhal: Add time.time() and time.localtime().
time.time: returns seconds since 1/1/2000, as an integer.

time.localtime: Returns 8-tuple: (year, month, date, hour, minute,
    second, weekday, yearday).
2014-05-08 22:25:49 +01:00
Paul Sokolovsky
62b5f42d81 Merge pull request #568 from stinos/windows-msvc-port
Windows MS Visual C port
2014-05-09 00:03:42 +03:00
Damien George
ffae48d750 py, compiler: Add basic support for A=const(123).
You can now do:

    X = const(123)
    Y = const(456 + X)

and the compiler will replace X and Y with their values.

See discussion in issue #266 and issue #573.
2014-05-08 15:58:39 +00:00
stijn
01d6be4d51 Windows MSVC port
Extend the windows port so it compiles with the toolchain from Visual Studio 2013
2014-05-08 10:06:43 +02:00
Ilya Dmitrichenko
c1c32d65af qemu-arm: fully integrated test suite.
This is primarily intended to provide testing of Thumb-specific code within
Travis CI as well as if anyone else want to run it locally.  As discussed in
purposes.  This is currently agains an emulated Cortex-M3 core, however in
the near future it can extended to support M0, M0+ as well M4 (work in
progress exists in sushihangover/qemu).

It's probably true that most of the code base can be covered running uPy
natively on a POSIX system, however we do have the tiny bit of assembly
code.  There may exist bugs related to endianness and type aliases, let
alone potential standard library or compiler bugs or even
architecture-specific optimisations.

This could also incorporate lwIP (or other TCP/IP stack) integration as well
as SDIO+FATFS drivers.

The solution to inline the test cases was chose due to simplicity. It could
alternatively be implemented in a number of different way (see #515), but
this looked the simplest.

Inclusion of tinytest was just to avoid writing boilerplate code for
counting failed tests and other utility functions.  Currently only a few
functions are used, however this could be extended.  Checking in the code
instead of using submodule was a personal preference, but if people do want
the pain of submodules, this can provided.  This particular framework is
also pretty good if one desires to run unit test on target.  The approach
with scripts being inlined is probably not quite suited for the size of
memory an MCU has, but the tinytest itself should be good, if lower-level C
code is to be unit tested.
2014-05-08 01:41:32 +03:00
Ilya Dmitrichenko
be86596bb9 tools: inline test suite generator. 2014-05-08 01:41:22 +03:00
Ilya Dmitrichenko
b1442e04d1 tools: check-in errordeveloper/tinytest@eb2dbc858f 2014-05-08 01:41:21 +03:00
Damien George
d509ac25f9 py: Fix stack access in thumb native emitter. 2014-05-07 23:27:45 +01:00
Paul Sokolovsky
be6aa53cdb Merge pull request #584 from stinos/windows-input
windows: Fix input.c missing in Makefile after changes for #582
2014-05-07 22:44:19 +03:00
Paul Sokolovsky
69cbec4afb tests/bench: Add testcase for positional/kwargs to enumerate().
Inspired by discussion in #577. So, in this case of builtin function,
passing args by keyword has less than 1% overhead.
2014-05-07 22:34:06 +03:00
Paul Sokolovsky
2a05f05f44 tests/bench: Add tests for various ways to pass function args.
Passing 3 args with keywords is for example 50% slower than via positional
args.
2014-05-07 22:34:04 +03:00
Paul Sokolovsky
1695151267 tests/bench: Add variation on loop_count/while_down_ne test. 2014-05-07 22:34:04 +03:00
Paul Sokolovsky
6638ea9ca3 tests/bench: Add testcases for lookup in 5-el instance and namedtuple.
... and we have not that bad mapping type after all - lookup time is ~ the
same as in one-attr instance. My namedtuple implementation on the other
hand degrades awfully.

So, need to rework it. First observation is that named tuple fields are
accessed as attributes, so all names are interned at the program start.
Then, really should store field array as qstr[], and do quick 32/64 bit
scan thru it.
2014-05-07 22:34:00 +03:00
Paul Sokolovsky
52b25293e2 tests/bench: Time namedtuple field access.
That's higher than instance field access - behold the power of hashing.
2014-05-07 22:33:37 +03:00
stijn
951335e102 windows: Fix input.c missing in Makefile after changes for #582 2014-05-07 21:15:00 +02:00
Damien George
c3602e159c py: Fix emitcpy, to work with latest changes to PASS variables. 2014-05-07 18:57:32 +01:00
Damien George
9102af6afb tests: Add a test for native code on pyboard. 2014-05-07 18:55:31 +01:00
Damien George
c4ccb078a5 tests: Add inline assembler test for pyboard. 2014-05-07 18:31:14 +01:00
Damien George
a32c1e41cc py: Improve native emitter; now supports more opcodes. 2014-05-07 18:30:52 +01:00
Damien George
36db6bcf54 py, compiler: Improve passes; add an extra pass for native emitter. 2014-05-07 17:24:22 +01:00
Damien George
ca25c15d56 py, compiler: Start adding support for compile-time constants.
Just a start, no working code yet.  As per issue #573.
2014-05-07 15:42:03 +01:00
Damien George
7c6c843965 unix: Add missing stdio.h header for readline. 2014-05-07 15:33:15 +01:00