Commit Graph

104 Commits

Author SHA1 Message Date
Paul Sokolovsky
d99e9083cb modsys, unix: Add sys.exit(), should be implemented by a port. 2014-05-10 16:56:21 +03:00
Dave Hylands
117c46d9eb Add input command for unix 2014-05-07 07:19:51 -07:00
Paul Sokolovsky
f9e54e0ea5 modgc: Add new module for GC-related functionality. 2014-05-06 02:28:49 +03:00
Paul Sokolovsky
6b344d7816 py, unix: Add -v option, print bytecode dump if used.
This will work if MICROPY_DEBUG_PRINTERS is defined, which is only for
unix/windows ports. This makes it convenient to user uPy normally, but
easily get bytecode dump on the spot if needed, without constant recompiles
back and forth.

TODO: Add more useful debug output, adjust verbosity level on which
specifically bytecode dump happens.
2014-05-05 00:57:00 +03:00
Damien George
c327c0de5d unix: Remove test class and code. 2014-05-04 12:24:26 +01:00
Damien George
04b9147e15 Add license header to (almost) all files.
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/.
2014-05-03 23:27:38 +01:00
Damien George
6ec835dfef Don't print git hash as well as git tag in banner. 2014-05-03 19:08:02 +01:00
Damien George
1549f17038 Merge branch 'master' of github.com:micropython/micropython 2014-05-03 19:02:47 +01:00
Damien George
977a0ce287 py: Print tag/version/git describe in uPy banner. 2014-05-03 19:02:14 +01:00
stijn
4cd21deebc mingw: Add implementation of realpath()
The mingw port used _fullpath() until now, but the behaviour is not exactly
the same as realpath()'s on unix; major difference being that it doesn't
return an error for non-existing files, which would bypass main's error
checking and bail out without any error message.

Also realpath() will return forward slashes only since main() relies on that.
2014-05-03 17:38:08 +02:00
Paul Sokolovsky
f54bcbf099 py, unix: Make "mpconfig.h" be first included, as other headers depend on it.
Specifically, nlr.h does.
2014-05-02 17:48:40 +03:00
Paul Sokolovsky
a196d08dfc unix windows: mingw32 doesn't have realpath(), use _fullpath() instead. 2014-04-20 22:24:44 +03:00
Paul Sokolovsky
b76fd842f0 unix mem_info(): Dump GC info only if it's enabled. 2014-04-20 22:24:43 +03:00
Paul Sokolovsky
4abaa1b12b unix modffi: Convert to static module structures. 2014-04-18 00:05:27 +03:00
Paul Sokolovsky
e1e4249a67 unix modsocket: Convert to static module structures. 2014-04-17 20:34:04 +03:00
Paul Sokolovsky
59a2f4828d unix: Make mem_info() dump GC info too.
mem_info() is already pretty hacky, let it be more hacky.
2014-04-17 20:27:01 +03:00
Paul Sokolovsky
eb2fc9787a unix modtime: Convert to static module structures. 2014-04-17 20:27:01 +03:00
Damien George
d553be5982 build: Simplify build directory layout by putting all headers in genhdr.
Any generated headers go in $(BUILD)/genhdr/, and are #included as
'genhdr/xxx.h'.
2014-04-17 18:03:27 +01:00
Paul Sokolovsky
5500cdeec7 py, unix: Convert sys module to static representation. 2014-04-13 07:02:56 +03:00
Damien George
f22626ee4f unix: Add option to only compile, and not execute code. 2014-04-10 11:30:35 +01:00
Damien George
72cfc6ef0a unix: Oops, remove nlr_jump test in main. 2014-04-08 15:10:21 +01:00
Damien George
26cf55ae05 Add a check for NULL nlr_top in nlr_jump.
If no nlr_buf has been pushed, and an nlr_jump is called, then control
is transferred to nlr_jump_fail (which should bail out with a fatal
error).
2014-04-08 14:08:14 +00:00
Damien George
97790455fe Improve REPL detecting when input needs to continue.
Full CPython compatibility with this requires actually parsing the
input so far collected, and if it fails parsing due to lack of tokens,
then continue collecting input.  It's not worth doing it this way.  Not
having compatibility at this level does not hurt the goals of Micro
Python.
2014-04-08 11:04:29 +00:00
Paul Sokolovsky
b8cf948550 unix, windows: There's no "help" builtin. 2014-04-08 04:07:02 +03:00
Damien George
6827f9fc55 Add uPy welcome message to UNIX and Windows ports; update Teensy port.
Partly addresses issue #154.
2014-04-07 13:27:50 +01:00
Damien George
65cad12d38 py: Add option to compiler to specify default code emitter.
Also add command line option to unix port to select emitter.
2014-04-06 11:48:15 +01:00
Paul Sokolovsky
cd31d826bf unix: Use STATIC modifier to enable code size analysis via map file. 2014-04-04 20:34:02 +03:00
Paul Sokolovsky
70193b2b4c unix: Routines related to terminal reading should use system malloc.
Otherwise we have mixup between system and GC alloc.
2014-04-04 17:50:02 +03:00
Damien George
bd17e1b3ae unix: Allocate more heap memory by default on 64 bit machines.
Pointers are 2x bigger on 64 bit machines, so we should allocate twice
the memory to have a comparable heap size.
2014-04-04 14:29:00 +01:00
Paul Sokolovsky
d440dc0513 unix: Use argv[0] for command name in usage. 2014-04-02 20:31:18 +03:00
Paul Sokolovsky
a55a5469c3 unix: Support #if-able impl-specific cmdline options.
For example, we still build w/o GC enabled, so cannot really set heap size.
2014-04-02 20:29:18 +03:00
Paul Sokolovsky
d4e7e06d7f unix: Properly recognize and report when script on cmdline not found.
Previosuly just silently exited.
2014-04-02 20:25:01 +03:00
Damien George
15d18069c5 py: Remove old "run time" functions that were 1 liners. 2014-03-31 16:28:13 +01:00
Damien George
df6567e634 Merge map.h into obj.h.
Pretty much everyone needs to include map.h, since it's such an integral
part of the Micro Python object implementation.  Thus, the definitions
are now in obj.h instead.  map.h is removed.
2014-03-30 13:54:02 +01:00
Damien George
d17926db71 Rename rt_* to mp_*.
Mostly just a global search and replace.  Except rt_is_true which
becomes mp_obj_is_true.

