Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

assert( tempVariables.GetLength() == 0 ) fails


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 RCL   Members   -  Reputation: 122

Like
0Likes
Like

Posted 04 September 2004 - 08:40 PM

Hi, Assertion tempVariables.GetLength() == 0 fails when Build()ing the following script:
int main()
{
    bstr s = true ? "true" : "false";

    return 0;
}


AngelScript 1.9.0 ( + BubbleSort fix ) Cheers, RCL

Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3061

Like
0Likes
Like

Posted 05 September 2004 - 02:14 AM

Thanks RCL. I'll look into it. The fix should be quite easy, just a matter of releasing the temporary variables at right location.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#3 Andreas Jonsson   Moderators   -  Reputation: 3061

Like
0Likes
Like

Posted 05 September 2004 - 03:01 AM

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, &ltype);

// 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, &ltype, 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);
}


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#4 RCL   Members   -  Reputation: 122

Like
0Likes
Like

Posted 05 September 2004 - 03:08 AM

Quote:
Original post by WitchLord
I've found and fixed the bug.


You are really quick :) I wish everyone fixed his/her bugs like you do.

Thanks, it compiles and works correctly.

Cheers,
RCL

#5 Andreas Jonsson   Moderators   -  Reputation: 3061

Like
0Likes
Like

Posted 05 September 2004 - 03:15 AM

Thanks. I try to do my best [wink]
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS