フォーラムメモ Edit

自分自身のプロパティアクセサを呼び出すとフリーズ Edit

  • ライブラリバージョン : r564
コールトレース
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
	GameProject.exe!asCArray<asCScriptFunction *>::operator[](unsigned int index=0)  Line 147 + 0x6 Bytes	C++
 	GameProject.exe!asCContext::CallInterfaceMethod(asCScriptFunction * func=0x0a8e1058)  Line 1254 + 0x15 Bytes	C++
 	GameProject.exe!asCContext::ExecuteNext()  Line 2790	C++
 	GameProject.exe!asCContext::Execute()  Line 1004 + 0x8 Bytes	C++
 	GameProject.exe!base::ags::ContextHandle::execute()  Line 104 + 0x23 Bytes	C++
 	GameProject.exe!app::scene::SceneASTest::onSceneStart()  Line 67	C++
 	GameProject.exe!app::Application::beginSceneProcess()  Line 191 + 0x23 Bytes	C++
 	GameProject.exe!app::Application::execute()  Line 99 + 0xc Bytes	C++
 	GameProject.exe!`anonymous namespace'::t_executeApplication()  Line 50 + 0xb Bytes	C++
 	GameProject.exe!app::EntryPoint::run()  Line 73	C++
 	GameProject.exe!wmain(int __formal=1, int __formal=1)  Line 16	C++
 	GameProject.exe!__tmainCRTStartup()  Line 594 + 0x19 Bytes	C
 	GameProject.exe!wmainCRTStartup()  Line 414	C
ASコード
すべてを展開すべてを収束
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 
-
|
|
|
!
 
 
-
|
-
|
!
|
-
|
!
|
|
!
 
 
 
-
|
|
!
class Vector3
{
    float x;
    float y;
    float z;
};
 
class Hoge
{
    const Vector3 get_pos()const
    {
        return mPos;
    }
    const Vector3 foo()const
    {
        return pos;
    }
 
    Vector3 mPos;
};
 
 
void main()
{
    Hoge h;
    const Vector3 vec = h.foo();
}

すべてを展開すべてを収束
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 
-
|
|
|
!
 
 
-
|
|
|
|
!
 
 
 
-
|
|
|
|
!
 
class Vector3
{
    float x;
    float y;
    float z;
};
 
class Hoge
{
    const Vector3 get_pos() { return mPos; }
    const Vector3 foo() { return pos;  }
    const Vector3 zoo() { return get_pos(); }
    Vector3 mPos;
};
 
 
void main()
{
    Hoge h;
    Vector3 vec;
    vec = h.zoo(); // ok
    vec = h.foo(); // runtime exception
}

__Hoge_foo.txt

  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
Temps: 1
 
    0   0 *    PUSH     1
    1   1 *    PshV4    v0
    2   2 *    CALLSYS  17           (void _builtin_object_::_beh_4_())
- 11,27 -
    4   1 *    SUSPEND
    5   1 *    PSF      v0
    6   2 *    CALLINTF 86           (const Vector3 Hoge::get_pos())
    8   1 *    STOREOBJ v1
    9   1 *    LOADOBJ  v1
   10   1 * 0:
   10   1 *    FREE     v0, 11276368
   12   0 *    RET      1

__Hoge_zoo.txt

  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
Temps: 1
 
    0   0 *    PUSH     1
    1   1 *    PshV4    v0
    2   2 *    CALLSYS  17           (void _builtin_object_::_beh_4_())
- 12,27 -
    4   1 *    SUSPEND
    5   1 *    PshV4    v0
    6   2 *    CALLINTF 86           (const Vector3 Hoge::get_pos())
    8   1 *    STOREOBJ v1
    9   1 *    LOADOBJ  v1
   10   1 * 0:
   10   1 *    FREE     v0, 11276368
   12   0 *    RET      1

opAssignを定義するとコンパイル時にAssert Edit

  • ライブラリバージョン : 2.18.1
エラーメッセージ
Assertion failed: tempVariables.GetLength() == 0, file ..\..\source\as_compiler.cpp, line 643
コールトレース
  0
  1
  2
  3
 	msvcr80d.dll!_wassert(const wchar_t * expr=0x007013cc, const wchar_t * filename=0x00701174, unsigned int lineno=643)  行 212	C
 	GameProject.exe!asCCompiler::CompileStatementBlock(asCScriptNode * block=0x0a8c1640, bool ownVariableScope=false, bool * hasReturn=0x0012b2e3, asCByteCode * bc=0x0012b2a0)  行 643 + 0x29 バイト	C++
 	GameProject.exe!asCCompiler::CompileFunction(asCBuilder * builder=0x0a8e2b08, asCScriptCode * script=0x0a8e2800, asCScriptNode * func=0x0a8e2878, asCScriptFunction * outFunc=0x0a8e3c10)  行 324	C++
 	GameProject.exe!asCBuilder::CompileFunctions()  行 524	C++
 	GameProject.exe!asCBuilder::Build()  行 184	C++
ASコード
すべてを展開すべてを収束
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 
-
|
|
|
-
|
!
|
|
-
|
|
!
!
 
 
-
|
!
class Hoge
{
    int mValue;
    
    Hoge()
    {
        mValue = 0;
    }
    
    Hoge@ opAssign(const Hoge &in aObj)
    {
        mValue = aObj.mValue;
        return @this;
    }
};
 
void main()
{
    Hoge a = Hoge();
}

デストラクタが呼ばれない Edit

すべてを展開すべてを収束
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 
 
 
 
-
!
 
 
-
|
-
|
!
|
-
|
!
|
!
 
 
-
|
-
|
!
|
-
|
!
|
!
 
 
-
|
-
|
!
-
|
!
|
|
!
 
 
-
|
!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
//-----------------------------------------------------------
// script code
 
class ObjType
{
};
 
class HaveObj
{
    HaveObj()
    {
        Print( "HaveObj::ctor\n" );
    }
    ~HaveObj()
    {
        Print( "HaveObj::dtor\n" );
    }
    ObjType o;
};
 
class HaveHandle
{
    HaveHandle()
    {
        Print( "HaveHandle::ctor\n" );
    }
    ~HaveHandle()
    {
        Print( "HaveHandle::dtor\n" );
    }
    ObjType@ o;
};
 
void testCase1()
{
    Print( "testCase1 start\n" );
    {
        HaveObj o;
    }// call o.~HaveObj();
    {
        HaveHandle o;
    }// not call o.~HaveHandle();
    
    Print( "testCase1 end\n" );
} 
 
void main()
{
    testCase1();
}
 
 
//-----------------------------------------------------------
 
 
//-----------------------------------------------------------
// output
 
testCase1 start
HaveObj::ctor
HaveObj::dtor
HaveHandle::ctor
testCase1 end
 
 
//-----------------------------------------------------------

回答
As with any language with automatic memory management, it can be hard to predict when the destructor is called.

In your case you have created a situation where the ordinary reference counting is not enough to control the life time of the objects, so the garbage collector is notified to keep a watch on the object instance. However, the garbage collector is not invoked automatically by the script engine (so that the application will have full control of when that is done). This means that unless you manually call the GC, the object will only be destroyed when you release the script engine.


    ホーム 一覧 検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS