Commit Graph

584 Commits

Author SHA1 Message Date
Paul Sokolovsky
1d30b11685 showbc: Update for recent int varlen storage refactor.
TODO: De-duplicate DECODE_UINT, etc. definitions.
2014-02-21 03:26:56 +02:00
Paul Sokolovsky
feacaa12ac __import__: Catch relative import attempts and throw NotImplementedError. 2014-02-21 01:15:20 +02:00
Paul Sokolovsky
a8d31b28bc emitbc: Correct buffer sizes for varlen int encoding.
Assuming we have truncating (floor) division, way to do ceiling division
by N is to use formula (x + (N-1)) / N. Specifically, 63 bits, if stored
7 bits per byte, require exactly 9 bytes. 64 bits overflow that and require
10 bytes.
2014-02-20 13:25:05 +02:00
Paul Sokolovsky
a1aba36feb compile: Add comments ergarding non-implemented relative imports. 2014-02-20 13:22:28 +02:00
Damien George
4d79d5dd7c py: Fix type of integer in decoding int. 2014-02-20 00:00:04 +00:00
Damien George
b74501c98f Merge pull request #312 from pfalcon/int-varlen
Support varlen encoding for arbitrary int and uint numbers
2014-02-19 23:56:23 +00:00
Damien George
948a58d56e Merge pull request #310 from dhylands/pin_map
Add pin mapping code.
2014-02-19 23:19:18 +00:00
Paul Sokolovsky
fb7f94392d import: Implement "from pkg.mod import sym" syntax properly.
http://docs.python.org/3.3/library/functions.html#__import__ :
"When the name variable is of the form package.module, normally, the
top-level package (the name up till the first dot) is returned, not
the module named by name. However, when a non-empty fromlist argument
is given, the module named by name is returned."
2014-02-20 00:37:12 +02:00
Paul Sokolovsky
047cd40313 Bytecode int varlen encoding: support arbitrary values for signed ints too. 2014-02-19 15:53:41 +02:00
Paul Sokolovsky
0f96ec8268 Bytecode uint varlen encoding: support arbitrary values. 2014-02-19 15:52:57 +02:00
Dave Hylands
51dabac096 Add pin mapping code.
This commit also introduces board directories and moves board
specific config into the appropriate board directory.

boards/stm32f4xx-af.csv was extracted from the STM32F4xx datasheet
and hand-tweaked.

make-pins.py takes boards/stm32f4xx-af.csv, boards/stm32f4xx-prefix.c,
and boards/BOARD-NAME/pins.csv as input and generates the file
build/pins_BOARD_NAME.c

The generated pin file for PYBOARD4 looks like this:
https://gist.github.com/dhylands/9063231

The generated pins file includes all of the supported alternate
functions, and includes upsupported alternate functions as comments.

See the commnet block at the top of stm/pin_map.c for details on
how to use the pin mapper.

I also went ahead and modified stm/gpio.c to use the pin mapper.
2014-02-17 21:20:38 -08:00
Paul Sokolovsky
4d0588df56 objint_longlong: Don't assert on invalid syntax, raise SyntaxError instead. 2014-02-18 00:22:19 +02:00
Paul Sokolovsky
4aee119f94 stm: Initialize sys.path with ["0:/", "0:/src", "0:/lib"].
This is compatible with what search path was before sys.path refactor,
with addition of module library path ("0:/lib").
2014-02-18 00:06:37 +02:00
Paul Sokolovsky
ac2e28c654 Support passing positional args as keywords to bytecode functions.
For this, record argument names along with each bytecode function. The code
still includes extensive debug logging support so far.
2014-02-16 18:36:33 +02:00
Paul Sokolovsky
44739e280e Make DEBUG_printf() a proper function, implementation is port-dependent.
In particular, unix outputs to stderr, to allow to run testsuite against
micropython built with debug output (by redirecting stderr to /dev/null).
2014-02-16 18:20:49 +02:00
Paul Sokolovsky
5fd7bc3264 Propagate scope flags refactor to emitcpy.c. 2014-02-16 03:02:47 +02:00
Paul Sokolovsky
91ba7a54c5 builtinimport: Get the basic (and only basic) package imports work. 2014-02-16 02:55:46 +02:00
Paul Sokolovsky
d3783570a4 builtinimport.c: Recognize "namespace package" and error out as unsupported.
See http://www.python.org/dev/peps/pep-0420/#specification for spec. See
https://github.com/micropython/micropython/issues/298 for the discussion
of the implemented behavior.
2014-02-16 02:55:46 +02:00
Damien George
e5d371b545 py: Pass keyword arguments to byte code. 2014-02-16 00:17:42 +00:00
Damien George
2e482cdb7b py: Implement *vargs support.
Addresses issue #295.
2014-02-16 00:01:29 +00:00
Damien George
96056a6272 py: Revent some long int configuration. 2014-02-15 23:02:00 +00:00
Damien George
c8f78bc280 py: VM never throws an exception, instead returns a status and value.
Addresses issue #290, and hopefully sets up things to allow generators
throwing exceptions, etc.
2014-02-15 22:55:00 +00:00
Damien George
36109d246f Small change to configuration of long int. 2014-02-15 22:16:33 +00:00
Damien George
22a0865d54 py: Improve exception bases, reduces ROM usage.
Thanks to @pfalcon for the tip!
2014-02-15 21:05:25 +00:00
Damien George
8725f8f7de py: Pass all scope flags through to runtime. 2014-02-15 19:33:11 +00:00
Damien George
c5966128c7 Implement proper exception type hierarchy.
Each built-in exception is now a type, with base type BaseException.
C exceptions are created by passing a pointer to the exception type to
make an instance of.  When raising an exception from the VM, an
instance is created automatically if an exception type is raised (as
opposed to an exception instance).

Exception matching (RT_BINARY_OP_EXCEPTION_MATCH) is now proper.

Handling of parse error changed to match new exceptions.

mp_const_type renamed to mp_type_type for consistency.
2014-02-15 16:10:44 +00:00
Damien George
a71c83a1d1 Change mp_obj_type_t.name from const char * to qstr.
Ultimately all static strings should be qstr.  This entry in the type
structure is only used for printing error messages (to tell the type of
the bad argument), and printing objects that don't supply a .print method.
2014-02-15 11:34:50 +00:00
Damien George
aa9b74fead py: Fix IMPORT_STAR, needs to pop the stack. 2014-02-14 23:06:33 +00:00
Damien George
7ef098000a Merge pull request #288 from pfalcon/port-builtins
Allow ports to define statically builtin functions.
2014-02-14 23:05:50 +00:00
Damien George
25735ba6d3 Merge pull request #282 from pfalcon/from-star
Implement "from mod import *"
2014-02-14 23:00:09 +00:00
Paul Sokolovsky
76f8cedb52 mp_binary_get_val(): Fix value type. 2014-02-15 00:30:03 +02:00
Paul Sokolovsky
60a0d3f1db objexcept: Fix a case of initialized object field. 2014-02-15 00:29:50 +02:00
Paul Sokolovsky
c203324e6c objarray: Refactor to use array accessors from binary.c . 2014-02-14 20:38:46 +02:00
Paul Sokolovsky
8bc3516389 ffi: Implement ffivar.get()/set() methods.
Done by introducing another factored out helper API in binary.c. This API
can be reused also by array and struct modules.
2014-02-14 20:38:35 +02:00
Paul Sokolovsky
910843e86d Allow ports to define statically builtin functions.
Convert unix open() to such.
2014-02-14 12:13:34 +02:00
Paul Sokolovsky
da1ce93da8 Implement "from module import *" construct. 2014-02-14 00:30:36 +02:00
Damien George
a8d404e0e1 Merge branch 'master' of github.com:micropython/micropython 2014-02-12 23:02:49 +00:00
Damien George
099a9cb575 Remove mp_obj_new_exception_msg_1_arg and _2_arg. 2014-02-12 23:02:19 +00:00
Paul Sokolovsky
2aa217b974 Implement full arg handling for exec(). 2014-02-13 00:36:54 +02:00
Paul Sokolovsky
520e2f58a5 Replace global "static" -> "STATIC", to allow "analysis builds". Part 2. 2014-02-12 18:31:30 +02:00
Paul Sokolovsky
d5df6cd44a Replace global "static" -> "STATIC", to allow "analysis builds". Part 1.
Some tools do not support local/static symbols (one example is GNU ld map file).
Exposing all functions will allow to do detailed size comparisons, etc.

Also, added bunch of statics where they were missing, and replaced few identity
functions with global mp_identity().
2014-02-12 18:21:11 +02:00
Paul Sokolovsky
550d804d95 Add prototype for gc_dump_info(). 2014-02-11 23:53:34 +02:00
Paul Sokolovsky
723a6ed371 More GC debugging improvements. 2014-02-11 18:09:50 +02:00
Paul Sokolovsky
b62c30b4bc Generalize malloc-via-gc-heap support, make it available to unix port. 2014-02-11 16:20:02 +02:00
Paul Sokolovsky
4e2460852a objstr: Mark few local symbols as static, cleanup codestyle.
Please don't submit patches with tab indentation!
2014-02-11 15:34:32 +02:00
Paul Sokolovsky
c0a8374103 gc: Don't segfault if gc_realloc() fails. 2014-02-11 15:34:32 +02:00
Paul Sokolovsky
af19cbd201 gc: Make debug output configurable, revamp test function.
Test function needs to be called by something else. Test heap size reduced so
its dump fits on a screenful of a typical terminal.
2014-02-11 02:31:28 +02:00
Paul Sokolovsky
4e836fb4ea mp_obj_equal(): Instead of assert(), throw NotImplementedError.
With a nice traceback, helps debugging much better.
2014-02-11 02:28:36 +02:00
Paul Sokolovsky
0a25aba046 Typo fix in comment. 2014-02-11 02:28:36 +02:00
Damien George
b0b7518dd1 Merge pull request #270 from pfalcon/down-with-calloc
Get rid of calloc().
2014-02-10 22:00:36 +00:00