py: Adjust some spaces in code style/format, purely for consistency.

This commit is contained in:
Damien George 2015-04-09 15:29:54 +00:00
parent df1637c580
commit 4dea922610
12 changed files with 47 additions and 52 deletions

View File

@ -223,7 +223,7 @@ void asm_arm_entry(asm_arm_t *as, int num_locals) {
| 1 << ASM_ARM_REG_R8; | 1 << ASM_ARM_REG_R8;
// Only adjust the stack if there are more locals than usable registers // Only adjust the stack if there are more locals than usable registers
if(num_locals > 3) { if (num_locals > 3) {
as->stack_adjust = num_locals * 4; as->stack_adjust = num_locals * 4;
// Align stack to 8 bytes // Align stack to 8 bytes
if (num_locals & 1) { if (num_locals & 1) {
@ -424,12 +424,12 @@ void asm_arm_b_label(asm_arm_t *as, uint label) {
void asm_arm_bl_ind(asm_arm_t *as, void *fun_ptr, uint fun_id, uint reg_temp) { void asm_arm_bl_ind(asm_arm_t *as, void *fun_ptr, uint fun_id, uint reg_temp) {
// If the table offset fits into the ldr instruction // If the table offset fits into the ldr instruction
if(fun_id < (0x1000 / 4)) { if (fun_id < (0x1000 / 4)) {
emit_al(as, asm_arm_op_mov_reg(ASM_ARM_REG_LR, ASM_ARM_REG_PC)); // mov lr, pc emit_al(as, asm_arm_op_mov_reg(ASM_ARM_REG_LR, ASM_ARM_REG_PC)); // mov lr, pc
emit_al(as, 0x597f000 | (fun_id << 2)); // ldr pc, [r7, #fun_id*4] emit_al(as, 0x597f000 | (fun_id << 2)); // ldr pc, [r7, #fun_id*4]
return; return;
} }
emit_al(as, 0x59f0004 | (reg_temp << 12)); // ldr rd, [pc, #4] emit_al(as, 0x59f0004 | (reg_temp << 12)); // ldr rd, [pc, #4]
// Set lr after fun_ptr // Set lr after fun_ptr
emit_al(as, asm_arm_op_add_imm(ASM_ARM_REG_LR, ASM_ARM_REG_PC, 4)); // add lr, pc, #4 emit_al(as, asm_arm_op_add_imm(ASM_ARM_REG_LR, ASM_ARM_REG_PC, 4)); // add lr, pc, #4

View File

@ -646,8 +646,7 @@ void asm_x64_push_local(asm_x64_t *as, int local_num) {
asm_x64_push_disp(as, ASM_X64_REG_RBP, asm_x64_local_offset_from_ebp(as, local_num)); asm_x64_push_disp(as, ASM_X64_REG_RBP, asm_x64_local_offset_from_ebp(as, local_num));
} }
void asm_x64_push_local_addr(asm_x64_t *as, int local_num, int temp_r64) void asm_x64_push_local_addr(asm_x64_t *as, int local_num, int temp_r64) {
{
asm_x64_mov_r64_r64(as, temp_r64, ASM_X64_REG_RBP); asm_x64_mov_r64_r64(as, temp_r64, ASM_X64_REG_RBP);
asm_x64_add_i32_to_r32(as, asm_x64_local_offset_from_ebp(as, local_num), temp_r64); asm_x64_add_i32_to_r32(as, asm_x64_local_offset_from_ebp(as, local_num), temp_r64);
asm_x64_push_r64(as, temp_r64); asm_x64_push_r64(as, temp_r64);
@ -657,16 +656,14 @@ void asm_x64_push_local_addr(asm_x64_t *as, int local_num, int temp_r64)
/* /*
can't use these because code might be relocated when resized can't use these because code might be relocated when resized
void asm_x64_call(asm_x64_t *as, void* func) void asm_x64_call(asm_x64_t *as, void* func) {
{
asm_x64_sub_i32_from_r32(as, 8, ASM_X64_REG_RSP); asm_x64_sub_i32_from_r32(as, 8, ASM_X64_REG_RSP);
asm_x64_write_byte_1(as, OPCODE_CALL_REL32); asm_x64_write_byte_1(as, OPCODE_CALL_REL32);
asm_x64_write_word32(as, func - (void*)(as->code_cur + 4)); asm_x64_write_word32(as, func - (void*)(as->code_cur + 4));
asm_x64_mov_r64_r64(as, ASM_X64_REG_RSP, ASM_X64_REG_RBP); asm_x64_mov_r64_r64(as, ASM_X64_REG_RSP, ASM_X64_REG_RBP);
} }
void asm_x64_call_i1(asm_x64_t *as, void* func, int i1) void asm_x64_call_i1(asm_x64_t *as, void* func, int i1) {
{
asm_x64_sub_i32_from_r32(as, 8, ASM_X64_REG_RSP); asm_x64_sub_i32_from_r32(as, 8, ASM_X64_REG_RSP);
asm_x64_sub_i32_from_r32(as, 12, ASM_X64_REG_RSP); asm_x64_sub_i32_from_r32(as, 12, ASM_X64_REG_RSP);
asm_x64_push_i32(as, i1); asm_x64_push_i32(as, i1);

View File

@ -325,7 +325,7 @@ STATIC mp_parse_node_t fold_constants(compiler_t *comp, mp_parse_node_t pn, mp_m
} else if (MP_PARSE_NODE_IS_SMALL_INT(pns->nodes[0]) && MP_PARSE_NODE_IS_NULL(pns->nodes[1]) && !MP_PARSE_NODE_IS_NULL(pns->nodes[2])) { } else if (MP_PARSE_NODE_IS_SMALL_INT(pns->nodes[0]) && MP_PARSE_NODE_IS_NULL(pns->nodes[1]) && !MP_PARSE_NODE_IS_NULL(pns->nodes[2])) {
// int ** x // int ** x
// can overflow; enabled only to compare with CPython // can overflow; enabled only to compare with CPython
mp_parse_node_struct_t* pns2 = (mp_parse_node_struct_t*)pns->nodes[2]; mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[2];
if (MP_PARSE_NODE_IS_SMALL_INT(pns2->nodes[0])) { if (MP_PARSE_NODE_IS_SMALL_INT(pns2->nodes[0])) {
int power = MP_PARSE_NODE_LEAF_SMALL_INT(pns2->nodes[0]); int power = MP_PARSE_NODE_LEAF_SMALL_INT(pns2->nodes[0]);
if (power >= 0) { if (power >= 0) {
@ -342,7 +342,7 @@ STATIC mp_parse_node_t fold_constants(compiler_t *comp, mp_parse_node_t pn, mp_m
} else if (MP_PARSE_NODE_IS_ID(pns->nodes[0]) && MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_trailer_period) && MP_PARSE_NODE_IS_NULL(pns->nodes[2])) { } else if (MP_PARSE_NODE_IS_ID(pns->nodes[0]) && MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_trailer_period) && MP_PARSE_NODE_IS_NULL(pns->nodes[2])) {
// id.id // id.id
// look it up in constant table, see if it can be replaced with an integer // look it up in constant table, see if it can be replaced with an integer
mp_parse_node_struct_t* pns1 = (mp_parse_node_struct_t*)pns->nodes[1]; mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1];
assert(MP_PARSE_NODE_IS_ID(pns1->nodes[0])); assert(MP_PARSE_NODE_IS_ID(pns1->nodes[0]));
qstr q_base = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]); qstr q_base = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]);
qstr q_attr = MP_PARSE_NODE_LEAF_ARG(pns1->nodes[0]); qstr q_attr = MP_PARSE_NODE_LEAF_ARG(pns1->nodes[0]);
@ -2225,8 +2225,8 @@ STATIC void compile_expr_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
&& MP_PARSE_NODE_STRUCT_NUM_NODES((mp_parse_node_struct_t*)pns1->nodes[0]) == 2 && MP_PARSE_NODE_STRUCT_NUM_NODES((mp_parse_node_struct_t*)pns1->nodes[0]) == 2
&& MP_PARSE_NODE_STRUCT_NUM_NODES((mp_parse_node_struct_t*)pns->nodes[0]) == 2) { && MP_PARSE_NODE_STRUCT_NUM_NODES((mp_parse_node_struct_t*)pns->nodes[0]) == 2) {
// optimisation for a, b = c, d; to match CPython's optimisation // optimisation for a, b = c, d; to match CPython's optimisation
mp_parse_node_struct_t* pns10 = (mp_parse_node_struct_t*)pns1->nodes[0]; mp_parse_node_struct_t *pns10 = (mp_parse_node_struct_t*)pns1->nodes[0];
mp_parse_node_struct_t* pns0 = (mp_parse_node_struct_t*)pns->nodes[0]; mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t*)pns->nodes[0];
if (MP_PARSE_NODE_IS_STRUCT_KIND(pns0->nodes[0], PN_star_expr) if (MP_PARSE_NODE_IS_STRUCT_KIND(pns0->nodes[0], PN_star_expr)
|| MP_PARSE_NODE_IS_STRUCT_KIND(pns0->nodes[1], PN_star_expr)) { || MP_PARSE_NODE_IS_STRUCT_KIND(pns0->nodes[1], PN_star_expr)) {
// can't optimise when it's a star expression on the lhs // can't optimise when it's a star expression on the lhs
@ -2243,8 +2243,8 @@ STATIC void compile_expr_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
&& MP_PARSE_NODE_STRUCT_NUM_NODES((mp_parse_node_struct_t*)pns1->nodes[0]) == 3 && MP_PARSE_NODE_STRUCT_NUM_NODES((mp_parse_node_struct_t*)pns1->nodes[0]) == 3
&& MP_PARSE_NODE_STRUCT_NUM_NODES((mp_parse_node_struct_t*)pns->nodes[0]) == 3) { && MP_PARSE_NODE_STRUCT_NUM_NODES((mp_parse_node_struct_t*)pns->nodes[0]) == 3) {
// optimisation for a, b, c = d, e, f; to match CPython's optimisation // optimisation for a, b, c = d, e, f; to match CPython's optimisation
mp_parse_node_struct_t* pns10 = (mp_parse_node_struct_t*)pns1->nodes[0]; mp_parse_node_struct_t *pns10 = (mp_parse_node_struct_t*)pns1->nodes[0];
mp_parse_node_struct_t* pns0 = (mp_parse_node_struct_t*)pns->nodes[0]; mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t*)pns->nodes[0];
if (MP_PARSE_NODE_IS_STRUCT_KIND(pns0->nodes[0], PN_star_expr) if (MP_PARSE_NODE_IS_STRUCT_KIND(pns0->nodes[0], PN_star_expr)
|| MP_PARSE_NODE_IS_STRUCT_KIND(pns0->nodes[1], PN_star_expr) || MP_PARSE_NODE_IS_STRUCT_KIND(pns0->nodes[1], PN_star_expr)
|| MP_PARSE_NODE_IS_STRUCT_KIND(pns0->nodes[2], PN_star_expr)) { || MP_PARSE_NODE_IS_STRUCT_KIND(pns0->nodes[2], PN_star_expr)) {
@ -3193,7 +3193,7 @@ STATIC void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
// check the first statement for a doc string // check the first statement for a doc string
if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_expr_stmt)) { if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_expr_stmt)) {
mp_parse_node_struct_t* pns = (mp_parse_node_struct_t*)pn; mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn;
if ((MP_PARSE_NODE_IS_LEAF(pns->nodes[0]) if ((MP_PARSE_NODE_IS_LEAF(pns->nodes[0])
&& MP_PARSE_NODE_LEAF_KIND(pns->nodes[0]) == MP_PARSE_NODE_STRING) && MP_PARSE_NODE_LEAF_KIND(pns->nodes[0]) == MP_PARSE_NODE_STRING)
|| MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_string)) { || MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_string)) {

View File

@ -67,7 +67,7 @@ emit_t *emit_bc_new(void) {
return emit; return emit;
} }
void emit_bc_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels) { void emit_bc_set_max_num_labels(emit_t *emit, mp_uint_t max_num_labels) {
emit->max_num_labels = max_num_labels; emit->max_num_labels = max_num_labels;
emit->label_offsets = m_new(mp_uint_t, emit->max_num_labels); emit->label_offsets = m_new(mp_uint_t, emit->max_num_labels);
} }
@ -77,7 +77,7 @@ void emit_bc_free(emit_t *emit) {
m_del_obj(emit_t, emit); m_del_obj(emit_t, emit);
} }
STATIC void emit_write_uint(emit_t* emit, byte*(*allocator)(emit_t*, int), mp_uint_t val) { STATIC void emit_write_uint(emit_t *emit, byte*(*allocator)(emit_t*, int), mp_uint_t val) {
// We store each 7 bits in a separate byte, and that's how many bytes needed // We store each 7 bits in a separate byte, and that's how many bytes needed
byte buf[BYTES_FOR_INT]; byte buf[BYTES_FOR_INT];
byte *p = buf + sizeof(buf); byte *p = buf + sizeof(buf);
@ -86,7 +86,7 @@ STATIC void emit_write_uint(emit_t* emit, byte*(*allocator)(emit_t*, int), mp_ui
*--p = val & 0x7f; *--p = val & 0x7f;
val >>= 7; val >>= 7;
} while (val != 0); } while (val != 0);
byte* c = allocator(emit, buf + sizeof(buf) - p); byte *c = allocator(emit, buf + sizeof(buf) - p);
while (p != buf + sizeof(buf) - 1) { while (p != buf + sizeof(buf) - 1) {
*c++ = *p++ | 0x80; *c++ = *p++ | 0x80;
} }
@ -94,7 +94,7 @@ STATIC void emit_write_uint(emit_t* emit, byte*(*allocator)(emit_t*, int), mp_ui
} }
// all functions must go through this one to emit code info // all functions must go through this one to emit code info
STATIC byte* emit_get_cur_to_write_code_info(emit_t* emit, int num_bytes_to_write) { STATIC byte *emit_get_cur_to_write_code_info(emit_t *emit, int num_bytes_to_write) {
//printf("emit %d\n", num_bytes_to_write); //printf("emit %d\n", num_bytes_to_write);
if (emit->pass < MP_PASS_EMIT) { if (emit->pass < MP_PASS_EMIT) {
emit->code_info_offset += num_bytes_to_write; emit->code_info_offset += num_bytes_to_write;
@ -107,20 +107,20 @@ STATIC byte* emit_get_cur_to_write_code_info(emit_t* emit, int num_bytes_to_writ
} }
} }
STATIC void emit_align_code_info_to_machine_word(emit_t* emit) { STATIC void emit_align_code_info_to_machine_word(emit_t *emit) {
emit->code_info_offset = (emit->code_info_offset + sizeof(mp_uint_t) - 1) & (~(sizeof(mp_uint_t) - 1)); emit->code_info_offset = (emit->code_info_offset + sizeof(mp_uint_t) - 1) & (~(sizeof(mp_uint_t) - 1));
} }
STATIC void emit_write_code_info_uint(emit_t* emit, mp_uint_t val) { STATIC void emit_write_code_info_uint(emit_t *emit, mp_uint_t val) {
emit_write_uint(emit, emit_get_cur_to_write_code_info, val); emit_write_uint(emit, emit_get_cur_to_write_code_info, val);
} }
STATIC void emit_write_code_info_qstr(emit_t* emit, qstr qst) { STATIC void emit_write_code_info_qstr(emit_t *emit, qstr qst) {
emit_write_uint(emit, emit_get_cur_to_write_code_info, qst); emit_write_uint(emit, emit_get_cur_to_write_code_info, qst);
} }
#if MICROPY_ENABLE_SOURCE_LINE #if MICROPY_ENABLE_SOURCE_LINE
STATIC void emit_write_code_info_bytes_lines(emit_t* emit, mp_uint_t bytes_to_skip, mp_uint_t lines_to_skip) { STATIC void emit_write_code_info_bytes_lines(emit_t *emit, mp_uint_t bytes_to_skip, mp_uint_t lines_to_skip) {
assert(bytes_to_skip > 0 || lines_to_skip > 0); assert(bytes_to_skip > 0 || lines_to_skip > 0);
//printf(" %d %d\n", bytes_to_skip, lines_to_skip); //printf(" %d %d\n", bytes_to_skip, lines_to_skip);
while (bytes_to_skip > 0 || lines_to_skip > 0) { while (bytes_to_skip > 0 || lines_to_skip > 0) {
@ -145,7 +145,7 @@ STATIC void emit_write_code_info_bytes_lines(emit_t* emit, mp_uint_t bytes_to_sk
#endif #endif
// all functions must go through this one to emit byte code // all functions must go through this one to emit byte code
STATIC byte* emit_get_cur_to_write_bytecode(emit_t* emit, int num_bytes_to_write) { STATIC byte *emit_get_cur_to_write_bytecode(emit_t *emit, int num_bytes_to_write) {
//printf("emit %d\n", num_bytes_to_write); //printf("emit %d\n", num_bytes_to_write);
if (emit->pass < MP_PASS_EMIT) { if (emit->pass < MP_PASS_EMIT) {
emit->bytecode_offset += num_bytes_to_write; emit->bytecode_offset += num_bytes_to_write;
@ -158,28 +158,28 @@ STATIC byte* emit_get_cur_to_write_bytecode(emit_t* emit, int num_bytes_to_write
} }
} }
STATIC void emit_align_bytecode_to_machine_word(emit_t* emit) { STATIC void emit_align_bytecode_to_machine_word(emit_t *emit) {
emit->bytecode_offset = (emit->bytecode_offset + sizeof(mp_uint_t) - 1) & (~(sizeof(mp_uint_t) - 1)); emit->bytecode_offset = (emit->bytecode_offset + sizeof(mp_uint_t) - 1) & (~(sizeof(mp_uint_t) - 1));
} }
STATIC void emit_write_bytecode_byte(emit_t* emit, byte b1) { STATIC void emit_write_bytecode_byte(emit_t *emit, byte b1) {
byte* c = emit_get_cur_to_write_bytecode(emit, 1); byte *c = emit_get_cur_to_write_bytecode(emit, 1);
c[0] = b1; c[0] = b1;
} }
STATIC void emit_write_bytecode_uint(emit_t* emit, mp_uint_t val) { STATIC void emit_write_bytecode_uint(emit_t *emit, mp_uint_t val) {
emit_write_uint(emit, emit_get_cur_to_write_bytecode, val); emit_write_uint(emit, emit_get_cur_to_write_bytecode, val);
} }
STATIC void emit_write_bytecode_byte_byte(emit_t* emit, byte b1, byte b2) { STATIC void emit_write_bytecode_byte_byte(emit_t *emit, byte b1, byte b2) {
assert((b2 & (~0xff)) == 0); assert((b2 & (~0xff)) == 0);
byte* c = emit_get_cur_to_write_bytecode(emit, 2); byte *c = emit_get_cur_to_write_bytecode(emit, 2);
c[0] = b1; c[0] = b1;
c[1] = b2; c[1] = b2;
} }
// Similar to emit_write_bytecode_uint(), just some extra handling to encode sign // Similar to emit_write_bytecode_uint(), just some extra handling to encode sign
STATIC void emit_write_bytecode_byte_int(emit_t* emit, byte b1, mp_int_t num) { STATIC void emit_write_bytecode_byte_int(emit_t *emit, byte b1, mp_int_t num) {
emit_write_bytecode_byte(emit, b1); emit_write_bytecode_byte(emit, b1);
// We store each 7 bits in a separate byte, and that's how many bytes needed // We store each 7 bits in a separate byte, and that's how many bytes needed
@ -198,19 +198,19 @@ STATIC void emit_write_bytecode_byte_int(emit_t* emit, byte b1, mp_int_t num) {
*--p = 0; *--p = 0;
} }
byte* c = emit_get_cur_to_write_bytecode(emit, buf + sizeof(buf) - p); byte *c = emit_get_cur_to_write_bytecode(emit, buf + sizeof(buf) - p);
while (p != buf + sizeof(buf) - 1) { while (p != buf + sizeof(buf) - 1) {
*c++ = *p++ | 0x80; *c++ = *p++ | 0x80;
} }
*c = *p; *c = *p;
} }
STATIC void emit_write_bytecode_byte_uint(emit_t* emit, byte b, mp_uint_t val) { STATIC void emit_write_bytecode_byte_uint(emit_t *emit, byte b, mp_uint_t val) {
emit_write_bytecode_byte(emit, b); emit_write_bytecode_byte(emit, b);
emit_write_uint(emit, emit_get_cur_to_write_bytecode, val); emit_write_uint(emit, emit_get_cur_to_write_bytecode, val);
} }
STATIC void emit_write_bytecode_prealigned_ptr(emit_t* emit, void *ptr) { STATIC void emit_write_bytecode_prealigned_ptr(emit_t *emit, void *ptr) {
mp_uint_t *c = (mp_uint_t*)emit_get_cur_to_write_bytecode(emit, sizeof(mp_uint_t)); mp_uint_t *c = (mp_uint_t*)emit_get_cur_to_write_bytecode(emit, sizeof(mp_uint_t));
// Verify thar c is already uint-aligned // Verify thar c is already uint-aligned
assert(c == MP_ALIGN(c, sizeof(mp_uint_t))); assert(c == MP_ALIGN(c, sizeof(mp_uint_t)));
@ -218,7 +218,7 @@ STATIC void emit_write_bytecode_prealigned_ptr(emit_t* emit, void *ptr) {
} }
// aligns the pointer so it is friendly to GC // aligns the pointer so it is friendly to GC
STATIC void emit_write_bytecode_byte_ptr(emit_t* emit, byte b, void *ptr) { STATIC void emit_write_bytecode_byte_ptr(emit_t *emit, byte b, void *ptr) {
emit_write_bytecode_byte(emit, b); emit_write_bytecode_byte(emit, b);
emit_align_bytecode_to_machine_word(emit); emit_align_bytecode_to_machine_word(emit);
mp_uint_t *c = (mp_uint_t*)emit_get_cur_to_write_bytecode(emit, sizeof(mp_uint_t)); mp_uint_t *c = (mp_uint_t*)emit_get_cur_to_write_bytecode(emit, sizeof(mp_uint_t));
@ -228,19 +228,19 @@ STATIC void emit_write_bytecode_byte_ptr(emit_t* emit, byte b, void *ptr) {
} }
/* currently unused /* currently unused
STATIC void emit_write_bytecode_byte_uint_uint(emit_t* emit, byte b, mp_uint_t num1, mp_uint_t num2) { STATIC void emit_write_bytecode_byte_uint_uint(emit_t *emit, byte b, mp_uint_t num1, mp_uint_t num2) {
emit_write_bytecode_byte(emit, b); emit_write_bytecode_byte(emit, b);
emit_write_bytecode_byte_uint(emit, num1); emit_write_bytecode_byte_uint(emit, num1);
emit_write_bytecode_byte_uint(emit, num2); emit_write_bytecode_byte_uint(emit, num2);
} }
*/ */
STATIC void emit_write_bytecode_byte_qstr(emit_t* emit, byte b, qstr qst) { STATIC void emit_write_bytecode_byte_qstr(emit_t *emit, byte b, qstr qst) {
emit_write_bytecode_byte_uint(emit, b, qst); emit_write_bytecode_byte_uint(emit, b, qst);
} }
// unsigned labels are relative to ip following this instruction, stored as 16 bits // unsigned labels are relative to ip following this instruction, stored as 16 bits
STATIC void emit_write_bytecode_byte_unsigned_label(emit_t* emit, byte b1, mp_uint_t label) { STATIC void emit_write_bytecode_byte_unsigned_label(emit_t *emit, byte b1, mp_uint_t label) {
mp_uint_t bytecode_offset; mp_uint_t bytecode_offset;
if (emit->pass < MP_PASS_EMIT) { if (emit->pass < MP_PASS_EMIT) {
bytecode_offset = 0; bytecode_offset = 0;
@ -254,14 +254,14 @@ STATIC void emit_write_bytecode_byte_unsigned_label(emit_t* emit, byte b1, mp_ui
} }
// signed labels are relative to ip following this instruction, stored as 16 bits, in excess // signed labels are relative to ip following this instruction, stored as 16 bits, in excess
STATIC void emit_write_bytecode_byte_signed_label(emit_t* emit, byte b1, mp_uint_t label) { STATIC void emit_write_bytecode_byte_signed_label(emit_t *emit, byte b1, mp_uint_t label) {
int bytecode_offset; int bytecode_offset;
if (emit->pass < MP_PASS_EMIT) { if (emit->pass < MP_PASS_EMIT) {
bytecode_offset = 0; bytecode_offset = 0;
} else { } else {
bytecode_offset = emit->label_offsets[label] - emit->bytecode_offset - 3 + 0x8000; bytecode_offset = emit->label_offsets[label] - emit->bytecode_offset - 3 + 0x8000;
} }
byte* c = emit_get_cur_to_write_bytecode(emit, 3); byte *c = emit_get_cur_to_write_bytecode(emit, 3);
c[0] = b1; c[0] = b1;
c[1] = bytecode_offset; c[1] = bytecode_offset;
c[2] = bytecode_offset >> 8; c[2] = bytecode_offset >> 8;

View File

@ -695,7 +695,7 @@ typedef double mp_float_t;
// must be somehow reachable for marking by the GC, since the native code // must be somehow reachable for marking by the GC, since the native code
// generators store pointers to GC managed memory in the code. // generators store pointers to GC managed memory in the code.
#ifndef MP_PLAT_ALLOC_EXEC #ifndef MP_PLAT_ALLOC_EXEC
#define MP_PLAT_ALLOC_EXEC(min_size, ptr, size) do { *ptr = m_new(byte, min_size); *size = min_size; } while(0) #define MP_PLAT_ALLOC_EXEC(min_size, ptr, size) do { *ptr = m_new(byte, min_size); *size = min_size; } while (0)
#endif #endif
#ifndef MP_PLAT_FREE_EXEC #ifndef MP_PLAT_FREE_EXEC

View File

@ -1174,8 +1174,7 @@ void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
/* computes dest = lhs * rhs /* computes dest = lhs * rhs
can have dest, lhs, rhs the same can have dest, lhs, rhs the same
*/ */
void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
{
if (lhs->len == 0 || rhs->len == 0) { if (lhs->len == 0 || rhs->len == 0) {
mpz_set_from_int(dest, 0); mpz_set_from_int(dest, 0);
return; return;

View File

@ -72,7 +72,7 @@ STATIC mp_obj_t bound_meth_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_
#if MICROPY_PY_FUNCTION_ATTRS #if MICROPY_PY_FUNCTION_ATTRS
STATIC void bound_meth_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { STATIC void bound_meth_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
if(attr == MP_QSTR___name__) { if (attr == MP_QSTR___name__) {
mp_obj_bound_meth_t *o = self_in; mp_obj_bound_meth_t *o = self_in;
dest[0] = MP_OBJ_NEW_QSTR(mp_obj_fun_get_name(o->meth)); dest[0] = MP_OBJ_NEW_QSTR(mp_obj_fun_get_name(o->meth));
} }

View File

@ -297,7 +297,7 @@ STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw,
#if MICROPY_PY_FUNCTION_ATTRS #if MICROPY_PY_FUNCTION_ATTRS
STATIC void fun_bc_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { STATIC void fun_bc_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
if(attr == MP_QSTR___name__) { if (attr == MP_QSTR___name__) {
dest[0] = MP_OBJ_NEW_QSTR(mp_obj_fun_get_name(self_in)); dest[0] = MP_OBJ_NEW_QSTR(mp_obj_fun_get_name(self_in));
} }
} }

View File

@ -36,7 +36,7 @@ typedef struct _mp_obj_str_t {
const byte *data; const byte *data;
} mp_obj_str_t; } mp_obj_str_t;
#define MP_DEFINE_STR_OBJ(obj_name, str) mp_obj_str_t obj_name = {{&mp_type_str}, 0, sizeof(str) - 1, (const byte*)str}; #define MP_DEFINE_STR_OBJ(obj_name, str) mp_obj_str_t obj_name = {{&mp_type_str}, 0, sizeof(str) - 1, (const byte*)str}
// use this macro to extract the string hash // use this macro to extract the string hash
#define GET_STR_HASH(str_obj_in, str_hash) \ #define GET_STR_HASH(str_obj_in, str_hash) \

View File

@ -63,7 +63,7 @@ qstr qstr_find_strn(const char *str, mp_uint_t str_len); // returns MP_QSTR_NULL
qstr qstr_from_str(const char *str); qstr qstr_from_str(const char *str);
qstr qstr_from_strn(const char *str, mp_uint_t len); qstr qstr_from_strn(const char *str, mp_uint_t len);
byte* qstr_build_start(mp_uint_t len, byte **q_ptr); byte *qstr_build_start(mp_uint_t len, byte **q_ptr);
qstr qstr_build_end(byte *q_ptr); qstr qstr_build_end(byte *q_ptr);
mp_uint_t qstr_hash(qstr q); mp_uint_t qstr_hash(qstr q);

View File

@ -107,8 +107,7 @@ mp_uint_t utf8_ptr_to_index(const byte *s, const byte *ptr) {
} }
// TODO: Rename to str_charlen // TODO: Rename to str_charlen
mp_uint_t unichar_charlen(const char *str, mp_uint_t len) mp_uint_t unichar_charlen(const char *str, mp_uint_t len) {
{
#if MICROPY_PY_BUILTINS_STR_UNICODE #if MICROPY_PY_BUILTINS_STR_UNICODE
mp_uint_t charlen = 0; mp_uint_t charlen = 0;
for (const char *top = str + len; str < top; ++str) { for (const char *top = str + len; str < top; ++str) {

View File

@ -112,7 +112,7 @@ mp_vm_return_kind_t mp_execute_bytecode(mp_code_state *code_state, volatile mp_o
TRACE(ip); \ TRACE(ip); \
MARK_EXC_IP_GLOBAL(); \ MARK_EXC_IP_GLOBAL(); \
goto *entry_table[*ip++]; \ goto *entry_table[*ip++]; \
} while(0) } while (0)
#define DISPATCH_WITH_PEND_EXC_CHECK() goto pending_exception_check #define DISPATCH_WITH_PEND_EXC_CHECK() goto pending_exception_check
#define ENTRY(op) entry_##op #define ENTRY(op) entry_##op
#define ENTRY_DEFAULT entry_default #define ENTRY_DEFAULT entry_default
@ -127,7 +127,7 @@ mp_vm_return_kind_t mp_execute_bytecode(mp_code_state *code_state, volatile mp_o
// sees that it's possible for us to jump from the dispatch loop to the exception // sees that it's possible for us to jump from the dispatch loop to the exception
// handler. Without this, the code may have a different stack layout in the dispatch // handler. Without this, the code may have a different stack layout in the dispatch
// loop and the exception handler, leading to very obscure bugs. // loop and the exception handler, leading to very obscure bugs.
#define RAISE(o) do { nlr_pop(); nlr.ret_val = o; goto exception_handler; } while(0) #define RAISE(o) do { nlr_pop(); nlr.ret_val = o; goto exception_handler; } while (0)
#if MICROPY_STACKLESS #if MICROPY_STACKLESS
run_code_state: ; run_code_state: ;