Permalink
Browse files

Another bug uncovered, another bug fixed o/

  • Loading branch information...
1 parent 50903d9 commit 0351e60b1dbcbb497db7026854fae756f1c300f3 Amos Wenger committed May 3, 2012
@@ -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(") ")
}
}
@@ -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
}
@@ -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 {
@@ -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)"), ""))
@@ -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() }
@@ -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
@@ -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
@@ -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)
}
}
@@ -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

0 comments on commit 0351e60

Please sign in to comment.