aboutsummaryrefslogtreecommitdiff
path: root/chunk.d
diff options
context:
space:
mode:
authormryouse2023-05-25 22:52:07 +0000
committermryouse2023-05-25 22:52:07 +0000
commit785b43a7b6635e6fadb94e224a094e524c9e0ccd (patch)
tree5c60ee3d25a747c21e480283a9dd4021457c43f3 /chunk.d
parent3535bfefccea789169786767ac80c54241cae019 (diff)
length on seq
Diffstat (limited to 'chunk.d')
-rw-r--r--chunk.d6
1 files changed, 6 insertions, 0 deletions
diff --git a/chunk.d b/chunk.d
index 70d7b1c..47d3c73 100644
--- a/chunk.d
+++ b/chunk.d
@@ -45,6 +45,7 @@ abstract class Seq {
SeqType type;
abstract Value first();
abstract Seq rest();
+ abstract int length();
}
class List : Seq {
@@ -71,6 +72,10 @@ class List : Seq {
return ret;
}
+ override int length() {
+ return to!int(this.inner.length);
+ }
+
override string toString() {
return format("list ('%s' + %d)", printableValue(this.inner[0]), this.inner.length - 1);
}
@@ -108,6 +113,7 @@ enum OpCode {
OP_FIRST, // No?
OP_REST,
+ OP_LENGTH,
OP_TYPE_CHECK_NUMBER,
OP_TYPE_CHECK_BOOLEAN,