Skip to content

Commit

Permalink
compiler: fix structure method declaration order
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Jul 29, 2024
1 parent f5204da commit 96dc5db
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/julec/obj/cxx/object.jule
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ impl ObjectCoder {
fn structureInsDecl(mut &self, mut &s: &StructIns) {
for (_, mut m) in s.Methods {
// Operator methods are declared by [structureDecl].
if isOpMethod(m) {
if isHeadDecl(m) {
self.funcDecl(m, false)
}
}
Expand Down Expand Up @@ -799,7 +799,7 @@ impl ObjectCoder {
for (_, mut ins) in s.Instances {
for (_, mut m) in ins.Methods {
// Operator methods are declared by [structureDecl].
if !isOpMethod(m) {
if !isHeadDecl(m) {
self.pushResult(m)
self.funcDecl(m, false)
}
Expand Down Expand Up @@ -1435,9 +1435,9 @@ fn pushMethodsFromInherits(mut &dest: &Trait, mut &src: &Trait) {
}
}

// Reports whtehr the m is operator overloading function.
// Reports whether the m is operator overloading method.
fn isOpMethod(&m: &Fn): bool {
if m == nil || len(m.Generics) > 0 || len(m.Instances) == 0 {
if len(m.Generics) > 0 || len(m.Instances) == 0 {
ret false
}
let mi = m.Instances[0]
Expand All @@ -1449,4 +1449,17 @@ fn isOpMethod(&m: &Fn): bool {
}
}
ret false
}

// Reports whether the m is a method which is declarated top of the struct.
fn isHeadDecl(mut &m: &Fn): bool {
if len(m.Generics) > 0 || len(m.Instances) == 0 {
ret false
}
if isOpMethod(m) {
ret true
}
let mut mi = m.Instances[0]
const Static = false
ret FuncPattern.Dispose(mi.Owner.FindMethod("Dispose", Static))
}

0 comments on commit 96dc5db

Please sign in to comment.