Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
6addc89e
Commit
6addc89e
authored
Nov 04, 2013
by
Damien
Browse files
Byte code for SMALL_INT uses 3 bytes for integer.
parent
0c70f887
Changes
2
Show whitespace changes
Inline
Side-by-side
py/emitbc.c
View file @
6addc89e
...
...
@@ -106,11 +106,12 @@ static void emit_write_byte_1_byte(emit_t* emit, byte b1, uint b2) {
}
static
void
emit_write_byte_1_int
(
emit_t
*
emit
,
byte
b1
,
int
num
)
{
assert
((
num
&
(
~
0x7fff
))
==
0
||
(
num
&
(
~
0x7fff
))
==
(
~
0x7fff
));
byte
*
c
=
emit_get_cur_to_write_bytes
(
emit
,
3
);
assert
((
num
&
(
~
0x7fff
ff
))
==
0
||
(
num
&
(
~
0x7fff
ff
))
==
(
~
0x7fff
ff
));
byte
*
c
=
emit_get_cur_to_write_bytes
(
emit
,
4
);
c
[
0
]
=
b1
;
c
[
1
]
=
num
;
c
[
2
]
=
num
>>
8
;
c
[
3
]
=
num
>>
16
;
}
static
void
emit_write_byte_1_uint
(
emit_t
*
emit
,
byte
b1
,
uint
num
)
{
...
...
@@ -186,8 +187,8 @@ static void emit_bc_label_assign(emit_t *emit, int l) {
emit
->
label_offsets
[
l
]
=
emit
->
code_offset
;
}
else
if
(
emit
->
pass
==
PASS_3
)
{
// ensure label offset has not changed from PASS_2 to PASS_3
//printf("l%d: (at %d vs %d)\n", l, emit->code_offset, emit->label_offsets[l]);
assert
(
emit
->
label_offsets
[
l
]
==
emit
->
code_offset
);
//printf("l%d: (at %d)\n", l, emit->code_offset);
}
}
...
...
py/vm.c
View file @
6addc89e
...
...
@@ -75,11 +75,11 @@ bool py_execute_byte_code_2(const byte *code, const byte **ip_in_out, py_obj_t *
break
;
case
PYBC_LOAD_CONST_SMALL_INT
:
snum
=
ip
[
0
]
|
(
ip
[
1
]
<<
8
);
snum
=
ip
[
0
]
|
(
ip
[
1
]
<<
8
)
|
(
ip
[
2
]
<<
16
)
;
if
(
snum
&
0x8000
)
{
snum
|=
~
0xffff
;
}
ip
+=
2
;
ip
+=
3
;
PUSH
((
py_obj_t
)(
snum
<<
1
|
1
));
break
;
...
...
@@ -162,6 +162,11 @@ bool py_execute_byte_code_2(const byte *code, const byte **ip_in_out, py_obj_t *
rt_store_name
(
qstr
,
POP
());
break
;
case
PYBC_STORE_GLOBAL
:
DECODE_QSTR
;
rt_store_global
(
qstr
,
POP
());
break
;
case
PYBC_STORE_ATTR
:
DECODE_QSTR
;
rt_store_attr
(
sp
[
0
],
qstr
,
sp
[
1
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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