Asu

Members
  • Content count

    8
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Asu

  • Rank
    Newbie

Personal Information

  • Interests
    Art
    Programming
  1. Constness questions

    Thanks for the answer. Because IIRC global variables can get initialized when/just after building, I thought the compiler would be able to figure out the case statement at compile-time... But it probably wouldn't make much sense. We were planning upgrading compilers primarily so we don't get locked in to older C++ versions, but avoided doing both the AS upgrade and compiler upgrade at the same time for testing convenience. But due to the issue with VS2010 we might actually get VS upgraded first in case the issue goes away with a newer compiler.
  2. Constness questions

    Hello, I have a few questions about constness in AS. I do like const both in C++ and AS because it helps with maintainability, but I was wondering how it could change performance for some cases I couldn't find on the wiki: Can registering methods as const methods when relevant ever help with script performance or could help crafting faster scripts? Can defining primitives or objects as const help with performance? I also have a question for something I'm not sure about: With AS 2.27.1 (which we are upgrading when we get the weirdness on our VS2010 builds sorted out), I can't seem to do something like: const SColor white(255, 255, 255, 255); switch(0xFFFFFFFF) { case white.color: print('ok'); }; I do get this error: Script: Case expressions must be constants Is this a bug or is this expected? Of course, our usecase is not as dumb as this example.. Thanks for your work on AS
  3. Weird... Our map loading is broken only on our Windows builds, but not on the Linux builds. I guess we will investigate on our side.
  4. Hello! After upgrading to r2418, we again found a bug related to constant handling, it seems. Test case: const int64 a = 4287660160; print(formatInt(a, "0h", 8)); // ffd08080 (WRONG) int64 a = 4287660160; print(formatInt(a, "0h", 8)); // ffd08080 (WRONG) const int64 a = 4287660160.0f; print(formatInt(a, "0h", 8)); // ffd08000 (WRONG) int64 a = 4287660160.0f; print(formatInt(a, "0h", 8)); // ff908000 (CORRECT) I cannot reproduce the issue with a linux build with gcc 4.2 nor gcc 7. It seems to happen exclusively on VS2010. This broke our PNG map loading scripts because these compare hex literals against colors. I think we didn't do anything wrong on our side? I hope it's not too hard to fix.
  5. New crash case: const uint8 constant = 5; void foo() { -constant; } Backtrace: #6 0xf6b7ad6b in asCCompiler::CompileExpressionPreOp(asCScriptNode*, asCExprContext*) () #7 0xf6b5ba55 in asCCompiler::CompileExpressionTerm(asCScriptNode*, asCExprContext*) () #8 0xf6b5c3b0 in asCCompiler::CompilePostFixExpression(asCArray<asCScriptNode*>*, asCExprContext*) () #9 0xf6b5c9b1 in asCCompiler::CompileExpression(asCScriptNode*, asCExprContext*) () #10 0xf6b5daea in asCCompiler::CompileCondition(asCScriptNode*, asCExprContext*) () #11 0xf6b5e570 in asCCompiler::CompileAssignment(asCScriptNode*, asCExprContext*) () #12 0xf6b8292c in asCCompiler::CompileExpressionStatement(asCScriptNode*, asCByteCode*) () #13 0xf6b8bb90 in asCCompiler::CompileStatementBlock(asCScriptNode*, bool, bool*, asCByteCode*) () #14 0xf6b8c208 in asCCompiler::CompileFunction(asCBuilder*, asCScriptCode*, asCArray<asCString>&, asCScriptNode*, asCScriptFunction*, sClassDeclaration*) () Hopefully it's the last one.
  6. That was quick, thanks
  7. Hello, I am upgrading AngelScript on a game engine. I get an assertion failure strinkingly similar to this one. I have AS_DEPRECATED set but I do not think it matters here. Edit: Forgot to specify: amd64 linux with revision 2414 from SVN. An assertion failure occurs in GetConstantDW. ../../source/as_compiler.cpp:15091: asDWORD asCExprValue::GetConstantDW(): Assertion `dataType.GetSizeInMemoryBytes() == 4' failed. The backtrace is as it follows: #6 0xf6bd685d in asCCompiler::CompileComparisonOperator(asCScriptNode*, asCExprContext*, asCExprContext*, asCExprContext*, eTokenType) () #7 0xf6bbeb5c in asCCompiler::CompileOperator(asCScriptNode*, asCExprContext*, asCExprContext*, asCExprContext*, eTokenType, bool) () #8 0xf6bb10c7 in asCCompiler::CompilePostFixExpression(asCArray<asCScriptNode*>*, asCExprContext*) () #9 0xf6bb1991 in asCCompiler::CompileExpression(asCScriptNode*, asCExprContext*) () #10 0xf6bb2ada in asCCompiler::CompileCondition(asCScriptNode*, asCExprContext*) () #11 0xf6bb3560 in asCCompiler::CompileAssignment(asCScriptNode*, asCExprContext*) () #12 0xf6be3172 in asCCompiler::CompileIfStatement(asCScriptNode*, bool*, asCByteCode*) () #13 0xf6be08d0 in asCCompiler::CompileStatementBlock(asCScriptNode*, bool, bool*, asCByteCode*) () #14 0xf6be0f48 in asCCompiler::CompileFunction(asCBuilder*, asCScriptCode*, asCArray<asCString>&, asCScriptNode*, asCScriptFunction*, sClassDeclaration*) () #15 0xf6b74520 in asCBuilder::CompileFunctions() () The script that triggers this is a comparison against a constant unsigned int: const uint16 FREQUENCY = 2000; /* ommitting some code */ void onTick(CBlob@ blob) { if (blob.getTickSinceCreated() < FREQUENCY) return; /* ... */ } blob.getTickSinceCreate() is returning an int. Removing the if condition makes the assertion failure go away. I get the same failure with another script: const u8 COIN_COST = 60; void blah() { if(/* ... */ && player.getCoins() < COIN_COST) { /* ... */ } } I'd love to have this fixed. Thanks!
  8. Hello, I am trying to upgrade AngelScript in a game engine and had a compile error when AS_DEPRECATED is set: ../../source/as_scriptengine.cpp: In member function 'virtual bool asCScriptEngine::IsHandleCompatibleWithObject(void*, int, int) const': ../../source/as_scriptengine.cpp:5346:53: error: 'asCObjectType* asCScriptObject::objType' is protected within this context asCObjectType *objType = ((asCScriptObject*)obj)->objType; ^~~~~~~ In file included from ../../source/as_scriptengine.cpp:51:0: ../../source/as_scriptobject.h:132:20: note: declared protected here asCObjectType *objType; ^~~~~~~ I am using the revision 2414 from SVN. A hacky workaround is to add `friend class asCScriptEngine;` in asCObjectType. It would be great if it was fixed. Thanks in advance