From f351b225fa640570074f3326606e66eb5a05c3c4 Mon Sep 17 00:00:00 2001 From: Jared Date: Sat, 2 Nov 2019 19:33:46 +0200 Subject: [PATCH] Made stdLibs a folder instead of a zip file to reduce curse wait times --- ZenCode | 2 +- src/main/resources/StdLibs.zip | Bin 29476 -> 0 bytes .../resources/StdLibs/collections/module.json | 4 + .../StdLibs/collections/src/HashSet.zs | 11 + .../StdLibs/collections/src/LinkedList.zs | 68 ++++ .../collections/src/NoSuchElementException.zs | 5 + .../StdLibs/collections/src/Queue.zs | 7 + .../resources/StdLibs/collections/src/Set.zs | 12 + .../StdLibs/collections/src/Stack.zs | 16 + .../resources/StdLibs/compactio/module.json | 6 + .../compactio/src/CompactBytesDataInput.zs | 293 ++++++++++++++ .../compactio/src/CompactBytesDataOutput.zs | 367 ++++++++++++++++++ .../StdLibs/compactio/src/CompactDataInput.zs | 103 +++++ .../compactio/src/CompactDataOutput.zs | 105 +++++ src/main/resources/StdLibs/io/module.json | 5 + .../resources/StdLibs/io/src/IOException.zs | 11 + .../resources/StdLibs/io/src/InputStream.zs | 14 + .../resources/StdLibs/io/src/OutputStream.zs | 14 + src/main/resources/StdLibs/io/src/Reader.zs | 15 + .../resources/StdLibs/io/src/StringReader.zs | 31 ++ .../resources/StdLibs/listeners/module.json | 5 + .../listeners/src/DummyListenerHandle.zs | 9 + .../StdLibs/listeners/src/ListenerHandle.zs | 5 + .../StdLibs/listeners/src/ListenerList.zs | 80 ++++ src/main/resources/StdLibs/live/module.json | 6 + .../StdLibs/live/src/ImmutableLiveBool.zs | 16 + .../StdLibs/live/src/ImmutableLiveObject.zs | 13 + .../StdLibs/live/src/ImmutableLiveString.zs | 13 + .../StdLibs/live/src/InverseLiveBool.zs | 14 + .../StdLibs/live/src/LiveArrayList.zs | 52 +++ .../resources/StdLibs/live/src/LiveBool.zs | 8 + .../StdLibs/live/src/LiveConcatList.zs | 86 ++++ .../resources/StdLibs/live/src/LiveInt.zs | 9 + .../resources/StdLibs/live/src/LiveList.zs | 21 + .../resources/StdLibs/live/src/LiveObject.zs | 8 + .../resources/StdLibs/live/src/LiveString.zs | 8 + .../StdLibs/live/src/MutableLiveBool.zs | 3 + .../StdLibs/live/src/MutableLiveInt.zs | 3 + .../StdLibs/live/src/MutableLiveList.zs | 13 + .../StdLibs/live/src/MutableLiveString.zs | 3 + .../StdLibs/live/src/SimpleLiveBool.zs | 24 ++ .../StdLibs/live/src/SimpleLiveInt.zs | 24 ++ .../StdLibs/live/src/SimpleLiveString.zs | 24 ++ src/main/resources/StdLibs/stdlib/module.json | 17 + src/main/resources/StdLibs/stdlib/src.7z | Bin 0 -> 2956 bytes .../resources/StdLibs/stdlib/src/Arrays.zs | 178 +++++++++ .../resources/StdLibs/stdlib/src/Assoc.zs | 8 + .../resources/StdLibs/stdlib/src/Chars.zs | 4 + .../StdLibs/stdlib/src/Comparable.zs | 5 + .../StdLibs/stdlib/src/EnforcementLevel.zs | 5 + .../StdLibs/stdlib/src/EqualsComparable.zs | 3 + .../resources/StdLibs/stdlib/src/Exception.zs | 8 + .../resources/StdLibs/stdlib/src/Hashable.zs | 4 + .../stdlib/src/IllegalArgumentException.zs | 7 + .../resources/StdLibs/stdlib/src/Integers.zs | 13 + .../resources/StdLibs/stdlib/src/Iterable.zs | 5 + .../resources/StdLibs/stdlib/src/Iterator.zs | 8 + src/main/resources/StdLibs/stdlib/src/List.zs | 43 ++ .../resources/StdLibs/stdlib/src/Result.zs | 48 +++ .../StdLibs/stdlib/src/StringBuildable.zs | 6 + .../StdLibs/stdlib/src/StringBuilder.zs | 69 ++++ .../resources/StdLibs/stdlib/src/Strings.zs | 96 +++++ .../resources/StdLibs/stdlib/src/USize.zs | 13 + src/main/resources/StdLibs/uuid/module.json | 6 + src/main/resources/StdLibs/uuid/src/uuid.zs | 9 + 65 files changed, 2090 insertions(+), 1 deletion(-) delete mode 100644 src/main/resources/StdLibs.zip create mode 100644 src/main/resources/StdLibs/collections/module.json create mode 100644 src/main/resources/StdLibs/collections/src/HashSet.zs create mode 100644 src/main/resources/StdLibs/collections/src/LinkedList.zs create mode 100644 src/main/resources/StdLibs/collections/src/NoSuchElementException.zs create mode 100644 src/main/resources/StdLibs/collections/src/Queue.zs create mode 100644 src/main/resources/StdLibs/collections/src/Set.zs create mode 100644 src/main/resources/StdLibs/collections/src/Stack.zs create mode 100644 src/main/resources/StdLibs/compactio/module.json create mode 100644 src/main/resources/StdLibs/compactio/src/CompactBytesDataInput.zs create mode 100644 src/main/resources/StdLibs/compactio/src/CompactBytesDataOutput.zs create mode 100644 src/main/resources/StdLibs/compactio/src/CompactDataInput.zs create mode 100644 src/main/resources/StdLibs/compactio/src/CompactDataOutput.zs create mode 100644 src/main/resources/StdLibs/io/module.json create mode 100644 src/main/resources/StdLibs/io/src/IOException.zs create mode 100644 src/main/resources/StdLibs/io/src/InputStream.zs create mode 100644 src/main/resources/StdLibs/io/src/OutputStream.zs create mode 100644 src/main/resources/StdLibs/io/src/Reader.zs create mode 100644 src/main/resources/StdLibs/io/src/StringReader.zs create mode 100644 src/main/resources/StdLibs/listeners/module.json create mode 100644 src/main/resources/StdLibs/listeners/src/DummyListenerHandle.zs create mode 100644 src/main/resources/StdLibs/listeners/src/ListenerHandle.zs create mode 100644 src/main/resources/StdLibs/listeners/src/ListenerList.zs create mode 100644 src/main/resources/StdLibs/live/module.json create mode 100644 src/main/resources/StdLibs/live/src/ImmutableLiveBool.zs create mode 100644 src/main/resources/StdLibs/live/src/ImmutableLiveObject.zs create mode 100644 src/main/resources/StdLibs/live/src/ImmutableLiveString.zs create mode 100644 src/main/resources/StdLibs/live/src/InverseLiveBool.zs create mode 100644 src/main/resources/StdLibs/live/src/LiveArrayList.zs create mode 100644 src/main/resources/StdLibs/live/src/LiveBool.zs create mode 100644 src/main/resources/StdLibs/live/src/LiveConcatList.zs create mode 100644 src/main/resources/StdLibs/live/src/LiveInt.zs create mode 100644 src/main/resources/StdLibs/live/src/LiveList.zs create mode 100644 src/main/resources/StdLibs/live/src/LiveObject.zs create mode 100644 src/main/resources/StdLibs/live/src/LiveString.zs create mode 100644 src/main/resources/StdLibs/live/src/MutableLiveBool.zs create mode 100644 src/main/resources/StdLibs/live/src/MutableLiveInt.zs create mode 100644 src/main/resources/StdLibs/live/src/MutableLiveList.zs create mode 100644 src/main/resources/StdLibs/live/src/MutableLiveString.zs create mode 100644 src/main/resources/StdLibs/live/src/SimpleLiveBool.zs create mode 100644 src/main/resources/StdLibs/live/src/SimpleLiveInt.zs create mode 100644 src/main/resources/StdLibs/live/src/SimpleLiveString.zs create mode 100644 src/main/resources/StdLibs/stdlib/module.json create mode 100644 src/main/resources/StdLibs/stdlib/src.7z create mode 100644 src/main/resources/StdLibs/stdlib/src/Arrays.zs create mode 100644 src/main/resources/StdLibs/stdlib/src/Assoc.zs create mode 100644 src/main/resources/StdLibs/stdlib/src/Chars.zs create mode 100644 src/main/resources/StdLibs/stdlib/src/Comparable.zs create mode 100644 src/main/resources/StdLibs/stdlib/src/EnforcementLevel.zs create mode 100644 src/main/resources/StdLibs/stdlib/src/EqualsComparable.zs create mode 100644 src/main/resources/StdLibs/stdlib/src/Exception.zs create mode 100644 src/main/resources/StdLibs/stdlib/src/Hashable.zs create mode 100644 src/main/resources/StdLibs/stdlib/src/IllegalArgumentException.zs create mode 100644 src/main/resources/StdLibs/stdlib/src/Integers.zs create mode 100644 src/main/resources/StdLibs/stdlib/src/Iterable.zs create mode 100644 src/main/resources/StdLibs/stdlib/src/Iterator.zs create mode 100644 src/main/resources/StdLibs/stdlib/src/List.zs create mode 100644 src/main/resources/StdLibs/stdlib/src/Result.zs create mode 100644 src/main/resources/StdLibs/stdlib/src/StringBuildable.zs create mode 100644 src/main/resources/StdLibs/stdlib/src/StringBuilder.zs create mode 100644 src/main/resources/StdLibs/stdlib/src/Strings.zs create mode 100644 src/main/resources/StdLibs/stdlib/src/USize.zs create mode 100644 src/main/resources/StdLibs/uuid/module.json create mode 100644 src/main/resources/StdLibs/uuid/src/uuid.zs diff --git a/ZenCode b/ZenCode index cb2950a27..1f4b126e1 160000 --- a/ZenCode +++ b/ZenCode @@ -1 +1 @@ -Subproject commit cb2950a278c5de665f2c8624521db94439744402 +Subproject commit 1f4b126e1857b4044ffbc7ef992f3aca3d43998e diff --git a/src/main/resources/StdLibs.zip b/src/main/resources/StdLibs.zip deleted file mode 100644 index 931b5b6cc0afe3161052cad5ec84e770d17e5301..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 29476 zcmagG1ymi)(l&~_ySoQ>cXxMpcPF?6cXxM4(2x)yI0Sch*WeIB$Q@oy&N<(I_gb}O zO|9KeNmqAQ)r_(nI0OdB%j=Ctt^6Nf{(3_IKFyr$?JdmQZJZq4n3MrdxIeBX0-WjG z0#Dq)uNT7p4^9Usa}Rq9Mq4*0M?XY3STbi5GdmM23o>33vS0p?jQ-`CwUe9s%LNZd z8&3;YHxqj@L^yv$xR=5Hgmu7J_Zuvf{}{~8)$9*wFWfL7m$Xs}ePDgn_Q0<;fbjkY zx3r0ywVH)HqpzFChys$ZFaqRe3y(xbZm{->TX1n^shPNycw{@iP*hr}&GP-8LZ{`L za4!uQn_b}>&yucq zu7w?=swTHjf-c_39+l{SO9TUQ4PZ2;Xp_4H1p%pr00ANV9~k9r9PKR3$|yWzc#gf$Qr)A-Z4wqK!oZ0BO|Foj3!NO8>eD4B_0r}-- zDCljJ$vA5lRfa&}U1kR?q}cvWen^Tw&TF}>p>*MZ57q>&WwHl6p35^C9NYqBGx_+( z8j?qrJCaB=*od@iIiFq z^5fXWO{(LS=|zyl+^G&^-MAB#&hX;+*t>i0BT+|^pQUnEB?r^`KBNsSg2a_MBtbDd zY%?jQvZL8&T1Z6va6T+S%A*meGjTjxYI$~H!bOK}!u%9+Lof4%7t!*Vo9Xj6pZALL z$d_f4dMsUvZ$tgweMzYC3VTD}T0ceDu3=s>!oB*zhpAJo4gp56tqt)g{RY0*0XYyH zQvM9Vc;2N_JAyDjjre*q7k4aICK1)^@s#=}$iKdF3;2p=hA)Q!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zl6e&GYr!_H0n`1F^wCq2~Ce2yhDPw { + public implements Set { + add(value as T) as bool; + remove(value as T) as bool; + + get size as usize; + + in(value as T) as bool; + for(x as T); + } +} diff --git a/src/main/resources/StdLibs/collections/src/LinkedList.zs b/src/main/resources/StdLibs/collections/src/LinkedList.zs new file mode 100644 index 000000000..dfb11cc47 --- /dev/null +++ b/src/main/resources/StdLibs/collections/src/LinkedList.zs @@ -0,0 +1,68 @@ +public class LinkedList { + var first as Node?; + var last as Node?; + var size as usize : get; + + public get isEmpty as bool + => first == null; + + public add(value as T) as void { + if first == null { + first = last = new Node(value); + } else { + val node = new Node(value); + last.next = node; + node.prev = last; + last = node; + } + size++; + } + + public clear() as void { + first = last = null; + size = 0; + } + + [Precondition(ENFORCE, index < size, "Index out of bounds")] + public [](index as usize) as T { + var node = first; + while index > 0 && node != null + node = node.next; + + if node == null + panic "index out of bounds"; + + return node.value; + } + + public implements Queue { + [Precondition(ENFORCE, first != null, "Cannot poll an empty queue")] + poll() as T { + val result = first.value; + first = first.next; + if first == null + last = null; + else + first.prev = null; + + size--; + } + + peek() as T? { + return first == null ? null : first.value; + } + + offer(value as T) as void + => add(value); + } + + private struct Node { + var next as Node?; + var prev as Node?; + val value as T; + + this(value as T) { + this.value = value; + } + } +} diff --git a/src/main/resources/StdLibs/collections/src/NoSuchElementException.zs b/src/main/resources/StdLibs/collections/src/NoSuchElementException.zs new file mode 100644 index 000000000..b2fe51f26 --- /dev/null +++ b/src/main/resources/StdLibs/collections/src/NoSuchElementException.zs @@ -0,0 +1,5 @@ +public class NoSuchElementException : Exception { + public this(message as string) { + super(message); + } +} diff --git a/src/main/resources/StdLibs/collections/src/Queue.zs b/src/main/resources/StdLibs/collections/src/Queue.zs new file mode 100644 index 000000000..a3608758d --- /dev/null +++ b/src/main/resources/StdLibs/collections/src/Queue.zs @@ -0,0 +1,7 @@ +public interface Queue { + get empty as bool; + + poll() as T; + peek() as T; + push(value as T) as void; +} diff --git a/src/main/resources/StdLibs/collections/src/Set.zs b/src/main/resources/StdLibs/collections/src/Set.zs new file mode 100644 index 000000000..3e35d6108 --- /dev/null +++ b/src/main/resources/StdLibs/collections/src/Set.zs @@ -0,0 +1,12 @@ +public interface Set { + add(value as T) as bool; + remove(value as T) as bool; + + get size as usize; + + toArray(); + toArray(comparator as function(a as T, b as T) as int); + + in(value as T) as bool; + for(x as T); +} diff --git a/src/main/resources/StdLibs/collections/src/Stack.zs b/src/main/resources/StdLibs/collections/src/Stack.zs new file mode 100644 index 000000000..7f67faae0 --- /dev/null +++ b/src/main/resources/StdLibs/collections/src/Stack.zs @@ -0,0 +1,16 @@ +public class Stack { + var values as List = new List(); + + public push(value as T) as void + => values.add(value); + + public get size as usize + => values.length; + + [Precondition(ENFORCE, size > 0, "Cannot pop an empty stack")] + public pop() as T + => values.remove(values.length - 1); + + public get isEmpty as bool + => values.isEmpty; +} diff --git a/src/main/resources/StdLibs/compactio/module.json b/src/main/resources/StdLibs/compactio/module.json new file mode 100644 index 000000000..d012cf55e --- /dev/null +++ b/src/main/resources/StdLibs/compactio/module.json @@ -0,0 +1,6 @@ +{ + "package": "compactio", + "javaPackage": "org.openzen.zencode.stdlib.compactio", + "host": "universal", + "dependencies": ["io"] +} diff --git a/src/main/resources/StdLibs/compactio/src/CompactBytesDataInput.zs b/src/main/resources/StdLibs/compactio/src/CompactBytesDataInput.zs new file mode 100644 index 000000000..b1907191b --- /dev/null +++ b/src/main/resources/StdLibs/compactio/src/CompactBytesDataInput.zs @@ -0,0 +1,293 @@ +public class CompactBytesDataInput { + private const P6 as uint = 1 << 6; + private const P7 as uint = 1 << 7; + private const P13 as uint = 1 << 13; + private const P14 as uint = 1 << 14; + private const P20 as uint = 1 << 20; + private const P21 as uint = 1 << 21; + private const P27 as uint = 1 << 27; + private const P28 as uint = 1 << 28; + private const P34 as ulong = 1UL << 34; + private const P35 as ulong = 1UL << 35; + private const P41 as ulong = 1UL << 41; + private const P42 as ulong = 1UL << 42; + private const P48 as ulong = 1UL << 48; + private const P49 as ulong = 1UL << 49; + private const P55 as ulong = 1UL << 55; + private const P56 as ulong = 1UL << 56; + + val data as byte[]`borrow:this; + var offset as usize : get; + + public this(data as byte[]`borrow:this) { + this.data = data; + this.offset = 0; + } + + public this(data as byte[]`borrow:this, offset as usize) { + this.data = data; + this.offset = offset; + } + + ~this {} + + public implements CompactDataInput { + readBool() => readByte() != 0; + + readByte() => data[offset++]; + + readSByte() => data[offset++]; + + readShort() { + val b0 = data[offset++] as uint; + val b1 = data[offset++] as uint; + return ((b0 << 8) | b1) as short; + } + + readUShort() => readShort(); + + readInt() { + val b0 = data[offset++] as int; + val b1 = data[offset++] as int; + val b2 = data[offset++] as int; + val b3 = data[offset++] as int; + return (b0 << 24) | (b1 << 16) | (b2 << 8) | b3; + } + + readUInt() => readInt(); + + readLong() { + val i0 = readUInt() as long; + val i1 = readUInt() as long; + return (i0 << 32) | i1; + } + + readULong() => readLong(); + + readVarInt() { + val value = readVarUInt(); + return (value & 1) == 0 ? (value >> 1) : -((value >> 1) as int + 1); + } + + readVarUInt() { + var value = data[offset++] as uint; + if (value & P7) == 0 + return value; + + value = (value & (P7 - 1)) | (data[offset++] as uint) << 7; + if (value & P14) == 0 + return value; + + value = (value & (P14 - 1)) | (data[offset++] as uint) << 14; + if (value & P21) == 0 + return value; + + value = (value & (P21 - 1)) | (data[offset++] as uint) << 21; + if (value & P28) == 0 + return value; + + return (value & (P28 - 1)) | (data[offset++] as uint) << 28; + } + + readVarLong() { + val value = readVarULong(); + return (value & 1) == 0 ? (value >> 1) : -((value >> 1) as long + 1); + } + + readVarULong() { + var value = data[offset++] as ulong; + if (value & P7) == 0 + return value; + + value = (value & (P7 - 1)) | (data[offset++] as ulong) << 7; + if (value & P14) == 0 + return value; + + value = (value & (P14 - 1)) | (data[offset++] as ulong) << 14; + if (value & P21) == 0 + return value; + + value = (value & (P21 - 1)) | (data[offset++] as ulong) << 21; + if (value & P28) == 0 + return value; + + value = (value & (P28 - 1)) | (data[offset++] as ulong) << 28; + if (value & P35) == 0 + return value; + + value = (value & (P35 - 1)) | (data[offset++] as ulong) << 35; + if (value & P42) == 0 + return value; + + value = (value & (P42 - 1)) | (data[offset++] as ulong) << 42; + if (value & P49) == 0 + return value; + + value = (value & (P49 - 1)) | (data[offset++] as ulong) << 49; + if (value & P56) == 0 + return value; + + return (value & (P56 - 1)) | (data[offset++] as ulong) << 56; + } + + readFloat() => float.fromBits(readUInt()); + + readDouble() => double.fromBits(readULong()); + + readChar() => readVarUInt() as char; + + readString() => string.fromUTF8Bytes(readBytes()); + + readBytes() as byte[] { + val size = readVarUInt(); + return readRawBytes(size); + } + + readRawBytes(size as usize) { + val result = data[offset .. offset + size]; + offset += size; + return result; + } + + readBoolArray() as bool[] { + val size = readVarUInt() as usize; + val result = new bool[](size); + for i in 0 .. ((size + 7) / 8) { + val bvalue = readByte(); + val remainingBits = result.length - 8 * i; + + if (remainingBits > 0) + result[i * 8 + 0] = (bvalue & 1) > 0; + if (remainingBits > 1) + result[i * 8 + 2] = (bvalue & 4) > 0; + if (remainingBits > 3) + result[i * 8 + 3] = (bvalue & 8) > 0; + if (remainingBits > 4) + result[i * 8 + 4] = (bvalue & 16) > 0; + if (remainingBits > 5) + result[i * 8 + 5] = (bvalue & 32) > 0; + if (remainingBits > 6) + result[i * 8 + 6] = (bvalue & 64) > 0; + if (remainingBits > 7) + result[i * 8 + 7] = (bvalue & 128) > 0; + } + + return result; + } + + readByteArray() => readBytes(); + + readSByteArray() => readBytes(); + + readShortArray() => readShortArrayRaw(readVarUInt()); + + readShortArrayRaw(length) { + val result = new short[](length); + for i in 0 .. result.length + result[i] = readShort(); + return result; + } + + readUShortArray() => readShortArray(); + + readUShortArrayRaw(length) => readShortArrayRaw(length); + + readVarIntArray() => readVarIntArrayRaw(readVarUInt()); + + readVarIntArrayRaw(length) { + val result = new int[](length); + for i in 0 .. result.length + result[i] = readVarInt(); + return result; + } + + readVarUIntArray() => readVarUIntArrayRaw(readVarUInt()); + + readVarUIntArrayRaw(length) { + val result = new uint[](length); + for i in 0 .. result.length + result[i] = readVarUInt(); + return result; + } + + readIntArray() => readIntArrayRaw(readVarUInt()); + + readIntArrayRaw(length) { + val result = new int[](length); + for i in 0 .. result.length + result[i] = readInt(); + return result; + } + + readUIntArray() => readUIntArrayRaw(readVarUInt()); + + readUIntArrayRaw(length) { + val result = new int[](length); + for i in 0 .. result.length + result[i] = readUInt(); + return result; + } + + readVarLongArray() => readVarLongArrayRaw(readVarUInt()); + + readVarLongArrayRaw(length) { + val result = new long[](length); + for i in 0 .. result.length + result[i] = readVarLong(); + return result; + } + + readVarULongArray() => readVarULongArrayRaw(readVarUInt()); + + readVarULongArrayRaw(length) { + val result = new long[](length); + for i in 0 .. result.length + result[i] = readVarULong(); + return result; + } + + readLongArray() => readLongArrayRaw(readVarUInt()); + + readLongArrayRaw(length) { + val result = new long[](length); + for i in 0 .. result.length + result[i] = readLong(); + return result; + } + + readULongArray() => readLongArray(); + + readULongArrayRaw(length) => readLongArrayRaw(length); + + readFloatArray() => readFloatArrayRaw(readVarUInt()); + + readFloatArrayRaw(length) { + val result = new float[](length); + for i in 0 .. result.length + result[i] = readFloat(); + return result; + } + + readDoubleArray() => readDoubleArrayRaw(readVarUInt()); + + readDoubleArrayRaw(length) { + val result = new double[](length); + for i in 0 .. length + result[i] = readDouble(); + return result; + } + + readStringArray() => readStringArrayRaw(readVarUInt()); + + readStringArrayRaw(length) { + val result = new string[](length); + for i in 0 .. result.length + result[i] = readString(); + return result; + } + + skip(bytes) => offset += bytes; + + hasMore() => offset < data.length; + } +} diff --git a/src/main/resources/StdLibs/compactio/src/CompactBytesDataOutput.zs b/src/main/resources/StdLibs/compactio/src/CompactBytesDataOutput.zs new file mode 100644 index 000000000..ce1aaf903 --- /dev/null +++ b/src/main/resources/StdLibs/compactio/src/CompactBytesDataOutput.zs @@ -0,0 +1,367 @@ +public class CompactBytesDataOutput { + private const P6 as uint = 1 << 6; + private const P7 as uint = 1 << 7; + private const P13 as uint = 1 << 13; + private const P14 as uint = 1 << 14; + private const P20 as uint = 1 << 20; + private const P21 as uint = 1 << 21; + private const P27 as uint = 1 << 27; + private const P28 as uint = 1 << 28; + private const P34 as ulong = 1UL << 34; + private const P35 as ulong = 1UL << 35; + private const P41 as ulong = 1UL << 41; + private const P42 as ulong = 1UL << 42; + private const P48 as ulong = 1UL << 48; + private const P49 as ulong = 1UL << 49; + private const P55 as ulong = 1UL << 55; + private const P56 as ulong = 1UL << 56; + + var data = new byte[](16); + var length as usize = 0; + + private reserve(bytes as usize) as void { + while length + bytes > data.length + data = data.copy(2 * data.length); + } + + public asByteArray() as byte[] => data.copy(length); + + ~this {} + + public implements CompactDataOutput { + writeBool(value) => writeByte(value ? 1 : 0); + + writeByte(value) { + reserve(1); + data[length++] = value; + } + + writeSByte(value) => writeByte(value); + + writeShort(value) => writeUShort(value); + + writeUShort(value) { + reserve(2); + data[length++] = (value >> 8) as byte; + data[length++] = value as byte; + } + + writeInt(value) => writeUInt(value); + + writeUInt(value) { + reserve(4); + data[length++] = (value >> 24) as byte; + data[length++] = (value >> 16) as byte; + data[length++] = (value >> 8) as byte; + data[length++] = value as byte; + } + + writeLong(value) => writeULong(value); + + writeULong(value) { + reserve(8); + data[length++] = (value >> 56) as byte; + data[length++] = (value >> 48) as byte; + data[length++] = (value >> 40) as byte; + data[length++] = (value >> 32) as byte; + data[length++] = (value >> 24) as byte; + data[length++] = (value >> 16) as byte; + data[length++] = (value >> 8) as byte; + data[length++] = value as byte; + } + + writeVarInt(value) => writeVarUInt(value < 0 ? (((1 - (value as uint)) << 1) + 1) : (value << 1)); + + writeVarUInt(value) { + reserve(5); + + if value < P7 { + data[length++] = (value & 0x7F) as byte; + } else if value < P14 { + data[length++] = ((value & 0x7F) | 0x80) as byte; + data[length++] = ((value >> 7) & 0x7F) as byte; + } else if value < P21 { + data[length++] = ((value & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 7) & 0x7F) | 0x80) as byte; + data[length++] = ((value >> 14) & 0x7F) as byte; + } else if value < P28 { + data[length++] = ((value & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 7) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 14) & 0x7F) | 0x80) as byte; + data[length++] = ((value >> 21) & 0x7F) as byte; + } else { + data[length++] = ((value & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 7) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 14) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 21) & 0x7F) | 0x80) as byte; + data[length++] = ((value >> 28) & 0x7F) as byte; + } + } + + writeVarLong(value) => writeVarULong(value < 0 ? (((1 - (value as ulong)) << 1) + 1) : (value << 1)); + + writeVarULong(value) { + reserve(9); + + if value < P7 { + data[length++] = (value & 0x7F) as byte; + } else if value < P14 { + data[length++] = ((value & 0x7F) | 0x80) as byte; + data[length++] = ((value >> 7) & 0x7F) as byte; + } else if value < P21 { + data[length++] = ((value & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 7) & 0x7F) | 0x80) as byte; + data[length++] = ((value >> 14) & 0x7F) as byte; + } else if value < P28 { + data[length++] = ((value & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 7) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 14) & 0x7F) | 0x80) as byte; + data[length++] = ((value >> 21) & 0x7F) as byte; + } else if value < P35 { + data[length++] = ((value & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 7) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 14) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 21) & 0x7F) | 0x80) as byte; + data[length++] = ((value >> 28) & 0x7F) as byte; + } else if value < P42 { + data[length++] = ((value & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 7) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 14) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 21) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 28) & 0x7F) | 0x80) as byte; + data[length++] = ((value >> 35) & 0x7F) as byte; + } else if value < P49 { + data[length++] = ((value & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 7) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 14) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 21) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 28) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 35) & 0x7F) | 0x80) as byte; + data[length++] = ((value >> 42) & 0x7F) as byte; + } else if value < P56 { + data[length++] = ((value & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 7) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 14) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 21) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 28) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 35) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 42) & 0x7F) | 0x80) as byte; + data[length++] = ((value >> 49) & 0x7F) as byte; + } else { + data[length++] = ((value & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 7) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 14) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 21) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 28) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 35) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 42) & 0x7F) | 0x80) as byte; + data[length++] = (((value >> 49) & 0x7F) | 0x80) as byte; + data[length++] = (value >> 56) as byte; + } + } + + writeFloat(value) => writeUInt(value.bits); + + writeDouble(value) => writeULong(value.bits); + + writeChar(value) => writeVarUInt(value); + + [Precondition(ENFORCE, data.length < uint.MAX_VALUE, "Array length cannot exceed uint limit")] + writeBytes(data) { + writeVarUInt(data.length as uint); + writeRawBytes(data); + } + + [Precondition(ENFORCE, length < uint.MAX_VALUE, "Array length cannot exceed uint limit")] + writeBytes(data, offset, length) { + writeVarUInt(length as uint); + writeRawBytes(data, offset, length); + } + + writeString(str) => writeBytes(str.toUTF8Bytes()); + + writeRawBytes(value) { + reserve(value.length); + value.copyTo(data, 0, length, value.length); + length += value.length; + } + + writeRawBytes(value, offset, length) { + reserve(value.length); + value.copyTo(data, offset, this.length, value.length); + this.length += length; + } + + [Precondition(ENFORCE, data.length < uint.MAX_VALUE, "Array length cannot exceed uint limit")] + writeBoolArray(data) { + writeVarUInt(data.length as uint); + + var i = 0 as usize; + while i < data.length - 7 { + var bvalue as byte = 0; + if data[i + 0] + bvalue |= 1; + if data[i + 1] + bvalue |= 2; + if data[i + 2] + bvalue += 4; + if data[i + 3] + bvalue += 8; + if data[i + 4] + bvalue += 16; + if data[i + 5] + bvalue += 32; + if data[i + 6] + bvalue += 64; + if data[i + 7] + bvalue += 128; + writeByte(bvalue); + i += 8; + } + + if i < data.length { + var bvalue as byte = 0; + for offset in 0 .. (data.length % 7) + if data[i + offset] + bvalue += (1 << i) as byte; + + writeByte(bvalue); + } + } + + [Precondition(ENFORCE, data.length < uint.MAX_VALUE, "Array length cannot exceed uint limit")] + writeByteArray(data) => writeBytes(data); + + [Precondition(ENFORCE, data.length < uint.MAX_VALUE, "Array length cannot exceed uint limit")] + writeSByteArray(data) => writeBytes(data); + + [Precondition(ENFORCE, data.length < uint.MAX_VALUE, "Array length cannot exceed uint limit")] + writeShortArray(data) { + writeVarUInt(data.length as uint); + writeShortArrayRaw(data); + } + + writeShortArrayRaw(data) { + for element in data + writeShort(element); + } + + [Precondition(ENFORCE, data.length < uint.MAX_VALUE, "Array length cannot exceed uint limit")] + writeUShortArray(data) => writeShortArray(data); + + writeUShortArrayRaw(data) => writeShortArrayRaw(data); + + [Precondition(ENFORCE, data.length < uint.MAX_VALUE, "Array length cannot exceed uint limit")] + writeVarIntArray(data) { + writeVarUInt(data.length as uint); + writeVarIntArrayRaw(data); + } + + writeVarIntArrayRaw(data) { + for element in data + writeVarInt(element); + } + + [Precondition(ENFORCE, data.length < uint.MAX_VALUE, "Array length cannot exceed uint limit")] + writeVarUIntArray(data) { + writeVarUInt(data.length as uint); + writeVarUIntArrayRaw(data); + } + + writeVarUIntArrayRaw(data) { + for element in data + writeVarUInt(element); + } + + [Precondition(ENFORCE, data.length < uint.MAX_VALUE, "Array length cannot exceed uint limit")] + writeIntArray(data) { + writeVarUInt(data.length as uint); + writeIntArrayRaw(data); + } + + writeIntArrayRaw(data) { + for element in data + writeInt(element); + } + + [Precondition(ENFORCE, data.length < uint.MAX_VALUE, "Array length cannot exceed uint limit")] + writeUIntArray(data) => writeIntArray(data); + + writeUIntArrayRaw(data) => writeIntArrayRaw(data); + + [Precondition(ENFORCE, data.length < uint.MAX_VALUE, "Array length cannot exceed uint limit")] + writeVarLongArray(data) { + writeVarUInt(data.length as uint); + writeVarLongArrayRaw(data); + } + + writeVarLongArrayRaw(data) { + for element in data + writeVarLong(element); + } + + [Precondition(ENFORCE, data.length < uint.MAX_VALUE, "Array length cannot exceed uint limit")] + writeVarULongArray(data) { + writeVarUInt(data.length as uint); + writeVarULongArrayRaw(data); + } + + writeVarULongArrayRaw(data) { + for element in data + writeVarULong(element); + } + + [Precondition(ENFORCE, data.length < uint.MAX_VALUE, "Array length cannot exceed uint limit")] + writeLongArray(data) { + writeVarUInt(data.length as uint); + writeLongArrayRaw(data); + } + + writeLongArrayRaw(data) { + for element in data + writeLong(element); + } + + [Precondition(ENFORCE, data.length < uint.MAX_VALUE, "Array length cannot exceed uint limit")] + writeULongArray(data) => writeLongArray(data); + + writeULongArrayRaw(data) => writeLongArrayRaw(data); + + [Precondition(ENFORCE, data.length < uint.MAX_VALUE, "Array length cannot exceed uint limit")] + writeFloatArray(data) { + writeVarUInt(data.length as uint); + writeFloatArrayRaw(data); + } + + writeFloatArrayRaw(data) { + for element in data + writeFloat(element); + } + + [Precondition(ENFORCE, data.length < uint.MAX_VALUE, "Array length cannot exceed uint limit")] + writeDoubleArray(data) { + writeVarUInt(data.length as uint); + writeDoubleArrayRaw(data); + } + + writeDoubleArrayRaw(data) { + for element in data + writeDouble(element); + } + + [Precondition(ENFORCE, data.length < uint.MAX_VALUE, "Array length cannot exceed uint limit")] + writeStringArray(data) { + writeVarUInt(data.length as uint); + writeStringArrayRaw(data); + } + + writeStringArrayRaw(data) { + for element in data + writeString(element); + } + + flush() { + // nothing to do + } + } +} diff --git a/src/main/resources/StdLibs/compactio/src/CompactDataInput.zs b/src/main/resources/StdLibs/compactio/src/CompactDataInput.zs new file mode 100644 index 000000000..4217404a8 --- /dev/null +++ b/src/main/resources/StdLibs/compactio/src/CompactDataInput.zs @@ -0,0 +1,103 @@ +public interface CompactDataInput { + readBool`mutable() as bool; + + readByte`mutable() as byte; + + readSByte`mutable() as sbyte; + + readShort`mutable() as short; + + readUShort`mutable() as ushort; + + readInt`mutable() as int; + + readUInt`mutable() as uint; + + readLong`mutable() as long; + + readULong`mutable() as ulong; + + readVarInt`mutable() as int; + + readVarUInt`mutable() as uint; + + readVarLong`mutable() as long; + + readVarULong`mutable() as ulong; + + readFloat`mutable() as float; + + readDouble`mutable() as double; + + readChar`mutable() as char; + + readString`mutable() as string; + + readBytes`mutable() as byte[]; + + readRawBytes`mutable(length as usize) as byte[]; + + readBoolArray`mutable() as bool[]; + + readByteArray`mutable() as byte[]; + + readSByteArray`mutable() as sbyte[]; + + readShortArray`mutable() as short[]; + + readShortArrayRaw`mutable(length as usize) as short[]; + + readUShortArray`mutable() as ushort[]; + + readUShortArrayRaw`mutable(length as usize) as ushort[]; + + readVarIntArray`mutable() as int[]; + + readVarIntArrayRaw`mutable(length as usize) as int[]; + + readVarUIntArray`mutable() as uint[]; + + readVarUIntArrayRaw`mutable(length as usize) as uint[]; + + readIntArray`mutable() as int[]; + + readIntArrayRaw`mutable(length as usize) as int[]; + + readUIntArray`mutable() as uint[]; + + readUIntArrayRaw`mutable(length as usize) as uint[]; + + readVarLongArray`mutable() as long[]; + + readVarLongArrayRaw`mutable(length as usize) as long[]; + + readVarULongArray`mutable() as ulong[]; + + readVarULongArrayRaw`mutable(length as usize) as ulong[]; + + readLongArray`mutable() as long[]; + + readLongArrayRaw`mutable(length as usize) as long[]; + + readULongArray`mutable() as ulong[]; + + readULongArrayRaw`mutable(length as usize) as ulong[]; + + readFloatArray`mutable() as float[]; + + readFloatArrayRaw`mutable(length as usize) as float[]; + + readDoubleArray`mutable() as double[]; + + readDoubleArrayRaw`mutable(length as usize) as double[]; + + readStringArray`mutable() as string[]; + + readStringArrayRaw`mutable(length as usize) as string[]; + + skip`mutable(bytes as usize) as void; + + hasMore`mutable() as bool; + + ~this; +} diff --git a/src/main/resources/StdLibs/compactio/src/CompactDataOutput.zs b/src/main/resources/StdLibs/compactio/src/CompactDataOutput.zs new file mode 100644 index 000000000..1a3ff1822 --- /dev/null +++ b/src/main/resources/StdLibs/compactio/src/CompactDataOutput.zs @@ -0,0 +1,105 @@ +public interface CompactDataOutput { + writeBool(value as bool) as void; + + writeByte(value as byte) as void; + + writeSByte(value as sbyte) as void; + + writeShort(value as short) as void; + + writeUShort(value as ushort) as void; + + writeInt(value as int) as void; + + writeUInt(value as uint) as void; + + writeLong(value as long) as void; + + writeULong(value as ulong) as void; + + writeVarInt(value as int) as void; + + writeVarUInt(value as uint) as void; + + writeVarLong(value as long) as void; + + writeVarULong(value as ulong) as void; + + writeFloat(value as float) as void; + + writeDouble(value as double) as void; + + writeChar(value as char) as void; + + writeString(value as string) as void; + + writeBytes(data as byte[]) as void; + + writeBytes(data as byte[], offset as usize, length as usize) as void; + + writeRawBytes(value as byte[]) as void; + + writeRawBytes(value as byte[], offset as usize, length as usize) as void; + + writeBoolArray(data as bool[]) as void; + + writeByteArray(data as byte[]) as void; + + writeSByteArray(data as sbyte[]) as void; + + writeShortArray(data as short[]) as void; + + writeShortArrayRaw(data as short[]) as void; + + writeUShortArray(data as short[]) as void; + + writeUShortArrayRaw(data as short[]) as void; + + writeVarIntArray(data as int[]) as void; + + writeVarIntArrayRaw(data as int[]) as void; + + writeVarUIntArray(data as uint[]) as void; + + writeVarUIntArrayRaw(data as uint[]) as void; + + writeIntArray(data as int[]) as void; + + writeIntArrayRaw(data as int[]) as void; + + writeUIntArray(data as uint[]) as void; + + writeUIntArrayRaw(data as uint[]) as void; + + writeVarLongArray(data as long[]) as void; + + writeVarLongArrayRaw(data as long[]) as void; + + writeVarULongArray(data as ulong[]) as void; + + writeVarULongArrayRaw(data as ulong[]) as void; + + writeLongArray(data as long[]) as void; + + writeLongArrayRaw(data as long[]) as void; + + writeULongArray(data as long[]) as void; + + writeULongArrayRaw(data as long[]) as void; + + writeFloatArray(data as float[]) as void; + + writeFloatArrayRaw(data as float[]) as void; + + writeDoubleArray(data as double[]) as void; + + writeDoubleArrayRaw(data as double[]) as void; + + writeStringArray(data as string[]) as void; + + writeStringArrayRaw(data as string[]) as void; + + flush() as void; + + ~this; +} diff --git a/src/main/resources/StdLibs/io/module.json b/src/main/resources/StdLibs/io/module.json new file mode 100644 index 000000000..5cb023b73 --- /dev/null +++ b/src/main/resources/StdLibs/io/module.json @@ -0,0 +1,5 @@ +{ + "package": "io", + "javaPackage": "org.openzen.zencode.stdlib.io", + "host": "universal" +} diff --git a/src/main/resources/StdLibs/io/src/IOException.zs b/src/main/resources/StdLibs/io/src/IOException.zs new file mode 100644 index 000000000..e41dfee90 --- /dev/null +++ b/src/main/resources/StdLibs/io/src/IOException.zs @@ -0,0 +1,11 @@ +[Native("io::IOException")] +public class IOException : Exception { + [Native("constructor")] + public this(message as string) { + super(message); + } + + /*public this(message as string, cause as Exception) { + super(message, cause); + }*/ +} diff --git a/src/main/resources/StdLibs/io/src/InputStream.zs b/src/main/resources/StdLibs/io/src/InputStream.zs new file mode 100644 index 000000000..54c7f50bf --- /dev/null +++ b/src/main/resources/StdLibs/io/src/InputStream.zs @@ -0,0 +1,14 @@ +[Native("io::InputStream")] +public interface InputStream { + [Native("read")] + read() as int throws IOException; + + [Native("readArray")] + read(array as byte[]) as usize throws IOException; + + [Native("readSlice")] + read(array as byte[], offset as usize, length as usize) as usize throws IOException; + + [Native("destruct")] + ~this; +} diff --git a/src/main/resources/StdLibs/io/src/OutputStream.zs b/src/main/resources/StdLibs/io/src/OutputStream.zs new file mode 100644 index 000000000..567aa209f --- /dev/null +++ b/src/main/resources/StdLibs/io/src/OutputStream.zs @@ -0,0 +1,14 @@ +[Native("io::OutputStream")] +public interface OutputStream { + [Native("write")] + write(value as byte) as void throws IOException; + + [Native("writeArray")] + write(value as byte[]) as void throws IOException; + + [Native("writeSlice")] + write(value as byte[], offset as usize, length as usize) as void throws IOException; + + [Native("destruct")] + ~this; +} diff --git a/src/main/resources/StdLibs/io/src/Reader.zs b/src/main/resources/StdLibs/io/src/Reader.zs new file mode 100644 index 000000000..7b341adf6 --- /dev/null +++ b/src/main/resources/StdLibs/io/src/Reader.zs @@ -0,0 +1,15 @@ +[Native("io::Reader")] +public interface Reader { + [Native("destruct")] + ~this; + + [Native("readCharacter")] + read() as int throws IOException; + + [Native("readArray")] + read(buffer as char[]) as usize throws IOException + => read(buffer, 0, buffer.length); + + [Native("readArraySlice")] + read(buffer as char[], offset as usize, length as usize) as usize throws IOException; +} diff --git a/src/main/resources/StdLibs/io/src/StringReader.zs b/src/main/resources/StdLibs/io/src/StringReader.zs new file mode 100644 index 000000000..5cb188703 --- /dev/null +++ b/src/main/resources/StdLibs/io/src/StringReader.zs @@ -0,0 +1,31 @@ +[Native("io::StringReader")] +public class StringReader { + val data as char[]; + var offset as usize; + + [Native("constructor")] + public this(value as string) { + data = value.characters; + } + + public implements Reader { + [Native("destructor")] + ~this {} + + [Native("readCharacter")] + read() + => offset == data.length ? -1 : data[offset++]; + + [Native("readArray")] + read(buffer) + => read(buffer, 0, buffer.length); + + [Native("readSlice")] + read(buffer, offset, length) { + length = usize.min(data.length - this.offset, length); + data.copyTo(buffer, this.offset, offset, length); + this.offset += length; + return length; + } + } +} diff --git a/src/main/resources/StdLibs/listeners/module.json b/src/main/resources/StdLibs/listeners/module.json new file mode 100644 index 000000000..2f20fe2a9 --- /dev/null +++ b/src/main/resources/StdLibs/listeners/module.json @@ -0,0 +1,5 @@ +{ + "package": "listeners", + "javaPackage": "org.openzen.zencode.stdlib.listeners", + "host": "universal" +} diff --git a/src/main/resources/StdLibs/listeners/src/DummyListenerHandle.zs b/src/main/resources/StdLibs/listeners/src/DummyListenerHandle.zs new file mode 100644 index 000000000..e1d00cbbe --- /dev/null +++ b/src/main/resources/StdLibs/listeners/src/DummyListenerHandle.zs @@ -0,0 +1,9 @@ +public class DummyListenerHandle { + val listener as T : get; + + public this(listener as T) { + this.listener = listener; + } + + public implements ListenerHandle {} +} diff --git a/src/main/resources/StdLibs/listeners/src/ListenerHandle.zs b/src/main/resources/StdLibs/listeners/src/ListenerHandle.zs new file mode 100644 index 000000000..9d319d9ff --- /dev/null +++ b/src/main/resources/StdLibs/listeners/src/ListenerHandle.zs @@ -0,0 +1,5 @@ +public interface ListenerHandle { + ~this; + + get listener as T; +} diff --git a/src/main/resources/StdLibs/listeners/src/ListenerList.zs b/src/main/resources/StdLibs/listeners/src/ListenerList.zs new file mode 100644 index 000000000..c4edab106 --- /dev/null +++ b/src/main/resources/StdLibs/listeners/src/ListenerList.zs @@ -0,0 +1,80 @@ +public class ListenerList { + public const PRIORITY_HIGH = 100; + public const PRIORITY_DEFAULT = 0; + public const PRIORITY_LOW = -100; + + var first as EventListenerNode`borrow? = null; + var last as EventListenerNode`borrow? = null; + + public add(listener as T) as ListenerHandle`unique + => add(listener, PRIORITY_DEFAULT); + + public add(listener as T, priority as int) as ListenerHandle`unique { + val node = new EventListenerNode`unique(listener, priority); + + if first == null { + first = last = node; + } else { + // prioritized list: where to insert? + var previousNode = last; + while previousNode != null && priority > previousNode.priority + previousNode = previousNode.prev; + + if previousNode == null { + node.next = first; + first.prev = previousNode; + first = node; + } else { + if previousNode.next == null + last = node; + else + previousNode.next.prev = node; + + previousNode.next = node; + node.prev = previousNode; + } + } + + return node; + } + + public clear() as void { + first = last = null; + } + + public accept(consumer as function(listener as T) as void) as void { + var current = first; + while current != null { + consumer(current.listener); + current = current.next; + } + } + + public get isEmpty => first == null; + + private class EventListenerNode { + val listener as T : get; + val priority as int; + var next as EventListenerNode`borrow? = null; + var prev as EventListenerNode`borrow? = null; + + public this(listener as T, priority as int) { + this.listener = listener; + this.priority = priority; + } + + ~this { + if prev == null + first = next; + else + prev.next = next; + + if next == null + last = prev; + else + next.prev = prev; + } + + public implements ListenerHandle {} + } +} \ No newline at end of file diff --git a/src/main/resources/StdLibs/live/module.json b/src/main/resources/StdLibs/live/module.json new file mode 100644 index 000000000..968cad44c --- /dev/null +++ b/src/main/resources/StdLibs/live/module.json @@ -0,0 +1,6 @@ +{ + "package": "live", + "javaPackage": "org.openzen.zencode.stdlib.live", + "host": "universal", + "dependencies": ["listeners"] +} diff --git a/src/main/resources/StdLibs/live/src/ImmutableLiveBool.zs b/src/main/resources/StdLibs/live/src/ImmutableLiveBool.zs new file mode 100644 index 000000000..daf746194 --- /dev/null +++ b/src/main/resources/StdLibs/live/src/ImmutableLiveBool.zs @@ -0,0 +1,16 @@ +import listeners.DummyListenerHandle; + +public class ImmutableLiveBool { + public const TRUE = new ImmutableLiveBool(true); + public const FALSE = new ImmutableLiveBool(false); + + val value as bool : get; + + private this(value as bool) { + this.value = value; + } + + public implements LiveBool { + addListener(listener) => new DummyListenerHandle`unique(listener); + } +} diff --git a/src/main/resources/StdLibs/live/src/ImmutableLiveObject.zs b/src/main/resources/StdLibs/live/src/ImmutableLiveObject.zs new file mode 100644 index 000000000..cdd4476f8 --- /dev/null +++ b/src/main/resources/StdLibs/live/src/ImmutableLiveObject.zs @@ -0,0 +1,13 @@ +import listeners.DummyListenerHandle; + +public class ImmutableLiveObject { + val value as T : get; + + public this(value as T) { + this.value = value; + } + + public implements LiveObject { + addListener(listener) => new DummyListenerHandle.Listener>`unique(listener); + } +} diff --git a/src/main/resources/StdLibs/live/src/ImmutableLiveString.zs b/src/main/resources/StdLibs/live/src/ImmutableLiveString.zs new file mode 100644 index 000000000..0d5a3574b --- /dev/null +++ b/src/main/resources/StdLibs/live/src/ImmutableLiveString.zs @@ -0,0 +1,13 @@ +import listeners.DummyListenerHandle; + +public class ImmutableLiveString { + val value as string : get; + + public this(value as string) { + this.value = value; + } + + public implements LiveString { + addListener(listener) => new DummyListenerHandle`unique(listener); + } +} diff --git a/src/main/resources/StdLibs/live/src/InverseLiveBool.zs b/src/main/resources/StdLibs/live/src/InverseLiveBool.zs new file mode 100644 index 000000000..9cef2ef78 --- /dev/null +++ b/src/main/resources/StdLibs/live/src/InverseLiveBool.zs @@ -0,0 +1,14 @@ +public class InverseLiveBool { + val source as LiveBool; + + public this(source as LiveBool) { + this.source = source; + } + + public implements LiveBool { + get value => !source.value; + + addListener(listener) + => source.addListener((oldVal, newVal) => listener(!oldVal, !newVal)); + } +} diff --git a/src/main/resources/StdLibs/live/src/LiveArrayList.zs b/src/main/resources/StdLibs/live/src/LiveArrayList.zs new file mode 100644 index 000000000..724fbda3d --- /dev/null +++ b/src/main/resources/StdLibs/live/src/LiveArrayList.zs @@ -0,0 +1,52 @@ +import listeners.ListenerList; + +public class LiveArrayList { + val values = new List(); + val listeners = new ListenerList.Listener>(); + + public implements MutableLiveList { + add(value) { + val index = values.length; + values.add(value); + listeners.accept(listener => listener.onInserted(index, value)); + } + + insert(index, value) { + values.insert(index, value); + listeners.accept(listener => listener.onInserted(index, value)); + } + + []=(index, value) { + val oldValue = values[index]; + values[index] = value; + listeners.accept(listener => listener.onChanged(index, oldValue, value)); + } + + remove(index as usize) { + val oldValue = values.remove(index); + listeners.accept(listener => listener.onRemoved(index, oldValue)); + } + + remove(value as T) { + val index = indexOf(value); + if index == null + return; + + remove(index); + } + + clear() { + var i = length; + while i > 0 { + i--; + remove(i); + } + } + + iterate() => values.iterate(); + indexOf(value) => values.indexOf(value); + get length => values.length; + [](index) => values[index]; + addListener(listener) => listeners.add(listener); + } +} diff --git a/src/main/resources/StdLibs/live/src/LiveBool.zs b/src/main/resources/StdLibs/live/src/LiveBool.zs new file mode 100644 index 000000000..b29eee61a --- /dev/null +++ b/src/main/resources/StdLibs/live/src/LiveBool.zs @@ -0,0 +1,8 @@ +public interface LiveBool { + get value as bool; + + addListener(listener as Listener) as ListenerHandle`unique; + + alias Listener as function(oldValue as bool, newValue as bool) as void; + alias ListenerHandle as listeners.ListenerHandle; +} diff --git a/src/main/resources/StdLibs/live/src/LiveConcatList.zs b/src/main/resources/StdLibs/live/src/LiveConcatList.zs new file mode 100644 index 000000000..86f61af38 --- /dev/null +++ b/src/main/resources/StdLibs/live/src/LiveConcatList.zs @@ -0,0 +1,86 @@ +import listeners.ListenerList; +import listeners.ListenerHandle; + +public class LiveConcatList { + val listeners = new ListenerList.Listener>; + val a as LiveList; + val b as LiveList; + + val aListener as ListenerHandle.Listener>`unique; + val bListener as ListenerHandle.Listener>`unique; + + public this(a as LiveList, b as LiveList) { + this.a = a; + this.b = b; + + aListener = a.addListener(new FirstListListener()); + bListener = b.addListener(new SecondListListener()); + } + + public implements LiveList { + indexOf(value) { + var result = a.indexOf(value); + if result != null + return result; + + result = b.indexOf(value); + return result == null ? null : result + a.length; + } + + iterate() => new ConcatIterator; + + get length => a.length + b.length; + + [](index) => index < a.length ? a[index] : b[index - a.length]; + + addListener(listener) => listeners.add(listener); + } + + private class ConcatIterator { + var firstList = true; + var iterator as Iterator; + + public this() { + iterator = a.iterate(); + if !iterator.hasNext { + firstList = false; + iterator = b.iterate(); + } + } + + public implements Iterator { + get hasNext => iterator.hasNext; + + next() { + val result = iterator.next(); + if firstList && !iterator.hasNext { + firstList = false; + iterator = b.iterator(); + } + return result; + } + } + } + + private class FirstListListener { + public implements LiveList.Listener { + onInserted(index, value) + => listeners.accept(listener => listener.onInserted(index, value)); + onChanged(index, oldValue, newValue) + => listeners.accept(listener => listener.onChanged(index, oldValue, newValue)); + onRemoved(index, oldValue) + => listeners.accept(listener => listener.onRemoved(index, oldValue)); + } + } + + private class SecondListListener { + public implements LiveList.Listener { + onInserted(index, value) + => listeners.accept(listener => listener.onInserted(a.length + index, value)); + onChanged(index, oldValue, newValue) + => listeners.accept(listener => listener.onChanged(a.length + index, oldValue, newValue)); + onRemoved(index, oldValue) + => listeners.accept(listener => listener.onRemoved(a.length + index, oldValue)); + } + } +} diff --git a/src/main/resources/StdLibs/live/src/LiveInt.zs b/src/main/resources/StdLibs/live/src/LiveInt.zs new file mode 100644 index 000000000..5d94e6ab6 --- /dev/null +++ b/src/main/resources/StdLibs/live/src/LiveInt.zs @@ -0,0 +1,9 @@ +public interface LiveInt { + get value as int; + set value as int; + + addListener(listener as Listener) as ListenerHandle`unique; + + alias Listener as function(oldValue as int, newValue as int) as void; + alias ListenerHandle as listeners.ListenerHandle; +} diff --git a/src/main/resources/StdLibs/live/src/LiveList.zs b/src/main/resources/StdLibs/live/src/LiveList.zs new file mode 100644 index 000000000..05181ab07 --- /dev/null +++ b/src/main/resources/StdLibs/live/src/LiveList.zs @@ -0,0 +1,21 @@ +public interface LiveList : Iterable { + ~this; + + get length as usize; + + indexOf(value as T) as usize?; + + //[IndexIterator] + //for (index as int, value as T); + + [](index as usize) as T; + + addListener(listener as Listener) as ListenerHandle`unique; + + public interface Listener { + onInserted(index as usize, value as T) as void; + onChanged(index as usize, oldValue as T, newValue as T) as void; + onRemoved(index as usize, oldValue as T) as void; + } + alias ListenerHandle as listeners.ListenerHandle>; +} diff --git a/src/main/resources/StdLibs/live/src/LiveObject.zs b/src/main/resources/StdLibs/live/src/LiveObject.zs new file mode 100644 index 000000000..b579c234b --- /dev/null +++ b/src/main/resources/StdLibs/live/src/LiveObject.zs @@ -0,0 +1,8 @@ +public interface LiveObject { + get value as T; + + addListener(listener as Listener) as ListenerHandle`unique; + + alias Listener as function(oldValue as T, newValue as T) as void; + alias ListenerHandle as listeners.ListenerHandle>; +} diff --git a/src/main/resources/StdLibs/live/src/LiveString.zs b/src/main/resources/StdLibs/live/src/LiveString.zs new file mode 100644 index 000000000..72da80528 --- /dev/null +++ b/src/main/resources/StdLibs/live/src/LiveString.zs @@ -0,0 +1,8 @@ +public interface LiveString { + get value as string; + + addListener(listener as Listener) as ListenerHandle`unique; + + alias Listener as function(oldValue as string, newValue as string) as void; + alias ListenerHandle as listeners.ListenerHandle; +} diff --git a/src/main/resources/StdLibs/live/src/MutableLiveBool.zs b/src/main/resources/StdLibs/live/src/MutableLiveBool.zs new file mode 100644 index 000000000..d6078b6e6 --- /dev/null +++ b/src/main/resources/StdLibs/live/src/MutableLiveBool.zs @@ -0,0 +1,3 @@ +public interface MutableLiveBool : LiveBool { + set value as bool; +} diff --git a/src/main/resources/StdLibs/live/src/MutableLiveInt.zs b/src/main/resources/StdLibs/live/src/MutableLiveInt.zs new file mode 100644 index 000000000..67d32206b --- /dev/null +++ b/src/main/resources/StdLibs/live/src/MutableLiveInt.zs @@ -0,0 +1,3 @@ +public interface MutableLiveInt : LiveInt { + set value as int; +} diff --git a/src/main/resources/StdLibs/live/src/MutableLiveList.zs b/src/main/resources/StdLibs/live/src/MutableLiveList.zs new file mode 100644 index 000000000..51662c9fc --- /dev/null +++ b/src/main/resources/StdLibs/live/src/MutableLiveList.zs @@ -0,0 +1,13 @@ +public interface MutableLiveList : LiveList { + add(value as T) as void; + + insert(index as usize, value as T) as void; + + []=(index as usize, value as T) as void; + + remove(index as usize) as void; + + remove(value as T) as void; + + clear() as void; +} diff --git a/src/main/resources/StdLibs/live/src/MutableLiveString.zs b/src/main/resources/StdLibs/live/src/MutableLiveString.zs new file mode 100644 index 000000000..26036ed5a --- /dev/null +++ b/src/main/resources/StdLibs/live/src/MutableLiveString.zs @@ -0,0 +1,3 @@ +public interface MutableLiveString : LiveString { + set value as string; +} diff --git a/src/main/resources/StdLibs/live/src/SimpleLiveBool.zs b/src/main/resources/StdLibs/live/src/SimpleLiveBool.zs new file mode 100644 index 000000000..109055d78 --- /dev/null +++ b/src/main/resources/StdLibs/live/src/SimpleLiveBool.zs @@ -0,0 +1,24 @@ +import listeners.ListenerList; + +public class SimpleLiveBool { + val listeners = new ListenerList; + + var value as bool : get; + + public this(value as bool) { + this.value = value; + } + + public implements MutableLiveBool { + addListener(listener) => listeners.add(listener); + + set value { + if $ == this.value + return; + + val oldValue = $value; + $value = $; + listeners.accept(listener => listener(oldValue, $value)); + } + } +} diff --git a/src/main/resources/StdLibs/live/src/SimpleLiveInt.zs b/src/main/resources/StdLibs/live/src/SimpleLiveInt.zs new file mode 100644 index 000000000..202dbf386 --- /dev/null +++ b/src/main/resources/StdLibs/live/src/SimpleLiveInt.zs @@ -0,0 +1,24 @@ +import listeners.ListenerList; + +public class SimpleLiveInt { + val listeners = new ListenerList; + + var value as int : get; + + public this(value as int) { + this.value = value; + } + + public implements MutableLiveInt { + addListener(listener) => listeners.add(listener); + + set value { + if $ == this.value + return; + + val oldValue = $value; + $value = $; + listeners.accept(listener => listener(oldValue, $value)); + } + } +} diff --git a/src/main/resources/StdLibs/live/src/SimpleLiveString.zs b/src/main/resources/StdLibs/live/src/SimpleLiveString.zs new file mode 100644 index 000000000..7eeb37018 --- /dev/null +++ b/src/main/resources/StdLibs/live/src/SimpleLiveString.zs @@ -0,0 +1,24 @@ +import listeners.ListenerList; + +public class SimpleLiveString { + val listeners = new ListenerList; + + var value as string : get; + + public this(value as string) { + this.value = value; + } + + public implements MutableLiveString { + addListener(listener) => listeners.add(listener); + + set value { + if $ == this.value + return; + + val oldValue = $value; + $value = $; + listeners.accept(listener => listener(oldValue, $value)); + } + } +} diff --git a/src/main/resources/StdLibs/stdlib/module.json b/src/main/resources/StdLibs/stdlib/module.json new file mode 100644 index 000000000..a45000ba1 --- /dev/null +++ b/src/main/resources/StdLibs/stdlib/module.json @@ -0,0 +1,17 @@ +{ + "package": "stdlib", + "host": "universal", + "globals": { + "Comparable": {"type": "Definition", "definition": "Comparable"}, + "Exception": {"type": "Definition", "definition": "Exception"}, + "EqualsComparable": {"type": "Definition", "definition": "EqualsComparable"}, + "Hashable": {"type": "Definition", "definition": "Hashable"}, + "IllegalArgumentException": {"type": "Definition", "definition": "IllegalArgumentException"}, + "Iterable": {"type": "Definition", "definition": "Iterable"}, + "Iterator": {"type": "Definition", "definition": "Iterator"}, + "List": {"type": "Definition", "definition": "List"}, + "StringBuilder": {"type": "Definition", "definition": "StringBuilder"}, + "StringBuildable": {"type": "Definition", "definition": "StringBuildable"}, + "Result": {"type": "Definition", "definition": "Result"} + } +} diff --git a/src/main/resources/StdLibs/stdlib/src.7z b/src/main/resources/StdLibs/stdlib/src.7z new file mode 100644 index 0000000000000000000000000000000000000000..b7b5e9f7b33867d889d6aba908241708c2d4a729 GIT binary patch literal 2956 zcmV;73v={0dc3bE8~_A#4-i#J3jhEB0000Z000000001y@#^m2FD(gLT>veUh>3cE z6(DpCsn2nYA;XpF%pM}Oqqn0-DJXT~^s9_;OQ*jYQFbCvdbX|1eP=;2Yw7WJG}cEU zX!a(d)SpKkG#XSCUzadIr5U5gCm{;p^NL?+?3mW^pbO8#x9ozpzI}bYF$~A`q#9ws zzjRmGytvENM$@qB>!@Fz-X#UcN}wS#ThG$FZem7-$QR0U3<0`DL7)9gr6?RZOA_8w zs|2-h0@Iw>WkAY4>?iP^%EMD|v)8=yqV)-ySeP|3Egju^!CL;ML9m%T=_Z4nsPTVH z`VQU(y-B}3__NeUNc_%jk22O%0iXw>McCxkzN~CTCNrlLXvN|qvfl~9p~26bw;S| z_nuL8!a(i@crWHDkRc$Zf|>v7%gG7v3rv~wOw8Deiv3iqxD!!{u_G4>U$kD7PPx{C z&_;1$gtM;tk>^f(5?bXKbdH@bNZ8N}naF1gt#^E1%`&9%@O%eIXk&{Dfxn7z< z0KNlZHG?@hbbf|{+DoybAdck1*$2evL*YblaDCy?%K@<_4B4ZL%BV}h6ilYh5D9|t z;F!fq&%^k>)QT7Ls|l$04$oNcZd8f75hMC;sdB)46J(Et(Oe^avCR#0#dP)fS+Jz$ zf3r85(j@+5n0%e;Ne=8o5NE5b10&&5@oN1_k~$1 zYK*XwOnD~}B`~!dnV}4Q8V?SIlq4lp35?U5eA5OToCr|!(Q&jwBC6qw!8UlfN4Fx7 zpsCBb@SCy~7~KL%*!ajfp{$y?X#}0y@m*<0hMpWLm0wta)!Df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!b-m5Gm06wlcSi?vrwOUcZiRLT$p@+3-zH zmTIfwYIK1Ycu$B18Nfrw>{qi;7E`NzgQH`ikiV>oT*T4-6p>5D?D`pi=h?f-Qa-Yc z0@g%{bOC*d6a-=fP*TO!TgklluzX z99>eX>8eg^j0frrtIYeGLgfdAkuj7*HBvQEzA-t=Jgvl1N8iO(MhF2qK_4*o*Iao9 zGp8JQB_V)gZJ;5`7yEM>*jZIVF}scMktGkpO*e~1JpcojeeIy4rE9M~1nH!>6^27+ zN@|vOXQuulE_gORPY!lAmg6%CDDc?8>?=C%FnEaKO&b66?neJc5+26!UFF*;t(X~0 zk4dyxR*7MqPlHSVlh;5mkwJ+WtKBgP_Bm`)-L$dHTV7)bw=sHRIwt|PNmYy^GsPvh z^p|*4?}YxM!i=vn5;bhlM7jBf^vB>+t|J-hmjKLwfZul#Wkh)=PSdfgQ->6q4%{fs zgHM{sH8FOBj9#&?bwc`K7LJ?vJ>(1Az-K6o(v zIt;E0kKki&fZA7N^CfebOz46~_Q-}+>)RUPOlEN!K%>M}y7gSH`n55dkT~D51}QR|ZLX z;Sg+Y*3%N*+t}7p3T4)z7ZA?8zZ2z;km>C-Au|IU_L?~H!U3_Z&hbU$xhIM}_1>}P zP1}?vJhqm&n#V+@yHcu8lHB}3U?e&U>$qhJEC;JL6IEL^UVEEE+o?*yLai-F$1+(Q z7E>V?6IGR zeOK>9H_4jL^NStUCh;3M_3}YJkr`1_#|;VEd?fN4D^?U3RApe>hX!E5bpKw)bk%+f zpVZ7DY$aH!uFI7itd~Lb3tzcEtEnTdEdtPF{9NJ00AQd0RaVF01yBG41@{_0id>Xg8%@3 C>!5D{ literal 0 HcmV?d00001 diff --git a/src/main/resources/StdLibs/stdlib/src/Arrays.zs b/src/main/resources/StdLibs/stdlib/src/Arrays.zs new file mode 100644 index 000000000..09b3aa17a --- /dev/null +++ b/src/main/resources/StdLibs/stdlib/src/Arrays.zs @@ -0,0 +1,178 @@ +[Native("stdlib::Arrays")] +public expand > T[] { + [Native("sort")] + public extern sort() as void; + [Native("sorted")] + public extern sorted() as T[]; +} + +public expand > T[] { + public implements Hashable { + public extern hashCode() as int; + public extern == (other as T[]) as bool; + } +} + +[Native("stdlib::Arrays")] +public expand T[] { + [Native("sortWithComparator")] + public extern sort(comparator as function(a as T, b as T) as int) as void; + [Native("sortedWithComparator")] + public extern sorted(comparator as function(a as T, b as T) as int) as T[]; + [Native("copy")] + public extern copy() as T[]; + [Native("copyResize")] + public extern copy(newSize as usize) as T[]; + [Native("copyTo")] + public extern copyTo(target as T[], sourceOffset as usize, targetOffset as usize, length as usize) as void; + + public get first as T? + => this.isEmpty ? null : this[0]; + + public get last as T? + => this.isEmpty ? null : this[$ - (1 as usize)]; + + [Native("reverse")] + public reverse() as void { + for i in 0 .. length / 2 { + var temp = this[i]; + this[i] = this[length - i - 1]; + this[length - i - 1] = temp; + } + } + + // TODO: fix compilation for these + /*[Native("reversed")] + public reversed() as T[] { + return new T[](this, (i, value) => this[length - i - 1]); + }*/ + + [Native("mapValues")] + public map(projection as function(value as T`borrow) as U) as U[] + => new U[](this, projection); + + [Native("mapKeyValues")] + public map(projection as function(index as usize, value as T`borrow) as U) as U[] + => new U[](this, projection); + + [Native("filterValues")] + public filter(predicate as function(value as T`borrow) as bool) as T[] { + var values = new List(); + for value in this + if predicate(value) + values.add(value); + return values as T[]; + } + + [Native("filterKeyValues")] + public filter(predicate as function(index as usize, value as T) as bool) as T[] { + var values = new List(); + for i, value in this + if predicate(i, value) + values.add(value); + return values as T[]; + } + + public each(consumer as function(value as T) as void) as void { + for value in this + consumer(value); + } + + public each(consumer as function(index as usize, value as T) as void) as void { + for i, value in this + consumer(i, value); + } + + public contains(predicate as function(value as T) as bool) as bool { + for value in this + if predicate(value) + return true; + + return false; + } + + public contains(predicate as function(index as usize, value as T) as bool) as bool { + for i, value in this + if predicate(i, value) + return true; + + return false; + } + + public all(predicate as function(value as T) as bool) as bool { + for value in this + if !predicate(value) + return false; + + return true; + } + + public all(predicate as function(i as usize, value as T) as bool) as bool { + for i, value in this + if !predicate(i, value) + return false; + + return true; + } + + public first(predicate as function(value as T) as bool) as T? { + for value in this + if predicate(value) + return value; + + return null; + } + + public first(predicate as function(i as usize, value as T) as bool) as T? { + for i, value in this + if predicate(i, value) + return value; + + return null; + } + + public last(predicate as function(value as T) as bool) as T? { + var i = length; + while i > 0 { + i--; + if predicate(this[i]) + return this[i]; + } + + return null; + } + + public last(predicate as function(index as usize, value as T) as bool) as T? { + var i = length; + while i > 0 { + i--; + if predicate(i, this[i]) + return this[i]; + } + + return null; + } + + public count(predicate as function(value as T) as bool) as usize { + var result = 0; + for value in this + if predicate(value) + result++; + return result; + } + + public count(predicate as function(index as usize, value as T) as bool) as usize { + var result = 0; + for i, value in this + if predicate(i, value) + result++; + return result; + } + + public index(key as function(value as T) as K) as T[K] { + var result = new T[K]; + for value in this + result[key(value)] = value; + return result; + } +} diff --git a/src/main/resources/StdLibs/stdlib/src/Assoc.zs b/src/main/resources/StdLibs/stdlib/src/Assoc.zs new file mode 100644 index 000000000..3d4209ee4 --- /dev/null +++ b/src/main/resources/StdLibs/stdlib/src/Assoc.zs @@ -0,0 +1,8 @@ +public expand V[K] { + mapValues(projection as function(value as V) as W) as W[K] { + val result = new W[K]; + for k, v in this + result[k] = projection(v); + return result; + } +} diff --git a/src/main/resources/StdLibs/stdlib/src/Chars.zs b/src/main/resources/StdLibs/stdlib/src/Chars.zs new file mode 100644 index 000000000..d40d63a91 --- /dev/null +++ b/src/main/resources/StdLibs/stdlib/src/Chars.zs @@ -0,0 +1,4 @@ +public expand char { + public times(number as usize) as string + => new string(new char[](number, this)); +} diff --git a/src/main/resources/StdLibs/stdlib/src/Comparable.zs b/src/main/resources/StdLibs/stdlib/src/Comparable.zs new file mode 100644 index 000000000..73f88673b --- /dev/null +++ b/src/main/resources/StdLibs/stdlib/src/Comparable.zs @@ -0,0 +1,5 @@ +[Native("stdlib::Comparable")] +public interface Comparable { + [Native("compareTo")] + compareTo(other as T) as int; +} diff --git a/src/main/resources/StdLibs/stdlib/src/EnforcementLevel.zs b/src/main/resources/StdLibs/stdlib/src/EnforcementLevel.zs new file mode 100644 index 000000000..225c19c5a --- /dev/null +++ b/src/main/resources/StdLibs/stdlib/src/EnforcementLevel.zs @@ -0,0 +1,5 @@ +public enum EnforcementLevel { + INFO, + ENFORCE, + PROVE +} diff --git a/src/main/resources/StdLibs/stdlib/src/EqualsComparable.zs b/src/main/resources/StdLibs/stdlib/src/EqualsComparable.zs new file mode 100644 index 000000000..00bef37da --- /dev/null +++ b/src/main/resources/StdLibs/stdlib/src/EqualsComparable.zs @@ -0,0 +1,3 @@ +public interface EqualsComparable { + ==(other as T) as bool; +} diff --git a/src/main/resources/StdLibs/stdlib/src/Exception.zs b/src/main/resources/StdLibs/stdlib/src/Exception.zs new file mode 100644 index 000000000..c0b001ab0 --- /dev/null +++ b/src/main/resources/StdLibs/stdlib/src/Exception.zs @@ -0,0 +1,8 @@ +[Native("stdlib::Exception")] +public virtual class Exception { + [Native("constructor")] + public this(message as string) {} + + [Native("constructorWithCause")] + public this(message as string, cause as Exception) {} +} diff --git a/src/main/resources/StdLibs/stdlib/src/Hashable.zs b/src/main/resources/StdLibs/stdlib/src/Hashable.zs new file mode 100644 index 000000000..c906e242d --- /dev/null +++ b/src/main/resources/StdLibs/stdlib/src/Hashable.zs @@ -0,0 +1,4 @@ +public interface Hashable { + hashCode() as int; + == (other as T) as bool; +} diff --git a/src/main/resources/StdLibs/stdlib/src/IllegalArgumentException.zs b/src/main/resources/StdLibs/stdlib/src/IllegalArgumentException.zs new file mode 100644 index 000000000..5008f6f85 --- /dev/null +++ b/src/main/resources/StdLibs/stdlib/src/IllegalArgumentException.zs @@ -0,0 +1,7 @@ +[Native("stdlib::IllegalArgumentException")] +public class IllegalArgumentException : Exception { + [Native("constructor")] + public this(message as string) { + super(message); + } +} diff --git a/src/main/resources/StdLibs/stdlib/src/Integers.zs b/src/main/resources/StdLibs/stdlib/src/Integers.zs new file mode 100644 index 000000000..aa9f3d76d --- /dev/null +++ b/src/main/resources/StdLibs/stdlib/src/Integers.zs @@ -0,0 +1,13 @@ +[Native("stdlib::Integer")] +public expand int { + [Native("toHexString")] + public extern toHexString() as string; + + [Native("min")] + public static min(a as int, b as int) as int + => a < b ? a : b; + + [Native("max")] + public static max(a as int, b as int) as int + => a > b ? a : b; +} diff --git a/src/main/resources/StdLibs/stdlib/src/Iterable.zs b/src/main/resources/StdLibs/stdlib/src/Iterable.zs new file mode 100644 index 000000000..daece6984 --- /dev/null +++ b/src/main/resources/StdLibs/stdlib/src/Iterable.zs @@ -0,0 +1,5 @@ +[Native("stdlib::Iterable")] +public interface Iterable { + [Native("iterate")] + iterate() as Iterator; +} diff --git a/src/main/resources/StdLibs/stdlib/src/Iterator.zs b/src/main/resources/StdLibs/stdlib/src/Iterator.zs new file mode 100644 index 000000000..c95c20cc4 --- /dev/null +++ b/src/main/resources/StdLibs/stdlib/src/Iterator.zs @@ -0,0 +1,8 @@ +[Native("stdlib::Iterator")] +public interface Iterator { + [Native("hasNext")] + get hasNext as bool; + + [Native("next")] + next() as T; +} diff --git a/src/main/resources/StdLibs/stdlib/src/List.zs b/src/main/resources/StdLibs/stdlib/src/List.zs new file mode 100644 index 000000000..83612aafe --- /dev/null +++ b/src/main/resources/StdLibs/stdlib/src/List.zs @@ -0,0 +1,43 @@ +[Native("stdlib::List")] +public class List { + [Native("constructor")] + public this() {} + + [Native("add")] + public add(value as T) as void; + + [Native("insert")] + public insert(index as usize, value as T) as void; + + [Native("remove")] + public remove(value as usize) as T; + + [Native("indexOf")] + public indexOf(value as T) as usize; + + [Native("lastIndexOf")] + public lastIndexOf(value as T) as usize; + + [Native("getAtIndex")] + public [](index as usize) as T; + + [Native("setAtIndex")] + public []=(index as usize, value as T) as T; + + [Native("contains")] + public in(value as T) as bool; + + [Native("toArray")] + public as T[]; + + [Native("length")] + public get length as usize; + + [Native("isEmpty")] + public get isEmpty as bool; + + public implements Iterable { + [Native("iterate")] + iterate(); + } +} diff --git a/src/main/resources/StdLibs/stdlib/src/Result.zs b/src/main/resources/StdLibs/stdlib/src/Result.zs new file mode 100644 index 000000000..8856bb526 --- /dev/null +++ b/src/main/resources/StdLibs/stdlib/src/Result.zs @@ -0,0 +1,48 @@ +public variant Result { + Ok(T), + Error(E); + + public then(fn as function(result as T) as Result) as Result { + return match this { + Ok(result) => fn(result), + Error(error) => Error(error) + }; + } + + public handle(handler as function(error as E) as Result) as Result { + return match this { + Ok(result) => Ok(result), + Error(error) => handler(error) + }; + } + + public expect() as T { + return match this { + Ok(result) => result, + Error(error) => panic "expect() called on an error value" + }; + } + + public orElse(other as T) as T { + return match this { + Ok(result) => result, + Error(error) => other + }; + } + + public orElse(other as function(error as E) as T) as T { + return match this { + Ok(result) => result, + Error(error) => other(error) + }; + } +} + +public expand Result { + public unwrap() as T throws E { + return match this { + Ok(result) => result, + Error(error) => throw error + }; + } +} diff --git a/src/main/resources/StdLibs/stdlib/src/StringBuildable.zs b/src/main/resources/StdLibs/stdlib/src/StringBuildable.zs new file mode 100644 index 000000000..acccc2c83 --- /dev/null +++ b/src/main/resources/StdLibs/stdlib/src/StringBuildable.zs @@ -0,0 +1,6 @@ +public interface StringBuildable { + toString(output as StringBuilder`borrow) as void; + + as string + => new StringBuilder() << this; +} diff --git a/src/main/resources/StdLibs/stdlib/src/StringBuilder.zs b/src/main/resources/StdLibs/stdlib/src/StringBuilder.zs new file mode 100644 index 000000000..da90ca6db --- /dev/null +++ b/src/main/resources/StdLibs/stdlib/src/StringBuilder.zs @@ -0,0 +1,69 @@ +[Native("stdlib::StringBuilder")] +public class StringBuilder { + [Native("constructor")] + public extern this(); + [Native("constructorWithCapacity")] + public extern this(capacity as usize); + [Native("constructorWithValue")] + public extern this(value as string); + + [Native("isEmpty")] + public extern get isEmpty as bool; + [Native("length")] + public extern get length as usize; + + [Native("appendBool")] + public extern <<(value as bool) as StringBuilder; + [Native("appendByte")] + public extern <<(value as byte) as StringBuilder; + [Native("appendSByte")] + public extern <<(value as sbyte) as StringBuilder; + [Native("appendShort")] + public extern <<(value as short) as StringBuilder; + [Native("appendUShort")] + public extern <<(value as ushort) as StringBuilder; + [Native("appendInt")] + public extern <<(value as int) as StringBuilder; + [Native("appendUInt")] + public extern <<(value as uint) as StringBuilder; + [Native("appendLong")] + public extern <<(value as long) as StringBuilder; + [Native("appendULong")] + public extern <<(value as ulong) as StringBuilder; + [Native("appendUSize")] + public extern <<(value as usize) as StringBuilder; + [Native("appendFloat")] + public extern <<(value as float) as StringBuilder; + [Native("appendDouble")] + public extern <<(value as double) as StringBuilder; + [Native("appendChar")] + public extern <<(value as char) as StringBuilder; + [Native("appendString")] + public extern <<(value as string) as StringBuilder; + + public <<(value as StringBuildable`borrow) as StringBuilder { + value.toString(this); + return this; + } + + public append(values as T[]`borrow, separator as string) as StringBuilder { + for i, value in values { + if i > 0 + this << separator; + value.toString(this); + } + return this; + } + + public append(values as T[]`borrow, stringer as function(value as T) as string, separator as string) as StringBuilder { + for i, value in values { + if i > 0 + this << separator; + this << stringer(value); + } + return this; + } + + [Native("asString")] + public extern implicit as string; +} diff --git a/src/main/resources/StdLibs/stdlib/src/Strings.zs b/src/main/resources/StdLibs/stdlib/src/Strings.zs new file mode 100644 index 000000000..8e82d2543 --- /dev/null +++ b/src/main/resources/StdLibs/stdlib/src/Strings.zs @@ -0,0 +1,96 @@ +[Native("stdlib::String")] +public expand string { + [Native("fromAsciiBytes")] + public static fromAsciiBytes(data as byte[]) as string; + + [Native("fromUTF8Bytes")] + public static fromUTF8Bytes(data as byte[]) as string; + + [Native("contains")] + public const in(c as char) as bool + => indexOf(c) != null; + + [Native("indexOf")] + public const indexOf(c as char) as usize? { + for i in 0 .. length { + if this[i] == c + return i; + } + + return null; + } + + [Native("indexOfFrom")] + public const indexOf(c as char, from as usize) as usize? { + for i in from .. length { + if this[i] == c + return i; + } + + return null; + } + + [Native("lastIndexOf")] + public const lastIndexOf(c as char) as usize? { + var i = length; + while i > 0 { + i--; + if this[i] == c + return i; + } + + return null; + } + + [Native("lastIndexOfFrom")] + public const lastIndexOf(c as char, until as usize) as usize? { + var i = until; + while i > 0 { + i--; + if this[i] == c + return i; + } + + return null; + } + + [Native("split")] + public const split(delimiter as char) as string[] { + val result = new List(); + var start = 0 as usize; + for i in 0 .. this.length { + if this[i] == delimiter { + result.add(this[start .. i]); + start = i + 1; + } + } + result.add(this[start .. $]); + return result as string[]; + } + + [Native("trim")] + public const trim() as string { + var from = 0 as usize; + while from < this.length && this[from] in [' ', '\t', '\r', '\n'] + from++; + var to = this.length; + while to > 0 && this[to - 1] in [' ', '\t', '\r', '\n'] + to--; + + return to < from ? "" : this[from .. to]; + } + + [Native("lpad")] + public const lpad(length as usize, c as char) as string + => this.length >= length ? this : c.times(length - this.length) + this; + + [Native("rpad")] + public const rpad(length as usize, c as char) as string + => this.length >= length ? this : this + c.times(length - this.length); + + [Native("toAsciiBytes")] + public const toAsciiBytes() as byte[]`unique; + + [Native("toUTF8Bytes")] + public const toUTF8Bytes() as byte[]`unique; +} diff --git a/src/main/resources/StdLibs/stdlib/src/USize.zs b/src/main/resources/StdLibs/stdlib/src/USize.zs new file mode 100644 index 000000000..1132fa357 --- /dev/null +++ b/src/main/resources/StdLibs/stdlib/src/USize.zs @@ -0,0 +1,13 @@ +[Native("stdlib::USize")] +public expand usize { + [Native("toHexString")] + public extern toHexString() as string; + + [Native("min")] + public static min(a as usize, b as usize) as usize + => a < b ? a : b; + + [Native("max")] + public static max(a as usize, b as usize) as usize + => a > b ? a : b; +} diff --git a/src/main/resources/StdLibs/uuid/module.json b/src/main/resources/StdLibs/uuid/module.json new file mode 100644 index 000000000..3c41451c1 --- /dev/null +++ b/src/main/resources/StdLibs/uuid/module.json @@ -0,0 +1,6 @@ +{ + "package": "live", + "javaPackage": "org.openzen.zencode.stdlib.uuid", + "host": "universal", + "dependencies": [] +} diff --git a/src/main/resources/StdLibs/uuid/src/uuid.zs b/src/main/resources/StdLibs/uuid/src/uuid.zs new file mode 100644 index 000000000..3de1a8089 --- /dev/null +++ b/src/main/resources/StdLibs/uuid/src/uuid.zs @@ -0,0 +1,9 @@ +[Native("uuid")] +export class UUID { + [Native("random")] + static random() as UUID; + + [Native("toString")] + as string; +} +