| Commit message (Collapse) | Author | Age |
| |
|
|
|
|
|
| |
This function is only used when DEBUG_PRINTERS and USE_RULE_NAME are
enabled.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
Previous to this patch, a big-int, float or imag constant was interned
(made into a qstr) and then parsed at runtime to create an object each
time it was needed. This is wasteful in RAM and not efficient. Now,
these constants are parsed straight away in the parser and turned into
objects. This allows constants with large numbers of digits (so
addresses issue #1103) and takes us a step closer to #722.
|
|
|
|
|
|
|
|
|
|
| |
To enable parsing constants more efficiently, mp_parse should be allowed
to raise an exception, and mp_compile can already raise a MemoryError.
So these functions need to be protected by an nlr push/pop block.
This patch adds that feature in all places. This allows to simplify how
mp_parse and mp_compile are called: they now raise an exception if they
have an error and so explicit checking is not needed anymore.
|
| |
|
|
|
|
| |
See issue #699.
|
|
|
|
| |
See issue #699.
|
|
|
|
|
| |
This helps compiler produce smaller code. Saves 124 bytes on stmhal and
bare-arm.
|
|
|
|
|
|
|
|
|
|
| |
Previously to this patch all constant string/bytes objects were
interned by the compiler, and this lead to crashes when the qstr was too
long (noticeable now that qstr length storage defaults to 1 byte).
With this patch, long string/bytes objects are never interned, and are
referenced directly as constant objects within generated code using
load_const_obj.
|
|
|
|
| |
Addresses issue #1022.
|
| |
|
|
|
|
| |
This saves around 100 bytes code space on stmhal, more on unix.
|
| |
|
|
|
|
|
|
|
|
|
| |
mp_lexer_t type is exposed, mp_token_t type is removed, and simple lexer
functions (like checking current token kind) are now inlined.
This saves 784 bytes ROM on 32-bit unix, 348 bytes on stmhal, and 460
bytes on bare-arm. It also saves a tiny bit of RAM since mp_lexer_t
is a bit smaller. Also will run a bit more efficiently.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
mp_parse_node_free now frees the memory associated with non-interned
strings. And the parser calls mp_parse_node_free when discarding a
non-used node (such as a doc string).
Also, the compiler now frees the parse tree explicitly just before it
exits (as opposed to relying on the caller to do this).
Addresses issue #708 as best we can.
|
|
|
|
|
|
|
|
|
| |
Viper functions can now be annotated with the type of their arguments
and return value. Eg:
@micropython.viper
def f(x:int) -> int:
return x + 1
|
| |
|
|
|
|
| |
See discussion in issue #50.
|
|
|
|
|
|
| |
It defines types used by all other headers.
Fixes #691.
|
|
|
|
| |
Also unifies use of SMALL_INT_FITS macro across parser and runtime.
|
|
|
|
|
| |
This removes need for some casts (at least, more than it adds need
for new casts!).
|
|
|
|
|
|
|
|
| |
This completes non-automatic interning of strings in the parser, so that
doc strings don't take up RAM. It complicates the parser and compiler,
and bloats stmhal by about 300 bytes. It's complicated because now
there are 2 kinds of parse-nodes that can be strings: interned leaves
and non-interned structs.
|
|\
| |
| |
| |
| |
| |
| | |
into pfalcon-keep-strings-uninterned
Conflicts:
py/parse.c
|
| |
| |
| |
| | |
https://github.com/micropython/micropython/issues/560#issuecomment-42213955
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
MP_ALLOC_* -> MICROPY_ALLOC_*
MICROPY_PATH_MAX -> MICROPY_ALLOC_PATH_MAX
MICROPY_ENABLE_REPL_HELPERS -> MICROPY_HELPER_REPL
MICROPY_ENABLE_LEXER_UNIX -> MICROPY_HELPER_LEXER_UNIX
MICROPY_EXTRA_* -> MICROPY_PORT_*
See issue #35.
|
|/
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
Doesn't help with RAM reduction because doc strings are interned as soon
as they are encountered, which is too soon to do any optimisations on
them.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There are 2 locations in parser, and 1 in compiler, where memory
allocation is not precise. In the parser it's the rule stack and result
stack, in the compiler it's the array for the identifiers in the current
scope. All other mallocs are exact (ie they don't allocate more than is
needed).
This patch adds tuning options (MP_ALLOC_*) to mpconfig.h for these 3
inexact allocations.
The inexact allocations in the parser should actually be close to
logarithmic: you need an exponentially larger script (absent pathological
cases) to use up more room on the rule and result stacks. As such, the
default allocation policy for these is now to start with a modest sized
stack, but grow only in small increments.
For the identifier arrays in the compiler, these now start out quite
small (4 entries, since most functions don't have that many ids), and
grow incrementally by 6 (since if you have more ids than 4, you probably
have quite a few more, but it wouldn't be exponentially more).
Partially addresses issue #560.
|
|
|
|
|
|
|
| |
Blanket wide to all .c and .h files. Some files originating from ST are
difficult to deal with (license wise) so it was left out of those.
Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
|
|
|
|
|
|
| |
Previously, a failed malloc/realloc would throw an exception, which was
not caught. I think it's better to keep the parser free from NLR
(exception throwing), hence this patch.
|
|
|
|
| |
Remove unnecessary includes. Add includes that improve portability.
|
|
|
|
|
|
| |
Implement not, shl and shr in mpz library. Add function to create mpzs
on the stack, used for memory efficiency when rhs is a small int.
Factor out code to parse base-prefix of number into a dedicated function.
|
|
|
|
|
| |
Based on suggestion by @dpgeorge at
https://github.com/micropython/micropython/pull/313
|
|
|
|
|
|
| |
Specifically, VM's small ints are 31 bit, while parser's only 28. There's already
MP_OBJ_FITS_SMALL_INT(), so, for clarity, rename MP_FIT_SMALL_INT() to
MP_PARSE_FITS_SMALL_INT().
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
| |
LOAD_METHOD bug was: emitbc did not correctly calculate the amount of
stack usage for a LOAD_METHOD operation.
small int bug was: int was being used to pass small ints, when it should
have been machine_int_t.
|
| |
|
|
|
|
| |
TODO: Check lexer/parse/compile error path for leaks too.
|
| |
|
|
|
|
|
| |
Can now have null bytes in strings. Can define ROM qstrs per port using
qstrdefsport.h
|
|
|
|
|
|
|
| |
Exceptions know source file, line and block name.
Also tidy up some debug printing functions and provide a global
flag to enable/disable them.
|
|
|
|
|
| |
Byte code has a map from byte-code offset to source-code line number,
used to give better error messages.
|
| |
|
|
|
|
|
| |
Parser no longer prints an error, but instead returns an exception ID
and message.
|
|
|
|
|
|
| |
Long int is something which doesn't fit into SMALL_INT partion of
machine_int_t. But it's also something which doesn't fit into
machine_int_t in the first place.
|
| |
|