summaryrefslogtreecommitdiffstatshomepage
path: root/py/builtinimport.c
Commit message (Collapse)AuthorAge
* py: Change type signature of builtin funs that take variable or kw args.Damien George2016-01-11
| | | | | With this patch the n_args parameter is changed type from mp_uint_t to size_t.
* py: Add MICROPY_ENABLE_COMPILER and MICROPY_PY_BUILTINS_EVAL_EXEC opts.Damien George2015-12-18
| | | | | | | | | | | | MICROPY_ENABLE_COMPILER can be used to enable/disable the entire compiler, which is useful when only loading of pre-compiled bytecode is supported. It is enabled by default. MICROPY_PY_BUILTINS_EVAL_EXEC controls support of eval and exec builtin functions. By default they are only included if MICROPY_ENABLE_COMPILER is enabled. Disabling both options saves about 40k of code size on 32-bit x86.
* py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR.Damien George2015-11-29
| | | | | | | | | This allows the mp_obj_t type to be configured to something other than a pointer-sized primitive type. This patch also includes additional changes to allow the code to compile when sizeof(mp_uint_t) != sizeof(void*), such as using size_t instead of mp_uint_t, and various casts.
* py: Add MP_ROM_* macros and mp_rom_* types and use them.Damien George2015-11-29
|
* py: Allow to import compiled bytecode files.Damien George2015-11-13
|
* builtinimport: Fix running package submodule with -m.Paul Sokolovsky2015-06-29
| | | | | | | When "micropython -m pkg.mod" command was used, relative imports in pkg.mod didn't work, because pkg.mod.__name__ was set to __main__, and the fact that it's a package submodule was missed. This is an original workaround to this issue. TODO: investigate and compare how CPython deals with this issue.
* builtinimport: Catch case when relative import happens without active package.Paul Sokolovsky2015-06-27
| | | | | CPython raises SystemError in this case, but we don't have that enabled, so raise ImportError.
* unix: Make micropython -m <module> work for frozen modules.Paul Sokolovsky2015-06-06
| | | | | This requires some special handling, which was previosuly applied only to the main code path.
* py: Add %q format support to mp_[v]printf, and use it.Damien George2015-04-16
|
* builtinimport: Revamp&refactor handling of relative imports.Paul Sokolovsky2015-02-16
| | | | | | | | | Relative imports are based of a package, so we're currently at a module within a package, we should get to package first. Also, factor out path travsering operation, but this broke testing for boundary errors with relative imports. TODO: reintroduce them, together with proper tests.
* builtinimport: Improve debugging output.Paul Sokolovsky2015-02-16
|
* py: Change vstr_null_terminate -> vstr_null_terminated_str, returns str.Damien George2015-01-29
|
* py: Change vstr so that it doesn't null terminate buffer by default.Damien George2015-01-28
| | | | | | | | | This cleans up vstr so that it's a pure "variable buffer", and the user can decide whether they need to add a terminating null byte. In most places where vstr is used, the vstr did not need to be null terminated and so this patch saves code size, a tiny bit of RAM, and makes vstr usage more efficient. When null termination is needed it must be done explicitly using vstr_null_terminate.
* builtinimport: Make sure that qstr is used properly to load frozen modules.Paul Sokolovsky2015-01-21
|
* py: Implement very simple frozen modules support.Paul Sokolovsky2015-01-20
| | | | | Only modules (not packages) supported now. Source modules can be converted to frozen module structures using tools/make-frozen.py script.
* py, unix: Allow to compile with -Wsign-compare.Damien George2015-01-16
| | | | See issue #699.
* py: Move to guarded includes, everywhere in py/ core.Damien George2015-01-01
| | | | Addresses issue #1022.
* py: Add basic framework for issuing compile/runtime warnings.Paul Sokolovsky2015-01-01
|
* py: Allow builtins to be overridden.Damien George2014-12-09
| | | | | | | | | | | | | | This patch adds a configuration option (MICROPY_CAN_OVERRIDE_BUILTINS) which, when enabled, allows to override all names within the builtins module. A builtins override dict is created the first time the user assigns to a name in the builtins model, and then that dict is searched first on subsequent lookups. Note that this implementation doesn't allow deleting of names. This patch also does some refactoring of builtins code, creating the modbuiltins.c file. Addresses issue #959.
* py: Optimise lexer by exposing lexer type.Damien George2014-12-05
| | | | | | | | | 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.
* py: Use shorter, static error msgs when ERROR_REPORTING_TERSE enabled.Damien George2014-11-06
| | | | | | | | Going from MICROPY_ERROR_REPORTING_NORMAL to MICROPY_ERROR_REPORTING_TERSE now saves 2020 bytes ROM for ARM Thumb2, and 2200 bytes ROM for 32-bit x86. This is about a 2.5% code size reduction for bare-arm.
* py: Deactivate more code without MICROPY_PY_SYSSven Wegener2014-11-05
| | | | | | | | When compiler optimization has been turned on, gcc knows that this code block is not going to be executed. But with -O0 it complains about path_items being used uninitialized. Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
* py: Fix some macros defines; cleanup some includes.Damien George2014-11-05
|
* unix: Implement -m option (execute module from stdlib).Paul Sokolovsky2014-10-26
| | | | | | | | Support for packages as argument not implemented, but otherwise error and exit handling should be correct. This for example will allow to do: pip-micropython install micropython-test.pystone micropython -m test.pystone
* py: Factor out mp_obj_is_package() function.Paul Sokolovsky2014-10-25
|
* py: mp_builtin___import__(): Add const to arg type.Paul Sokolovsky2014-10-25
|
* py: Add module weak link support.Damien George2014-10-12
| | | | | | | | | | | 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.
* py: Implement proper context save/restore for eval/exec; factor code.Damien George2014-10-05
| | | | | | | | | 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.
* py: Make compiler return a proper exception on SyntaxError.Damien George2014-10-05
|
* py: Convert [u]int to mp_[u]int_t where appropriate.Damien George2014-10-03
| | | | Addressing issue #50.
* py: Free non-interned strings in the parser when not needed.Damien George2014-09-23
| | | | | | | | | | | 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.
* stmhal: Initialise stack pointer correctly.Damien George2014-09-23
| | | | | | | | | | | | | Stack is full descending and must be 8-byte aligned. It must start off pointing to just above the last byte of RAM. Previously, stack started pointed to last byte of RAM (eg 0x2001ffff) and so was not 8-byte aligned. This caused a bug in combination with alloca. This patch also updates some debug printing code. Addresses issue #872 (among many other undiscovered issues).
* py: Change uint to mp_uint_t in runtime.h, stackctrl.h, binary.h.Damien George2014-08-30
| | | | Part of code cleanup, working towards resolving issue #50.
* py: Change all uint to mp_uint_t in obj.h.Damien George2014-08-30
| | | | Part of code cleanup, working towards resolving issue #50.
* py: Make tuple and list use mp_int_t/mp_uint_t.Damien George2014-08-30
| | | | Part of code cleanup, to resolve issue #50.
* py: Implement __file__ attribute for modules.Paul Sokolovsky2014-07-28
|
* py: Make 3 functions static.Damien George2014-06-11
|
* - FreeBSD provides alloca() via stdlib.h, in contrast to Linux and WindowsMarcus von Appen2014-06-07
| | | | - Move the includes for alloca() intp mpconfigport.h
* Change comments (mainly URLs) to no longer specifically say Python 3.3Chris Angelico2014-06-06
|
* objstr: Implement "%(key)s" % {} formatting for strings and dicts.Paul Sokolovsky2014-06-05
| | | | | Also, make sure that args to "*" format specifiers are bounds-checked properly and don't lead for segfaults in case of mismatch.
* Change const byte* to const char* where sensible.Damien George2014-05-25
| | | | | This removes need for some casts (at least, more than it adds need for new casts!).
* Rename configuration variables controling Python features.Damien George2014-05-24
| | | | Now of the form MICROPY_PY_*. See issue #35.
* Tidy up some configuration options.Damien George2014-05-21
| | | | | | | | | | 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.
* py, unix: Add copyright for modules I worked closely on.Paul Sokolovsky2014-05-13
|
* builtinimport: Fix broken namespace imports due to dup vstr_cut_tail_bytes().Paul Sokolovsky2014-05-10
|
* builtinimport: Fix comment orphaned by one of previous commits.Paul Sokolovsky2014-05-10
|
* Add license header to (almost) all files.Damien George2014-05-03
| | | | | | | 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/.
* py: Use <alloca.h> for alloca()stijn2014-05-03
| | | | | | | | alloca() is declared in alloca.h which als happens to be included by stdlib.h. On mingw however it resides in malloc.h only. So if we include alloca.h directly, and add an alloca.h for mingw in it's port directory we can get rid of the mingw-specific define to include malloc.h and the other ports are happy as well.
* py, unix: Make "mpconfig.h" be first included, as other headers depend on it.Paul Sokolovsky2014-05-02
| | | | Specifically, nlr.h does.
* builtinimport: If there was error compiling imported module, raise exception.Paul Sokolovsky2014-04-22
|