Still would like to tidy up some of the names, but this will do for now.
2014-03-30 13:35:08 +01:00
Damien George
9b196cddab Remove mp_obj_type_t.methods entry and use .locals_dict instead.
Originally, .methods was used for methods in a ROM class, and
locals_dict for methods in a user-created class.  That distinction is
unnecessary, and we can use locals_dict for ROM classes now that we have
ROMable maps.

This removes an entry in the bloated mp_obj_type_t struct, saving a word
for each ROM object and each RAM object.  ROM objects that have a
methods table (now a locals_dict) need an extra word in total (removed
the methods pointer (1 word), no longer need the sentinel (2 words), but
now need an mp_obj_dict_t wrapper (4 words)).  But RAM objects save a
word because they never used the methods entry.

Overall the ROM usage is down by a few hundred bytes, and RAM usage is
down 1 word per user-defined type/class.

There is less code (no need to check 2 tables), and now consistent with
the way ROM modules have their tables initialised.

Efficiency is very close to equivaluent.
2014-03-26 21:47:19 +00:00
Damien George
c12b2213c1 Change mp_method_t.name from const char * to qstr.
Addresses issue #377.
2014-03-26 20:15:40 +00:00
xbe
c93a22197b unix: Clean up includes.
Remove unnecessary includes. Add includes that improve portability.
2014-03-16 12:14:15 -07:00
Damien George
5e34909a12 unix: Make usage info reflect actual usage of -X option. 2014-03-08 19:04:47 +00:00
Damien George
0c36da0b59 Implement ROMable modules. Add math module.
mp_module_obj_t can now be put in ROM.

Configuration of float type is now similar to longint: can now choose
none, float or double as the implementation.

math module has basic math functions.  For STM port, these are not yet
implemented (they are just stub functions).
2014-03-08 15:24:39 +00:00
Damien George
635927bbce unix: Add to usage print-out telling about -X option. 2014-03-04 08:39:47 +00:00
Paul Sokolovsky
a374d9c860 unix: Allow to set heap size using "-X heapsize=N" option. 2014-03-04 10:56:52 +08: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
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
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
e7db8171d8 unix: Implement garbage collection support. 2014-02-11 16:20:02 +02:00
Paul Sokolovsky
a075741c90 Rename str_join -> strjoin to make it not clash with objstr's one. 2014-02-11 14:39:10 +02:00
Paul Sokolovsky
9945f33886 Rename "rawsocket" module to "microsocket".
It's no longer intended to provide just "raw" socket interface, may include
some convenience methods for compatibility with CPython socket - but anyway
just minimal set required to deal with socket client and servers, not wider
network functionality.
2014-02-08 21:20:32 +02:00
Damien George
e09ffa1400 Search paths properly on import and execute __init__.py if it exists. 2014-02-05 23:57:48 +00:00