• R/O
  • SSH

kink: Commit

Kink runtime


Commit MetaInfo

Revision48130374bde0480c0199f2fc3bfe420046620aa0 (tree)
Time2022-01-15 00:15:38
Authormiyakawataku
Commitermiyakawataku

Log Message

add lhsRepr property to opt-vec-assignment itree

Change Summary

Incremental Difference

diff -r c9396e41e82d -r 48130374bde0 src/main/java/org/kink_lang/kink/internal/program/i2w/TranslationSession.java
--- a/src/main/java/org/kink_lang/kink/internal/program/i2w/TranslationSession.java Sat Jan 15 00:05:17 2022 +0900
+++ b/src/main/java/org/kink_lang/kink/internal/program/i2w/TranslationSession.java Sat Jan 15 00:15:38 2022 +0900
@@ -586,14 +586,7 @@
586586
587587 // => bye
588588 int minArity = mandatorySyms.size();
589- List<String> reprs = new ArrayList<>(mandatorySyms.stream()
590- .map(m -> String.format(Locale.ROOT, ":%s", m))
591- .collect(Collectors.toList()));
592- reprs.addAll(optSyms.stream()
593- .map(o -> String.format(Locale.ROOT, ":%s.opt", o))
594- .collect(Collectors.toList()));
595- String repr = reprs.stream().collect(Collectors.joining(" ", "[", "]"));
596- insns.addAll(raiseWrongNumberOfArgs(pos, minArity, repr));
589+ insns.addAll(raiseWrongNumberOfArgs(pos, minArity, assignment.lhsRepr()));
597590
598591 // => { e1 e2 ,,, eMaxArity }
599592 insns.add(new LabelPseudoInsn(remainingLables.get(optSyms.size())));
diff -r c9396e41e82d -r 48130374bde0 src/main/java/org/kink_lang/kink/internal/program/itree/OptVecAssignmentItree.java
--- a/src/main/java/org/kink_lang/kink/internal/program/itree/OptVecAssignmentItree.java Sat Jan 15 00:05:17 2022 +0900
+++ b/src/main/java/org/kink_lang/kink/internal/program/itree/OptVecAssignmentItree.java Sat Jan 15 00:15:38 2022 +0900
@@ -10,11 +10,14 @@
1010 * @param mandatorySyms the syms of mandatory params.
1111 * @param optSyms the syms of optional params.
1212 * @param rhs the right-hand-side.
13+ * @param lhsRepr the string representation of the left hand side.
1314 * @param pos the pos index of the assignment.
1415 */
1516 public record OptVecAssignmentItree(List<String> mandatorySyms,
1617 List<String> optSyms,
17- Itree rhs, int pos) implements Itree {
18+ Itree rhs,
19+ String lhsRepr,
20+ int pos) implements Itree {
1821
1922 /**
2023 * Constructs an assignment itree.
@@ -30,11 +33,28 @@
3033 }
3134
3235 /**
36+ * Constructs an assignment itree.
37+ *
38+ * @param mandatorySyms the syms of mandatory params.
39+ * @param optSyms the syms of optional params.
40+ * @param rhs the right-hand-side.
41+ * @param lhsRepr the string representation of the left hand side.
42+ * @param pos the pos index of the assignment.
43+ */
44+ public OptVecAssignmentItree(
45+ List<String> mandatorySyms,
46+ List<String> optSyms,
47+ Itree rhs,
48+ int pos) {
49+ this(mandatorySyms, optSyms, rhs, makeLhsRepr(mandatorySyms, optSyms), pos);
50+ }
51+
52+ /**
3353 * Returns the string representation of the left hand side.
3454 *
3555 * @return the string representation of the left hand side.
3656 */
37- public String lhsRepr() {
57+ private static String makeLhsRepr(List<String> mandatorySyms, List<String> optSyms) {
3858 return Stream.concat(
3959 mandatorySyms.stream().map(s -> ":" + s),
4060 optSyms.stream().map(s -> ":" + s + ".opt"))
Show on old repository browser