Skip to content

Commit

Permalink
Another bug uncovered, another bug fixed o/
Browse files Browse the repository at this point in the history
  • Loading branch information
Amos Wenger committed May 3, 2012
1 parent 50903d9 commit 0351e60
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion source/rock/backend/cnaughty/CGenerator.ooc
Expand Up @@ -125,7 +125,7 @@ CGenerator: class extends Skeleton {
if(leftType isPointer() ||
rightType isPointer()) {
current app("(void*) ")
} else if(rightType inheritsFrom?(leftType)) {
} else if(rightType subclassOf?(leftType)) {
current app('('). app(leftType). app(") ")
}
}
Expand Down
3 changes: 1 addition & 2 deletions source/rock/backend/cnaughty/FunctionCallWriter.ooc
Expand Up @@ -154,8 +154,7 @@ FunctionCallWriter: abstract class extends Skeleton {
if (arg instanceOf?(VariableAccess)) {
writeRefAddrOf = false
}
} else if(arg getType() != null && declArg getType() != null && arg getType() inheritsFrom?(declArg getType())) {
//printf("%s inherits from %s, casting!\n", arg getType() toString(), declArg getType() toString())
} else if(arg getType() != null && declArg getType() != null && arg getType() subclassOf?(declArg getType())) {
current app("("). app(declArg getType()). app(") (")
writeCast = true
}
Expand Down
4 changes: 2 additions & 2 deletions source/rock/middle/BaseType.ooc
Expand Up @@ -375,13 +375,13 @@ BaseType: class extends Type {
}
}

inheritsFrom?: func (t: Type) -> Bool {
subclassOf?: func (t: Type) -> Bool {
if(!t instanceOf?(BaseType)) return false
bt := t as BaseType
if( ref == null || ! ref instanceOf?(TypeDecl)) return false
if(bt ref == null || !bt ref instanceOf?(TypeDecl)) return false

return ref as TypeDecl inheritsFrom?(bt ref as TypeDecl)
return ref as TypeDecl subclassOf?(bt ref as TypeDecl)
}

replace: func (oldie, kiddo: Node) -> Bool {
Expand Down
2 changes: 1 addition & 1 deletion source/rock/middle/FunctionCall.ooc
Expand Up @@ -468,7 +468,7 @@ FunctionCall: class extends Expression {
// check we are not trying to call a non-static member function on the metaclass
if(expr instanceOf?(VariableAccess) && \
(expr as VariableAccess getRef() instanceOf?(ClassDecl) || expr as VariableAccess getRef() instanceOf?(CoverDecl)) && \
(expr as VariableAccess getRef() as TypeDecl inheritsFrom?(ref getOwner()) || \
(expr as VariableAccess getRef() as TypeDecl subclassOf?(ref getOwner()) || \
expr as VariableAccess getRef() == ref getOwner()) && !ref isStatic) {
res throwError(UnresolvedCall new(this, "No such function %s%s for `%s` (%s)" format(name, getArgsTypesRepr(),
expr getType() toString(), expr getType() getRef() ? expr getType() getRef() token toString() : "(nil)"), ""))
Expand Down
2 changes: 1 addition & 1 deletion source/rock/middle/FunctionDecl.ooc
Expand Up @@ -1108,7 +1108,7 @@ FunctionDecl: class extends Declaration {

}

isVoid: func -> Bool { returnType == Type voidType() }
isVoid: func -> Bool { returnType void? }

isMain: func -> Bool { name == "main" && suffix == null && !isMember() }

Expand Down
2 changes: 1 addition & 1 deletion source/rock/middle/Type.ooc
Expand Up @@ -127,7 +127,7 @@ Type: abstract class extends Expression {

getScoreImpl: abstract func (other: This, scoreSeed: Int) -> Int

inheritsFrom?: func (t: This) -> Bool { false }
subclassOf?: func (t: This) -> Bool { false }

dig: abstract func -> This

Expand Down
4 changes: 2 additions & 2 deletions source/rock/middle/TypeDecl.ooc
Expand Up @@ -813,11 +813,11 @@ TypeDecl: abstract class extends Declaration {
0
}

inheritsFrom?: func (tDecl: TypeDecl) -> Bool {
subclassOf?: func (tDecl: TypeDecl) -> Bool {
superRef := getSuperRef()
if(superRef != null) {
if(superRef == tDecl) return true
return superRef inheritsFrom?(tDecl)
return superRef subclassOf?(tDecl)
}

return false
Expand Down
4 changes: 2 additions & 2 deletions source/rock/middle/VariableDecl.ooc
Expand Up @@ -202,7 +202,7 @@ VariableDecl: class extends Declaration {
res wholeAgain(this, "Need type of an Expression.")
return Response OK
}
if (exprType inheritsFrom?(type)) {
if (exprType subclassOf?(type)) {
expr = Cast new(expr, type, token)
}
}
Expand Down Expand Up @@ -372,7 +372,7 @@ VariableDecl: class extends Declaration {
if(lRef instanceOf?(ClassDecl) && rRef instanceOf?(ClassDecl)) {
if(!(
(lType equals?(rType)) ||
(rRef as ClassDecl inheritsFrom?(lRef as ClassDecl))
(rRef as ClassDecl subclassOf?(lRef as ClassDecl))
)) {
"Decl, l = %s, r = %s" printfln(lType toString(), rType toString())
return false
Expand Down

0 comments on commit 0351e60

Please sign in to comment.