Skip to content

Commit

Permalink
fixed interface casting bug
Browse files Browse the repository at this point in the history
  • Loading branch information
objeck committed Sep 21, 2015
1 parent c5cd4de commit 71ee0f4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/compiler/intermediate.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ class IntermediateEmitter {

// emits class cast checks
void EmitClassCast(Expression* expression) {
// ensure scalar cast
if(expression->GetExpressionType() == METHOD_CALL_EXPR) {
if(static_cast<MethodCall*>(expression)->GetLibraryMethod()) {
if(static_cast<MethodCall*>(expression)->GetLibraryMethod()->GetReturn()->GetDimension() > 0) {
Expand All @@ -245,15 +246,18 @@ class IntermediateEmitter {
static_cast<MethodCall*>(expression)->GetCallType() == NEW_ARRAY_CALL)) {
if(is_lib) {
imm_block->AddInstruction(IntermediateFactory::Instance()->MakeInstruction(cur_line_num, LIB_OBJ_INST_CAST, expression->GetToClass()->GetName()));
} else {
}
else {
imm_block->AddInstruction(IntermediateFactory::Instance()->MakeInstruction(cur_line_num, OBJ_INST_CAST, expression->GetToClass()->GetId()));
}
}
// class library cast
else if(expression->GetToLibraryClass() && !(expression->GetExpressionType() == METHOD_CALL_EXPR &&
static_cast<MethodCall*>(expression)->GetCallType() == NEW_ARRAY_CALL)) {
if(is_lib) {
imm_block->AddInstruction(IntermediateFactory::Instance()->MakeInstruction(cur_line_num, LIB_OBJ_INST_CAST, expression->GetToLibraryClass()->GetName()));
} else {
}
else {
imm_block->AddInstruction(IntermediateFactory::Instance()->MakeInstruction(cur_line_num, OBJ_INST_CAST, expression->GetToLibraryClass()->GetId()));
}
}
Expand Down

0 comments on commit 71ee0f4

Please sign in to comment.