Difference between revisions of "LSL エラー"

From Second Life Wiki
Jump to navigation Jump to search
m
m
Line 139: Line 139:
===ERROR : Syntax error===
===ERROR : Syntax error===


You must punctuate the script and spell the words of the script as will please the compiler, of course.
もちろんあなたはスクリプトやスクリプト内の語をコンパイラが受け入れられるように厳密に記述しなければなりません。


Also you must make each script reasonably small. The compiler may astonishingly complain of a "syntax" error rather than politely complaining more specifically of an "out of memory" "byte code assembly failed" error, when you make a script unreasonably large.
そして、スクリプトをほどよく小さく書かなければなりません。あまりに大きなスクリプトを書いた場合、コンパイラは"out of memory(メモリあふれ)" "byte code assembly failed(バイトコード生成に失敗)"のような丁寧で明確なエラーではなく、 "syntax" error(構文エラー)だと言うかもしれません。


For example, the 2007-08 Windows Second Life client complained of a Syntax error if you cascaded too many else-if's. The exact limits enforced can vary astonishingly. For example, the 2007-08 Windows Second Life client sometimes accepted as many as 22 cascaded else-if's, but also sometimes rejected as few as 19 cascaded else-if's, depending on other details of the script.
For example, the 2007-08 Windows Second Life client complained of a Syntax error if you cascaded too many else-if's. The exact limits enforced can vary astonishingly. For example, the 2007-08 Windows Second Life client sometimes accepted as many as 22 cascaded else-if's, but also sometimes rejected as few as 19 cascaded else-if's, depending on other details of the script.


Programmers who learned LSL on one compiler may feel that that compiler's limits are reasonable, ''e.g.'', up to five hundred cascaded else-if's in Mac OS X, while programmers trained on another compiler may feel instead that only its significantly different limits are reasonable, ''e.g.'', no more than a dozen cascaded else-if's in Windows.
Programmers who learned LSL on one compiler may feel that that compiler's limits are reasonable, ''e.g.'', up to five hundred cascaded else-if's in Mac OS X, while programmers trained on another compiler may feel instead that only its significantly different limits are reasonable, ''e.g.'', no more than a dozen cascaded else-if's in Windows.

Revision as of 00:10, 12 December 2007

Run-time error messages

スクリプトは実行中に停止し、以下のようなメッセージと共に"Script run-time error"をあなたに伝えるかもしれません。 such as:

Script run-time error: Heap Error

無意味な事をしないでください。例えば、結果を返さないルーチンでリスト型を返さないでください。

Script run-time error: Lists may not contain lists

リスト内にリストを入れることはできません。

Script run-time error: Math Error

Float型の数値を0で割ろうとした、integer型の数値を0で割ろうとした、等。

Script run-time error: Stack-Heap Collision

スタック領域がバイトコード領域やヒープ領域に衝突した。

それぞれのスクリプトは、16キロバイトに分割されたメモリ内で実行されます。そのメモリはバイトコード領域、スタック領域、ヒープ領域に分割されています。

あなたが長すぎるスクリプトを書いてコンパイルすると、大きすぎるバイトコードが生成され、衝突が発生します。 スクリプトがコンパイルできてセーブに成功したとしても、スクリプトを含んだオブジェクトを rez しようとすると、スクリプトはすぐに、あるいは実行中にクラッシュします。

See llGetFreeMemory.

Run-time error demo scripts

ランタイム・エラーを経験するために、以下の例のコンパイルして実行してください。

default
{
    state_entry()
    {
        llOwnerSay((string) [llOwnerSay("bye")]); // Script run-time error: Heap Error
    }
}
default
{
    state_entry()
    {
        list once = [];
        list twice = [once, once]; // Script run-time error: Lists may not contain lists
    }
}
default
{
    state_entry()
    {
        float one = 1.0;
        float zero = 0.0;
        float quotient = one / zero; // Script run-time error: Math Error
        llOwnerSay((string) quotient);
    }
}
default
{
    state_entry()
    {
        list entries = [0];
        while (TRUE)
        {
            entries += entries; // Script run-time error: Stack-Heap Collision
            llOwnerSay((string) llGetListLength(entries));
        }
    }
}

Compile-time error messages

The SL GUI はあなたが完璧だと思ったいくつかのコードを拒絶し、いくつかの説明と共にERRORを出力するかもしれません。

ERROR : Type mismatch

vector型やrotation型に値を指定するには、 .x .y .z .s という名の要素を使わなければなりません。一度にlistで指定することはできません。例えば:

default
{
    state_entry()
    {
        vector vec = (vector) [1, 2, 3]; // ERROR : Type mismatch
        llOwnerSay((string) vec);
    }
}

ERROR : Byte code assembly failed -- out of memory

スクリプトは、ほどよく小さく(reasonably small)書かなければなりません。

例えば、あまりにも多くのelse-ifを並べた場合、コンパイラはスクリプトが大きすぎると報告します。

demoElseIfCompileError(integer count)
{
    if (count == 0)
    {
        ;
    }
    else if (count == 1)
    {
        ;
    }
    else if (count == 2)
    {
        ;
    }
    ...
    ... // ERROR : Byte code assembly failed -- out of memory
    ... // or ERROR : Syntax error
    ...
    else if (count == ...)
    {
        ;
    }
}

どのくらいのスクリプトが大きすぎるスクリプトなのかは、驚くほど変化することがあります。例えば、the 2007-08 Second Life クライアントは30倍程度に変化しました。具体的には、Windowsクライアントは22個の22を受け付け、23個のelse-ifを拒絶しましたが、Mac OS Xは692 else-if個のを受け付け、693個のelse-ifを拒絶しました。

OSによって変化するコンパイラの制限が、コピー制限の手段のように働きます。制限のゆるいコンパイラでコンパイルされたスクリプトを、誰でも実行できます。しかし、制限の多いコンパイラしか持たないユーザは、ソースを変更してもセーブできません。

See llGetFreeMemory, llMessageLinked.

ERROR : Syntax error

もちろんあなたはスクリプトやスクリプト内の語をコンパイラが受け入れられるように厳密に記述しなければなりません。

そして、スクリプトをほどよく小さく書かなければなりません。あまりに大きなスクリプトを書いた場合、コンパイラは"out of memory(メモリあふれ)" や "byte code assembly failed(バイトコード生成に失敗)"のような丁寧で明確なエラーではなく、 "syntax" error(構文エラー)だと言うかもしれません。

For example, the 2007-08 Windows Second Life client complained of a Syntax error if you cascaded too many else-if's. The exact limits enforced can vary astonishingly. For example, the 2007-08 Windows Second Life client sometimes accepted as many as 22 cascaded else-if's, but also sometimes rejected as few as 19 cascaded else-if's, depending on other details of the script.

Programmers who learned LSL on one compiler may feel that that compiler's limits are reasonable, e.g., up to five hundred cascaded else-if's in Mac OS X, while programmers trained on another compiler may feel instead that only its significantly different limits are reasonable, e.g., no more than a dozen cascaded else-if's in Windows.