[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[COMMITTED] pkl, pvm: new instruction SSETI
From: |
Jose E. Marchesi |
Subject: |
[COMMITTED] pkl, pvm: new instruction SSETI |
Date: |
Sun, 26 Dec 2021 17:31:47 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
2021-12-26 Jose E. Marchesi <jemarch@gnu.org>
* libpoke/pkl-insn.def: Define PKL_INSN_SSETI.
* libpoke/pvm.jitter (sseti): New instruction.
---
ChangeLog | 5 +++++
libpoke/pkl-insn.def | 1 +
libpoke/pvm.jitter | 30 ++++++++++++++++++++++++++++++
3 files changed, 36 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index f269a7b0..515ca918 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2021-12-26 Jose E. Marchesi <jemarch@gnu.org>
+ * libpoke/pkl-insn.def: Define PKL_INSN_SSETI.
+ * libpoke/pvm.jitter (sseti): New instruction.
+
+2021-12-26 Jose E. Marchesi <jemarch@gnu.org>
+
* libpoke/pkl-asm.pks (ssetc): Renamed from sseti.
* libpoke/pkl-asm.c (pkl_asm_insn_ssetc): Likewise.
(pkl_asm_insn): Likewise.
diff --git a/libpoke/pkl-insn.def b/libpoke/pkl-insn.def
index b7886ee1..b7cf15d2 100644
--- a/libpoke/pkl-insn.def
+++ b/libpoke/pkl-insn.def
@@ -285,6 +285,7 @@ PKL_DEF_INSN(PKL_INSN_SREFIO,"","srefio")
PKL_DEF_INSN(PKL_INSN_SREFIA,"","srefia")
PKL_DEF_INSN(PKL_INSN_SREFMNT,"","srefmnt")
PKL_DEF_INSN(PKL_INSN_SSET,"","sset")
+PKL_DEF_INSN(PKL_INSN_SSETI,"","sseti")
PKL_DEF_INSN(PKL_INSN_SMODI,"","smodi")
/* Instructions to handle mapped values. */
diff --git a/libpoke/pvm.jitter b/libpoke/pvm.jitter
index c9da1420..8c63f31b 100644
--- a/libpoke/pvm.jitter
+++ b/libpoke/pvm.jitter
@@ -4819,6 +4819,7 @@ end
# does not have a field with the given name, then raise PVM_E_ELEM.
#
# Stack: ( SCT STR VAL -- SCT )
+# Exceptions: PVM_E_ELEM
instruction sset ()
branching # because of PVM_RAISE_DIRECT
@@ -4836,6 +4837,35 @@ instruction sset ()
end
end
+# Instruction: sseti
+#
+# Given a struct, a field index and a value, replace the value
+# of the referred struct field with the given value. If the
+# given index does not refer to a struct field, then raise
+# PVM_E_ELEM.
+#
+# Stack: (SCT IDX VAL -- SCT)
+# Exceptions: PVM_E_ELEM
+
+instruction sseti ()
+ branching # because of PVM_RAISE_DIRECT
+ code
+ pvm_val val = JITTER_TOP_STACK ();
+ pvm_val idx = JITTER_UNDER_TOP_STACK ();
+ size_t field_index = PVM_VAL_ULONG (idx);
+ pvm_val sct;
+
+ JITTER_DROP_STACK ();
+ JITTER_DROP_STACK ();
+
+ sct = JITTER_TOP_STACK ();
+
+ if (field_index >= PVM_VAL_SCT_NFIELDS (sct))
+ PVM_RAISE_DFL (PVM_E_ELEM);
+ PVM_VAL_SCT_FIELD_VALUE (sct, field_index) = val;
+ end
+end
+
# Instruction: sref
#
# Given a struct and a field name, push the value contained in the
--
2.11.0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [COMMITTED] pkl, pvm: new instruction SSETI,
Jose E. Marchesi <=