diff --git a/src/compiler/intermediate.h b/src/compiler/intermediate.h index bdeba8c117..2b288d5d8e 100644 --- a/src/compiler/intermediate.h +++ b/src/compiler/intermediate.h @@ -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(expression)->GetLibraryMethod()) { if(static_cast(expression)->GetLibraryMethod()->GetReturn()->GetDimension() > 0) { @@ -245,15 +246,18 @@ class IntermediateEmitter { static_cast(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(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())); } }