Skip to content

Commit

Permalink
std::comptime: add the Ordered method to the comptimeTypeInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Jun 26, 2024
1 parent 3d301bf commit 1fa0d04
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions std/comptime/type.jule
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ impl comptimeTypeInfo {
// Reports whether type is binded as constant expression.
// Supports only structures.
fn Binded(self): bool

// Reports whether kind supports ordered constrait as constant expression.
fn Ordered(self): bool
}

*/
Expand Down
18 changes: 18 additions & 0 deletions std/jule/sema/comptime.jule
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,17 @@ impl comptimeType {
}
}

fn _Ordered(&self): &Data {
let mut constant = Const.NewBool(self.base.Ordered())
ret &Data{
Kind: &TypeKind{
Kind: buildPrimType(PrimKind.Str),
},
Constant: constant,
Model: constant,
}
}

fn subIdent(mut &self, ident: str): &Data {
match ident {
| "Str":
Expand Down Expand Up @@ -443,6 +454,13 @@ impl comptimeType {
},
}
ret buildAsComptimeMethodData(method)
| "Ordered":
let mut method = &FnIns{
caller: fn(mut &e: &Eval, mut &fc: &ast::FnCallExpr, mut &_: &Data): &Data {
ret self._Ordered()
},
}
ret buildAsComptimeMethodData(method)
| "Kind":
let mut method = &FnIns{
caller: fn(mut &e: &Eval, mut &fc: &ast::FnCallExpr, mut &_: &Data): &Data {
Expand Down

0 comments on commit 1fa0d04

Please sign in to comment.