Skip to content

Commit f1081f4

Browse files
committed
Merge branch 'master' of github.com:micropython/micropython
2 parents ed378cd + 724026a commit f1081f4

16 files changed

Lines changed: 458 additions & 90 deletions

File tree

py/compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2764,7 +2764,7 @@ void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
27642764
apply_to_single_or_list(comp, pns->nodes[1], PN_typedargslist, compile_scope_func_param);
27652765
}
27662766

2767-
assert(MP_PARSE_NODE_IS_NULL(pns->nodes[2])); // 2 is something...
2767+
// pns->nodes[2] is return/whole function annotation
27682768

27692769
compile_node(comp, pns->nodes[3]); // 3 is function body
27702770
// emit return if it wasn't the last opcode

py/grammar.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ DEF_RULE(decorator, nc, and(4), tok(DEL_AT), rule(dotted_name), opt_rule(trailer
3333
DEF_RULE(decorators, nc, one_or_more, rule(decorator))
3434
DEF_RULE(decorated, c(decorated), and(2), rule(decorators), rule(decorated_body))
3535
DEF_RULE(decorated_body, nc, or(2), rule(classdef), rule(funcdef))
36-
DEF_RULE(funcdef, c(funcdef), and(8), tok(KW_DEF), tok(NAME), tok(DEL_PAREN_OPEN), opt_rule(typedargslist), tok(DEL_PAREN_CLOSE), opt_rule(funcdef_2), tok(DEL_COLON), rule(suite))
37-
DEF_RULE(funcdef_2, nc, and(2), tok(DEL_MINUS_MORE), rule(test))
36+
DEF_RULE(funcdef, c(funcdef), and(8), tok(KW_DEF), tok(NAME), tok(DEL_PAREN_OPEN), opt_rule(typedargslist), tok(DEL_PAREN_CLOSE), opt_rule(funcdefrettype), tok(DEL_COLON), rule(suite))
37+
DEF_RULE(funcdefrettype, nc, and(2), tok(DEL_MINUS_MORE), rule(test))
3838
// TODO typedargslist lets through more than is allowed
3939
DEF_RULE(typedargslist, nc, list_with_end, rule(typedargslist_item), tok(DEL_COMMA))
4040
DEF_RULE(typedargslist_item, nc, or(3), rule(typedargslist_name), rule(typedargslist_star), rule(typedargslist_dbl_star))

py/malloc.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <stdio.h>
22
#include <stdlib.h>
3+
#include <string.h>
34

45
#include "misc.h"
56
#include "mpconfig.h"
@@ -37,20 +38,10 @@ void *m_malloc(int num_bytes) {
3738
}
3839

3940
void *m_malloc0(int num_bytes) {
40-
if (num_bytes == 0) {
41-
return NULL;
42-
}
43-
void *ptr = calloc(1, num_bytes);
44-
if (ptr == NULL) {
45-
printf("could not allocate memory, allocating %d bytes\n", num_bytes);
46-
return NULL;
41+
void *ptr = m_malloc(num_bytes);
42+
if (ptr != NULL) {
43+
memset(ptr, 0, num_bytes);
4744
}
48-
#if MICROPY_MEM_STATS
49-
total_bytes_allocated += num_bytes;
50-
current_bytes_allocated += num_bytes;
51-
UPDATE_PEAK();
52-
#endif
53-
DEBUG_printf("malloc0 %d : %p\n", num_bytes, ptr);
5445
return ptr;
5546
}
5647

stm/malloc0.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@ void *realloc(void *ptr, size_t n) {
2929

3030
#endif
3131

32-
void *calloc(size_t sz, size_t n) {
33-
char *ptr = malloc(sz * n);
34-
for (int i = 0; i < sz * n; i++) {
35-
ptr[i] = 0;
36-
}
37-
return ptr;
38-
}
39-
4032
void *malloc(size_t n) {
4133
return gc_alloc(n);
4234
}

stm/std.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ void __assert_func(void);
44

55
void *malloc(size_t n);
66
void free(void *ptr);
7-
void *calloc(size_t sz, size_t n);
87
void *realloc(void *ptr, size_t n);
98

109
void *memcpy(void *dest, const void *src, size_t n);

teensy/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
include ../py/mkenv.mk
22

3+
# qstr definitions (must come before including py.mk)
4+
QSTR_DEFS = qstrdefsport.h
5+
36
# include py core make definitions
47
include ../py/py.mk
58

@@ -32,6 +35,8 @@ SRC_C = \
3235
lexerfatfs.c \
3336
lexermemzip.c \
3437
memzip.c \
38+
servo.c \
39+
usart.c \
3540
usb.c \
3641

3742
STM_SRC_C = $(addprefix stm/,\
@@ -54,7 +59,7 @@ SRC_TEENSY = \
5459
usb_serial.c \
5560
yield.c \
5661

57-
OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(STM_SRC_C:.c=.o) $(STM_SRC_S:.s=.o) $(SRC_TEENSY:.c=.o)) $(PY_O)
62+
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(STM_SRC_C:.c=.o) $(STM_SRC_S:.s=.o) $(SRC_TEENSY:.c=.o))
5863
#LIB = -lreadline
5964
# the following is needed for BSD
6065
#LIB += -ltermcap

teensy/led.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "misc.h"
44
#include "mpconfig.h"
5+
#include "qstr.h"
56
#include "obj.h"
67
#include "led.h"
78

teensy/lexerfatfs.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
#include <stdio.h>
33

44
#include "misc.h"
5+
#include "mpconfig.h"
6+
#include "qstr.h"
57
#include "lexer.h"
68
typedef int FIL;
79
#include "../stm/lexerfatfs.h"
810

9-
mp_lexer_t *mp_lexer_new_from_file(const char *filename, mp_lexer_file_buf_t *fb) {
11+
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
1012
printf("import not implemented\n");
1113
return NULL;
1214
}
@@ -15,3 +17,8 @@ mp_lexer_t *mp_import_open_file(qstr mod_name) {
1517
printf("import not implemented\n");
1618
return NULL;
1719
}
20+
21+
mp_import_stat_t mp_import_stat(const char *path) {
22+
// TODO implement me!
23+
return MP_IMPORT_STAT_NO_EXIST;
24+
}

teensy/lexermemzip.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#include <stdlib.h>
33

44
#include "misc.h"
5+
#include "mpconfig.h"
6+
#include "qstr.h"
57
#include "lexer.h"
68
#include "memzip.h"
79

@@ -13,6 +15,7 @@ mp_lexer_t *mp_lexer_new_from_memzip_file(const char *filename)
1315
if (memzip_locate(filename, &data, &len) != MZ_OK) {
1416
return NULL;
1517
}
16-
return mp_lexer_new_from_str_len(filename, (const char *)data, (uint)len, 0);
18+
19+
return mp_lexer_new_from_str_len(qstr_from_str(filename), (const char *)data, (uint)len, 0);
1720
}
1821

0 commit comments

Comments
 (0)