Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
3417bc2f
Commit
3417bc2f
authored
May 10, 2014
by
Damien George
Browse files
py: Rename byte_code to bytecode everywhere.
bytecode is the more widely used. See issue #590.
parent
6e8085b4
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
examples/micropython.py
View file @
3417bc2f
...
...
@@ -5,4 +5,4 @@
def
nodecor
(
x
):
return
x
byte
_
code
=
native
=
viper
=
nodecor
bytecode
=
native
=
viper
=
nodecor
py/bc.h
View file @
3417bc2f
...
...
@@ -36,10 +36,10 @@ typedef struct _mp_exc_stack {
byte
opcode
;
}
mp_exc_stack_t
;
mp_vm_return_kind_t
mp_execute_byte
_
code
(
const
byte
*
code
,
const
mp_obj_t
*
args
,
uint
n_args
,
const
mp_obj_t
*
args2
,
uint
n_args2
,
mp_obj_t
*
ret
);
mp_vm_return_kind_t
mp_execute_byte
_
code
_
2
(
const
byte
*
code_info
,
const
byte
**
ip_in_out
,
mp_obj_t
*
fastn
,
mp_obj_t
**
sp_in_out
,
mp_exc_stack_t
*
exc_stack
,
mp_exc_stack_t
**
exc_sp_in_out
,
volatile
mp_obj_t
inject_exc
);
void
mp_byte
_
code_print
(
const
byte
*
code
,
int
len
);
void
mp_byte
_
code_print2
(
const
byte
*
code
,
int
len
);
mp_vm_return_kind_t
mp_execute_bytecode
(
const
byte
*
code
,
const
mp_obj_t
*
args
,
uint
n_args
,
const
mp_obj_t
*
args2
,
uint
n_args2
,
mp_obj_t
*
ret
);
mp_vm_return_kind_t
mp_execute_bytecode2
(
const
byte
*
code_info
,
const
byte
**
ip_in_out
,
mp_obj_t
*
fastn
,
mp_obj_t
**
sp_in_out
,
mp_exc_stack_t
*
exc_stack
,
mp_exc_stack_t
**
exc_sp_in_out
,
volatile
mp_obj_t
inject_exc
);
void
mp_bytecode_print
(
const
byte
*
code
,
int
len
);
void
mp_bytecode_print2
(
const
byte
*
code
,
int
len
);
// Helper macros to access pointer with least significant bit holding a flag
#define MP_TAGPTR_PTR(x) ((void*)((machine_uint_t)(x) & ~((machine_uint_t)1)))
...
...
py/compile.c
View file @
3417bc2f
...
...
@@ -1146,7 +1146,7 @@ STATIC bool compile_built_in_decorator(compiler_t *comp, int name_len, mp_parse_
}
qstr
attr
=
MP_PARSE_NODE_LEAF_ARG
(
name_nodes
[
1
]);
if
(
attr
==
MP_QSTR_byte
_
code
)
{
if
(
attr
==
MP_QSTR_bytecode
)
{
*
emit_options
=
MP_EMIT_OPT_BYTE_CODE
;
#if MICROPY_EMIT_NATIVE
}
else
if
(
attr
==
MP_QSTR_native
)
{
...
...
py/emitbc.c
View file @
3417bc2f
This diff is collapsed.
Click to expand it.
py/emitcpy.c
View file @
3417bc2f
...
...
@@ -46,7 +46,7 @@
struct
_emit_t
{
int
pass
;
int
byte
_
code_offset
;
int
bytecode_offset
;
int
stack_size
;
bool
last_emit_was_return_value
;
...
...
@@ -68,7 +68,7 @@ STATIC void emit_cpy_set_native_types(emit_t *emit, bool do_native_types) {
STATIC
void
emit_cpy_start_pass
(
emit_t
*
emit
,
pass_kind_t
pass
,
scope_t
*
scope
)
{
emit
->
pass
=
pass
;
emit
->
byte
_
code_offset
=
0
;
emit
->
bytecode_offset
=
0
;
emit
->
stack_size
=
0
;
emit
->
last_emit_was_return_value
=
false
;
emit
->
scope
=
scope
;
...
...
@@ -108,20 +108,20 @@ STATIC void emit_cpy_delete_id(emit_t *emit, qstr qstr) {
}
// TODO: module-polymorphic function (read: name clash if made global)
static
void
emit_pre
(
emit_t
*
emit
,
int
stack_size_delta
,
int
byte
_
code_size
)
{
static
void
emit_pre
(
emit_t
*
emit
,
int
stack_size_delta
,
int
bytecode_size
)
{
emit
->
stack_size
+=
stack_size_delta
;
if
(
emit
->
stack_size
>
emit
->
scope
->
stack_size
)
{
emit
->
scope
->
stack_size
=
emit
->
stack_size
;
}
emit
->
last_emit_was_return_value
=
false
;
if
(
emit
->
pass
==
MP_PASS_EMIT
&&
byte
_
code_size
>
0
)
{
if
(
emit
->
byte
_
code_offset
>=
1000
)
{
printf
(
"%d "
,
emit
->
byte
_
code_offset
);
if
(
emit
->
pass
==
MP_PASS_EMIT
&&
bytecode_size
>
0
)
{
if
(
emit
->
bytecode_offset
>=
1000
)
{
printf
(
"%d "
,
emit
->
bytecode_offset
);
}
else
{
printf
(
"% 4d "
,
emit
->
byte
_
code_offset
);
printf
(
"% 4d "
,
emit
->
bytecode_offset
);
}
}
emit
->
byte
_
code_offset
+=
byte
_
code_size
;
emit
->
bytecode_offset
+=
bytecode_size
;
}
STATIC
void
emit_cpy_label_assign
(
emit_t
*
emit
,
uint
l
)
{
...
...
@@ -130,11 +130,11 @@ STATIC void emit_cpy_label_assign(emit_t *emit, uint l) {
if
(
emit
->
pass
<
MP_PASS_EMIT
)
{
// assign label offset
assert
(
emit
->
label_offsets
[
l
]
==
-
1
);
emit
->
label_offsets
[
l
]
=
emit
->
byte
_
code_offset
;
emit
->
label_offsets
[
l
]
=
emit
->
bytecode_offset
;
}
else
{
// ensure label offset has not changed from MP_PASS_CODE_SIZE to MP_PASS_EMIT
assert
(
emit
->
label_offsets
[
l
]
==
emit
->
byte
_
code_offset
);
//printf("l%d: (at %d)\n", l, emit->byte
_
code_offset);
assert
(
emit
->
label_offsets
[
l
]
==
emit
->
bytecode_offset
);
//printf("l%d: (at %d)\n", l, emit->bytecode_offset);
}
}
...
...
@@ -421,7 +421,7 @@ STATIC void emit_cpy_jump(emit_t *emit, uint label) {
emit_pre
(
emit
,
0
,
3
);
if
(
emit
->
pass
==
MP_PASS_EMIT
)
{
int
dest
=
emit
->
label_offsets
[
label
];
if
(
dest
<
emit
->
byte
_
code_offset
)
{
if
(
dest
<
emit
->
bytecode_offset
)
{
printf
(
"JUMP_ABSOLUTE %d
\n
"
,
emit
->
label_offsets
[
label
]);
}
else
{
printf
(
"JUMP_FORWARD %d
\n
"
,
emit
->
label_offsets
[
label
]);
...
...
py/emitglue.c
View file @
3417bc2f
...
...
@@ -73,7 +73,7 @@ mp_raw_code_t *mp_emit_glue_new_raw_code(void) {
return
rc
;
}
void
mp_emit_glue_assign_byte
_
code
(
mp_raw_code_t
*
rc
,
byte
*
code
,
uint
len
,
uint
n_pos_args
,
uint
n_kwonly_args
,
qstr
*
arg_names
,
uint
scope_flags
)
{
void
mp_emit_glue_assign_bytecode
(
mp_raw_code_t
*
rc
,
byte
*
code
,
uint
len
,
uint
n_pos_args
,
uint
n_kwonly_args
,
qstr
*
arg_names
,
uint
scope_flags
)
{
rc
->
kind
=
MP_CODE_BYTE
;
rc
->
scope_flags
=
scope_flags
;
rc
->
n_pos_args
=
n_pos_args
;
...
...
@@ -99,7 +99,7 @@ void mp_emit_glue_assign_byte_code(mp_raw_code_t *rc, byte *code, uint len, uint
#endif
#if MICROPY_DEBUG_PRINTERS
if
(
mp_verbose_flag
>
0
)
{
mp_byte
_
code_print
(
code
,
len
);
mp_bytecode_print
(
code
,
len
);
}
#endif
}
...
...
py/emitglue.h
View file @
3417bc2f
...
...
@@ -59,7 +59,7 @@ void mp_emit_glue_deinit(void);
mp_raw_code_t
*
mp_emit_glue_new_raw_code
(
void
);
void
mp_emit_glue_assign_byte
_
code
(
mp_raw_code_t
*
rc
,
byte
*
code
,
uint
len
,
uint
n_pos_args
,
uint
n_kwonly_args
,
qstr
*
arg_names
,
uint
scope_flags
);
void
mp_emit_glue_assign_bytecode
(
mp_raw_code_t
*
rc
,
byte
*
code
,
uint
len
,
uint
n_pos_args
,
uint
n_kwonly_args
,
qstr
*
arg_names
,
uint
scope_flags
);
void
mp_emit_glue_assign_native_code
(
mp_raw_code_t
*
rc
,
void
*
f
,
uint
len
,
int
n_args
);
void
mp_emit_glue_assign_inline_asm_code
(
mp_raw_code_t
*
rc
,
void
*
f
,
uint
len
,
int
n_args
);
...
...
py/mpconfig.h
View file @
3417bc2f
...
...
@@ -100,7 +100,7 @@
// Whether to build functions that print debugging info:
// mp_token_show
// mp_byte
_
code_print
// mp_bytecode_print
// mp_parse_node_print
#ifndef MICROPY_DEBUG_PRINTERS
#define MICROPY_DEBUG_PRINTERS (0)
...
...
py/objfun.c
View file @
3417bc2f
...
...
@@ -378,7 +378,7 @@ continue2:;
DEBUG_printf
(
"Calling: args=%p, n_args=%d, extra_args=%p, n_extra_args=%d
\n
"
,
args
,
n_args
,
extra_args
,
n_extra_args
);
dump_args
(
args
,
n_args
);
dump_args
(
extra_args
,
n_extra_args
);
mp_vm_return_kind_t
vm_return_kind
=
mp_execute_byte
_
code
(
self
->
bytecode
,
args
,
n_args
,
extra_args
,
n_extra_args
,
&
result
);
mp_vm_return_kind_t
vm_return_kind
=
mp_execute_bytecode
(
self
->
bytecode
,
args
,
n_args
,
extra_args
,
n_extra_args
,
&
result
);
mp_globals_set
(
old_globals
);
if
(
vm_return_kind
==
MP_VM_RETURN_NORMAL
)
{
...
...
py/objgenerator.c
View file @
3417bc2f
...
...
@@ -118,7 +118,7 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_
}
mp_obj_dict_t
*
old_globals
=
mp_globals_get
();
mp_globals_set
(
self
->
globals
);
mp_vm_return_kind_t
ret_kind
=
mp_execute_byte
_
code
_
2
(
self
->
code_info
,
&
self
->
ip
,
mp_vm_return_kind_t
ret_kind
=
mp_execute_bytecode2
(
self
->
code_info
,
&
self
->
ip
,
&
self
->
state
[
self
->
n_state
-
1
],
&
self
->
sp
,
(
mp_exc_stack_t
*
)(
self
->
state
+
self
->
n_state
),
&
self
->
exc_sp
,
throw_value
);
mp_globals_set
(
old_globals
);
...
...
@@ -276,7 +276,7 @@ mp_obj_t mp_obj_new_gen_instance(mp_obj_dict_t *globals, const byte *bytecode, u
o
->
exc_sp
=
(
mp_exc_stack_t
*
)(
o
->
state
+
n_state
)
-
1
;
o
->
n_state
=
n_state
;
// copy args to end of state array, in reverse (that's how mp_execute_byte
_
code
_
2 needs it)
// copy args to end of state array, in reverse (that's how mp_execute_bytecode2 needs it)
for
(
uint
i
=
0
;
i
<
n_args
;
i
++
)
{
o
->
state
[
n_state
-
1
-
i
]
=
args
[
i
];
}
...
...
py/qstrdefs.h
View file @
3417bc2f
...
...
@@ -61,7 +61,7 @@ Q(__del__)
Q
(
__call__
)
Q
(
micropython
)
Q
(
byte
_
code
)
Q
(
bytecode
)
Q
(
native
)
Q
(
viper
)
Q
(
const
)
...
...
py/showbc.c
View file @
3417bc2f
...
...
@@ -54,9 +54,9 @@
ip += sizeof(machine_uint_t); \
} while (0)
void
mp_byte
_
code_print2
(
const
byte
*
ip
,
int
len
);
void
mp_bytecode_print2
(
const
byte
*
ip
,
int
len
);
void
mp_byte
_
code_print
(
const
byte
*
ip
,
int
len
)
{
void
mp_bytecode_print
(
const
byte
*
ip
,
int
len
)
{
const
byte
*
ip_start
=
ip
;
// get code info size
...
...
@@ -99,10 +99,10 @@ void mp_byte_code_print(const byte *ip, int len) {
printf
(
" bc="
INT_FMT
" line="
UINT_FMT
"
\n
"
,
bc
,
source_line
);
}
}
mp_byte
_
code_print2
(
ip
,
len
-
0
);
mp_bytecode_print2
(
ip
,
len
-
0
);
}
void
mp_byte
_
code_print2
(
const
byte
*
ip
,
int
len
)
{
void
mp_bytecode_print2
(
const
byte
*
ip
,
int
len
)
{
const
byte
*
ip_start
=
ip
;
machine_uint_t
unum
;
qstr
qstr
;
...
...
py/vm.c
View file @
3417bc2f
...
...
@@ -47,7 +47,7 @@
#define DETECT_VM_STACK_OVERFLOW (0)
#if 0
#define TRACE(ip) mp_byte
_
code_print2(ip, 1);
#define TRACE(ip) mp_bytecode_print2(ip, 1);
#else
#define TRACE(ip)
#endif
...
...
@@ -104,7 +104,7 @@ typedef enum {
currently_in_except_block = MP_TAGPTR_TAG(exc_sp->val_sp);
/* restore previous state */
\
exc_sp--;
/* pop back to previous exception handler */
mp_vm_return_kind_t
mp_execute_byte
_
code
(
const
byte
*
code
,
const
mp_obj_t
*
args
,
uint
n_args
,
const
mp_obj_t
*
args2
,
uint
n_args2
,
mp_obj_t
*
ret
)
{
mp_vm_return_kind_t
mp_execute_bytecode
(
const
byte
*
code
,
const
mp_obj_t
*
args
,
uint
n_args
,
const
mp_obj_t
*
args2
,
uint
n_args2
,
mp_obj_t
*
ret
)
{
const
byte
*
ip
=
code
;
// get code info size, and skip line number table
...
...
@@ -155,7 +155,7 @@ mp_vm_return_kind_t mp_execute_byte_code(const byte *code, const mp_obj_t *args,
}
// execute the byte code
mp_vm_return_kind_t
vm_return_kind
=
mp_execute_byte
_
code
_
2
(
code
,
&
ip
,
&
state
[
n_state
-
1
],
&
sp
,
exc_stack
,
&
exc_sp
,
MP_OBJ_NULL
);
mp_vm_return_kind_t
vm_return_kind
=
mp_execute_bytecode2
(
code
,
&
ip
,
&
state
[
n_state
-
1
],
&
sp
,
exc_stack
,
&
exc_sp
,
MP_OBJ_NULL
);
#if DETECT_VM_STACK_OVERFLOW
// We can't check the case when an exception is returned in state[n_state - 1]
...
...
@@ -217,10 +217,10 @@ mp_vm_return_kind_t mp_execute_byte_code(const byte *code, const mp_obj_t *args,
// MP_VM_RETURN_NORMAL, sp valid, return value in *sp
// MP_VM_RETURN_YIELD, ip, sp valid, yielded value in *sp
// MP_VM_RETURN_EXCEPTION, exception in fastn[0]
mp_vm_return_kind_t
mp_execute_byte
_
code
_
2
(
const
byte
*
code_info
,
const
byte
**
ip_in_out
,
mp_obj_t
*
fastn
,
mp_obj_t
**
sp_in_out
,
mp_exc_stack_t
*
exc_stack
,
mp_exc_stack_t
**
exc_sp_in_out
,
volatile
mp_obj_t
inject_exc
)
{
mp_vm_return_kind_t
mp_execute_bytecode2
(
const
byte
*
code_info
,
const
byte
**
ip_in_out
,
mp_obj_t
*
fastn
,
mp_obj_t
**
sp_in_out
,
mp_exc_stack_t
*
exc_stack
,
mp_exc_stack_t
**
exc_sp_in_out
,
volatile
mp_obj_t
inject_exc
)
{
#if MICROPY_USE_COMPUTED_GOTO
#include
"vmentrytable.h"
#define DISPATCH() do { \
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment