Commit Graph

5130 Commits

Author SHA1 Message Date
Damien George
27bf5b829b py: Add more bytecodes to showbc.c. 2014-01-02 18:15:33 +00:00
Paul Sokolovsky
bdf822b3d8 Add quick impl for MP_BC_LOAD_CONST_BYTES which just creates qstr so far.
This is based on the fact that qstr so far behaves more like byte string
than like Unicode string (for example, "012"[0] returns 48 (int)).
2014-01-02 18:51:19 +02:00
Damien George
fe8fb9165c py: remove depedence on strcat and stpcpy.
This fixes Issue #29, and means the core is no longer dependent on
string functions, except strlen.
2014-01-02 16:36:09 +00:00
Damien George
40563d56bd py: Add framework for built-in "type()" function. 2014-01-02 16:01:17 +00:00
Edd Barrett
67ab5ee779 On OpenBSD MAP_ANONYMOUS is called MAP_ANON. 2014-01-01 23:16:27 +00:00
Damien George
df884fe4cc py: change declaration of mp_map_t in obj.h (for issue #24). 2014-01-01 21:27:43 +00:00
Damien George
209d1b1835 py: add int() and float() built-ins, partially implemented. 2014-01-01 17:03:35 +00:00
Damien George
83c437cb0d Merge pull request #12 from pfalcon/minor-fixes
Minor fixes
2013-12-30 14:43:21 -08:00
Damien George
6baf76e28b py: make closures work. 2013-12-30 22:32:17 +00:00
Paul Sokolovsky
2efbc622cb Typo fix in comment. 2013-12-30 21:03:41 +02:00
Damien George
8cc96a35e5 Put unicode functions in unicode.c, and tidy their names. 2013-12-30 18:23:50 +00:00
Damien George
212c296c0b Make unix-cpy cross platform; remove dependency of asmx64 on mpconfig. 2013-12-30 12:52:32 +00:00
Damien George
cd340c44c2 Merge branch 'cross-plat' of https://github.com/pfalcon/micropython into pfalcon-cross-plat 2013-12-30 12:08:18 +00:00
Paul Sokolovsky
e85c38992d Make "unix" target be crossplatform and support x86, x64, ARM hosts. 2013-12-30 03:38:32 +02:00
Damien
dae7eb7226 py: add dict length function, and fix rt_store_set. 2013-12-29 22:32:51 +00:00
Damien
732407f1bf Change memory allocation API to require size for free and realloc. 2013-12-29 19:33:23 +00:00
Damien
02a7c41e76 py: implement POP_BLOCK in VM. 2013-12-29 18:48:37 +00:00
Paul Sokolovsky
44d0f3cfa2 Handle return value of read() call. 2013-12-29 20:11:05 +02:00
Damien
de690d128b Add unix-cpy, used to test Micro Python byte code against CPython. 2013-12-29 18:01:01 +00:00
Damien
b86e3f9293 py: implement some basic exception matching. 2013-12-29 17:17:43 +00:00
Damien
8f9e2ee157 Add code in VM to handle nested exceptions correctly. 2013-12-29 16:54:59 +00:00
Damien
dd12d1378f Parse upper-case hex numbers correctly. 2013-12-29 13:03:49 +00:00
Damien
d9d6201b52 py: simplify __next__ method for generators. 2013-12-21 18:38:03 +00:00
Damien
d99b05282d Change object representation from 1 big union to individual structs.
A big change.  Micro Python objects are allocated as individual structs
with the first element being a pointer to the type information (which
is itself an object).  This scheme follows CPython.  Much more flexible,
not necessarily slower, uses same heap memory, and can allocate objects
statically.

Also change name prefix, from py_ to mp_ (mp for Micro Python).
2013-12-21 18:17:45 +00:00
Damien
e2880aa2fd Fix a few compiler warnings. 2013-12-20 14:22:59 +00:00
Damien
a3dcd9e80c py: add more Python built-in functions. 2013-12-17 21:35:38 +00:00
Damien
660365e14c py: split runtime into map, obj, builtin. 2013-12-17 18:27:24 +00:00
Damien
a1b2693161 py: remove further unnecessary emit_verbatim code. 2013-12-12 15:34:40 +00:00
Damien
e388f1034e py: fix bug with doc string not recognised after first newline of file. 2013-12-12 15:24:38 +00:00
Damien
02f8941bf6 py: reduce use of emit_verbatim calls to minimum. 2013-12-12 15:13:36 +00:00
Damien
9ecbcfff99 py: work towards working closures. 2013-12-11 00:41:43 +00:00
Damien
318aec6ba9 py: emit correct id for closed over variables. 2013-12-10 18:28:17 +00:00
Damien
6332174ab4 py: compiler supports string juxtaposition=concatenation. 2013-12-10 17:41:49 +00:00
Damien
db4c361f1c py: add skeletal import functionality. 2013-12-10 17:27:24 +00:00
Damien
033d17a633 py: built-in range now accepts variable number of arguments. 2013-11-28 19:22:56 +00:00
Damien
d79338969b py: restrict further when for-range optimisation is done. 2013-11-28 19:12:18 +00:00
Damien
86c7fc7dd9 py: add list pop and sort, unpack_sequence, and keywords in method_call. 2013-11-26 15:16:41 +00:00
Damien
6f3e7fc505 py: add UNPACK_SEQUENCE and keyword methods to VM. 2013-11-26 15:15:50 +00:00
Damien
ff099f36d6 py: add more functionality to showbc. 2013-11-26 15:14:50 +00:00
Damien
d47f9d5a4f py: add call to __init__ when instantiating class object. 2013-11-25 23:40:02 +00:00
Damien
c1075ddc8f py: add some more opcodes to showbc. 2013-11-25 23:39:36 +00:00
Damien
f03001f8a6 Add function to decode and show byte code. 2013-11-17 13:19:33 +00:00
Damien
0446a0d76d Change some debugging/output messages for native code generation. 2013-11-17 13:16:36 +00:00
Damien
6d4f3462c4 Viper: function calls now convert constant arguments to objects. 2013-11-16 20:44:39 +00:00
Damien
6b92d451b2 Add len and subscr (a hack) support for strings. 2013-11-09 20:13:55 +00:00
Damien
94658e2e25 Add JUMP_IF_x_OR_POP opcodes to VM. 2013-11-09 20:12:32 +00:00
Damien
f3822fc34c Fix but with optimised range being 1 over. 2013-11-09 20:12:03 +00:00
Damien
f72fd0e875 Add optimisation for "for x in range". 2013-11-06 20:20:49 +00:00
Damien
5bf32c3b6b Built-in print function supports variable number of arguments. 2013-11-06 17:16:35 +00:00
Damien
ae0bc08a37 Viper supports inplace add (trivial). 2013-11-06 17:11:07 +00:00
Damien
40fdfe3000 Improve allocation of stack for byte code. 2013-11-05 22:16:22 +00:00
Damien
03c9cfb015 Make byte code jumps relative. 2013-11-05 22:06:08 +00:00
Damien
6addc89e55 Byte code for SMALL_INT uses 3 bytes for integer. 2013-11-04 23:04:50 +00:00
Damien
96a0addb18 Fixup include of stdarg and va_list definition. 2013-11-03 18:30:10 +00:00
Damien
2f06c57f8a Add simple var-arg functions; add simple string.format. 2013-11-03 18:20:56 +00:00
Damien
33af3bf028 Change Py API names, py_get_* -> py_obj_get_*. 2013-11-03 14:39:47 +00:00
Damien
9b9e996df6 Support for for-loop in native thumb. 2013-11-03 14:25:43 +00:00
Damien
1a6633a74d Implement more thumb branch instructions. 2013-11-03 13:58:19 +00:00
Damien
d57eba51e5 Add user object to runtime. 2013-11-02 23:58:14 +00:00
Damien
6ba1314265 Fix bug: emit native didn't clear last_was_return in label_assign. 2013-11-02 20:34:54 +00:00
Damien
7410e440ab Add basic complex number support. 2013-11-02 19:47:57 +00:00
Damien
e0b1864337 Small hack to temporarily fix allocation of unique_code slots. 2013-11-02 16:41:24 +00:00
Damien
ccfc9c51ba Py runtime: list.append returns None. 2013-11-02 15:10:37 +00:00
Damien
4ebb32fb95 Implement: str.join, more float support, ROT_TWO in VM. 2013-11-02 14:33:10 +00:00
Damien
2839168340 Add py_get_array_fixed_n function. 2013-10-25 00:40:38 +01:00
Damien
6f08f8ce51 Add working MMA support. 2013-10-23 22:17:26 +01:00
Damien
d2c1a732e5 Call gc_free in gc_realloc after allocating new block. 2013-10-23 21:03:27 +01:00
Damien
8b3a7c2237 Fix func decls with no arguments: () -> (void). 2013-10-23 20:20:17 +01:00
Damien
9fc7933ff2 Add py_get_qstr. 2013-10-23 00:01:10 +01:00
Damien
ec63cce470 Add simple support for C modules. 2013-10-22 22:58:17 +01:00
Damien
92c06561a3 Improve REPL compount statement detection. 2013-10-22 22:32:27 +01:00
Damien
bb5316b905 gc: reserve first block; lexer: free vstr. 2013-10-22 21:12:29 +01:00
Damien
fd8b6bcf55 Add gc_free function to force a block to be freed. 2013-10-22 20:26:36 +01:00
Damien
7b2d3f38ce Implement some more operators, mostly for small ints. 2013-10-22 16:53:02 +01:00
Damien
f086ecf57c Shrink py_obj_base_t size to 4 machine words. 2013-10-22 16:05:11 +01:00
Damien
eefcc79022 Clear ATBs on gc_init; better gc_info. 2013-10-22 15:25:25 +01:00
Damien
dcced92c26 Add mark-sweep garbage collector. 2013-10-21 23:45:08 +01:00
Damien
fa2162bc77 Integrate new lexer stream with stm framework. 2013-10-20 17:42:00 +01:00
Damien
27fb45eb1c Add local_num skeleton framework to deref/closure emit calls. 2013-10-20 15:07:49 +01:00
Damien
a5185f4bc8 Abstract out back-end stream functionality from lexer. 2013-10-20 14:41:27 +01:00
Damien
68f59a96e3 Add vstr and its functions. 2013-10-20 14:39:58 +01:00
Damien
df4b4f31ef Make grammar rules const so the go in .text section. 2013-10-19 18:28:01 +01:00
Damien
4d7adce9c5 Remove obsolete emitthumb.c (now use emitnative.c). 2013-10-19 18:17:12 +01:00
Damien
1595f3257e Make rt_fun_table const, so it goes in .text section. 2013-10-19 15:09:32 +01:00
Damien
5ac1b2efbd Implement REPL. 2013-10-18 19:58:12 +01:00
Damien
7bbd110691 Remove line in emitbc.c to print code size. 2013-10-18 19:57:17 +01:00
Damien
3997be444c Add single_input rule to grammar, for REPL. 2013-10-18 19:56:48 +01:00
Damien
9f770c658f Fix up insertion of newline at end of lexer stream. 2013-10-18 19:54:31 +01:00
Damien
d2755ec538 Add iterators and comprehension to emitnative. 2013-10-16 23:58:48 +01:00
Damien
c12aa468a1 Add SET_ADD opcode to VM. 2013-10-16 20:57:49 +01:00
Damien
5fd09668b7 Add MAP_ADD opcode to VM. 2013-10-16 20:54:01 +01:00
Damien
bd25445a82 Implement BC & runtime support for generator/yielding. 2013-10-16 20:39:12 +01:00
Damien
c226dca1f7 Support tuples and list comprehension, albeit crude. 2013-10-16 16:12:52 +01:00
Damien
152568bcb6 NLR and Python exceptions work on the board. 2013-10-16 00:46:39 +01:00
Damien
c9f91976e1 Crude try-except working. 2013-10-15 23:46:01 +01:00
Damien
ce89a21ea4 Implement basic exception framework, and simple for loop. 2013-10-15 22:25:17 +01:00
Damien
3ef4abb446 Change ifdef/if defined to simple if's. 2013-10-12 16:53:13 +01:00
Damien
0efb3a1b66 Tidy up SMALL_INT optimisations and CPython compatibility. 2013-10-12 16:16:56 +01:00
Damien
3a205179ea Option in compile.c to emit compatible or not with CPython. 2013-10-12 15:01:56 +01:00
Damien
c025ebb2dc Separate out mpy core and unix version. 2013-10-12 14:30:21 +01:00
Damien
a56f292626 Remove obsolete emitx64.c (now in emitnative.c). 2013-10-10 23:30:29 +01:00
Damien
a1ddfcc213 Wrap out-native code in preprocessor declarations. 2013-10-10 23:25:50 +01:00
Damien
eb19efb27e Simplify and improve function & method calling. 2013-10-10 22:06:54 +01:00
Damien
5609cca2ce Rename vm.h to bc.h. 2013-10-10 20:00:08 +01:00
Damien
7f5dacf345 Implement basic class/object in native code. 2013-10-10 11:24:39 +01:00
Damien
a397776d6b Implement basic class/object functionality in runtime. 2013-10-09 23:10:10 +01:00
Damien
91d387de7d Improve indent/dedent error checking and reporting. 2013-10-09 15:09:52 +01:00
Damien
ff8ed77cc1 Improve push/pop and register usage for native emit. 2013-10-08 22:18:32 +01:00
Damien
13ed3a658d Native Python and Viper support for x64 and thumb all together. 2013-10-08 09:05:10 +01:00
Damien
3410be8035 Merge viper types with standard native emitter. 2013-10-07 23:09:10 +01:00
Damien
acbf9a50d0 Rename r64->reg, i64->imm. 2013-10-07 21:52:14 +01:00
Damien
016f75f434 Add comments. 2013-10-07 21:22:39 +01:00
Damien
7af3d19a3c Implement crude viper emit stage. 2013-10-07 00:02:49 +01:00
Damien
e4af64f307 Functions to convert values to/from inline asm. 2013-10-06 12:04:13 +01:00
Damien
dc83382903 Make runtime able to call inline asm with 1 argument. 2013-10-06 01:01:01 +01:00
Damien
03d4124320 Add b_n opcode to inline thumb asm. 2013-10-06 00:36:05 +01:00
Damien
b14de21fc8 Optimise typedargslist_name to not create a node if just an id. 2013-10-06 00:28:28 +01:00
Damien
a2f2f7db1f Almost supports arguments for inline asm functions. 2013-10-06 00:14:13 +01:00
Damien
5fa5ae40be Make range of small int 24 bits. 2013-10-06 00:13:15 +01:00
Damien
39cf3285c7 Oops: add emitpass1.c for new factorised emit code. 2013-10-05 23:18:38 +01:00
Damien
826005c60b Add support for inline thumb assembly. 2013-10-05 23:17:28 +01:00
Damien
5bfb759980 Incorporate emit_thumb into new emit framework. 2013-10-05 18:41:24 +01:00
Damien
6cdd3af601 Implement built-in decorators to select emit type. 2013-10-05 18:08:26 +01:00
Damien
4b03e77d4a Factorise EMIT_COMMON calls, mostly into emit_pass1. 2013-10-05 14:17:09 +01:00
Damien
054848a1b8 Compiler computes labels and max_num_labels. 2013-10-05 13:44:41 +01:00
Damien
b05d707b23 Further factorise PASS_1 out of specific emit code. 2013-10-05 13:37:10 +01:00
Damien
415eb6f850 Restructure emit so it goes through a method table. 2013-10-05 12:19:06 +01:00
Damien
492d082455 Use macro EMIT_COMMON for emit_common calls. 2013-10-04 20:35:08 +01:00
Damien
d69adc19c7 Small fixes to Makefile. 2013-10-04 20:34:47 +01:00
Damien
429d71943d Initial commit. 2013-10-04 19:53:11 +01:00