Commit c12aa468 authored by Damien's avatar Damien
Browse files

Add SET_ADD opcode to VM.

parent 5fd09668
...@@ -1305,6 +1305,11 @@ py_obj_t rt_build_set(int n_args, py_obj_t *items) { ...@@ -1305,6 +1305,11 @@ py_obj_t rt_build_set(int n_args, py_obj_t *items) {
return o; return o;
} }
py_obj_t rt_store_set(py_obj_t set, py_obj_t item) {
py_set_lookup(set, item, true);
return set;
}
py_obj_t rt_build_map(int n_args) { py_obj_t rt_build_map(int n_args) {
py_obj_base_t *o = m_new(py_obj_base_t, 1); py_obj_base_t *o = m_new(py_obj_base_t, 1);
o->kind = O_MAP; o->kind = O_MAP;
......
...@@ -119,9 +119,10 @@ py_obj_t rt_call_method_n(int n_args, const py_obj_t *args); ...@@ -119,9 +119,10 @@ py_obj_t rt_call_method_n(int n_args, const py_obj_t *args);
py_obj_t rt_build_tuple(int n_args, py_obj_t *items); py_obj_t rt_build_tuple(int n_args, py_obj_t *items);
py_obj_t rt_build_list(int n_args, py_obj_t *items); py_obj_t rt_build_list(int n_args, py_obj_t *items);
py_obj_t rt_list_append(py_obj_t list, py_obj_t arg); py_obj_t rt_list_append(py_obj_t list, py_obj_t arg);
py_obj_t rt_build_set(int n_args, py_obj_t *items);
py_obj_t rt_store_set(py_obj_t set, py_obj_t item);
py_obj_t rt_build_map(int n_args); py_obj_t rt_build_map(int n_args);
py_obj_t rt_store_map(py_obj_t map, py_obj_t key, py_obj_t value); py_obj_t rt_store_map(py_obj_t map, py_obj_t key, py_obj_t value);
py_obj_t rt_build_set(int n_args, py_obj_t *items);
py_obj_t rt_load_attr(py_obj_t base, qstr attr); py_obj_t rt_load_attr(py_obj_t base, qstr attr);
void rt_load_method(py_obj_t base, qstr attr, py_obj_t *dest); void rt_load_method(py_obj_t base, qstr attr, py_obj_t *dest);
void rt_store_attr(py_obj_t base, qstr attr, py_obj_t val); void rt_store_attr(py_obj_t base, qstr attr, py_obj_t val);
......
...@@ -319,6 +319,13 @@ bool py_execute_byte_code_2(const byte *code, const byte **ip_in_out, py_obj_t * ...@@ -319,6 +319,13 @@ bool py_execute_byte_code_2(const byte *code, const byte **ip_in_out, py_obj_t *
*sp = obj1; *sp = obj1;
break; break;
case PYBC_SET_ADD:
DECODE_UINT;
// I think it's guaranteed by the compiler that sp[unum] is a set
rt_store_set(sp[unum], sp[0]);
sp++;
break;
case PYBC_MAKE_FUNCTION: case PYBC_MAKE_FUNCTION:
DECODE_UINT; DECODE_UINT;
PUSH(rt_make_function_from_id(unum)); PUSH(rt_make_function_from_id(unum));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment