diff --git a/docs/math.md b/docs/math.md index 48b4460..743d54a 100644 --- a/docs/math.md +++ b/docs/math.md @@ -9,17 +9,37 @@ Same as in C++. | **Highest**
0 | power, not, calls, indexing, dot,... | | 1 | `%` `*` `/` | | 2 | `+` `-` | -| 3 | bit shifts (NI) | +| 3 | bit shifts `<<` `>>` | | 4 | `<=>` (1) | | 5 | `<=` `>=` `<` `>` | | 6 | `==` `!=` | -| 7 | bitwise and `&` (NI) | -| 9 | bitwise or `\|` (NI) | +| 7 | bitwise and `&` | +| 8 | bitwise xor `^` | +| 9 | bitwise or `\|` | | 10 | `&&` | | 11
lowest | `\|\|` | -(NI) -: not yet implemented. +Bitwise operators +: available only for `Int` values. For mixed `Int`/`Real` numeric expressions, bitwise operators are not defined. + +Bitwise NOT `~x` +: unary operator that inverts all bits of a 64‑bit signed integer (`Int`). It follows two's‑complement rules, so + `~x` is numerically equal to `-(x + 1)`. Examples: `~0 == -1`, `~1 == -2`, `~(-1) == 0`. + +Examples: + +``` +5 & 3 // -> 1 +5 | 3 // -> 7 +5 ^ 3 // -> 6 +~0 // -> -1 +1 << 3 // -> 8 +8 >> 3 // -> 1 +``` + +Notes: +- Shifts operate on 64-bit signed integers (`Int` is 64-bit). Right shift `>>` is arithmetic (sign-propagating). +- Shift count is masked to the range 0..63, similar to the JVM/Kotlin behavior (e.g., `1 << 65` equals `1 << 1`). (1) : Shuttle operator: `a <=> b` returns 0 if a == b, negative Int if a < b and positive Int otherwise. It is necessary to diff --git a/lyng/src/jvmMain/kotlin/net/sergeych/lyng_cli/Benchmark.kt b/lyng/src/jvmMain/kotlin/net/sergeych/lyng_cli/Benchmark.kt index dada3f6..e7fbd85 100644 --- a/lyng/src/jvmMain/kotlin/net/sergeych/lyng_cli/Benchmark.kt +++ b/lyng/src/jvmMain/kotlin/net/sergeych/lyng_cli/Benchmark.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng_cli import kotlinx.coroutines.runBlocking diff --git a/lynglib/src/androidMain/kotlin/net/sergeych/lyng/ArgBuilderAndroid.kt b/lynglib/src/androidMain/kotlin/net/sergeych/lyng/ArgBuilderAndroid.kt index 51f8d21..b8d03f3 100644 --- a/lynglib/src/androidMain/kotlin/net/sergeych/lyng/ArgBuilderAndroid.kt +++ b/lynglib/src/androidMain/kotlin/net/sergeych/lyng/ArgBuilderAndroid.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng import net.sergeych.lyng.obj.Obj diff --git a/lynglib/src/androidMain/kotlin/net/sergeych/lyng/PerfDefaults.android.kt b/lynglib/src/androidMain/kotlin/net/sergeych/lyng/PerfDefaults.android.kt index 2d31712..2f8ee5d 100644 --- a/lynglib/src/androidMain/kotlin/net/sergeych/lyng/PerfDefaults.android.kt +++ b/lynglib/src/androidMain/kotlin/net/sergeych/lyng/PerfDefaults.android.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng actual object PerfDefaults { diff --git a/lynglib/src/androidMain/kotlin/net/sergeych/lyng/ScopePoolAndroid.kt b/lynglib/src/androidMain/kotlin/net/sergeych/lyng/ScopePoolAndroid.kt index aaddf53..fc97ff9 100644 --- a/lynglib/src/androidMain/kotlin/net/sergeych/lyng/ScopePoolAndroid.kt +++ b/lynglib/src/androidMain/kotlin/net/sergeych/lyng/ScopePoolAndroid.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng import net.sergeych.lyng.obj.Obj diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/ArgBuilder.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/ArgBuilder.kt index 9a597a0..7ffa6a4 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/ArgBuilder.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/ArgBuilder.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng import net.sergeych.lyng.obj.Obj diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/ArgRuntime.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/ArgRuntime.kt index 5444aa3..ed5d051 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/ArgRuntime.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/ArgRuntime.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng import net.sergeych.lyng.obj.Obj diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt index a697642..a71440a 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt @@ -277,6 +277,12 @@ class Compiler( operand = UnaryOpRef(UnaryOp.NOT, op) } + Token.Type.BITNOT -> { + if (operand != null) throw ScriptError(t.pos, "unexpected operator '~'") + val op = parseTerm() ?: throw ScriptError(t.pos, "Expecting expression after '~'") + operand = UnaryOpRef(UnaryOp.BITNOT, op) + } + Token.Type.DOT, Token.Type.NULL_COALESCE -> { val isOptional = t.type == Token.Type.NULL_COALESCE operand?.let { left -> @@ -1867,6 +1873,16 @@ class Compiler( Operator(Token.Type.AND, ++lastPriority) { _, a, b -> LogicalAndRef(a, b) }, + // bitwise or/xor/and (tighter than &&, looser than equality) + Operator(Token.Type.BITOR, ++lastPriority) { _, a, b -> + BinaryOpRef(BinOp.BOR, a, b) + }, + Operator(Token.Type.BITXOR, ++lastPriority) { _, a, b -> + BinaryOpRef(BinOp.BXOR, a, b) + }, + Operator(Token.Type.BITAND, ++lastPriority) { _, a, b -> + BinaryOpRef(BinOp.BAND, a, b) + }, // equality/not equality and related Operator(Token.Type.EQARROW, ++lastPriority) { _, a, b -> BinaryOpRef(BinOp.EQARROW, a, b) @@ -1924,6 +1940,13 @@ class Compiler( Operator(Token.Type.SHUTTLE, ++lastPriority) { _, a, b -> BinaryOpRef(BinOp.SHUTTLE, a, b) }, + // shifts (tighter than shuttle, looser than +/-) + Operator(Token.Type.SHL, ++lastPriority) { _, a, b -> + BinaryOpRef(BinOp.SHL, a, b) + }, + Operator(Token.Type.SHR, lastPriority) { _, a, b -> + BinaryOpRef(BinOp.SHR, a, b) + }, // arithmetic Operator(Token.Type.PLUS, ++lastPriority) { _, a, b -> BinaryOpRef(BinOp.PLUS, a, b) diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Parser.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Parser.kt index b03659d..1c18bfc 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Parser.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Parser.kt @@ -191,6 +191,10 @@ private class Parser(fromPos: Pos) { } else { Token("<=", from, Token.Type.LTE) } + } else if (currentChar == '<') { + // Shift left << + pos.advance() + Token("<<", from, Token.Type.SHL) } else Token("<", from, Token.Type.LT) } @@ -199,6 +203,10 @@ private class Parser(fromPos: Pos) { if (currentChar == '=') { pos.advance() Token(">=", from, Token.Type.GTE) + } else if (currentChar == '>') { + // Shift right >> + pos.advance() + Token(">>", from, Token.Type.SHR) } else Token(">", from, Token.Type.GT) } @@ -253,6 +261,10 @@ private class Parser(fromPos: Pos) { Token("&", from, Token.Type.BITAND) } + '^' -> Token("^", from, Token.Type.BITXOR) + + '~' -> Token("~", from, Token.Type.BITNOT) + '@' -> { val label = loadChars(idNextChars) if (label.isNotEmpty()) Token(label, from, Token.Type.ATLABEL) diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/PerfDefaults.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/PerfDefaults.kt index 3d0cb15..f1fbeb6 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/PerfDefaults.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/PerfDefaults.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng /** diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/PerfFlags.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/PerfFlags.kt index 83e6a5f..26d4098 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/PerfFlags.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/PerfFlags.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng /** diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/PerfStats.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/PerfStats.kt index 5a4f44a..90618a8 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/PerfStats.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/PerfStats.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng /** diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/RegexCache.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/RegexCache.kt index 9af8aad..3ab51ab 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/RegexCache.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/RegexCache.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng /** diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/ScopePool.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/ScopePool.kt index 5fb9044..e853e7f 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/ScopePool.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/ScopePool.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng import net.sergeych.lyng.obj.Obj diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Token.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Token.kt index a457a08..aee7e3b 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Token.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Token.kt @@ -39,7 +39,8 @@ data class Token(val value: String, val pos: Pos, val type: Type) { IN, NOTIN, IS, NOTIS, EQ, NEQ, LT, LTE, GT, GTE, REF_EQ, REF_NEQ, MATCH, NOTMATCH, SHUTTLE, - AND, BITAND, OR, BITOR, NOT, BITNOT, DOT, ARROW, EQARROW, QUESTION, COLONCOLON, + AND, BITAND, OR, BITOR, BITXOR, NOT, BITNOT, DOT, ARROW, EQARROW, QUESTION, COLONCOLON, + SHL, SHR, SINLGE_LINE_COMMENT, MULTILINE_COMMENT, LABEL, ATLABEL, // label@ at@label //PUBLIC, PROTECTED, INTERNAL, EXPORT, OPEN, INLINE, OVERRIDE, ABSTRACT, SEALED, EXTERNAL, VAL, VAR, CONST, TYPE, FUN, CLASS, INTERFACE, ENUM, OBJECT, TRAIT, THIS, diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt index c0bb6dc..c5a9901 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt @@ -183,6 +183,31 @@ open class Obj { return operatorMatch(scope,other).logicalNot(scope) } + // Bitwise ops default (override in numeric types that support them) + open suspend fun bitAnd(scope: Scope, other: Obj): Obj { + scope.raiseNotImplemented() + } + + open suspend fun bitOr(scope: Scope, other: Obj): Obj { + scope.raiseNotImplemented() + } + + open suspend fun bitXor(scope: Scope, other: Obj): Obj { + scope.raiseNotImplemented() + } + + open suspend fun shl(scope: Scope, other: Obj): Obj { + scope.raiseNotImplemented() + } + + open suspend fun shr(scope: Scope, other: Obj): Obj { + scope.raiseNotImplemented() + } + + open suspend fun bitNot(scope: Scope): Obj { + scope.raiseNotImplemented() + } + open suspend fun assign(scope: Scope, other: Obj): Obj? = null open fun getValue(scope: Scope) = this diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInt.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInt.kt index 7a02be0..03c79f4 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInt.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInt.kt @@ -118,6 +118,29 @@ class ObjInt(var value: Long, override val isConst: Boolean = false) : Obj(), Nu return ObjInt(-value) } + // Bitwise operations + override suspend fun bitAnd(scope: Scope, other: Obj): Obj = + if (other is ObjInt) ObjInt(this.value and other.value) + else scope.raiseIllegalArgument("bitwise and '&' requires Int, got ${other.objClass.className}") + + override suspend fun bitOr(scope: Scope, other: Obj): Obj = + if (other is ObjInt) ObjInt(this.value or other.value) + else scope.raiseIllegalArgument("bitwise or '|' requires Int, got ${other.objClass.className}") + + override suspend fun bitXor(scope: Scope, other: Obj): Obj = + if (other is ObjInt) ObjInt(this.value xor other.value) + else scope.raiseIllegalArgument("bitwise xor '^' requires Int, got ${other.objClass.className}") + + override suspend fun shl(scope: Scope, other: Obj): Obj = + if (other is ObjInt) ObjInt(this.value shl (other.value.toInt() and 63)) + else scope.raiseIllegalArgument("shift left '<<' requires Int, got ${other.objClass.className}") + + override suspend fun shr(scope: Scope, other: Obj): Obj = + if (other is ObjInt) ObjInt(this.value shr (other.value.toInt() and 63)) + else scope.raiseIllegalArgument("shift right '>>' requires Int, got ${other.objClass.className}") + + override suspend fun bitNot(scope: Scope): Obj = ObjInt(this.value.inv()) + override suspend fun lynonType(): LynonType = when (value) { 0L -> LynonType.Int0 else -> { diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt index 96b3242..1397c37 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt @@ -1,5 +1,5 @@ /* - * Copyright 2025 Sergey S. Chernov + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -12,6 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * */ package net.sergeych.lyng.obj @@ -40,7 +41,7 @@ class ValueFnRef(private val fn: suspend (Scope) -> ObjRecord) : ObjRef { } /** Unary operations supported by ObjRef. */ -enum class UnaryOp { NOT, NEGATE } +enum class UnaryOp { NOT, NEGATE, BITNOT } /** Binary operations supported by ObjRef. */ enum class BinOp { @@ -50,6 +51,11 @@ enum class BinOp { IN, NOTIN, IS, NOTIS, SHUTTLE, + // bitwise + BAND, BXOR, BOR, + // shifts + SHL, SHR, + // arithmetic PLUS, MINUS, STAR, SLASH, PERCENT } @@ -60,6 +66,7 @@ class UnaryOpRef(private val op: UnaryOp, private val a: ObjRef) : ObjRef { val r = when (op) { UnaryOp.NOT -> v.logicalNot(scope) UnaryOp.NEGATE -> v.negate(scope) + UnaryOp.BITNOT -> v.bitNot(scope) } return r.asReadonly } @@ -97,6 +104,11 @@ class BinaryOpRef(private val op: BinOp, private val left: ObjRef, private val r BinOp.STAR -> ObjInt(av * bv) BinOp.SLASH -> if (bv != 0L) ObjInt(av / bv) else null BinOp.PERCENT -> if (bv != 0L) ObjInt(av % bv) else null + BinOp.BAND -> ObjInt(av and bv) + BinOp.BXOR -> ObjInt(av xor bv) + BinOp.BOR -> ObjInt(av or bv) + BinOp.SHL -> ObjInt(av shl (bv.toInt() and 63)) + BinOp.SHR -> ObjInt(av shr (bv.toInt() and 63)) BinOp.EQ -> if (av == bv) ObjTrue else ObjFalse BinOp.NEQ -> if (av != bv) ObjTrue else ObjFalse BinOp.LT -> if (av < bv) ObjTrue else ObjFalse @@ -210,6 +222,11 @@ class BinaryOpRef(private val op: BinOp, private val left: ObjRef, private val r BinOp.IS -> ObjBool(a.isInstanceOf(b)) BinOp.NOTIS -> ObjBool(!a.isInstanceOf(b)) BinOp.SHUTTLE -> ObjInt(a.compareTo(scope, b).toLong()) + BinOp.BAND -> a.bitAnd(scope, b) + BinOp.BXOR -> a.bitXor(scope, b) + BinOp.BOR -> a.bitOr(scope, b) + BinOp.SHL -> a.shl(scope, b) + BinOp.SHR -> a.shr(scope, b) BinOp.PLUS -> a.plus(scope, b) BinOp.MINUS -> a.minus(scope, b) BinOp.STAR -> a.mul(scope, b) diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/tools/bm.kt b/lynglib/src/commonMain/kotlin/net/sergeych/tools/bm.kt index d65cbac..913d6e7 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/tools/bm.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/tools/bm.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.tools import kotlinx.datetime.Clock diff --git a/lynglib/src/commonTest/kotlin/BitwiseTest.kt b/lynglib/src/commonTest/kotlin/BitwiseTest.kt new file mode 100644 index 0000000..33732a6 --- /dev/null +++ b/lynglib/src/commonTest/kotlin/BitwiseTest.kt @@ -0,0 +1,50 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +import kotlinx.coroutines.test.runTest +import net.sergeych.lyng.eval +import net.sergeych.lyng.obj.ObjInt +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFails + +class BitwiseTest { + @Test + fun bitwiseOperators_Int() = runTest { + suspend fun e(src: String) = eval(src) + + assertEquals(ObjInt(1), e("5 & 3")) + assertEquals(ObjInt(7), e("5 | 3")) + assertEquals(ObjInt(6), e("5 ^ 3")) + assertEquals(ObjInt(-1), e("~0")) + + assertEquals(ObjInt(8), e("1 << 3")) + assertEquals(ObjInt(1), e("8 >> 3")) + + // shift count masking (like JVM): 65 -> 1 + assertEquals(ObjInt(2), e("1 << 65")) + + // precedence: additive tighter than shifts + assertEquals(ObjInt(24), e("1 + 2 << 3")) + + // precedence chain: & tighter than ^ tighter than | + assertEquals(ObjInt(3), e("1 | 2 ^ 3 & 1")) + + // type mismatch should raise + assertFails { e("1 & 2.0") } + } +} diff --git a/lynglib/src/commonTest/kotlin/ScriptTest.kt b/lynglib/src/commonTest/kotlin/ScriptTest.kt index 7bc5301..a09b835 100644 --- a/lynglib/src/commonTest/kotlin/ScriptTest.kt +++ b/lynglib/src/commonTest/kotlin/ScriptTest.kt @@ -28,7 +28,6 @@ import kotlin.test.* import kotlin.time.Duration.Companion.seconds class ScriptTest { - @Test fun testVersion() { println("--------------------------------------------") @@ -3381,4 +3380,4 @@ class ScriptTest { .trimIndent() ) } -} \ No newline at end of file +} diff --git a/lynglib/src/commonTest/kotlin/ScriptTest_OptionalAssign.kt b/lynglib/src/commonTest/kotlin/ScriptTest_OptionalAssign.kt index 51f4eae..f285367 100644 --- a/lynglib/src/commonTest/kotlin/ScriptTest_OptionalAssign.kt +++ b/lynglib/src/commonTest/kotlin/ScriptTest_OptionalAssign.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /* * Tests for optional chaining assignment semantics (no-op on null receiver) */ diff --git a/lynglib/src/jsMain/kotlin/net/sergeych/lyng/ArgBuilderJs.kt b/lynglib/src/jsMain/kotlin/net/sergeych/lyng/ArgBuilderJs.kt index b2b56bf..a6ad620 100644 --- a/lynglib/src/jsMain/kotlin/net/sergeych/lyng/ArgBuilderJs.kt +++ b/lynglib/src/jsMain/kotlin/net/sergeych/lyng/ArgBuilderJs.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng import net.sergeych.lyng.obj.Obj diff --git a/lynglib/src/jsMain/kotlin/net/sergeych/lyng/PerfDefaults.js.kt b/lynglib/src/jsMain/kotlin/net/sergeych/lyng/PerfDefaults.js.kt index 29c7ca1..5e6dbaa 100644 --- a/lynglib/src/jsMain/kotlin/net/sergeych/lyng/PerfDefaults.js.kt +++ b/lynglib/src/jsMain/kotlin/net/sergeych/lyng/PerfDefaults.js.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng actual object PerfDefaults { diff --git a/lynglib/src/jsMain/kotlin/net/sergeych/lyng/ScopePoolJs.kt b/lynglib/src/jsMain/kotlin/net/sergeych/lyng/ScopePoolJs.kt index 1e8ffc2..21c9ff2 100644 --- a/lynglib/src/jsMain/kotlin/net/sergeych/lyng/ScopePoolJs.kt +++ b/lynglib/src/jsMain/kotlin/net/sergeych/lyng/ScopePoolJs.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng import net.sergeych.lyng.obj.Obj diff --git a/lynglib/src/jvmMain/kotlin/net/sergeych/lyng/ArgBuilderJvm.kt b/lynglib/src/jvmMain/kotlin/net/sergeych/lyng/ArgBuilderJvm.kt index 013e698..ddd2c1a 100644 --- a/lynglib/src/jvmMain/kotlin/net/sergeych/lyng/ArgBuilderJvm.kt +++ b/lynglib/src/jvmMain/kotlin/net/sergeych/lyng/ArgBuilderJvm.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng import net.sergeych.lyng.obj.Obj diff --git a/lynglib/src/jvmMain/kotlin/net/sergeych/lyng/PerfDefaults.jvm.kt b/lynglib/src/jvmMain/kotlin/net/sergeych/lyng/PerfDefaults.jvm.kt index f48590a..12db4a6 100644 --- a/lynglib/src/jvmMain/kotlin/net/sergeych/lyng/PerfDefaults.jvm.kt +++ b/lynglib/src/jvmMain/kotlin/net/sergeych/lyng/PerfDefaults.jvm.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng actual object PerfDefaults { diff --git a/lynglib/src/jvmMain/kotlin/net/sergeych/lyng/ScopePoolJvm.kt b/lynglib/src/jvmMain/kotlin/net/sergeych/lyng/ScopePoolJvm.kt index d43b0ce..8ad2479 100644 --- a/lynglib/src/jvmMain/kotlin/net/sergeych/lyng/ScopePoolJvm.kt +++ b/lynglib/src/jvmMain/kotlin/net/sergeych/lyng/ScopePoolJvm.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng import net.sergeych.lyng.obj.Obj diff --git a/lynglib/src/jvmTest/kotlin/ArithmeticBenchmarkTest.kt b/lynglib/src/jvmTest/kotlin/ArithmeticBenchmarkTest.kt index 249790f..a61d9ac 100644 --- a/lynglib/src/jvmTest/kotlin/ArithmeticBenchmarkTest.kt +++ b/lynglib/src/jvmTest/kotlin/ArithmeticBenchmarkTest.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /* * JVM micro-benchmarks for primitive arithmetic and comparison fast paths. */ diff --git a/lynglib/src/jvmTest/kotlin/BenchLog.kt b/lynglib/src/jvmTest/kotlin/BenchLog.kt index e69de29..d3cda70 100644 --- a/lynglib/src/jvmTest/kotlin/BenchLog.kt +++ b/lynglib/src/jvmTest/kotlin/BenchLog.kt @@ -0,0 +1,17 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + diff --git a/lynglib/src/jvmTest/kotlin/CallBenchmarkTest.kt b/lynglib/src/jvmTest/kotlin/CallBenchmarkTest.kt index b4dce9b..7d736fe 100644 --- a/lynglib/src/jvmTest/kotlin/CallBenchmarkTest.kt +++ b/lynglib/src/jvmTest/kotlin/CallBenchmarkTest.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /* * JVM micro-benchmarks for function/method call overhead and argument building. */ diff --git a/lynglib/src/jvmTest/kotlin/CallMixedArityBenchmarkTest.kt b/lynglib/src/jvmTest/kotlin/CallMixedArityBenchmarkTest.kt index 80f6515..0a872ac 100644 --- a/lynglib/src/jvmTest/kotlin/CallMixedArityBenchmarkTest.kt +++ b/lynglib/src/jvmTest/kotlin/CallMixedArityBenchmarkTest.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /* * JVM micro-benchmark for mixed-arity function calls and ARG_BUILDER. */ diff --git a/lynglib/src/jvmTest/kotlin/CallPoolingBenchmarkTest.kt b/lynglib/src/jvmTest/kotlin/CallPoolingBenchmarkTest.kt index 73767f8..820e3d3 100644 --- a/lynglib/src/jvmTest/kotlin/CallPoolingBenchmarkTest.kt +++ b/lynglib/src/jvmTest/kotlin/CallPoolingBenchmarkTest.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /* * JVM micro-benchmark for Scope frame pooling impact on call-heavy code paths. */ diff --git a/lynglib/src/jvmTest/kotlin/CallSplatBenchmarkTest.kt b/lynglib/src/jvmTest/kotlin/CallSplatBenchmarkTest.kt index 73814f2..be1e865 100644 --- a/lynglib/src/jvmTest/kotlin/CallSplatBenchmarkTest.kt +++ b/lynglib/src/jvmTest/kotlin/CallSplatBenchmarkTest.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /* * JVM micro-benchmark for calls with splat (spread) arguments. */ diff --git a/lynglib/src/jvmTest/kotlin/ConcurrencyCallBenchmarkTest.kt b/lynglib/src/jvmTest/kotlin/ConcurrencyCallBenchmarkTest.kt index 39390af..7d1e7cf 100644 --- a/lynglib/src/jvmTest/kotlin/ConcurrencyCallBenchmarkTest.kt +++ b/lynglib/src/jvmTest/kotlin/ConcurrencyCallBenchmarkTest.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /* * Multithreaded benchmark to quantify SCOPE_POOL speedup on JVM. */ diff --git a/lynglib/src/jvmTest/kotlin/DeepPoolingStressJvmTest.kt b/lynglib/src/jvmTest/kotlin/DeepPoolingStressJvmTest.kt index 2c19c2b..6f40430 100644 --- a/lynglib/src/jvmTest/kotlin/DeepPoolingStressJvmTest.kt +++ b/lynglib/src/jvmTest/kotlin/DeepPoolingStressJvmTest.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /* * JVM stress tests for scope frame pooling (deep nesting and recursion). */ diff --git a/lynglib/src/jvmTest/kotlin/ExpressionBenchmarkTest.kt b/lynglib/src/jvmTest/kotlin/ExpressionBenchmarkTest.kt index 863e4e5..9b8f781 100644 --- a/lynglib/src/jvmTest/kotlin/ExpressionBenchmarkTest.kt +++ b/lynglib/src/jvmTest/kotlin/ExpressionBenchmarkTest.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /* * JVM micro-benchmark for expression evaluation with RVAL_FASTPATH. */ diff --git a/lynglib/src/jvmTest/kotlin/ListOpsBenchmarkTest.kt b/lynglib/src/jvmTest/kotlin/ListOpsBenchmarkTest.kt index 995464b..ff48367 100644 --- a/lynglib/src/jvmTest/kotlin/ListOpsBenchmarkTest.kt +++ b/lynglib/src/jvmTest/kotlin/ListOpsBenchmarkTest.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /* * JVM micro-benchmark for list operations specialization under PRIMITIVE_FASTOPS. */ diff --git a/lynglib/src/jvmTest/kotlin/LocalVarBenchmarkTest.kt b/lynglib/src/jvmTest/kotlin/LocalVarBenchmarkTest.kt index f2c50c5..fbc4168 100644 --- a/lynglib/src/jvmTest/kotlin/LocalVarBenchmarkTest.kt +++ b/lynglib/src/jvmTest/kotlin/LocalVarBenchmarkTest.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /* * JVM micro-benchmark focused on local variable access paths: * - LOCAL_SLOT_PIC (per-frame slot PIC in LocalVarRef) diff --git a/lynglib/src/jvmTest/kotlin/MethodPoolingBenchmarkTest.kt b/lynglib/src/jvmTest/kotlin/MethodPoolingBenchmarkTest.kt index 9aa06f8..7c5ab35 100644 --- a/lynglib/src/jvmTest/kotlin/MethodPoolingBenchmarkTest.kt +++ b/lynglib/src/jvmTest/kotlin/MethodPoolingBenchmarkTest.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /* * JVM micro-benchmark for scope frame pooling on instance method calls. */ diff --git a/lynglib/src/jvmTest/kotlin/MixedBenchmarkTest.kt b/lynglib/src/jvmTest/kotlin/MixedBenchmarkTest.kt index 67a0267..4e19735 100644 --- a/lynglib/src/jvmTest/kotlin/MixedBenchmarkTest.kt +++ b/lynglib/src/jvmTest/kotlin/MixedBenchmarkTest.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /* * JVM mixed workload micro-benchmark to exercise multiple hot paths together. */ diff --git a/lynglib/src/jvmTest/kotlin/MultiThreadPoolingStressJvmTest.kt b/lynglib/src/jvmTest/kotlin/MultiThreadPoolingStressJvmTest.kt index a9d8cb5..54671bd 100644 --- a/lynglib/src/jvmTest/kotlin/MultiThreadPoolingStressJvmTest.kt +++ b/lynglib/src/jvmTest/kotlin/MultiThreadPoolingStressJvmTest.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /* * Multithreaded stress tests for ScopePool on JVM. */ diff --git a/lynglib/src/jvmTest/kotlin/PicBenchmarkTest.kt b/lynglib/src/jvmTest/kotlin/PicBenchmarkTest.kt index 18719ff..c8cb031 100644 --- a/lynglib/src/jvmTest/kotlin/PicBenchmarkTest.kt +++ b/lynglib/src/jvmTest/kotlin/PicBenchmarkTest.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /* * JVM micro-benchmarks for FieldRef and MethodCallRef PICs. */ diff --git a/lynglib/src/jvmTest/kotlin/PicInvalidationJvmTest.kt b/lynglib/src/jvmTest/kotlin/PicInvalidationJvmTest.kt index a8a10b1..ae16035 100644 --- a/lynglib/src/jvmTest/kotlin/PicInvalidationJvmTest.kt +++ b/lynglib/src/jvmTest/kotlin/PicInvalidationJvmTest.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + import kotlinx.coroutines.runBlocking import net.sergeych.lyng.PerfFlags import net.sergeych.lyng.PerfStats diff --git a/lynglib/src/jvmTest/kotlin/RangeBenchmarkTest.kt b/lynglib/src/jvmTest/kotlin/RangeBenchmarkTest.kt index ba96645..95cc831 100644 --- a/lynglib/src/jvmTest/kotlin/RangeBenchmarkTest.kt +++ b/lynglib/src/jvmTest/kotlin/RangeBenchmarkTest.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /* * JVM micro-benchmark for range for-in lowering under PRIMITIVE_FASTOPS. */ diff --git a/lynglib/src/jvmTest/kotlin/RegexBenchmarkTest.kt b/lynglib/src/jvmTest/kotlin/RegexBenchmarkTest.kt index 318b180..6946a7c 100644 --- a/lynglib/src/jvmTest/kotlin/RegexBenchmarkTest.kt +++ b/lynglib/src/jvmTest/kotlin/RegexBenchmarkTest.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /* * JVM micro-benchmark for regex caching under REGEX_CACHE. */ diff --git a/lynglib/src/jvmTest/kotlin/ScriptSubsetJvmTest.kt b/lynglib/src/jvmTest/kotlin/ScriptSubsetJvmTest.kt index 445a96b..4b2fb89 100644 --- a/lynglib/src/jvmTest/kotlin/ScriptSubsetJvmTest.kt +++ b/lynglib/src/jvmTest/kotlin/ScriptSubsetJvmTest.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + import kotlinx.coroutines.runBlocking import net.sergeych.lyng.PerfFlags import net.sergeych.lyng.Scope diff --git a/lynglib/src/jvmTest/kotlin/ScriptSubsetJvmTest_Additions3.kt b/lynglib/src/jvmTest/kotlin/ScriptSubsetJvmTest_Additions3.kt index 1ba9974..72fb100 100644 --- a/lynglib/src/jvmTest/kotlin/ScriptSubsetJvmTest_Additions3.kt +++ b/lynglib/src/jvmTest/kotlin/ScriptSubsetJvmTest_Additions3.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + import kotlinx.coroutines.runBlocking import net.sergeych.lyng.PerfFlags import net.sergeych.lyng.Scope diff --git a/lynglib/src/jvmTest/kotlin/ScriptSubsetJvmTest_Additions4.kt b/lynglib/src/jvmTest/kotlin/ScriptSubsetJvmTest_Additions4.kt index 5a64ece..4f788f7 100644 --- a/lynglib/src/jvmTest/kotlin/ScriptSubsetJvmTest_Additions4.kt +++ b/lynglib/src/jvmTest/kotlin/ScriptSubsetJvmTest_Additions4.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + import kotlinx.coroutines.runBlocking import net.sergeych.lyng.PerfFlags import net.sergeych.lyng.Scope diff --git a/lynglib/src/jvmTest/kotlin/ScriptSubsetJvmTest_Additions5.kt b/lynglib/src/jvmTest/kotlin/ScriptSubsetJvmTest_Additions5.kt index 89c967a..b4cd484 100644 --- a/lynglib/src/jvmTest/kotlin/ScriptSubsetJvmTest_Additions5.kt +++ b/lynglib/src/jvmTest/kotlin/ScriptSubsetJvmTest_Additions5.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + import kotlinx.coroutines.runBlocking import net.sergeych.lyng.PerfFlags import net.sergeych.lyng.Scope diff --git a/lynglib/src/jvmTest/kotlin/ScriptSubsetJvmTest_additions.kt b/lynglib/src/jvmTest/kotlin/ScriptSubsetJvmTest_additions.kt index 8a8a3f9..e0752de 100644 --- a/lynglib/src/jvmTest/kotlin/ScriptSubsetJvmTest_additions.kt +++ b/lynglib/src/jvmTest/kotlin/ScriptSubsetJvmTest_additions.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + import kotlinx.coroutines.runBlocking import net.sergeych.lyng.Scope import net.sergeych.lyng.obj.ObjInt diff --git a/lynglib/src/nativeMain/kotlin/net/sergeych/lyng/ArgBuilderNative.kt b/lynglib/src/nativeMain/kotlin/net/sergeych/lyng/ArgBuilderNative.kt index 4371f21..0e2e8e9 100644 --- a/lynglib/src/nativeMain/kotlin/net/sergeych/lyng/ArgBuilderNative.kt +++ b/lynglib/src/nativeMain/kotlin/net/sergeych/lyng/ArgBuilderNative.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng import net.sergeych.lyng.obj.Obj diff --git a/lynglib/src/nativeMain/kotlin/net/sergeych/lyng/PerfDefaults.native.kt b/lynglib/src/nativeMain/kotlin/net/sergeych/lyng/PerfDefaults.native.kt index 2169c5c..2a86d33 100644 --- a/lynglib/src/nativeMain/kotlin/net/sergeych/lyng/PerfDefaults.native.kt +++ b/lynglib/src/nativeMain/kotlin/net/sergeych/lyng/PerfDefaults.native.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng actual object PerfDefaults { diff --git a/lynglib/src/nativeMain/kotlin/net/sergeych/lyng/ScopePoolNative.kt b/lynglib/src/nativeMain/kotlin/net/sergeych/lyng/ScopePoolNative.kt index 82e04b8..27308df 100644 --- a/lynglib/src/nativeMain/kotlin/net/sergeych/lyng/ScopePoolNative.kt +++ b/lynglib/src/nativeMain/kotlin/net/sergeych/lyng/ScopePoolNative.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng import net.sergeych.lyng.obj.Obj diff --git a/lynglib/src/wasmJsMain/kotlin/net/sergeych/lyng/ArgBuilderWasm.kt b/lynglib/src/wasmJsMain/kotlin/net/sergeych/lyng/ArgBuilderWasm.kt index 5234fb5..d5380bc 100644 --- a/lynglib/src/wasmJsMain/kotlin/net/sergeych/lyng/ArgBuilderWasm.kt +++ b/lynglib/src/wasmJsMain/kotlin/net/sergeych/lyng/ArgBuilderWasm.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng import net.sergeych.lyng.obj.Obj diff --git a/lynglib/src/wasmJsMain/kotlin/net/sergeych/lyng/PerfDefaults.wasmJs.kt b/lynglib/src/wasmJsMain/kotlin/net/sergeych/lyng/PerfDefaults.wasmJs.kt index 6e528b6..b81f11c 100644 --- a/lynglib/src/wasmJsMain/kotlin/net/sergeych/lyng/PerfDefaults.wasmJs.kt +++ b/lynglib/src/wasmJsMain/kotlin/net/sergeych/lyng/PerfDefaults.wasmJs.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng actual object PerfDefaults { diff --git a/lynglib/src/wasmJsMain/kotlin/net/sergeych/lyng/ScopePoolWasm.kt b/lynglib/src/wasmJsMain/kotlin/net/sergeych/lyng/ScopePoolWasm.kt index 03d8b33..bcd1500 100644 --- a/lynglib/src/wasmJsMain/kotlin/net/sergeych/lyng/ScopePoolWasm.kt +++ b/lynglib/src/wasmJsMain/kotlin/net/sergeych/lyng/ScopePoolWasm.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package net.sergeych.lyng import net.sergeych.lyng.obj.Obj