Skip to content

Commit

Permalink
sema: rename comptimeType as comptimeTypeInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Jun 28, 2024
1 parent a1c9aad commit 5c04370
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
18 changes: 9 additions & 9 deletions std/jule/sema/comptime.jule
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl comptimeRangeKind for comptimeEnumFields {

// Compile-time type info range.
struct comptimeTypeInfos {
types: []&comptimeType
types: []&comptimeTypeInfo
}

impl Kind for comptimeTypeInfos {
Expand Down Expand Up @@ -267,7 +267,7 @@ impl comptimeRangeKind for comptimeTypeInfos {
}
keyB.Kind = &TypeSymbol{
Kind: &TypeKind{
Kind: new(comptimeType),
Kind: new(comptimeTypeInfo),
},
}
}
Expand All @@ -291,16 +291,16 @@ impl comptimeRangeKind for comptimeTypeInfos {
}

// Compile-time type information data.
struct comptimeType {
struct comptimeTypeInfo {
base: &TypeKind
}

impl Kind for comptimeType {
fn Str(self): str { ret "comptimeTypeInfo" }
impl Kind for comptimeTypeInfo {
fn Str(self): str { ret "comptimeTypeInfo[" + self.base.Str() + "]" }
fn Equal(&self, other: &TypeKind): bool { ret false }
}

impl comptimeType {
impl comptimeTypeInfo {
fn _Str(&self): &Data {
let mut constant = Const.NewStr(self.base.Str())
ret &Data{
Expand Down Expand Up @@ -571,10 +571,10 @@ impl comptimeType {
ret nil
}
let mut infos = &comptimeTypeInfos{
types: make([]&comptimeType, 0, len(tup.Types)),
types: make([]&comptimeTypeInfo, 0, len(tup.Types)),
}
for (_, mut t) in tup.Types {
infos.types = append(infos.types, e.s.meta.pushComptimeType(t))
infos.types = append(infos.types, e.s.meta.pushComptimeTypeInfo(t))
}
ret &Data{
Kind: &TypeKind{
Expand Down Expand Up @@ -749,7 +749,7 @@ fn findComptimePackage(mut &s: &Sema): &ImportInfo {
fn buildComptimeTypeInfoData(mut &s: &Sema, mut &t: &TypeKind): &Data {
ret &Data{
Kind: &TypeKind{
Kind: s.meta.pushComptimeType(t),
Kind: s.meta.pushComptimeTypeInfo(t),
},
}
}
6 changes: 3 additions & 3 deletions std/jule/sema/eval.jule
Original file line number Diff line number Diff line change
Expand Up @@ -2695,9 +2695,9 @@ impl Eval {
}

match {
| d.Kind.comptimeType() != nil:
let mut comptimeType = d.Kind.comptimeType()
let mut cd = comptimeType.subIdent(si.Ident.Kind)
| d.Kind.comptimeTypeInfo() != nil:
let mut cti = d.Kind.comptimeTypeInfo()
let mut cd = cti.subIdent(si.Ident.Kind)
if cd == nil {
self.pushErr(si.Ident, LogMsg.ObjHaveNotIdent, d.Kind.Str(), si.Ident.Kind)
}
Expand Down
10 changes: 5 additions & 5 deletions std/jule/sema/sema.jule
Original file line number Diff line number Diff line change
Expand Up @@ -206,18 +206,18 @@ unsafe fn pushSuggestion(mut log: *Log, fmt: LogMsg, args: ...any) {
}

struct commonSemaMeta {
comptimeTypes: []&comptimeType
comptimeTypeInfos: []&comptimeTypeInfo
}

impl commonSemaMeta {
fn pushComptimeType(mut self, mut &t: &TypeKind): &comptimeType {
for (_, mut t2) in self.comptimeTypes {
fn pushComptimeTypeInfo(mut self, mut &t: &TypeKind): &comptimeTypeInfo {
for (_, mut t2) in self.comptimeTypeInfos {
if t2.base.Equal(t) {
ret t2
}
}
let mut t1 = &comptimeType{base: t}
self.comptimeTypes = append(self.comptimeTypes, t1)
let mut t1 = &comptimeTypeInfo{base: t}
self.comptimeTypeInfos = append(self.comptimeTypeInfos, t1)
ret t1
}
}
Expand Down
10 changes: 5 additions & 5 deletions std/jule/sema/type.jule
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ impl TypeKind {
// Reports whether kind is comptime type.
fn comptime(mut self): bool {
ret self.comptimeTypeInfos() != nil ||
self.comptimeType() != nil ||
self.comptimeTypeInfo() != nil ||
self.comptimeStructFields() != nil ||
self.comptimeStructField() != nil ||
self.comptimeEnumFields() != nil ||
Expand Down Expand Up @@ -431,10 +431,10 @@ impl TypeKind {
}
}

fn comptimeType(mut self): &comptimeType {
fn comptimeTypeInfo(mut self): &comptimeTypeInfo {
match type self.Kind {
| &comptimeType:
ret (&comptimeType)(self.Kind)
| &comptimeTypeInfo:
ret (&comptimeTypeInfo)(self.Kind)
|:
ret nil
}
Expand Down Expand Up @@ -1728,7 +1728,7 @@ fn isValidForRef(mut &t: &TypeKind): bool { ret t.Fn() == nil }

// Reports whether type has built-in string conversion support.
fn isBuiltinStrConvertable(mut &t: &TypeKind): bool {
ret !t.Void() && t.Fn() == nil && t.Tup() == nil && t.comptimeType() == nil
ret !t.Void() && t.Fn() == nil && t.Tup() == nil && !t.comptime()
}

fn buildLinkPathByTokens(&tokens: []&Token): str {
Expand Down

0 comments on commit 5c04370

Please sign in to comment.