[Feat] 支持运算符重载!详见文档或 Library/lang/lang.fig中的定义。通过 impl Operation for xxx实现重载

[Impl] 函数参数指定现在也接受一个 exp,逐渐改动其他中...
This commit is contained in:
2026-02-02 16:11:08 +08:00
parent 41bff72d44
commit 01c16dee3f
20 changed files with 698 additions and 355 deletions

View File

@@ -31,6 +31,44 @@ public interface Error
getErrorMessage() -> String;
}
// Operation interface
public interface Operation
{
// math
Add(T, T) -> T;
Sub(T, T) -> T;
Mul(T, T) -> T;
Div(T, T) -> T;
Mod(T, T) -> T;
Pow(T, T) -> T;
// logic
Neg(T) -> T;
Not(T) -> T;
And(T, T) -> T;
Or(T, T) -> T;
// comparision
Equal(T, T) -> T;
NotEqual(T, T) -> T;
LessThan(T, T) -> T;
LessEqual(T, T) -> T;
GreaterThan(T, T) -> T;
GreaterEqual(T, T) -> T;
Is(T, T) -> T;
// Bit
BitNot(T) -> T;
BitAnd(T, T) -> T;
BitOr(T, T) -> T;
BitXor(T, T) -> T;
ShiftLeft(T, T) -> T;
ShiftRight(T, T) -> T:
}
public struct Any {}
public struct Int {}
public struct Null {}