int main()
{
bstr s = true ? "true" : "false";
return 0;
}
assert( tempVariables.GetLength() == 0 ) fails
Hi,
Assertion tempVariables.GetLength() == 0 fails when Build()ing the following script:
AngelScript 1.9.0 ( + BubbleSort fix )
Cheers,
RCL
Thanks RCL. I'll look into it. The fix should be quite easy, just a matter of releasing the temporary variables at right location.
I've found and fixed the bug. The fix is not quite as simple as I thought, but here it is: Exchange the function asCCompiler::CompileCondition() in as_compiler_expressions.cpp for the below function.
void asCCompiler::CompileCondition(asCScriptNode *expr, asCByteCode *bc, sTypeInfo *type){ sTypeInfo ctype, rtype, ltype; // Compile the conditional expression asCScriptNode *cexpr = expr->firstChild; if( cexpr->next ) { CompileExpression(cexpr, bc, &ctype); PrepareOperand(&ctype, bc, cexpr); if( ctype.dataType != asCDataType(ttBool, true, false) ) Error(TXT_EXPR_MUST_BE_BOOL, cexpr); int afterLabel = nextLabel++; int elseLabel = nextLabel++; bc->InstrINT(BC_JMP0, elseLabel); CompileAssignment(cexpr->next, bc, <ype); // Allocate temporary variable and copy the result to that one sTypeInfo temp; temp = ltype; int offset = AllocateVariable(temp.dataType, true); temp.isTemporary = true; temp.stackOffset = (short)offset; CompileConstructor(temp.dataType, offset, bc); bc->InstrWORD(BC_PSF, offset); sTypeInfo rtemp; rtemp = temp; rtemp.dataType.isReference = true; rtemp.dataType.isReadOnly = false; PrepareForAssignment(&rtemp.dataType, <ype, bc, cexpr->next); PerformAssignment(&rtemp, bc, cexpr->next); // Release the old temporary variable ReleaseTemporaryVariable(ltype, bc); bc->InstrINT(BC_JMP, afterLabel); bc->Label((short)elseLabel); CompileAssignment(cexpr->next->next, bc, &rtype); // Copy the result to the same temporary variable CompileConstructor(temp.dataType, offset, bc); bc->InstrWORD(BC_PSF, offset); PrepareForAssignment(&rtemp.dataType, &rtype, bc, cexpr->next); PerformAssignment(&rtemp, bc, cexpr->next); // Release the old temporary variable ReleaseTemporaryVariable(rtype, bc); bc->Label((short)afterLabel); // Make sure both expressions have the same type if( ltype.dataType != rtype.dataType ) Error(TXT_BOTH_MUST_BE_SAME, expr); // Set the temporary variable as output *type = temp; } else CompileExpression(cexpr, bc, type);}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement