summaryrefslogtreecommitdiffstatshomepage
path: root/unix-cpy
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-08-14 12:24:11 +0100
committerDamien George <damien.p.george@gmail.com>2015-08-17 12:51:26 +0100
commit65dc960e3b22a8426e369607e47c19b380ce30ea (patch)
tree5e55ec2861df54e14fdb0eac1d030b34f684743b /unix-cpy
parent0e978349a5e7696aa44a0faf5d046081a0616ca5 (diff)
downloadmicropython-65dc960e3b22a8426e369607e47c19b380ce30ea.tar.gz
micropython-65dc960e3b22a8426e369607e47c19b380ce30ea.zip
unix-cpy: Remove unix-cpy. It's no longer needed.
unix-cpy was originally written to get semantic equivalent with CPython without writing functional tests. When writing the initial implementation of uPy it was a long way between lexer and functional tests, so the half-way test was to make sure that the bytecode was correct. The idea was that if the uPy bytecode matched CPython 1-1 then uPy would be proper Python if the bytecodes acted correctly. And having matching bytecode meant that it was less likely to miss some deep subtlety in the Python semantics that would require an architectural change later on. But that is all history and it no longer makes sense to retain the ability to output CPython bytecode, because: 1. It outputs CPython 3.3 compatible bytecode. CPython's bytecode changes from version to version, and seems to have changed quite a bit in 3.5. There's no point in changing the bytecode output to match CPython anymore. 2. uPy and CPy do different optimisations to the bytecode which makes it harder to match. 3. The bytecode tests are not run. They were never part of Travis and are not run locally anymore. 4. The EMIT_CPYTHON option needs a lot of extra source code which adds heaps of noise, especially in compile.c. 5. Now that there is an extensive test suite (which tests functionality) there is no need to match the bytecode. Some very subtle behaviour is tested with the test suite and passing these tests is a much better way to stay Python-language compliant, rather than trying to match CPy bytecode.
Diffstat (limited to 'unix-cpy')
-rw-r--r--unix-cpy/.gitignore2
-rw-r--r--unix-cpy/Makefile32
-rw-r--r--unix-cpy/main.c88
-rw-r--r--unix-cpy/mpconfigport.h59
4 files changed, 0 insertions, 181 deletions
diff --git a/unix-cpy/.gitignore b/unix-cpy/.gitignore
deleted file mode 100644
index e3778ee721..0000000000
--- a/unix-cpy/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-build
-cpy
diff --git a/unix-cpy/Makefile b/unix-cpy/Makefile
deleted file mode 100644
index 9f8ad3b51c..0000000000
--- a/unix-cpy/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-include ../py/mkenv.mk
-
-# define main target
-PROG = cpy
-
-# include py core make definitions
-include ../py/py.mk
-
-INC = -I.
-INC += -I..
-INC += -I$(BUILD)
-
-# compiler settings
-CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -ansi -std=gnu99 -DUNIX
-LDFLAGS = -lm
-
-# Debugging/Optimization
-ifdef DEBUG
-CFLAGS += -O0 -g
-else
-CFLAGS += -Os #-DNDEBUG
-endif
-
-# source files
-SRC_C = \
- main.c \
-
-OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
-LIB =
-
-include ../py/mkrules.mk
-
diff --git a/unix-cpy/main.c b/unix-cpy/main.c
deleted file mode 100644
index 219e3e6048..0000000000
--- a/unix-cpy/main.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * This file is part of the Micro Python project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013, 2014 Damien P. George
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "py/nlr.h"
-#include "py/compile.h"
-#include "py/runtime.h"
-
-void do_file(const char *file) {
- mp_lexer_t *lex = mp_lexer_new_from_file(file);
- if (lex == NULL) {
- return;
- }
-
- if (0) {
- // just tokenise
- while (lex->tok_kind != MP_TOKEN_END) {
- mp_lexer_show_token(lex);
- mp_lexer_to_next(lex);
- }
- mp_lexer_free(lex);
-
- } else {
- // parse
- mp_parse_node_t pn = mp_parse(lex, MP_PARSE_FILE_INPUT);
-
- if (pn != MP_PARSE_NODE_NULL) {
- //printf("----------------\n");
- //mp_parse_node_print(pn, 0);
- //printf("----------------\n");
-
- // compile
- mp_compile(pn, 0, MP_EMIT_OPT_NONE, false);
-
- //printf("----------------\n");
- }
- }
-}
-
-int main(int argc, char **argv) {
- mp_init();
-
- if (argc == 2) {
- do_file(argv[1]);
- } else {
- printf("usage: py [<file>]\n");
- return 1;
- }
- mp_deinit();
-
- return 0;
-}
-
-mp_import_stat_t mp_import_stat(const char *path) {
- return MP_IMPORT_STAT_NO_EXIST;
-}
-
-void nlr_jump_fail(void *val) {
- printf("FATAL: uncaught NLR %p\n", val);
- exit(1);
-}
diff --git a/unix-cpy/mpconfigport.h b/unix-cpy/mpconfigport.h
deleted file mode 100644
index 9d446b68a1..0000000000
--- a/unix-cpy/mpconfigport.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * This file is part of the Micro Python project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013, 2014 Damien P. George
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-// options to control how Micro Python is built
-
-#define MICROPY_EMIT_CPYTHON (1)
-#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (1)
-#define MICROPY_HELPER_LEXER_UNIX (1)
-#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
-#define MICROPY_PY_IO (0)
-
-// type definitions for the specific machine
-
-#ifdef __LP64__
-typedef long mp_int_t; // must be pointer size
-typedef unsigned long mp_uint_t; // must be pointer size
-#else
-// These are definitions for machines where sizeof(int) == sizeof(void*),
-// regardless for actual size.
-typedef int mp_int_t; // must be pointer size
-typedef unsigned int mp_uint_t; // must be pointer size
-#endif
-
-#define BYTES_PER_WORD sizeof(mp_int_t)
-
-typedef void *machine_ptr_t; // must be of pointer size
-typedef const void *machine_const_ptr_t; // must be of pointer size
-typedef double machine_float_t;
-typedef long mp_off_t;
-
-// We need to provide a declaration/definition of alloca()
-#ifdef __FreeBSD__
-#include <stdlib.h>
-#else
-#include <alloca.h>
-#endif