• R/O
  • SSH

kink: Commit

Kink runtime


Commit MetaInfo

Révision19147518601cb0a918da5d26b373899102257f24 (tree)
l'heure2020-10-26 01:30:12
Auteurmiyakawataku
Commitermiyakawataku

Message de Log

add JUMPIFPLAINNUM qcode insn

Change Summary

Modification

diff -r 65aa5d694e7d -r 19147518601c src/main/java/org/kink_lang/kink/internal/qcode/Opcodes.java
--- a/src/main/java/org/kink_lang/kink/internal/qcode/Opcodes.java Sun Oct 25 21:07:58 2020 +0900
+++ b/src/main/java/org/kink_lang/kink/internal/qcode/Opcodes.java Mon Oct 26 01:30:12 2020 +0900
@@ -350,6 +350,16 @@
350350 public static final int IFPLAINNUM = 36;
351351
352352 /**
353+ * If the top val is a num which does not have own vars,
354+ * jumps to the destination address.
355+ *
356+ * <p>intOperand: destination.</p>
357+ *
358+ * <p>dataStack: [_ val] → [_].</p>
359+ */
360+ public static final int JUMPIFPLAINNUM = 41;
361+
362+ /**
353363 * Returns a val from the run.
354364 *
355365 * <p>Operand: none.</p>
diff -r 65aa5d694e7d -r 19147518601c src/main/java/org/kink_lang/kink/internal/qcode/Qinsn.java
--- a/src/main/java/org/kink_lang/kink/internal/qcode/Qinsn.java Sun Oct 25 21:07:58 2020 +0900
+++ b/src/main/java/org/kink_lang/kink/internal/qcode/Qinsn.java Mon Oct 26 01:30:12 2020 +0900
@@ -555,6 +555,17 @@
555555 }
556556
557557 /**
558+ * Makes a JUMPIFPLAINNUM insn.
559+ *
560+ * @param destination the destination address which is used when the val is a plain num.
561+ * @param pos the pos of the insn.
562+ * @return IFPLAINNUM insn.
563+ */
564+ public static Qinsn makeJumpIfPlainNum(int destination, int pos) {
565+ return new Qinsn(Opcodes.JUMPIFPLAINNUM, destination, null, null, pos);
566+ }
567+
568+ /**
558569 * Makes a RET insn.
559570 *
560571 * @param pos the pos of the insn.
diff -r 65aa5d694e7d -r 19147518601c src/test/java/org/kink_lang/kink/internal/qcode/QinsnTest.java
--- a/src/test/java/org/kink_lang/kink/internal/qcode/QinsnTest.java Sun Oct 25 21:07:58 2020 +0900
+++ b/src/test/java/org/kink_lang/kink/internal/qcode/QinsnTest.java Mon Oct 26 01:30:12 2020 +0900
@@ -438,6 +438,13 @@
438438 }
439439
440440 @Test
441+ public void test_makeJumpIfPlainNum() {
442+ Qinsn insn = Qinsn.makeJumpIfPlainNum(42, 400);
443+ assertThat(insn).isEqualTo(
444+ new Qinsn(Opcodes.JUMPIFPLAINNUM, 42, null, null, 400));
445+ }
446+
447+ @Test
441448 public void test_makeRet() {
442449 Qinsn insn = Qinsn.makeRet(400);
443450 assertThat(insn).isEqualTo(
Afficher sur ancien navigateur de dépôt.