spl 编写编译器基础框架 ai修复出现的stage2和stage3问题并提供新语法

This commit is contained in:
zzy committed 2026-11-07 21:52:02 +08:00
1 parent 126b979f72
commit 50ee126d44
87 files changed
+3168 -394

No files matched your search

+32 -32
View File
@@ -17,7 +17,7 @@ comptime fn Slice(T: type): type {
_ptr: *T,
_len: usize,
fn len(self: @self): usize {
fn len(@Self self: @self): usize {
ret self._len;
}
@@ -53,7 +53,7 @@ comptime fn Slice(T: type): type {
comptime fn Array(T: type, N: usize): type {
ret struct: IntoIter[Item = T, Iter = @Slice(T)] + Index[Output = T] {
#builtin(array_len)
fn len(self: @self): usize;
fn len(@Self self: @self): usize;
#builtin(array_index)
fn index(@Self self: *@self, i: usize): *T;
@@ -83,46 +83,46 @@ comptime fn Int(bits: usize, signed: bool): type {
+ Eq[Rhs = @self]
+ Ord[Rhs = @self] {
#op(add)
fn add(lhs: @self, rhs: @self): @self;
fn add(@Self lhs: @self, rhs: @self): @self;
#op(sub)
fn sub(lhs: @self, rhs: @self): @self;
fn sub(@Self lhs: @self, rhs: @self): @self;
#op(mul)
fn mul(lhs: @self, rhs: @self): @self;
fn mul(@Self lhs: @self, rhs: @self): @self;
#op(div)
fn div(lhs: @self, rhs: @self): @self;
fn div(@Self lhs: @self, rhs: @self): @self;
#op(mod)
fn rem(lhs: @self, rhs: @self): @self;
fn rem(@Self lhs: @self, rhs: @self): @self;
#op(neg)
fn neg(value: @self): @self;
fn neg(@Self value: @self): @self;
#op(bit_and)
fn bit_and(lhs: @self, rhs: @self): @self;
fn bit_and(@Self lhs: @self, rhs: @self): @self;
#op(bit_or)
fn bit_or(lhs: @self, rhs: @self): @self;
fn bit_or(@Self lhs: @self, rhs: @self): @self;
#op(bit_xor)
fn bit_xor(lhs: @self, rhs: @self): @self;
fn bit_xor(@Self lhs: @self, rhs: @self): @self;
#op(shl)
fn shl(lhs: @self, rhs: @self): @self;
fn shl(@Self lhs: @self, rhs: @self): @self;
#op(shr)
fn shr(lhs: @self, rhs: @self): @self;
fn shr(@Self lhs: @self, rhs: @self): @self;
#op(bit_not)
fn bit_not(value: @self): @self;
fn bit_not(@Self value: @self): @self;
#op(eq)
fn eq(lhs: @self, rhs: @self): bool;
fn eq(@Self lhs: @self, rhs: @self): bool;
#op(ord)
fn cmp(lhs: @self, rhs: @self): Ordering;
fn cmp(@Self lhs: @self, rhs: @self): Ordering;
};
}
@@ -137,28 +137,28 @@ comptime fn Float(bits: usize): type {
+ Eq[Rhs = @self]
+ Ord[Rhs = @self] {
#op(add)
fn add(lhs: @self, rhs: @self): @self;
fn add(@Self lhs: @self, rhs: @self): @self;
#op(sub)
fn sub(lhs: @self, rhs: @self): @self;
fn sub(@Self lhs: @self, rhs: @self): @self;
#op(mul)
fn mul(lhs: @self, rhs: @self): @self;
fn mul(@Self lhs: @self, rhs: @self): @self;
#op(div)
fn div(lhs: @self, rhs: @self): @self;
fn div(@Self lhs: @self, rhs: @self): @self;
#op(mod)
fn rem(lhs: @self, rhs: @self): @self;
fn rem(@Self lhs: @self, rhs: @self): @self;
#op(neg)
fn neg(value: @self): @self;
fn neg(@Self value: @self): @self;
#op(eq)
fn eq(lhs: @self, rhs: @self): bool;
fn eq(@Self lhs: @self, rhs: @self): bool;
#op(ord)
fn cmp(lhs: @self, rhs: @self): Ordering;
fn cmp(@Self lhs: @self, rhs: @self): Ordering;
};
}
@@ -166,10 +166,10 @@ comptime fn Float(bits: usize): type {
comptime fn Bool(): type {
ret struct: Eq[Rhs = @self] + Ord[Rhs = @self] {
#op(eq)
fn eq(lhs: @self, rhs: @self): bool;
fn eq(@Self lhs: @self, rhs: @self): bool;
#op(ord)
fn cmp(lhs: @self, rhs: @self): Ordering;
fn cmp(@Self lhs: @self, rhs: @self): Ordering;
};
}
@@ -196,16 +196,16 @@ comptime fn Ptr(key: usize): type {
+ Eq[Rhs = @self]
+ Ord[Rhs = @self] {
#op(add)
fn add(lhs: @self, rhs: usize): @self;
fn add(@Self lhs: @self, rhs: usize): @self;
#op(sub)
fn sub(lhs: @self, rhs: usize): @self;
fn sub(@Self lhs: @self, rhs: usize): @self;
#op(eq)
fn eq(lhs: @self, rhs: @self): bool;
fn eq(@Self lhs: @self, rhs: @self): bool;
#op(ord)
fn cmp(lhs: @self, rhs: @self): Ordering;
fn cmp(@Self lhs: @self, rhs: @self): Ordering;
};
}
@@ -213,9 +213,9 @@ comptime fn Ptr(key: usize): type {
comptime fn Fn(key: usize): type {
ret struct: Eq[Rhs = @self] + Ord[Rhs = @self] {
#op(eq)
fn eq(lhs: @self, rhs: @self): bool;
fn eq(@Self lhs: @self, rhs: @self): bool;
#op(ord)
fn cmp(lhs: @self, rhs: @self): Ordering;
fn cmp(@Self lhs: @self, rhs: @self): Ordering;
};
}