[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/2] pkl: move type logic from insn `asettb' to new insn `tyasetb
|
From: |
Mohammad-Reza Nabipoor |
|
Subject: |
[PATCH 2/2] pkl: move type logic from insn `asettb' to new insn `tyasetb' |
|
Date: |
Sat, 18 Feb 2023 13:48:17 +0100 |
2023-02-18 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* libpoke/pkl-insn.def (asettb): Remove instruction.
(tyasetb): New instruction.
* libpoke/pvm.jitter (asettb): Remove.
(tyasetb): New instruction to update the array's type bounder.
* libpoke/pkl-asm.c (pkl_asm_insn_atoa): Use new instruction.
* libpoke/pkl-asm.pks (array_conv_sel): Likewise.
(array_conv_siz): Likewise.
---
ChangeLog | 10 ++++++++++
libpoke/pkl-asm.c | 6 ++++--
libpoke/pkl-asm.pks | 12 ++++++++----
libpoke/pkl-insn.def | 2 +-
libpoke/pvm.jitter | 36 ++++++++++++++++++------------------
5 files changed, 41 insertions(+), 25 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 180b0902..1b2df01d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-02-18 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
+
+ * libpoke/pkl-insn.def (asettb): Remove instruction.
+ (tyasetb): New instruction.
+ * libpoke/pvm.jitter (asettb): Remove.
+ (tyasetb): New instruction to update the array's type bounder.
+ * libpoke/pkl-asm.c (pkl_asm_insn_atoa): Use new instruction.
+ * libpoke/pkl-asm.pks (array_conv_sel): Likewise.
+ (array_conv_siz): Likewise.
+
2023-02-18 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* libpoke/pkl-asm.c (pkl_asm_insn_atoa): Do not use `PVM_NULL' as
diff --git a/libpoke/pkl-asm.c b/libpoke/pkl-asm.c
index 0fde2cd9..4e0bcc33 100644
--- a/libpoke/pkl-asm.c
+++ b/libpoke/pkl-asm.c
@@ -231,8 +231,10 @@ pkl_asm_insn_atoa (pkl_asm pasm,
the array. */
bounder = PKL_AST_TYPE_A_BOUNDER (to_type);
- pkl_asm_insn (pasm, PKL_INSN_PUSH, bounder); /* ARR CLS */
- pkl_asm_insn (pasm, PKL_INSN_ASETTB); /* ARR */
+ pkl_asm_insn (pasm, PKL_INSN_TYPOF); /* ARR TYP */
+ pkl_asm_insn (pasm, PKL_INSN_PUSH, bounder); /* ARR TYP CLS */
+ pkl_asm_insn (pasm, PKL_INSN_TYASETB); /* ARR TYP */
+ pkl_asm_insn (pasm, PKL_INSN_DROP); /* ARR */
}
else
{
diff --git a/libpoke/pkl-asm.pks b/libpoke/pkl-asm.pks
index fd7fe365..c1cd4635 100644
--- a/libpoke/pkl-asm.pks
+++ b/libpoke/pkl-asm.pks
@@ -668,8 +668,10 @@
raise
.bound_ok:
drop3 ; ARR
- push #bounder ; ARR BOUNDER
- asettb ; ARR
+ typof ; ARR TYP
+ push #bounder ; ARR TYP BOUNDER
+ tyasetb ; ARR TYP
+ drop ; ARR
.end
;;; RAS_MACRO_ARRAY_CONV_SIZ
@@ -697,8 +699,10 @@
raise
.bound_ok:
drop2 ; ARR
- push #bounder ; ARR BOUNDER
- asettb ; ARR
+ typof ; ARR TYP
+ push #bounder ; ARR TYP BOUNDER
+ tyasetb ; ARR TYP
+ drop ; ARR
.end
;;; RAS_MACRO_CDIV
diff --git a/libpoke/pkl-insn.def b/libpoke/pkl-insn.def
index c086bdf1..36f495c3 100644
--- a/libpoke/pkl-insn.def
+++ b/libpoke/pkl-insn.def
@@ -293,7 +293,6 @@ PKL_DEF_INSN(PKL_INSN_AREM,"","arem")
PKL_DEF_INSN(PKL_INSN_AREF,"","aref")
PKL_DEF_INSN(PKL_INSN_AREFO,"","arefo")
PKL_DEF_INSN(PKL_INSN_ASET,"","aset")
-PKL_DEF_INSN(PKL_INSN_ASETTB,"","asettb")
/* Struct instructions. */
@@ -384,6 +383,7 @@ PKL_DEF_INSN(PKL_INSN_MKTYA,"","mktya")
PKL_DEF_INSN(PKL_INSN_TYAGETN,"","tyagetn")
PKL_DEF_INSN(PKL_INSN_TYAGETT,"","tyagett")
PKL_DEF_INSN(PKL_INSN_TYAGETB,"","tyagetb")
+PKL_DEF_INSN(PKL_INSN_TYASETB,"","tyasetb")
PKL_DEF_INSN(PKL_INSN_TYISA,"","tyisa")
/* Branch instructions. */
diff --git a/libpoke/pvm.jitter b/libpoke/pvm.jitter
index b623fc91..03b4c06e 100644
--- a/libpoke/pvm.jitter
+++ b/libpoke/pvm.jitter
@@ -5143,24 +5143,6 @@ instruction arefo ()
end
end
-# Instruction: asettb
-#
-# Given an array ARR and a closure BOUND, set the later as the array's
-# bounder function. This is a function that, once executed with no
-# arguments, returns the size of the array.
-#
-# Stack: ( ARR BOUND -- ARR )
-
-instruction asettb () # ( ARR BOUND -- ARR )
- code
- pvm_val type = PVM_VAL_ARR_TYPE (JITTER_UNDER_TOP_STACK ());
-
- PVM_ASSERT (PVM_VAL_TYP_CODE (type) == PVM_TYPE_ARRAY);
- PVM_VAL_TYP_A_BOUND (type) = JITTER_TOP_STACK ();
- JITTER_DROP_STACK ();
- end
-end
-
## Struct instructions
@@ -6266,6 +6248,24 @@ instruction tyagetb ()
end
end
+# Instruction: tyasetb
+#
+# Given an array ARR and a closure BOUND, set the later as the array's
+# bounder function. This is a function that, once executed with no
+# arguments, returns the size of the array or null.
+#
+# Stack: ( TYPE BOUND -- TYPE )
+
+instruction tyasetb ()
+ code
+ pvm_val type = JITTER_UNDER_TOP_STACK ();
+
+ PVM_ASSERT (PVM_VAL_TYP_CODE (type) == PVM_TYPE_ARRAY);
+ PVM_VAL_TYP_A_BOUND (type) = JITTER_TOP_STACK ();
+ JITTER_DROP_STACK ();
+ end
+end
+
# Instruction: mktyc
#
# Given a list of argument types, a return type and a number of
--
2.39.1