diff --git a/source/rock/backend/cnaughty/CGenerator.ooc b/source/rock/backend/cnaughty/CGenerator.ooc index c7a228b9..fdf55b94 100644 --- a/source/rock/backend/cnaughty/CGenerator.ooc +++ b/source/rock/backend/cnaughty/CGenerator.ooc @@ -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(") ") } } diff --git a/source/rock/backend/cnaughty/FunctionCallWriter.ooc b/source/rock/backend/cnaughty/FunctionCallWriter.ooc index eacbb01d..fa794253 100644 --- a/source/rock/backend/cnaughty/FunctionCallWriter.ooc +++ b/source/rock/backend/cnaughty/FunctionCallWriter.ooc @@ -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 } diff --git a/source/rock/middle/BaseType.ooc b/source/rock/middle/BaseType.ooc index 6f85a86e..52f9049e 100644 --- a/source/rock/middle/BaseType.ooc +++ b/source/rock/middle/BaseType.ooc @@ -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 { diff --git a/source/rock/middle/FunctionCall.ooc b/source/rock/middle/FunctionCall.ooc index d2e0a91d..0911f7ee 100644 --- a/source/rock/middle/FunctionCall.ooc +++ b/source/rock/middle/FunctionCall.ooc @@ -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)"), "")) diff --git a/source/rock/middle/FunctionDecl.ooc b/source/rock/middle/FunctionDecl.ooc index 86eeca99..a3dc14d7 100644 --- a/source/rock/middle/FunctionDecl.ooc +++ b/source/rock/middle/FunctionDecl.ooc @@ -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() } diff --git a/source/rock/middle/Type.ooc b/source/rock/middle/Type.ooc index 3c80cd6a..2e266ba5 100644 --- a/source/rock/middle/Type.ooc +++ b/source/rock/middle/Type.ooc @@ -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 diff --git a/source/rock/middle/TypeDecl.ooc b/source/rock/middle/TypeDecl.ooc index f7028032..199d5b1f 100644 --- a/source/rock/middle/TypeDecl.ooc +++ b/source/rock/middle/TypeDecl.ooc @@ -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 diff --git a/source/rock/middle/VariableDecl.ooc b/source/rock/middle/VariableDecl.ooc index de6ca9ca..f8c2620d 100644 --- a/source/rock/middle/VariableDecl.ooc +++ b/source/rock/middle/VariableDecl.ooc @@ -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