Global variable weirdness
Alright, here's more funky stuff with 2.5. With the new 2.5.0b I tried to move once again to the new version from 2.4.1, and I'm getting corrupted global variables. I have a certain number of global variables, kind of like this: const double somevariable=2; Now there's a decent number of these variables, and what I'm seeing is that some of them seem to contain random data, and some of them not. I'll try to see if I can patch up a test script for you. [edit] It seems that it's enough just to declare global variables like: const double a=12; const double b=5; const double c=35.2; const double d=4; Here's the funny thing. It depends on the kind of number it is whether it freaks out or not. For example the above would give the results: a=5.92879e-323 b=2.47033e-323 c=35.2 d=1.97626e-323 [edit] If I just leave the const out, then it works alright. [Edited by - villemon on February 2, 2006 6:40:30 AM]
That's strange. It's probably related to the pure constant feature that I implemented, to allow the use of named constants in expressions.
I'll look into it.
When are you seeing the corrupted values? Right after building the scripts or after loading pre-compiled bytecode?
I'll look into it.
When are you seeing the corrupted values? Right after building the scripts or after loading pre-compiled bytecode?
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
This would be a non-preloaded issue, as in it happens right after compiling the code.
I found the problem. This bug actually showed up with constant local variables as well.
Two lines of code must be added to as_compiler.cc to fix this:
line 516:
line 1269:
Hopefully you shouldn't find any more bugs now. [wink] But if you do, don't hesitate to tell me.
Regards,
Andreas
Two lines of code must be added to as_compiler.cc to fix this:
line 516:
void asCCompiler::CompileDeclaration(asCScriptNode *decl, asCByteCode *bc){ ... while( node ) { ... if( node && node->nodeType == snArgList ) { ... } else if( node && node->nodeType == snInitList ) { ... } else { ... if( node && node->nodeType == snAssignment ) { ... if( type.IsPrimitive() ) { if( type.IsReadOnly() && expr.type.isConstant ) { ImplicitConversion(&expr, type, node, false); sVariable *v = variables->GetVariable(name.AddressOf()); v->isPureConstant = true; v->constantValue = expr.type.qwordValue; } ... } else { ... } ... } ... } }}
line 1269:
int asCCompiler::CompileGlobalVariable(asCBuilder *builder, asCScriptCode *script, asCScriptNode *node, sGlobalVariableDescription *gvar){ ... if( node && node->nodeType == snArgList ) { ... } else if( node && node->nodeType == snInitList ) { ... } else { ... if( node ) { ... if( gvar->datatype.IsPrimitive() ) { if( gvar->datatype.IsReadOnly() && expr.type.isConstant ) { ImplicitConversion(&expr, gvar->datatype, node, false); gvar->isPureConstant = true; gvar->constantValue = expr.type.qwordValue; } ... } else { ... } ... } ... }}
Hopefully you shouldn't find any more bugs now. [wink] But if you do, don't hesitate to tell me.
Regards,
Andreas
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement