added make_association, pop_into_association_key, pop_into_association_value byte codes to support assocation expressions
This commit is contained in:
parent
eb83c8d83a
commit
60c38a1ecb
@ -221,8 +221,27 @@ class MyObject(Object)
|
|||||||
a,
|
a,
|
||||||
4,
|
4,
|
||||||
1 + 1,
|
1 + 1,
|
||||||
2 + 2
|
#{ 1, 2, #{a, a := a + 1, a, if (a > 10) { a + 20 } }, 3},
|
||||||
|
2 + 2,
|
||||||
|
#'a b c'
|
||||||
}.
|
}.
|
||||||
|
|
||||||
|
(* Dictionary ???
|
||||||
|
a := #{
|
||||||
|
"a": 20,
|
||||||
|
b : 30
|
||||||
|
}.
|
||||||
|
a := #{
|
||||||
|
{ key, value },
|
||||||
|
{ key, value },
|
||||||
|
{ key, value },
|
||||||
|
{ key, value }
|
||||||
|
}
|
||||||
|
*)
|
||||||
|
|
||||||
|
abc := { key, value }.
|
||||||
|
{ key, value } dump.
|
||||||
|
|
||||||
a do: [ :v | v dump].
|
a do: [ :v | v dump].
|
||||||
|
|
||||||
(*
|
(*
|
||||||
|
@ -3993,7 +3993,6 @@ static int compile_array_expression (moo_t* moo)
|
|||||||
index = 0;
|
index = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* TODO: check if index exceeds the index that the BCODE_POP_INTO_ARRAY and BCODE_MAKE_ARRAY can support */
|
|
||||||
if (compile_method_expression (moo, 0) <= -1) return -1;
|
if (compile_method_expression (moo, 0) <= -1) return -1;
|
||||||
if (emit_single_param_instruction (moo, BCODE_POP_INTO_ARRAY, index) <= -1) return -1;
|
if (emit_single_param_instruction (moo, BCODE_POP_INTO_ARRAY, index) <= -1) return -1;
|
||||||
index++;
|
index++;
|
||||||
|
@ -488,6 +488,18 @@ int moo_decode (moo_t* moo, moo_oop_method_t mth, const moo_oocs_t* classfqn)
|
|||||||
break;
|
break;
|
||||||
/* -------------------------------------------------------- */
|
/* -------------------------------------------------------- */
|
||||||
|
|
||||||
|
case BCODE_MAKE_ASSOCIATION:
|
||||||
|
LOG_INST_0 (moo, "make_association");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BCODE_POP_INTO_ASSOCIATION_KEY:
|
||||||
|
LOG_INST_0 (moo, "pop_into_association_key");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BCODE_POP_INTO_ASSOCIATION_VALUE:
|
||||||
|
LOG_INST_0 (moo, "pop_into_association_value");
|
||||||
|
break;
|
||||||
|
|
||||||
case BCODE_MAKE_ARRAY:
|
case BCODE_MAKE_ARRAY:
|
||||||
FETCH_PARAM_CODE_TO (moo, b1);
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
LOG_INST_1 (moo, "make_array %zu", b1);
|
LOG_INST_1 (moo, "make_array %zu", b1);
|
||||||
|
@ -3795,6 +3795,45 @@ int moo_execute (moo_t* moo)
|
|||||||
break;
|
break;
|
||||||
/* -------------------------------------------------------- */
|
/* -------------------------------------------------------- */
|
||||||
|
|
||||||
|
case BCODE_MAKE_ASSOCIATION:
|
||||||
|
{
|
||||||
|
moo_oop_t t;
|
||||||
|
|
||||||
|
LOG_INST_0 (moo, "make_association");
|
||||||
|
|
||||||
|
t = moo_instantiate (moo, moo->_association, MOO_NULL, 0);
|
||||||
|
if (!t) goto oops;
|
||||||
|
|
||||||
|
MOO_STACK_PUSH (moo, t); /* push the association created */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case BCODE_POP_INTO_ASSOCIATION_KEY:
|
||||||
|
{
|
||||||
|
moo_oop_t t1, t2;
|
||||||
|
|
||||||
|
LOG_INST_0 (moo, "pop_into_association_key");
|
||||||
|
|
||||||
|
t1 = MOO_STACK_GETTOP(moo);
|
||||||
|
MOO_STACK_POP (moo);
|
||||||
|
t2 = MOO_STACK_GETTOP(moo);
|
||||||
|
((moo_oop_association_t)t2)->key = t1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case BCODE_POP_INTO_ASSOCIATION_VALUE:
|
||||||
|
{
|
||||||
|
moo_oop_t t1, t2;
|
||||||
|
|
||||||
|
LOG_INST_0 (moo, "pop_into_association_value");
|
||||||
|
|
||||||
|
t1 = MOO_STACK_GETTOP(moo);
|
||||||
|
MOO_STACK_POP (moo);
|
||||||
|
t2 = MOO_STACK_GETTOP(moo);
|
||||||
|
((moo_oop_association_t)t2)->value = t1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case BCODE_MAKE_ARRAY:
|
case BCODE_MAKE_ARRAY:
|
||||||
{
|
{
|
||||||
moo_oop_t t;
|
moo_oop_t t;
|
||||||
|
@ -859,6 +859,9 @@ enum moo_bcode_t
|
|||||||
BCODE_POP_INTO_OBJVAR_X = 0xEC, /* 236 ## */
|
BCODE_POP_INTO_OBJVAR_X = 0xEC, /* 236 ## */
|
||||||
|
|
||||||
BCODE_SEND_MESSAGE_X = 0xF0, /* 240 ## */
|
BCODE_SEND_MESSAGE_X = 0xF0, /* 240 ## */
|
||||||
|
BCODE_MAKE_ASSOCIATION = 0xF1, /* 241 */
|
||||||
|
BCODE_POP_INTO_ASSOCIATION_KEY = 0xF2, /* 242 */
|
||||||
|
BCODE_POP_INTO_ASSOCIATION_VALUE = 0xF3, /* 243 */
|
||||||
BCODE_SEND_MESSAGE_TO_SUPER_X = 0xF4, /* 244 ## */
|
BCODE_SEND_MESSAGE_TO_SUPER_X = 0xF4, /* 244 ## */
|
||||||
|
|
||||||
/* -------------------------------------- */
|
/* -------------------------------------- */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user