From f525a0c77afe056cdebbe8f62edd21c88b1759d5 Mon Sep 17 00:00:00 2001 From: angel Date: Wed, 11 Oct 2006 12:18:52 +0000 Subject: [PATCH] New opcode HASH2, that is optimizable and will substitute HASH. git-svn-id: file:///home/angel/tmp/svn-triptico/mpsl/trunk@5616 c87de0a0-a11c-0410-a1e5-866214bc28b2 --- mpsl.y | 7 ++++--- mpsl_c.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/mpsl.y b/mpsl.y index 99cc2e7..485f808 100644 --- a/mpsl.y +++ b/mpsl.y @@ -257,15 +257,16 @@ sym_list: hash: expr HASHPAIR expr { - $$ = INS2(L"HASH", $1, $3); + $$ = INS2(L"HASH2", $1, $3); } | hash ',' expr HASHPAIR expr { /* build hash from list of instructions */ - mpdm_push($1, $3); + /*mpdm_push($1, $3); mpdm_push($1, $5); - $$ = $1; + $$ = $1;*/ + $$ = INS3(L"HASH2", $3, $5, $1); } ; diff --git a/mpsl_c.c b/mpsl_c.c index deb48e9..937d86d 100644 --- a/mpsl_c.c +++ b/mpsl_c.c @@ -423,6 +423,16 @@ O_TYPE O_hash(O_ARGS) } +O_TYPE O_hash2(O_ARGS) +{ + mpdm_t k, v; + mpdm_t ret = RF(mpdm_size(c) == 3 ? MPDM_H(0) : M(3)); + + k = RF(M(1)); v = RF(M(2)); + mpdm_hset(ret, UF(k), UF(v)); + return(UF(ret)); +} + O_TYPE O_subframe(O_ARGS) /* runs an instruction inside a subroutine frame */ { @@ -479,8 +489,9 @@ static struct mpsl_op_s { L"RETURN", 0, O_return }, { L"LOCAL", 0, O_local }, { L"LIST", 0, O_list }, /* should be */ - { L"LIST2", 0, O_list2 }, /* should be */ + { L"LIST2", 1, O_list2 }, /* should be */ { L"HASH", 0, O_hash }, /* should be */ + { L"HASH2", 1, O_hash2 }, /* should be */ { L"RANGE", 1, O_range }, { L"UMINUS", 1, O_uminus }, { L"ADD", 1, O_add }, -- 2.11.4.GIT