Skip to content

Commit

Permalink
Fix error code generation in FunctionCallWriter. When a member function
Browse files Browse the repository at this point in the history
of cover is called with array, should use thisRef and correctly check if
we are really need cast. This fixes #7.
  • Loading branch information
horasal committed Jun 28, 2014
1 parent 31cd393 commit e0ce8cf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions source/rock/backend/cnaughty/FunctionCallWriter.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ FunctionCallWriter: abstract class extends Skeleton {

// TODO maybe check there's some kind of inheritance/compatibility here?
// or in the tinker phase?
if(shouldCastThis || !(callType equals?(declType))) {
if(shouldCastThis || (!(callType equals?(declType)))) {
// If this is a ref call, we should write down the referenced type that is passed as the callType (as determined in tinkering phase)
current app("("). app(fDecl isThisRef ? callType : declType). app(") ")
// FIXME: When it is a non-ref Array we should not cast it. I'm not sure if it is correct, but it works.
if(!(callType class == ArrayType && !fDecl isThisRef))
current app("("). app(fDecl isThisRef ? (fDecl owner thisRefDecl getType()) : declType). app(") ")
}

if(fDecl isThisRef) current app("&("). app(fCall expr). app(")")
Expand Down

0 comments on commit e0ce8cf

Please sign in to comment.