Skip to content

Commit

Permalink
std::comptime: add the Mutable 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 2ebf222 commit 1a74ec8
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 @@ -92,6 +92,9 @@ impl comptimeTypeInfo {

// Reports whether kind supports comparable constrait as constant expression.
fn Comparable(self): bool

// Reports whether kind is mutable as constant expression.
fn Mutable(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 @@ -505,6 +505,17 @@ impl comptimeType {
}
}

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

fn subIdent(mut &self, ident: str): &Data {
match ident {
| "Str":
Expand Down Expand Up @@ -584,6 +595,13 @@ impl comptimeType {
},
}
ret buildAsComptimeMethodData(method)
| "Mutable":
let mut method = &FnIns{
caller: fn(mut &e: &Eval, mut &fc: &ast::FnCallExpr, mut &_: &Data): &Data {
ret self._Mutable()
},
}
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 1a74ec8

Please sign in to comment.