diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/javascript/reference/global_objects/webassembly/instance | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/ja/web/javascript/reference/global_objects/webassembly/instance')
4 files changed, 265 insertions, 0 deletions
diff --git a/files/ja/web/javascript/reference/global_objects/webassembly/instance/exports/index.html b/files/ja/web/javascript/reference/global_objects/webassembly/instance/exports/index.html new file mode 100644 index 0000000000..1e7a2bb83c --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/webassembly/instance/exports/index.html @@ -0,0 +1,69 @@ +--- +title: WebAssembly.Instance.prototype.exports +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/exports +tags: + - API + - JavaScript + - Property + - Reference + - WebAssembly + - exports + - instance + - プロパティ +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/exports +--- +<div>{{JSRef}}</div> + +<p><strong><code>exports</code></strong> は {{jsxref("WebAssembly.Instance")}} オブジェクトプロトタイプの読み取り専用プロパティで、 WebAssembly モジュールインスタンスからエクスポートされたすべての関数をメンバ-として持つオブジェクトを返します。これらは、 JavaScript からアクセスして使用することができます。</p> + +<pre class="syntaxbox">instance.exports</pre> + +<h2 id="Examples" name="Examples">例</h2> + +<p>fetch を使用して WebAssembly バイトコードを読み取った後、 {{jsxref("WebAssembly.instantiate()")}} 関数を使用してモジュールをコンパイル、インスタンス化します。このプロセスの中で、 JavaScript 関数を WebAssembly モジュールにインポートします。その後、 <code>Instance</code> からエクスポートされた<a href="/ja/docs/WebAssembly/Exported_functions">エクスポート済み WebAssembly 関数</a> を呼び出します。</p> + +<pre class="brush: js">var importObject = { + imports: { + imported_func: function(arg) { + console.log(arg); + } + } +}; + +WebAssembly.instantiateStreaming(fetch('simple.wasm'), importObject) +.then(obj => obj.instance.exports.exported_func());</pre> + +<div class="note"> +<p><strong>メモ</strong>: この例は GitHub 上の <a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/instantiate-streaming.html">instantiate-streaming.html</a> (<a href="https://mdn.github.io/webassembly-examples/js-api-examples/instantiate-streaming.html">ライブでも</a>) で見ることができます。</p> +</div> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('WebAssembly JS', '#dom-instance-exports', 'WebAssembly.Instance: exports')}}</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div> +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<p>{{Compat("javascript.builtins.WebAssembly.Instance.exports")}}</p> +</div> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li><a href="/ja/docs/WebAssembly">WebAssembly</a> 概要ページ</li> + <li><a href="/ja/docs/WebAssembly/Concepts">WebAssembly の概念</a></li> + <li><a href="/ja/docs/WebAssembly/Using_the_JavaScript_API">WebAssembly JavaScript API の使用</a></li> +</ul> diff --git a/files/ja/web/javascript/reference/global_objects/webassembly/instance/index.html b/files/ja/web/javascript/reference/global_objects/webassembly/instance/index.html new file mode 100644 index 0000000000..2f8ad23054 --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/webassembly/instance/index.html @@ -0,0 +1,69 @@ +--- +title: WebAssembly.Instance +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance +tags: + - Class + - JavaScript + - Reference + - WebAssembly + - クラス +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance +--- +<div>{{JSRef}}</div> + +<p><strong><code>WebAssembly.Instance</code></strong> オブジェクトはステートフルで、実行可能な {{jsxref("WebAssembly.Module")}} のインスタンスです。 <code>Instance</code> オブジェクトには JavaScript から WebAssembly コードを呼び出すことができるすべての<a href="/en-US/docs/WebAssembly/Exported_functions">エクスポートされた WebAssembly 関数</a>が含まれます。</p> + +<h2 id="Constructor" name="Constructor">コンストラクター</h2> + +<dl> + <dt>{{jsxref("WebAssembly.Instance()")}}</dt> + <dd>新しい <code>Instance</code> オブジェクトを生成します。</dd> +</dl> + +<h2 id="Instance_のインスタンス"><code>Instance</code> のインスタンス</h2> + +<p>全ての <code>Instance</code> インスタンスは <code>Instance()</code> コンストラクターのプロトタイプオブジェクトを継承します。これは全ての <code>Instance</code> インスタンスに影響するように変更可能です。</p> + +<h3 id="Instance_properties" name="Instance_properties">インスタンスプロパティ</h3> + +<dl> + <dt><code>Instance.prototype.constructor</code></dt> + <dd>このオブジェクトインスタンスを生成した関数を返します。既定では、これは {{jsxref("WebAssembly.Instance()")}} コンストラクターです。</dd> + <dt>{{jsxref("WebAssembly/Instance/exports", "Instance.prototype.exports")}} {{readonlyinline}}</dt> + <dd>メンバーとして WebAssembly モジュールのインスタンスからエクスポートされたすべての関数を含むオブジェクトを返します。 JavaScript からアクセスしたり使用したりすることができます。</dd> +</dl> + +<h3 id="Instance_methods" name="Instance_methods">インスタンスメソッド</h3> + +<p>なし。</p> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('WebAssembly JS', '#instances', 'Instance')}}</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div> +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<p>{{Compat("javascript.builtins.WebAssembly.Memory")}}</p> +</div> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li><a href="/ja/docs/WebAssembly">WebAssembly</a> 概要ページ</li> + <li><a href="/ja/docs/WebAssembly/Concepts">WebAssembly の概念</a></li> + <li><a href="/ja/docs/WebAssembly/Using_the_JavaScript_API">WebAssembly JavaScript API の使用</a></li> +</ul> diff --git a/files/ja/web/javascript/reference/global_objects/webassembly/instance/instance/index.html b/files/ja/web/javascript/reference/global_objects/webassembly/instance/instance/index.html new file mode 100644 index 0000000000..117e82225f --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/webassembly/instance/instance/index.html @@ -0,0 +1,64 @@ +--- +title: WebAssembly.Instance() コンストラクター +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/Instance +tags: + - Constructor + - JavaScript + - Reference + - WebAssembly + - コンストラクター +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/Instance +--- +<div>{{JSRef}}</div> + +<p> <strong><code>WebAssembly.Instance()</code></strong> コンストラクターは、新しい <code>Instance</code> オブジェクトを生成し、これはステートフルで実行可能な {{jsxref("WebAssembly.Module")}} のインスタンスです。</p> + +<p> <code>WebAssembly.Instance()</code> コンストラクター関数は同期的に {{jsxref("WebAssembly.Module")}} オブジェクトをインスタンス化することができます。しかし、主な <code>Instance</code> の取得方法は非同期の {{jsxref("WebAssembly.instantiateStreaming()")}} 関数を使用する方法です。</p> + +<h2 id="Syntax" name="Syntax">構文</h2> + +<div class="warning"> +<p><strong>重要</strong>: 巨大なモジュールのインスタンス化は高コストになる可能性があります。開発者が同期的な <code>Instance()</code> コンストラクターを使用するのは、絶対に必要な場合のみにするべきです。他のすべての場合で非同期の {{jsxref("WebAssembly.instantiateStreaming()")}} メソッドの使用が推奨されます。</p> +</div> + +<pre class="syntaxbox">new WebAssembly.Instance(<em>module</em>, <em>importObject</em>);</pre> + +<h3 id="Parameters" name="Parameters">引数</h3> + +<dl> + <dt><em>module</em></dt> + <dd>インスタンス化する {{jsxref("WebAssembly.Module")}} オブジェクト。</dd> + <dt><em>importObject</em> {{optional_inline}}</dt> + <dd>関数や {{jsxref("WebAssembly.Memory")}} オブジェクトなどの新しく生成される <code>Instance</code> にインポートされる値を持つオブジェクト。モジュール内で宣言されたインポートそれぞれに対応するプロパティが存在する必要があります。そうでない場合、 {{jsxref("WebAssembly.LinkError")}} が発生します。</dd> +</dl> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('WebAssembly JS', '#dom-instance-instance', 'Instance')}}</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div> +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<p>{{Compat("javascript.builtins.WebAssembly.Instance.Instance")}}</p> +</div> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li><a href="/ja/docs/WebAssembly">WebAssembly</a> 概要ページ</li> + <li><a href="/ja/docs/WebAssembly/Concepts">WebAssembly の概念</a></li> + <li><a href="/ja/docs/WebAssembly/Using_the_JavaScript_API">WebAssembly JavaScript API の使用</a></li> +</ul> diff --git a/files/ja/web/javascript/reference/global_objects/webassembly/instance/prototype/index.html b/files/ja/web/javascript/reference/global_objects/webassembly/instance/prototype/index.html new file mode 100644 index 0000000000..f1f8361b0c --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/webassembly/instance/prototype/index.html @@ -0,0 +1,63 @@ +--- +title: WebAssembly.Instance.prototype +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/prototype +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance +--- +<div>{{JSRef}} {{SeeCompatTable}}</div> + +<p><code><strong>WebAssembly.Instance</strong></code><strong><code>.prototype</code></strong> プロパティは {{jsxref("WebAssembly.Instance()")}} コンストラクタのプロトタイプを表します。</p> + +<div>{{js_property_attributes(0, 0, 0)}}</div> + +<h2 id="説明">説明</h2> + +<p>全ての {{jsxref("WebAssembly.Instance")}} インスタンスは <code>Instance.prototype</code> を継承します。{{jsxref("WebAssembly.Instance()")}} コンストラクタのプロトタイプオブジェクトは全ての {{jsxref( "WebAssembly.Instance")}} インスタンスに影響するように変更可能です。 </p> + +<h2 id="プロパティ">プロパティ</h2> + +<dl> + <dt><code>Instance.prototype.constructor</code></dt> + <dd>このオブジェクトのインスタンスを生成した関数を返します。デフォルトでは {{jsxref("WebAssembly.Instance()")}} コンストラクタです。</dd> + <dt><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/exports">Instance.prototype.exports</a></code> {{readonlyinline}}</dt> + <dd>WebAssembly モジュールインスタンスからエクスポートされた全ての関数をメンバとして持つオブジェクトを返します。これらは、JavaScriptからアクセスして使用することができます。</dd> +</dl> + +<h2 id="メソッド">メソッド</h2> + +<p>なし。</p> + +<h2 id="仕様">仕様</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様</th> + <th scope="col">策定状況</th> + <th scope="col">コメント</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('WebAssembly JS', '#webassemblymodule-objects', 'WebAssembly.Module()')}}</td> + <td>{{Spec2('WebAssembly JS')}}</td> + <td>初回ドラフト定義</td> + </tr> + </tbody> +</table> + +<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2> + +<div> + + +<p>{{Compat("javascript.builtins.WebAssembly.Instance.prototype")}}</p> +</div> + +<h2 id="関連情報">関連情報</h2> + +<ul> + <li>{{jsxref("WebAssembly.Instance()")}}</li> + <li><a href="/ja/docs/WebAssembly">WebAssembly</a> overview page</li> + <li><a href="/ja/docs/WebAssembly/Concepts">WebAssemblyのコンセプト</a></li> + <li><a href="/ja/docs/WebAssembly/Using_the_JavaScript_API">WebAssembly JavaScript API を使用する</a></li> +</ul> |