diff --git a/documentation/xs/XS Conformance.md b/documentation/xs/XS Conformance.md index 3c5f4f7c8..4a44dab3d 100644 --- a/documentation/xs/XS Conformance.md +++ b/documentation/xs/XS Conformance.md @@ -1,34 +1,34 @@ -# XS Conformance +# XS 準拠性 Copyright 2016-2023 Moddable Tech, Inc.
-Revised: February 15, 2024 +更新日: 2024年2月15日 -## Caveat +## 注意事項 #### Realm -XS supports one realm by virtual machine. Tests that expect `$262.createRealm` to return a new realm fail. +XSは仮想マシンあたり1つのRealmをサポートしています。`$262.createRealm`が新しいRealmを返すことを期待するテストは失敗します。 -#### Internationalization +#### 国際化 -XS does not implement ECMA-402, the Internationalization API Specification, so the `intl402` tests are skipped. +XSはECMA-402(国際化API仕様)を実装していないため、`intl402`テストはスキップされます。 #### Annex B -No XS hosts are web browsers, so the `annexB` tests are skipped. However XS implements `Date.prototype.getYear`, `Date.prototype.setYear`, `Object.prototype.__defineGetter__`, `Object.prototype.__defineSetter__`, `Object.prototype.__lookupGetter__`, `Object.prototype.__lookupSetter__`, `Object.prototype.__proto__`, `String.prototype.substr`, `escape` and `unescape`, +XSホストはWebブラウザではないため、`annexB`テストはスキップされます。ただし、XSは`Date.prototype.getYear`、`Date.prototype.setYear`、`Object.prototype.__defineGetter__`、`Object.prototype.__defineSetter__`、`Object.prototype.__lookupGetter__`、`Object.prototype.__lookupSetter__`、`Object.prototype.__proto__`、`String.prototype.substr`、`escape`、`unescape`を実装しています。 -## Runtime models +## ランタイムモデル -On microcontrollers, XS uses a runtime model based on a virtual machine prepared by the XS compiler and linker. The prepared virtual machine contains the ECMAScript built-ins, along with the classes, functions and objects of preloaded modules. The prepared virtual machine is in ROM, its contents is shared by the tiny virtual machines that XS quickly creates in RAM to run apps. +マイクロコントローラ上では、XSはXSコンパイラとリンカーによって準備された仮想マシンに基づくランタイムモデルを使用します。準備された仮想マシンには、ECMAScriptの組み込み機能と、プリロードされたモジュールのクラス、関数、オブジェクトが含まれています。準備された仮想マシンはROMにあり、その内容はXSがアプリを実行するためにRAM内に迅速に作成する小さな仮想マシンによって共有されます。 -Such a runtime model introduces no conformance issues in itself since XS can alias shared classes, functions and objects if apps modify them. However, in order to save ROM and RAM, other restrictions have been introduced: +このようなランタイムモデルは、アプリが変更した場合にXSが共有されたクラス、関数、オブジェクトをエイリアスできるため、それ自体では準拠性の問題を引き起こしません。ただし、ROMとRAMを節約するために、他の制限が導入されています: -- Host functions, i.e. functions implemented in C, are primitive values like booleans, numbers, strings, etc. They are promoted to `Function` objects when necessary. -- Scripts evaluation is optional. So some platforms do not support `eval`, `new Function`, etc. But all platforms support `JSON.parse`. -- Optionally the XS linker can dead strip ECMAScript built-ins that Moddable apps do not use, and remove `length` and `name` properties from functions. +- ホスト関数(Cで実装された関数)は、ブール値、数値、文字列などのプリミティブ値です。必要に応じて`Function`オブジェクトに昇格されます。 +- スクリプトの評価はオプションです。そのため、一部のプラットフォームは`eval`、`new Function`などをサポートしていません。ただし、すべてのプラットフォームは`JSON.parse`をサポートしています。 +- オプションで、XSリンカーはModdableアプリが使用しないECMAScript組み込み機能をデッドストリップし、関数から`length`と`name`プロパティを削除できます。 -Here the conformance is tested on macOS with a traditional runtime model and without any restrictions. For each case, XS creates a virtual machine, then parses and runs the script. The XS harness, `xst`, uses [LibYAML](http://pyyaml.org/wiki/LibYAML) to load the frontmatter, which contains, among other information, the harness scripts to parse and run before the case script itself. +ここでは、伝統的なランタイムモデルを使用し、制限なしでmacOS上で準拠性がテストされています。各ケースで、XSは仮想マシンを作成し、スクリプトを解析して実行します。XSハーネス`xst`は、[LibYAML](http://pyyaml.org/wiki/LibYAML)を使用してフロントマターを読み込みます。これには、ケーススクリプト自体の前に解析および実行するハーネススクリプトなどの情報が含まれています。 -To build `xst`: +`xst`をビルドするには: #### Linux @@ -45,25 +45,25 @@ To build `xst`: cd %MODDABLE%\xs\makefiles\win build -To pass some tests, clone [test262](https://github.com/tc39/test262.git) and change the directory to the `test` directory inside the `test262` directory. Then you can run `xst` with files or directories. For instance: +一部のテストを実行するには、[test262](https://github.com/tc39/test262.git)をクローンし、`test262`ディレクトリ内の`test`ディレクトリに移動します。その後、ファイルやディレクトリで`xst`を実行できます。例えば: cd ~/test262/test $MODDABLE/build/bin/mac/release/xst language/block-scope $MODDABLE/build/bin/mac/release/xst built-ins/TypedArray* -## Results +## 結果 -After the 6th edition, TC39 adopted a [process](https://tc39.github.io/process-document/) based on [proposals](https://github.com/tc39/proposals). Each proposal has a maturity stage. At stage 4, proposals are finished and will be published in the following edition of the specifications. +第6版以降、TC39は[プロポーザル](https://github.com/tc39/proposals)に基づく[プロセス](https://tc39.github.io/process-document/)を採用しました。各プロポーザルには成熟度ステージがあります。ステージ4では、プロポーザルが完了し、仕様書の次の版で公開されます。 -The official conformance test suite, [test262](https://github.com/tc39/test262), contains cases for the published specifications, together with cases for proposals at stages 3 and 4, which is great to prepare XS for future editions. The XS harness, `xst` uses adhoc comparisons of the frontmatter `[features]` to skip cases related to not yet implemented proposals. See the skipped cases at the end of this document. +公式の準拠性テストスイートである[test262](https://github.com/tc39/test262)には、公開された仕様書のケースと、ステージ3および4のプロポーザルのケースが含まれており、XSを将来の版に備えるのに優れています。XSハーネス`xst`は、フロントマター`[features]`のアドホック比較を使用して、まだ実装されていないプロポーザルに関連するケースをスキップします。このドキュメントの最後にスキップされたケースを参照してください。 -Currently, on macOS, XS passes **99.41%** of the language tests and **82.04%** of the built-ins tests. +現在、macOS上でXSは言語テストの**99.41%**と組み込みテストの**82.04%**を通過しています。 -Mostly because of `Temporal`, the number of skipped cases is significant. For implemented features, XS passes **99.92%** of the language tests and **99.88%** of the built-ins tests. +主に`Temporal`のため、スキップされたケースの数は多くなっています。実装された機能では、XSは言語テストの**99.92%**と組み込みテストの**99.88%**を通過しています。 -Details are here under. The numbers of skipped cases are between parentheses. The following section lists the failed tests with some explanations. +詳細は以下の通りです。スキップされたケースの数は括弧内に示されています。次のセクションでは、失敗したテストについていくつかの説明とともにリストしています。 -### Language +### 言語 42636/42888 (218) language 460/460 arguments-object @@ -450,7 +450,7 @@ Details are here under. The numbers of skipped cases are between parentheses. Th 15/15 undefined 134/134 white-space -### Built-ins +### 組み込み機能 34077/41392 (7275) built-ins 5763/5869 (94) Array @@ -1517,20 +1517,20 @@ Details are here under. The numbers of skipped cases are between parentheses. Th 120/120 parseInt 12/12 undefined -## Failures +## 失敗 -Here under are the failed tests. The comments are primarily here for the sake of future versions of XS. +以下は失敗したテストです。コメントは主にXSの将来のバージョンのためのものです。 -### Language +### 言語 language/eval-code/indirect/realm.js language/expressions/call/eval-realm-indirect.js (sloppy) -One realm. +1つのRealm。 language/expressions/assignment/fn-name-lhs-cover.js -Assignments should rename functions only if the left hand side is an identifier. XS also rename functions if the left hand side is a group with only an identifier. +代入は、左辺が識別子の場合のみ関数をリネームするべきです。XSは左辺が識別子のみのグループの場合も関数をリネームします。 language/expressions/async-function/named-reassign-fn-name-in-body-in-arrow.js (sloppy) language/expressions/async-function/named-reassign-fn-name-in-body-in-eval.js (sloppy) @@ -1547,36 +1547,36 @@ Assignments should rename functions only if the left hand side is an identifier. language/expressions/generators/named-no-strict-reassign-fn-name-in-body.js (sloppy) language/expressions/generators/scope-name-var-open-non-strict.js (sloppy) -The name of a function expression always defines a constant variable that reference the current function. In sloppy mode it should define a variable that can be assigned but does not change! +関数式の名前は常に現在の関数を参照する定数変数を定義します。sloppyモードでは、代入可能だが変更されない変数を定義するべきです! language/expressions/object/literal-property-name-bigint.js -XS does not support bigint as property name. +XSはプロパティ名としてbigintをサポートしていません。 language/expressions/super/call-proto-not-ctor.js -XS checks if super is a constructor before evaluating arguments. +XSは引数を評価する前にsuperがコンストラクタかどうかをチェックします。 language/statements/class/subclass/default-constructor-spread-override.js -The default derived constructor should not use `%Array.prototype% @@iterator` +デフォルトの派生コンストラクタは`%Array.prototype% @@iterator`を使用すべきではありません language/statements/for-await-of/head-lhs-async.js -`for (async of x)` is a syntax error but `for await (async of x)` should not be! +`for (async of x)`は構文エラーですが、`for await (async of x)`はそうであるべきではありません! language/statements/try/tco-catch.js (strict) -XS does not tail call optimize `return` inside `catch` +XSは`catch`内の`return`を末尾呼び出し最適化しません language/expressions/assignment/target-member-computed-reference-null.js language/expressions/assignment/target-member-computed-reference-undefined.js language/global-code/script-decl-lex-var-declared-via-eval-sloppy.js language/identifier-resolution/assign-to-global-undefined.js -To be investigated. +調査中。 -### Built-ins +### 組み込み機能 built-ins/Array/prototype/concat/create-proto-from-ctor-realm-array.js built-ins/Array/prototype/filter/create-proto-from-ctor-realm-array.js @@ -1596,21 +1596,21 @@ To be investigated. built-ins/Symbol/keyFor/cross-realm.js built-ins/Symbol/keyFor/cross-realm.js -One realm. +1つのRealm。 built-ins/Array/prototype/reduceRight/length-near-integer-limit.js built-ins/String/prototype/localeCompare/15.5.4.9_CE.js built-ins/JSON/stringify/replacer-function-object-deleted-property.js -To be investigated. +調査中。 built-ins/Function/prototype/toString/method-computed-property-name.js -Invalid test. +無効なテスト。 -### Skipped cases +### スキップされたケース -`xst` skips cases with the following features: +`xst`は以下の機能を持つケースをスキップします: - Array.fromAsync - FinalizationRegistry.prototype.cleanupSome diff --git a/documentation/xs/XS Platforms.md b/documentation/xs/XS Platforms.md index fe8f2f507..a9c4b9f7c 100644 --- a/documentation/xs/XS Platforms.md +++ b/documentation/xs/XS Platforms.md @@ -1,26 +1,26 @@ -# XS Platforms +# XS プラットフォーム Copyright 2016-2024 Moddable Tech, Inc.
-Revised: April 22, 2024 +更新日: 2024年4月22日 -## History +## 歴史 -A platform is a combination of hardware and system software. For each platform, XS requires an interface file, `xsPlatform.h`, and an implementation file, `xsPlatform.c` +プラットフォームは、ハードウェアとシステムソフトウェアの組み合わせです。各プラットフォームに対して、XSはインターフェースファイル`xsPlatform.h`と実装ファイル`xsPlatform.c`を必要とします。 -Historically, XS used one interface file, `xsPlatform.h` splitting the implementation into two files: `xsPlatform.c` and `xsHost.c`. Many platforms shared the same interface and implementation files, based either on the KinomaJS platform abstraction, or on an adhoc platform abstraction for command line tools. +歴史的に、XSは1つのインターフェースファイル`xsPlatform.h`を使用し、実装を`xsPlatform.c`と`xsHost.c`の2つのファイルに分割していました。多くのプラットフォームは、KinomaJSプラットフォーム抽象化か、コマンドラインツール用のアドホックプラットフォーム抽象化のいずれかに基づいて、同じインターフェースと実装ファイルを共有していました。 -Further, an XS machine had many ways to find and load modules and programs: from JS files, from stand alone compiled XSB files with or without companion DLL or SO files, and from a linked XSA file with a companion DLL or SO file... The XS platform was in charge of providing such options. +さらに、XSマシンには、モジュールとプログラムを見つけてロードする多くの方法がありました:JSファイルから、付属のDLLまたはSOファイルありまたはなしのスタンドアロンでコンパイルされたXSBファイルから、付属のDLLまたはSOファイルを持つリンクされたXSAファイルから...XSプラットフォームは、そのようなオプションを提供する責任がありました。 -When we started working on microcontrollers, the main inspiration for XS platforms was the adhoc platform abstraction for command line tools, which was the most complex version. +マイクロコントローラでの作業を開始したとき、XSプラットフォームの主なインスピレーションは、最も複雑なバージョンであったコマンドラインツール用のアドホックプラットフォーム抽象化でした。 -Today the XS runtime has been significantly streamlined, especially on microcontrollers. XS machines are always cloned from a read-only machine prepared by the XS linker. There are only modules, byte coded by the XS compiler. Modules are either preloaded or prepared to be loaded and unloaded at runtime. +今日、XSランタイムは、特にマイクロコントローラ上で大幅に合理化されています。XSマシンは常に、XSリンカーによって準備された読み取り専用マシンからクローンされます。XSコンパイラによってバイトコード化されたモジュールのみが存在します。モジュールは、プリロードされるか、実行時にロードおよびアンロードされるように準備されています。 -Consequently, it is now much simpler to build an XS platform. This document describes the necessary interface and implementation files. +したがって、XSプラットフォームを構築することは現在はるかに簡単になりました。このドキュメントでは、必要なインターフェースと実装ファイルについて説明します。 ## xsPlatform.h -### Basic types +### 基本型 -XS uses a few basic types that the interface file has to define. +XSは、インターフェースファイルで定義する必要があるいくつかの基本型を使用します。 ```c #include @@ -32,9 +32,9 @@ typedef int32_t txS4; typedef uint32_t txU4; ``` -### C defines and includes +### C定義とインクルード -XS mostly relies on constants and functions from the C standard library, accessed thru macros with `C_` or `c_` prefixes: +XSは主にC標準ライブラリの定数と関数に依存し、`C_`または`c_`プレフィックスを持つマクロを介してアクセスします: ```c #include @@ -47,11 +47,11 @@ XS mostly relies on constants and functions from the C standard library, accesse //... ``` -Such definitions, and the corresponding includes, are the most significant part of the interface file. The macros allows a platform to provide its own constants and functions. See any of the provided `xsPlatform.h` for the list of macros to define. +これらの定義と対応するインクルードは、インターフェースファイルの最も重要な部分です。マクロにより、プラットフォームが独自の定数と関数を提供できます。定義すべきマクロのリストについては、提供されている任意の`xsPlatform.h`を参照してください。 -### ESP macros +### ESPマクロ -The Xtensa instruction set and architecture, used most notably in microcontrollers by Espressif, requires special macros to locate certain constant data in ROM and to read that data. On other platforms these macros are trivially defined: +Espressifのマイクロコントローラで最も顕著に使用されるXtensa命令セットとアーキテクチャでは、ROMの特定の定数データを配置し、そのデータを読み取るための特別なマクロが必要です。他のプラットフォームでは、これらのマクロは単純に定義されます: ```c #define c_read8(POINTER) *((txU1 *)(POINTER)) @@ -70,9 +70,9 @@ The Xtensa instruction set and architecture, used most notably in microcontrolle ### `mxMachinePlatform` -The platform can add fields to the machine record by defining the `mxMachinePlatform` macro. Since the machine is passed to all functions that XS calls (as the ubiquitous `the`), it is a convenient way for platforms to have their own context besides the application context. +プラットフォームは、`mxMachinePlatform`マクロを定義することで、マシンレコードにフィールドを追加できます。マシンはXSが呼び出すすべての関数に渡される(ユビキタスな`the`として)ため、プラットフォームがアプリケーションコンテキスト以外に独自のコンテキストを持つ便利な方法です。 -For instance, on Mac, the `mxMachinePlatform` macro adds references to a socket and a run loop source for the communication with **xsbug**, and another run loop source for promises. +例えば、Macでは、`mxMachinePlatform`マクロは**xsbug**との通信用のソケットとランループソース、およびプロミス用の別のランループソースへの参照を追加します。 ```c #include @@ -83,7 +83,7 @@ For instance, on Mac, the `mxMachinePlatform` macro adds references to a socket CFRunLoopSourceRef promiseSource; ``` -On Windows, the `mxMachinePlatform` macro adds the socket and message window handles that are used for the same purposes. +Windowsでは、`mxMachinePlatform`マクロは同じ目的で使用されるソケットとメッセージウィンドウハンドルを追加します。 ```c #include @@ -95,29 +95,29 @@ On Windows, the `mxMachinePlatform` macro adds the socket and message window han ## xsPlatform.c -The implementation file first includes `xsAll.h`, which contains the definitions of all XS macros and types, and the declarations of all XS extern functions. Then the platform has to implement the functions described here under. +実装ファイルは最初に`xsAll.h`をインクルードします。これにはすべてのXSマクロと型の定義、およびすべてのXS extern関数の宣言が含まれています。その後、プラットフォームは以下で説明する関数を実装する必要があります。 -XS machines do not support multiple threads, though platforms can support multiple threads, each with their own XS machines. All calls and callbacks described here must happen in the thread that created or cloned the machine. +XSマシンはマルチスレッドをサポートしていませんが、プラットフォームはそれぞれ独自のXSマシンを持つマルチスレッドをサポートできます。ここで説明するすべての呼び出しとコールバックは、マシンを作成またはクローンしたスレッドで実行される必要があります。 -The functions are grouped into meaningful sections. The xsPlatform.c file can also provide POSIX functions that the platform is missing. +関数は意味のあるセクションにグループ化されています。xsPlatform.cファイルは、プラットフォームに不足しているPOSIX関数も提供できます。 -- - `void fxCreateMachinePlatform(txMachine* the)` -`fxCreateMachinePlatform` is called when creating and cloning an XS machine. The platform initializes the fields defined by its `mxMachinePlatform` macro. By default all fields are zero. +`fxCreateMachinePlatform`は、XSマシンの作成とクローン時に呼び出されます。プラットフォームは、その`mxMachinePlatform`マクロで定義されたフィールドを初期化します。デフォルトでは、すべてのフィールドはゼロです。 -- - `void fxDeleteMachinePlatform(txMachine* the)` -`fxDeleteMachinePlatform` is called when deleting an XS machine. The platform must dispose or free here appropriate fields defined by its `mxMachinePlatform` macro. +`fxDeleteMachinePlatform`は、XSマシンの削除時に呼び出されます。プラットフォームは、その`mxMachinePlatform`マクロで定義された適切なフィールドをここで破棄または解放する必要があります。 -- -### Debug +### デバッグ -The functions in this section are only necessary for the debug version of XS. They can be condtionally defined within: +このセクションの関数は、XSのデバッグバージョンでのみ必要です。これらは条件付きで定義できます: ```c #ifdef mxDebug @@ -125,13 +125,13 @@ The functions in this section are only necessary for the debug version of XS. Th #endif ``` -If the platform does not support the communication with **xsbug**, functions in this section can be empty, except `fxIsConnected` and `fxIsReadable`, which must return `0`. +プラットフォームが**xsbug**との通信をサポートしていない場合、このセクションの関数は空にできますが、`fxIsConnected`と`fxIsReadable`は`0`を返す必要があります。 -Communication between **xsbug** and the XS machine can be done over either a TCP/IP or serial connection. In the case of a TCP/IP connection, **xsbug** is the server and XS machines are clients. When using a serial connection, **xsbug** continues to communication over TCP/IP and a bridge running on the computer relays data between the serial and TCP connections. In the case of the ESP8266, this relay is performed by **serial2xsbug**. +**xsbug**とXSマシン間の通信は、TCP/IPまたはシリアル接続のいずれかで行うことができます。TCP/IP接続の場合、**xsbug**がサーバーでXSマシンがクライアントです。シリアル接続を使用する場合、**xsbug**はTCP/IPでの通信を継続し、コンピュータ上で動作するブリッジがシリアル接続とTCP接続間でデータを中継します。ESP8266の場合、この中継は**serial2xsbug**によって実行されます。 -Platforms must implement `fxIsReadable` to allow XS machines to receive messages from **xsbug** while executing byte codes, i.e. when platforms are inside the `fxRun` function. Most of the time, platforms are outside the `fxRun` function. So they use a system event and `fxDebugCommand` to tell XS about messages from **xsbug**. +プラットフォームは、XSマシンがバイトコードを実行中、つまりプラットフォームが`fxRun`関数内にいるときに**xsbug**からメッセージを受信できるように`fxIsReadable`を実装する必要があります。ほとんどの場合、プラットフォームは`fxRun`関数の外にいます。そのため、システムイベントと`fxDebugCommand`を使用して**xsbug**からのメッセージについてXSに通知します。 -For instance on Mac the platform uses `CFSocketCreate` with a `kCFSocketReadCallBack`: +例えば、Macでは、プラットフォームは`kCFSocketReadCallBack`で`CFSocketCreate`を使用します: ```c void fxReadableCallback(CFSocketRef socketRef, CFSocketCallBackType cbType, CFDataRef addr, const void* data, void* context) @@ -142,7 +142,7 @@ void fxReadableCallback(CFSocketRef socketRef, CFSocketCallBackType cbType, CFDa } ``` -On Windows the platform uses `WSAAsyncSelect` with the `WM_XSBUG` message: +Windowsでは、プラットフォームは`WM_XSBUG`メッセージで`WSAAsyncSelect`を使用します: ```c LRESULT CALLBACK fxMessageWindowProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) @@ -166,67 +166,67 @@ LRESULT CALLBACK fxMessageWindowProc(HWND window, UINT message, WPARAM wParam, L - `void fxConnect(txMachine* the)` -XS calls `fxConnect` to connect `the` machine to **xsbug**. +XSは、`the`マシンを**xsbug**に接続するために`fxConnect`を呼び出します。 -For TCP/IP connections, platforms create a socket and connect it to **xsbug**. On Mac and Windows the address of **xsbug** is usually `localhost`, on other platforms it is usually defined by an environment variable. The port of **xsbug** defaults to `5002` by convention. +TCP/IP接続の場合、プラットフォームはソケットを作成し、**xsbug**に接続します。MacとWindowsでは、**xsbug**のアドレスは通常`localhost`で、他のプラットフォームでは通常環境変数で定義されます。**xsbug**のポートは慣例により`5002`がデフォルトです。 -Machines are connect to **xsbug** after being created, i.e. `fxConnect` happens after `fxCreateMachinePlatform`. +マシンは作成後に**xsbug**に接続されます。つまり、`fxConnect`は`fxCreateMachinePlatform`の後に発生します。 -- - `void fxDisconnect(txMachine* the)` -XS calls `fxDisconnect` to disconnect `the` machine from **xsbug**. +XSは、`the`マシンを**xsbug**から切断するために`fxDisconnect`を呼び出します。 -For TCP/IP connections, platforms close the socket. +TCP/IP接続の場合、プラットフォームはソケットを閉じます。 -Machines are disconnected before being deleted, i.e. `fxDisconnect` happens before `fxDeleteMachinePlatform`. +マシンは削除前に切断されます。つまり、`fxDisconnect`は`fxDeleteMachinePlatform`の前に発生します。 -- - `txBoolean fxIsConnected(txMachine* the)` -XS calls `fxIsConnected` to know if `the` machine is connected to **xsbug**. +XSは、`the`マシンが**xsbug**に接続されているかどうかを知るために`fxIsConnected`を呼び出します。 -- - `txBoolean fxIsReadable(txMachine* the)` -XS calls `fxIsReadable` to know if `the` machine received a message from **xsbug**. Platforms must return 1 or 0 depending on the availability of bytes to read. +XSは、`the`マシンが**xsbug**からメッセージを受信したかどうかを知るために`fxIsReadable`を呼び出します。プラットフォームは、読み取り可能なバイトの有無に応じて1または0を返す必要があります。 -The performance of the implementation of `fxIsReadable` is important since XS calls `fxIsReadable` at every `LINE` byte code (e.g. for each line of JavaScript source code executed). +XSは`LINE`バイトコードごと(つまり、実行されるJavaScriptソースコードの各行)に`fxIsReadable`を呼び出すため、`fxIsReadable`の実装のパフォーマンスは重要です。 -- - `void fxReceive(txMachine* the)` -XS calls `fxReceive` to receive a message from **xsbug**. The implementation reads bytes into `the->debugBuffer` and sets `the->debugOffset` to the number of bytes received. +XSは、**xsbug**からメッセージを受信するために`fxReceive`を呼び出します。実装は`the->debugBuffer`にバイトを読み込み、受信したバイト数を`the->debugOffset`に設定します。 -XS calls `fxReceive` repeatedly until the entire message is received. The maximum number of bytes that can be read by `fxReceive` is `sizeof(the->debugBuffer) - 1`. +XSは、メッセージ全体が受信されるまで`fxReceive`を繰り返し呼び出します。`fxReceive`で読み取れるバイトの最大数は`sizeof(the->debugBuffer) - 1`です。 -- - `void fxSend(txMachine* the, txBoolean more)` -XS calls `fxSend` to send a message to **xsbug**. The implementation gets the number of bytes to send from `the->echoOffset` and write bytes from `the->echoBuffer`. +XSは、**xsbug**にメッセージを送信するために`fxSend`を呼び出します。実装は`the->echoOffset`から送信するバイト数を取得し、`the->echoBuffer`からバイトを書き込みます。 -XS calls `fxSend ` repeatedly until the entire message is sent, `more` equals `1` while the message is incomplete, `0` when the message is complete. +XSは、メッセージ全体が送信されるまで`fxSend`を繰り返し呼び出します。`more`は、メッセージが不完全な間は`1`、メッセージが完了すると`0`になります。 -- ### Eval -The standard `eval` function, `Function` constructor and `Generator` constructor must transform source code into byte codes and keys. +標準の`eval`関数、`Function`コンストラクタ、`Generator`コンストラクタは、ソースコードをバイトコードとキーに変換する必要があります。 -XS lets the platform decides is such feature is worth the memory it takes. +XSは、このような機能がメモリコストに見合うかどうかをプラットフォームに決定させます。 -- - `txScript* fxParseScript(txMachine* the, void* stream, txGetter getter, txUnsigned flags)` -XS calls `fxParseScript` to transform source code into XS byte codes and keys. The `stream` and `getter` arguments allow the parser to access the source code. The `flags` argument tells the parser the kind of source code: `mxModuleCode`, `mxProgramCode` or `mxEvalCode`. +XSは、ソースコードをXSバイトコードとキーに変換するために`fxParseScript`を呼び出します。`stream`と`getter`引数により、パーサーがソースコードにアクセスできます。`flags`引数は、ソースコードの種類をパーサーに伝えます:`mxModuleCode`、`mxProgramCode`、または`mxEvalCode`。 -If the platform supports such feature, it must include `xsScript.h` and implements `fxParseScript` like: +プラットフォームがこのような機能をサポートする場合、`xsScript.h`をインクルードし、以下のように`fxParseScript`を実装する必要があります: ```c #include "xsScript.h" @@ -250,15 +250,15 @@ txScript* fxParseScript(txMachine* the, void* stream, txGetter getter, txUnsigne } ``` -The platform must also compile and link `xsScript.c`, `xsLexical.c`, `xsSyntaxical.c`, `xsTree.c`, `xsSourceMap.c`, `xsScope.c` and `xsCode.c`. +プラットフォームは、`xsScript.c`、`xsLexical.c`、`xsSyntaxical.c`、`xsTree.c`、`xsSourceMap.c`、`xsScope.c`、および`xsCode.c`もコンパイルしてリンクする必要があります。 -If the platform does not support such feature, `fxParseScript` must return `NULL` and the C files here above do not have to be compiled and linked. +プラットフォームがこのような機能をサポートしない場合、`fxParseScript`は`NULL`を返す必要があり、上記のCファイルをコンパイルしてリンクする必要はありません。 -- -### Keys +### キー -Keys are the names and symbols that XS uses to identify properties. +キーは、XSがプロパティを識別するために使用する名前とシンボルです。 -- diff --git a/documentation/xs/XS Profiler.md b/documentation/xs/XS Profiler.md index 7a0f3bff0..e2af9156c 100644 --- a/documentation/xs/XS Profiler.md +++ b/documentation/xs/XS Profiler.md @@ -1,27 +1,27 @@ -# XS Profiler -Updated: December 1, 2022 +# XS プロファイラー +更新日: 2022年12月1日 -The XS profiler is a sample based JavaScript profiler. The XS profiler also reports time spent in native functions or in the garbage collector. This document is a guide to the implementation of the profiler in XS. The information it contains, particularly in the [Viewers](#viewers) section, is useful in interpreting the results of a profiling session. +XSプロファイラーは、サンプルベースのJavaScriptプロファイラーです。XSプロファイラーは、ネイティブ関数やガベージコレクタで費やされた時間も報告します。このドキュメントは、XSにおけるプロファイラーの実装に関するガイドです。このドキュメントに含まれる情報、特に[ビューアー](#viewers)セクションは、プロファイリングセッションの結果を解釈するのに役立ちます。 -There are two implementations of the profiler: +プロファイラーには2つの実装があります: -- **Instrument**: XS sends profile records and samples to **xsbug**. The instrument profiler is used by Moddable SDK applications in the simulator and on devices. +- **Instrument**: XSはプロファイルレコードとサンプルを**xsbug**に送信します。Instrumentプロファイラーは、シミュレーターとデバイス上のModdable SDKアプリケーションで使用されます。 -> Build XS with `mxInstrument` defined. +> `mxInstrument`を定義してXSをビルドしてください。 -- **File**: XS accumulates profile records and samples in RAM then saves them into a [`.cpuprofile`](https://chromedevtools.github.io/devtools-protocol/tot/Profiler/#type-Profile) file. The file profiler is used by command line tools including **xst** and **xsnap**. +- **File**: XSはプロファイルレコードとサンプルをRAMに蓄積し、その後[`.cpuprofile`](https://chromedevtools.github.io/devtools-protocol/tot/Profiler/#type-Profile)ファイルに保存します。Fileプロファイラーは、**xst**や**xsnap**を含むコマンドラインツールで使用されます。 -> Build XS with `mxProfile` defined and xsProfile.c included. +> `mxProfile`を定義してxsProfile.cをインクルードしてXSをビルドしてください。 -Both profilers require debugging information, so scripts must be built with debugging enabled. The instrument profiler requires a connection to **xsbug**. Therefore, profiling is only supported in builds of XS with debugging support enabled. +両方のプロファイラーにはデバッグ情報が必要なため、スクリプトはデバッグを有効にしてビルドする必要があります。Instrumentプロファイラーは**xsbug**への接続が必要です。したがって、プロファイリングはデバッグサポートが有効になっているXSのビルドでのみサポートされます。 -## Profile -This section describes the data the XS profiler collects and how it transmits and stores that data. +## プロファイル +このセクションでは、XSプロファイラーが収集するデータと、そのデータを送信・保存する方法について説明します。 ### ID -Every function has a unique profile ID, which is assigned when the function is defined. All function instances created from the same function definition have the same profile ID. For example, the following creates only a single profile ID: +すべての関数は一意のプロファイルIDを持ち、これは関数が定義されるときに割り当てられます。同じ関数定義から作成されたすべての関数インスタンスは同じプロファイルIDを持ちます。例えば、以下は単一のプロファイルIDのみを作成します: ```js for (let i = 0; i < 10; i++) { @@ -32,88 +32,88 @@ for (let i = 0; i < 10; i++) { } ``` -For function instances, the profile ID is stored in the ID of the internal home slot. For function primitives, the profile ID is stored in the slot itself. This approach means that profile IDs require no additional RAM or storage space. All debug builds are ready to be profiled. +関数インスタンスの場合、プロファイルIDは内部ホームスロットのIDに格納されます。関数プリミティブの場合、プロファイルIDはスロット自体に格納されます。このアプローチにより、プロファイルIDは追加のRAMやストレージ領域を必要としません。すべてのデバッグビルドはプロファイリングの準備ができています。 -The profile ID of the host is 0. The profile ID of the garbage collector is 1. For newly created machines, function profile IDs start incrementing from 2; for cloned machines, from the profile ID stored in the preparation. +ホストのプロファイルIDは0です。ガベージコレクタのプロファイルIDは1です。新しく作成されたマシンの場合、関数プロファイルIDは2から増分を開始します。クローンされたマシンの場合は、準備に格納されたプロファイルIDから開始します。 -### Record +### レコード -A profile record is created for each function observed to run during a profile session. The profile record contains: +プロファイルレコードは、プロファイルセッション中に実行が観察された各関数に対して作成されます。プロファイルレコードには以下が含まれます: -- Profile ID -- Function identifier (name) -- Path (source file) -- Line number +- プロファイルID +- 関数識別子(名前) +- パス(ソースファイル) +- 行番号 -Profile records are only stored once by the file profiler and only sent once to **xsbug** by the instrument profiler. +プロファイルレコードは、ファイルプロファイラーでは一度だけ保存され、インストルメントプロファイラーでは**xsbug**に一度だけ送信されます。 -The home slot allows function identifiers to be more detailed for function instances (`Array.prototype.push`) than for function primitives (`push`). +ホームスロットにより、関数識別子は関数プリミティブ(`push`)よりも関数インスタンス(`Array.prototype.push`)の方がより詳細になります。 -### Sample +### サンプル -A profile sample is created for each sample taken during a profile session. The profile sample contains: +プロファイルサンプルは、プロファイルセッション中に取得された各サンプルに対して作成されます。プロファイルサンプルには以下が含まれます: -- Time delta: microseconds since the last sample. -- Profile ID stack: sequence of profile ID in stack order. The first profile ID is the function hit by the profiler. The last profile ID is always the host (0). +- 時間デルタ:前回のサンプルからのマイクロ秒。 +- プロファイルIDスタック:スタック順のプロファイルIDのシーケンス。最初のプロファイルIDはプロファイラーがヒットした関数です。最後のプロファイルIDは常にホスト(0)です。 -For each sample, The instrument profiler simply sends the sample to **xsbug**, which updates the call graph and the durations of the profile records. The file profiler updates the call graph and stores the time delta and the first profile ID. +各サンプルに対して、インストルメントプロファイラーは単純にサンプルを**xsbug**に送信し、**xsbug**がコールグラフとプロファイルレコードの継続時間を更新します。ファイルプロファイラーはコールグラフを更新し、時間デルタと最初のプロファイルIDを保存します。 -### Time +### 時間 -XS checks the profiler to determine if a sample should be taken at several points in execution: +XSは、実行の以下の時点でプロファイラーをチェックし、サンプルを取るべきかどうかを判断します: -- Each `LINE` byte code -- Exiting a native function -- Exiting the garbage collector -- Entering the machine from the host +- 各`LINE`バイトコード +- ネイティブ関数からの退出 +- ガベージコレクタからの退出 +- ホストからマシンへの入場 -## Memory and Performance +## メモリとパフォーマンス -Starting and stopping the profiler creates and deletes a profiler. No RAM is used when the profiler is inactive. +プロファイラーの開始と停止はプロファイラーを作成・削除します。プロファイラーが非アクティブのときはRAMは使用されません。 -Both the instrument and file profilers allocate their buffers outside the XS heaps. These ensures that enabling profiling does not change the runtime behavior of the garbage collector. +インストルメントプロファイラーとファイルプロファイラーの両方で、バッファをXSヒープの外側に割り当てます。これにより、プロファイリングを有効にしてもガベージコレクタのランタイム動作が変わらないことが保証されます。 -### Instrument Profiler +### インストルメントプロファイラー -The instrument profiler uses: +インストルメントプロファイラーは以下を使用します: -- A bitmap to remember which profile records have already been sent to **xsbug**, i.e. one bit for each profile ID. -- Buffers for profile samples. The size of the buffers is the size of the XS stack divided by the size of a frame and multiplied by the size of a profile ID. +- どのプロファイルレコードがすでに**xsbug**に送信されたかを記憶するビットマップ、つまり各プロファイルIDに対して1ビット。 +- プロファイルサンプル用のバッファ。バッファのサイズは、XSスタックのサイズをフレームのサイズで割って、プロファイルIDのサイズを掛けたものです。 -### File Profiler +### ファイルプロファイラー -The file profiler uses growing buffers to store profile records and samples. +ファイルプロファイラーは、プロファイルレコードとサンプルを保存するために成長するバッファを使用します。 -## How To Use +## 使用方法 -### Instrument Profiler +### インストルメントプロファイラー -In xsbug, the stopwatch icon starts and stops the profiler. The icon is located at the top-right of the PROFILE pane of a debuggee tab. +xsbugでは、ストップウォッチアイコンがプロファイラーを開始・停止します。アイコンはデバッグ対象タブのPROFILEペインの右上にあります。 -There is also a preference to automatically start the profiler when the debuggee starts. +デバッグ対象が開始するときに自動的にプロファイラーを開始する設定もあります。 -### File Profiler +### ファイルプロファイラー -For **xst**, the `-p` option starts and stops the profiler around the execution of the script or module. The `.cpuprofile` file containing the profile results is saved in the current directory. +**xst**の場合、`-p`オプションがスクリプトまたはモジュールの実行を囲んでプロファイラーを開始・停止します。プロファイル結果を含む`.cpuprofile`ファイルは現在のディレクトリに保存されます。 -The `.cpuprofile` file can be viewed in **Google Chrome DevTools**, **Visual Studio Code**, and **xsbug**. +`.cpuprofile`ファイルは**Google Chrome DevTools**、**Visual Studio Code**、**xsbug**で表示できます。 -### Programming Interface +### プログラミングインターフェース -Use the `xsStartProfiling` and `xsStopProfiling` macros to start and stop the profiler. +プロファイラーを開始・停止するには`xsStartProfiling`と`xsStopProfiling`マクロを使用します。 -## Viewers +## ビューアー -Because you can open the `.cpuprofile` file created by the File Profiler with at least three different applications, you get somewhat different views of the same data. +ファイルプロファイラーが作成した`.cpuprofile`ファイルは少なくとも3つの異なるアプリケーションで開くことができるため、同じデータのやや異なるビューを得ることができます。 -In the three viewers, the first column is the "Self Time", the second column is the "Total Time". +3つのビューアーでは、最初の列が「Self Time」、二番目の列が「Total Time」です。 -Google Chrome DevTools and xsbug can toggle between a "Bottom Up" viewer (from callees to callers) and a "Top Down" viewer (from callers to callees). +Google Chrome DevToolsとxsbugは、「Bottom Up」ビューアー(被呼び出しから呼び出し元へ)と「Top Down」ビューアー(呼び出し元から被呼び出しへ)を切り替えることができます。 -For reference, here are links to relevant source files: +参考のため、関連するソースファイルへのリンクを以下に示します: - Google Chrome DevTools: [CPUProfileDataModel.ts](https://github.com/ChromeDevTools/devtools-frontend/blob/main/front_end/core/sdk/CPUProfileDataModel.ts) - Visual Studio Code: [profilingModel.ts](https://github.com/microsoft/vscode/blob/main/src/vs/platform/profiling/common/profilingModel.ts) @@ -121,22 +121,22 @@ For reference, here are links to relevant source files: ### Self Time -The Self Time is the sum of the sample durations of functions hit by the profiler, i.e. functions that were executing when the profiler sampled. The sample duration is the time delta between a sample and its next sample. +Self Timeは、プロファイラーがヒットした関数、つまりプロファイラーがサンプルしたときに実行していた関数のサンプル継続時間の合計です。サンプル継続時間は、サンプルとその次のサンプル間の時間デルタです。 -Visual Studio Code and xsbug display the same Self Time. Google Chrome DevTools does not, although values are similar. +Visual Studio Codeとxsbugは同じSelf Timeを表示します。Google Chrome DevToolsはそうではありませんが、値は似ています。 ### Total Time -Visual Studio Code computes the Total Time of a function by recursively adding, from callers to callees, the Self Time and the Total Time of all its callees. Since one function can be called by several different functions, the results can be greater than the duration of the profile itself. +Visual Studio Codeは、呼び出し元から被呼び出しへと再帰的に、すべての被呼び出しのSelf TimeとTotal Timeを加算することで関数のTotal Timeを計算します。1つの関数は複数の異なる関数から呼び出される可能性があるため、結果はプロファイル自体の継続時間よりも大きくなる可能性があります。 -xsbug computes the Total Time by recursively propagating the Self Time from callees to callers, dividing the propagated duration by the number of callers at each step. No results are greater than the duration of the profile itself. +xsbugは、被呼び出しから呼び出し元へと再帰的にSelf Timeを伝播し、各ステップで伝播された継続時間を呼び出し元の数で割ることでTotal Timeを計算します。どの結果もプロファイル自体の継続時間よりも大きくなることはありません。 -Visual Studio Code and xsbug agree on the Total Time if the call graph is a tree. +コールグラフがツリーの場合、Visual Studio CodeとxsbugはTotal Timeについて一致します。 -How Google Chrome DevTools compute the Total Time? To be investigated but the results are closer to xsbug than to Visual Studio Code. +Google Chrome DevToolsはTotal Timeをどのように計算しているのでしょうか?調査が必要ですが、結果はVisual Studio Codeよりもxsbugに近いです。 -### Notes +### 注意事項 -- To be able to open a `.cpuprofile` file in Visual Studio Code, there cannot be cycles in the call graph. Therefore, the File Profiler eliminates cycles when saving the file. -- Both Google Chrome DevTools and Visual Studio Code merge profile records by location (function name, file, line). xsbug does not since the XS engine ensures that there is only one profile record for each function. -- Google Chrome DevTools crashes when opening `.cpuprofile` files saved by **xsnap** when replaying a session of the Agoric runtime. +- `.cpuprofile`ファイルをVisual Studio Codeで開くことができるようにするためには、コールグラフにサイクルがあってはいけません。そのため、ファイルプロファイラーはファイルを保存するときにサイクルを除去します。 +- Google Chrome DevToolsとVisual Studio Codeの両方で、プロファイルレコードを場所(関数名、ファイル、行)でマージします。XSエンジンは各関数に対して1つのプロファイルレコードのみあることを保証しているため、xsbugはそうしません。 +- Google Chrome DevToolsは、Agoricランタイムのセッションを再生するときに**xsnap**が保存した`.cpuprofile`ファイルを開くとクラッシュします。 diff --git a/documentation/xs/XS in C.md b/documentation/xs/XS in C.md index 67174e59b..bb5e430f5 100644 --- a/documentation/xs/XS in C.md +++ b/documentation/xs/XS in C.md @@ -36,44 +36,44 @@ --> # XS in C -Revised: November 17, 2023 +更新日: 2023年11月17日 -**See end of document for [copyright and license](#license)** +**著作権とライセンスについては[ドキュメント末尾](#license)を参照してください** -## About This Document +## このドキュメントについて -This document describes XS in C, the C interface to the runtime of the XS JavaScript engine. Information on building XS for target software/hardware platforms is provided in the companion document [XS Platforms.md](./XS%20Platforms.md). +このドキュメントでは、XS JavaScriptエンジンのランタイムへのCインターフェースであるXS in Cについて説明します。対象ソフトウェア/ハードウェアプラットフォーム用のXSのビルドに関する情報は、付属のドキュメント[XS Platforms.md](./XS%20Platforms.md)で提供されています。 -In accordance with the ECMAScript specifications, the XS runtime implements only generic features that all scripts can use. An application defines the specific features that its own scripts can use through C callbacks. An application that uses the XS runtime is a host in ECMAScript terminology. +ECMAScript仕様に従い、XSランタイムはすべてのスクリプトが使用できる汎用機能のみを実装しています。アプリケーションは、Cコールバックを通じて独自のスクリプトが使用できる特定の機能を定義します。XSランタイムを使用するアプリケーションは、ECMAScript用語でホストと呼ばれます。 -XS in C provides macros to access properties of objects. XS provides two functionally equivalent variations of many of the macros. The macros prefixed with `xs` alone are somewhat more convenient to work with but generate larger binary code whereas the macros prefixed with `xsmc` generate smaller binary code at the expense of being more difficult to use. To use the `xsmc*` macros include "xsmc.h" and do not include "xs.h". to use the macros prefixed with `xs` alone, include "xs.h" and do not include "xsmc.h". Including the `xsmc.h` header file makes the `xs` versions of some operations available. +XS in Cは、オブジェクトのプロパティにアクセスするためのマクロを提供します。XSは、多くのマクロについて機能的に同等な2つのバリエーションを提供しています。`xs`のみが前置されたマクロは作業がやや便利ですが、より大きなバイナリコードを生成します。一方、`xsmc`が前置されたマクロは、使いにくくなる代償として、より小さなバイナリコードを生成します。`xsmc*`マクロを使用するには、"xsmc.h"をインクルードし、"xs.h"をインクルードしないでください。`xs`のみが前置されたマクロを使用するには、"xs.h"をインクルードし、"xsmc.h"をインクルードしないでください。`xsmc.h`ヘッダーファイルをインクルードすると、一部の操作の`xs`バージョンが利用可能になります。 -## Table of Contents +## 目次 -* [Slots](#slots): Describes how to handle ECMAScript constructs in C callbacks, with examples that show the correspondences between ECMAScript and XS in C. - * [Slot types](#slot-types) - * [Primitives](#primitives) +* [スロット](#slots): CコールバックでECMAScript構造を処理する方法を説明し、ECMAScriptとXS in Cの対応関係を示す例を提供します。 + * [スロット型](#slot-types) + * [プリミティブ](#primitives) * [ArrayBuffer](#arraybuffer) - * [Instances and Prototypes](#instances-and-prototypes) - * [Identifiers](#identifiers) - * [Properties](#properties) - * [Arguments and Variables](#xsvars) - * [Garbage Collector](#garbage-collector) - * [Exceptions](#exceptions) - * [Errors](#errors) - * [Debugger](#debugger) -* [Machine](#machine): Introduces the main structure of the XS runtime (its virtual machine) and explains how to use the runtime to build a host and to make C callbacks available to scripts. This section concludes with an example that demonstrates how to use XS in C to implement a JavaScript class with C functions. - * [Machine Allocation](#machine-allocation) - * [Context](#context) - * [Host](#host) - * [JavaScript `@` language syntax extension](#syntax-extension) -* [Glossary](#glossary): Includes all the terms defined or referenced in this document. -* [License](#license) + * [インスタンスとプロトタイプ](#instances-and-prototypes) + * [識別子](#identifiers) + * [プロパティ](#properties) + * [引数と変数](#xsvars) + * [ガベージコレクタ](#garbage-collector) + * [例外](#exceptions) + * [エラー](#errors) + * [デバッガー](#debugger) +* [マシン](#machine): XSランタイムの主要構造(仮想マシン)を紹介し、ランタイムを使用してホストを構築し、スクリプトでCコールバックを利用可能にする方法を説明します。このセクションは、XS in CでC関数を使用してJavaScriptクラスを実装する方法を示す例で締めくくられます。 + * [マシン割り当て](#machine-allocation) + * [コンテキスト](#context) + * [ホスト](#host) + * [JavaScript `@` 言語構文拡張](#syntax-extension) +* [用語集](#glossary): このドキュメントで定義または参照されているすべての用語が含まれます。 +* [ライセンス](#license) -## Slots +## スロット -In the XS runtime, the *slot* is a fundamental storage unit. A slot is an opaque structure that is manipulated only through XS in C. +XSランタイムでは、*スロット*は基本的なストレージ単位です。スロットは、XS in Cを通じてのみ操作される不透明な構造です。 ```c typedef struct xsSlotRecord xsSlot @@ -83,9 +83,9 @@ struct xsSlotRecord { ``` -### Slot types +### スロット型 -There are eleven types of slots: +スロットには11種類あります: ```c enum { @@ -104,7 +104,7 @@ enum { typedef char xsType; ``` -The undefined, null, boolean, number, string, symbol, and bigint slots correspond to the ECMAScript primitive types. The reference slot corresponds to the ECMAScript `reference` type. The integer, stringx and bigintx slots are optimizations that are unobservable by scripts. The integer slot is equivalent to the number slot, but allowing floating point operations to be bypassed. The stringx slot is equivalent to the string slot, but uses a string in place (e.g. in ROM) without making a copy. The bigintx slot is equivalent to the bigint slot, but uses a bigint in place (e.g. in ROM) without making a copy. +undefined、null、boolean、number、string、symbol、bigintスロットは、ECMAScriptプリミティブ型に対応します。referenceスロットは、ECMAScript `reference`型に対応します。integer、stringx、bigintxスロットは、スクリプトでは観察できない最適化です。integerスロットはnumberスロットと同等ですが、浮動小数点演算をバイパスできます。stringxスロットはstringスロットと同等ですが、コピーを作成せずに(例:ROM内の)文字列をその場で使用します。bigintxスロットはbigintスロットと同等ですが、コピーを作成せずに(例:ROM内の)bigintをその場で使用します。 ##### In ECMAScript: @@ -130,18 +130,18 @@ xsNumber(0.0); xsString("foo"); ``` -The `xsTypeOf` macro returns the type of a slot. It is similar to the ECMAScript `typeof` keyword. +`xsTypeOf`マクロは、スロットの型を返します。これはECMAScript `typeof`キーワードに似ています。 **`xsType xsTypeOf(xsSlot theSlot)`**
**`xsType xsmcTypeOf(xsSlot theSlot)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot`| The slot to test +| `theSlot`| テストするスロット -Returns the type of the slot +スロットの型を返します -> **Note**: The macros in the XS in C API require a reference to the target virtual machine in a variable in the current scope with the name `the` of type `xsMachine *`. +> **注意**: XS in C APIのマクロは、現在のスコープ内で`xsMachine *`型の`the`という名前の変数にターゲット仮想マシンへの参照が必要です。 ##### In ECMAScript: @@ -179,369 +179,369 @@ switch(xsTypeOf(xsArg(0))) { ``` -### Primitives +### プリミティブ -The undefined, null, boolean, integer, number, string, and symbol slots (collectively known as *direct slots*) correspond to the ECMAScript primitive types, with the integer and stringx slots added as optimizations. +undefined、null、boolean、integer、number、string、symbolスロット(総称して*ダイレクトスロット*と呼ばれる)は、ECMAScriptプリミティブ型に対応し、integerとstringxスロットは最適化として追加されています。 -#### Undefined and null +#### Undefinedとnull -The undefined and null slots contain no value. The `xsUndefined` and `xsNull` macros return slots of those types. +undefinedとnullスロットは値を含みません。`xsUndefined`と`xsNull`マクロは、これらの型のスロットを返します。 **`xsSlot xsUndefined`** -Returns an undefined slot +undefinedスロットを返します *** **`void xsmcSetUndefined(xsSlot theSlot)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The slot to set to `undefined` +| `theSlot` | `undefined`に設定するスロット -Sets the specified slot value to `undefined` +指定されたスロットの値を`undefined`に設定します *** **`xsSlot xsNull`** -Returns a null slot +nullスロットを返します *** **`void xsmcSetNull(xsSlot theSlot)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The slot to set to `null` +| `theSlot` | `null`に設定するスロット -Sets the specified slot value to `null` +指定されたスロットの値を`null`に設定します *** -#### Booleans, integers, and numbers +#### ブール値、整数、数値 -These slots contain values of the corresponding type. +これらのスロットは対応する型の値を含みます。 typedef char xsBooleanValue; typedef long xsIntegerValue; typedef double xsNumberValue; -The following macros return slots of each of these types (set to a particular value) or access/set the value in a slot. When accessing the value in a slot, you specify a desired type; the slot is coerced to the requested type if necessary, and the value is returned. +以下のマクロは、これらの各型のスロット(特定の値に設定)を返すか、スロット内の値にアクセス/設定します。スロット内の値にアクセスするときは、希望する型を指定します。必要に応じてスロットは要求された型に変換され、値が返されます。 **`xsSlot xsTrue`** -Returns a boolean slot containing `true` +`true`を含むブールスロットを返します *** **`xsSlot xsFalse`** -Returns a boolean slot containing `false` +`false`を含むブールスロットを返します *** **`xsSlot xsBoolean(xsBooleanValue theValue)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theValue` | The value to be contained in the slot +| `theValue` | スロットに含める値 -Returns a boolean slot +ブールスロットを返します *** **`xsBooleanValue xsToBoolean(xsSlot theSlot)`**
**`xsBooleanValue xsmcToBoolean(xsSlot theSlot)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The slot to coerce to boolean +| `theSlot` | ブール値に変換するスロット -Returns the value contained in the slot +スロットに含まれる値を返します *** **`void xsmcSetFalse(xsSlot theSlot)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The slot to set false +| `theSlot` | falseに設定するスロット -Sets the slot value to `false` +スロットの値を`false`に設定します *** **`void xsmcSetTrue(xsSlot theSlot)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The slot to set true +| `theSlot` | trueに設定するスロット -Sets the slot value to `true` +スロットの値を`true`に設定します *** **`void xsmcSetBoolean(xsSlot theSlot, xsBooleanValue theValue)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The slot to set -| `theValue` | The boolean `true` or `false` value to set +| `theSlot` | 設定するスロット +| `theValue` | 設定するブール値`true`または`false` -Sets the slot value to `true` or `false` +スロットの値を`true`または`false`に設定します *** **`xsSlot xsInteger(xsIntegerValue theValue)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theValue` | The value to be contained in the slot +| `theValue` | スロットに含める値 -Returns an integer slot +整数スロットを返します *** **`xsIntegerValue xsToInteger(xsSlot theSlot)`**
**`xsIntegerValue xsmcToInteger(xsSlot theSlot)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The slot to coerce to integer +| `theSlot` | 整数に変換するスロット -Returns the value contained in the slot +スロットに含まれる値を返します *** **`void xsmcSetInteger(xsSlot theSlot, xsIntegerValue theValue)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The slot to set -| `theValue` | The integer value to set +| `theSlot` | 設定するスロット +| `theValue` | 設定する整数値 -Sets the slot value to an integer +スロットの値を整数に設定します *** **`xsSlot xsNumber(xsNumberValue theValue)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theValue` | The value to be contained in the slot +| `theValue` | スロットに含める値 -Returns a number slot +数値スロットを返します *** **`xsNumberValue xsToNumber(xsSlot theSlot)`**
**`xsNumberValue xsmcToNumber(xsSlot theSlot)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The slot to coerce to number +| `theSlot` | 数値に変換するスロット -Returns the value contained in the slot +スロットに含まれる値を返します *** **`void xsmcSetNumber(xsSlot theSlot, xsNumberValue theValue)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The slot to set -| `theValue` | The number value to set +| `theSlot` | 設定するスロット +| `theValue` | 設定する数値 -Sets the slot value to a number +スロットの値を数値に設定します *** -#### Strings +#### 文字列 -These slots contain values of the corresponding type. +これらのスロットは対応する型の値を含みます。 ```c typedef char* xsStringValue; ``` -A string value is a pointer to a UTF-8 C string. The XS runtime virtual machine and the garbage collector manage UTF-8 C strings used by scripts. +文字列値はUTF-8 C文字列へのポインタです。XSランタイム仮想マシンとガベージコレクタは、スクリプトが使用するUTF-8 C文字列を管理します。 **`xsSlot xsString(xsStringValue theValue)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theValue` | The value to be contained in the slot +| `theValue` | スロットに含める値 -Returns a string slot +文字列スロットを返します -C constants, C globals, or C locals can safely be passed to the `xsString` macro, since it duplicates its parameter. +`xsString`マクロはパラメータを複製するため、C定数、Cグローバル、またはCローカルを安全に渡すことができます。 *** **`xsStringValue xsToString(xsSlot theSlot)`**
**`xsStringValue xsmcToString(xsSlot theSlot)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The slot to coerce to string +| `theSlot` | 文字列に変換するスロット -Returns the string contained in the slot +スロットに含まれる文字列を返します -For speed, the `xsToString` macro returns the value contained in the slot itself, a pointer to the string in the memory managed by XS. Since the XS runtime can compact memory containing string values, the result of the `xsToString` macro cannot be used across or in other macros of XS in C. The ECMAScript language specification forbids modifying the string in place. +速度のため、`xsToString`マクロはスロット自体に含まれる値、つまりXSが管理するメモリ内の文字列へのポインタを返します。XSランタイムは文字列値を含むメモリを圧縮できるため、`xsToString`マクロの結果は、XS in Cの他のマクロをまたいで使用することはできません。ECMAScript言語仕様は、文字列のインプレース修正を禁止しています。 *** **`void xsmcSetString(xsSlot theSlot, xsStringValue theValue)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The slot to set -| `theValue` | The string value to set +| `theSlot` | 設定するスロット +| `theValue` | 設定する文字列値 -Sets the slot value to a string +スロットの値を文字列に設定します *** **`xsStringValue xsToStringBuffer(xsSlot theSlot, xsStringValue theBuffer, xsIntegerValue theSize)`**
**`xsStringValue xsmcToStringBuffer(xsSlot theSlot, xsStringValue theBuffer, xsIntegerValue theSize)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The slot to coerce to string -| `theBuffer` | A buffer to copy the string into -| `theSize` | The size of the buffer +| `theSlot` | 文字列に変換するスロット +| `theBuffer` | 文字列をコピーするバッファ +| `theSize` | バッファのサイズ -Copies the string value and returns the buffer containing the copy of the string. The buffer provided has to be large enough to hold a copy of the string value. +文字列値をコピーし、文字列のコピーを含むバッファを返します。提供されるバッファは、文字列値のコピーを保持するのに十分な大きさでなければなりません。 *** **`xsSlot xsStringBuffer(void *theData, xsIntegerValue theSize)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theData` | A pointer to the data to copy into the string buffer, or `NULL` to leave the string buffer data uninitialized -| `theSize` | The data size to copy in bytes +| `theData` | 文字列バッファにコピーするデータへのポインタ、または文字列バッファデータを未初期化のままにする場合は`NULL` +| `theSize` | コピーするデータサイズ(バイト単位) -Copies the string into an allocated buffer, sets a slot value to the string buffer, and returns a reference to the new string buffer instance. +文字列を割り当てられたバッファにコピーし、スロット値を文字列バッファに設定し、新しい文字列バッファインスタンスへの参照を返します。 *** **`void xsmcSetStringBuffer(xsSlot theSlot, xsStringValue theValue, xsIntegerValue theSize)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The slot to set -| `theValue` | The string value to set -| `theSize` | The size of the string in bytes +| `theSlot` | 設定するスロット +| `theValue` | 設定する文字列値 +| `theSize` | 文字列のサイズ(バイト単位) -Copies the string into an allocated buffer and sets the slot value to the string buffer. +文字列を割り当てられたバッファにコピーし、スロット値を文字列バッファに設定します。 *** ### ArrayBuffer -In ECMAScript an `ArrayBuffer` is commonly used to store fixed length binary data. +ECMAScriptでは、`ArrayBuffer`は固定長のバイナリデータを格納するために一般的に使用されます。 -#### Macros +#### マクロ **`xsSlot xsArrayBuffer(void *theData, xsIntegerValue theSize)`** **`void xsmcSetArrayBuffer(xsSlot theSlot, void *theData, xsIntegerValue theSize)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theData` | A pointer to the data to copy into the `ArrayBuffer`, or `NULL` to leave the `ArrayBuffer` data uninitialized -| `theSize` | The size of the data in bytes +| `theData` | `ArrayBuffer`にコピーするデータへのポインタ、または`ArrayBuffer`データを未初期化のままにする場合は`NULL` +| `theSize` | データのサイズ(バイト単位) -Creates an `ArrayBuffer` instance and returns a reference to the new `ArrayBuffer` instance +`ArrayBuffer`インスタンスを作成し、新しい`ArrayBuffer`インスタンスへの参照を返します *** **`void xsGetArrayBufferData(xsSlot theSlot, xsIntegerValue theOffset, void *theData, xsIntegerValue theSize)`**
**`void xsmcGetArrayBufferData(xsSlot theSlot, xsIntegerValue theOffset, void *theData, xsIntegerValue theSize)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The `ArrayBuffer` slot -| `theOffset` | The starting byte offset to get the data -| `theData` | The data pointer to get the `ArrayBuffer` data -| `theSize` | The data size to copy in bytes +| `theSlot` | `ArrayBuffer`スロット +| `theOffset` | データを取得する開始バイトオフセット +| `theData` | `ArrayBuffer`データを取得するデータポインタ +| `theSize` | コピーするデータサイズ(バイト単位) -Copies bytes from the `ArrayBuffer` +`ArrayBuffer`からバイトをコピーします *** **`void xsSetArrayBufferData(xsSlot theSlot, xsIntegerValue theOffset, void *theData, xsIntegerValue theSize)`**
**`void xsmcSetArrayBufferData(xsSlot theSlot, xsIntegerValue theOffset, void *theData, xsIntegerValue theSize)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The `ArrayBuffer` slot -| `theOffset` | The starting byte offset to set the data -| `theData` | The data pointer to set the `ArrayBuffer` data -| `theSize` | The data size to copy in bytes +| `theSlot` | `ArrayBuffer`スロット +| `theOffset` | データを設定する開始バイトオフセット +| `theData` | `ArrayBuffer`データを設定するデータポインタ +| `theSize` | コピーするデータサイズ(バイト単位) -Copies bytes into the `ArrayBuffer` +`ArrayBuffer`にバイトをコピーします *** **`void xsmcSetArrayBuffer(xsSlot theSlot, void *theData, xsIntegerValue theSize)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The `ArrayBuffer` slot -| `theData` | The data pointer to set the `ArrayBuffer` data -| `theSize` | The data size to copy in bytes +| `theSlot` | `ArrayBuffer`スロット +| `theData` | `ArrayBuffer`データを設定するデータポインタ +| `theSize` | コピーするデータサイズ(バイト単位) -Creates an `ArrayBuffer` instance initialized from the provided data +提供されたデータから初期化された`ArrayBuffer`インスタンスを作成します *** **`xsIntegerValue xsGetArrayBufferLength(xsSlot theSlot)`**
**`xsIntegerValue xsmcGetArrayBufferLength(xsSlot theSlot)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The `ArrayBuffer` slot +| `theSlot` | `ArrayBuffer`スロット -Returns the size of the `ArrayBuffer` in bytes +`ArrayBuffer`のサイズをバイト単位で返します *** **`void xsSetArrayBufferLength(xsSlot theSlot, xsIntegerValue theSize)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The `ArrayBuffer` slot -| `theSize` | The size of the `ArrayBuffer` data in bytes. If the size of the buffer is increased, the new data is initialized to 0. +| `theSlot` | `ArrayBuffer`スロット +| `theSize` | `ArrayBuffer`データのサイズ(バイト単位)。バッファのサイズが増加される場合、新しいデータは0に初期化されます。 -Sets the length of the `ArrayBuffer` +`ArrayBuffer`の長さを設定します *** **`void *xsToArrayBuffer(xsSlot theSlot)`**
**`void *xsmcToArrayBuffer(xsSlot theSlot)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The `ArrayBuffer` slot +| `theSlot` | `ArrayBuffer`スロット -Returns a pointer to the `ArrayBuffer` data +`ArrayBuffer`データへのポインタを返します -For speed, the `xsToArrayBuffer ` macro returns the value contained in the slot itself, a pointer to the buffer in the memory managed by XS. Since the XS runtime can compact memory containing string values, the result of the `xsToArrayBuffer ` macro cannot be used across or in other macros of XS in C. +速度のため、`xsToArrayBuffer`マクロはスロット自体に含まれる値、つまりXSが管理するメモリ内のバッファへのポインタを返します。XSランタイムは文字列値を含むメモリを圧縮できるため、`xsToArrayBuffer`マクロの結果は、XS in Cの他のマクロをまたいで使用することはできません。 *** -### Instances and Prototypes +### インスタンスとプロトタイプ -In XS in C, as in ECMAScript, an object can inherit properties from another object, which can inherit from another object, and so on; the inheriting object is the *instance*, and the object from which it inherits is the *prototype*. +XS in Cでは、ECMAScriptと同様に、オブジェクトは他のオブジェクトからプロパティを継承でき、そのオブジェクトはさらに他のオブジェクトから継承できます。継承するオブジェクトは*インスタンス*であり、継承元のオブジェクトは*プロトタイプ*です。 -Reference slots (type `xsReferenceType`) are *indirect* slots: they contain a reference to an instance of an object, function, array, and so on. Instances themselves are made of slots that are the properties of the instance (or, for an array, the items of the instance). +参照スロット(型`xsReferenceType`)は*間接*スロットであり、オブジェクト、関数、配列などのインスタンスへの参照を含みます。インスタンス自体は、インスタンスのプロパティ(または配列の場合はインスタンスのアイテム)であるスロットで構成されます。 -#### Macros +#### マクロ **`xsSlot xsObjectPrototype`**
**`xsSlot xsFunctionPrototype`**
@@ -570,26 +570,26 @@ Reference slots (type `xsReferenceType`) are *indirect* slots: they contain a re **`xsSlot xsPromisePrototype`**
**`xsSlot xsProxyPrototype`**
-Returns a reference to the prototype instance created by the XS runtime. +XSランタイムによって作成されたプロトタイプインスタンスへの参照を返します。 *** **`xsSlot xsNewArray(xsIntegerValue theLength)`**
**`xsSlot xsmcNewArray(xsIntegerValue theLength)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theLength` | The array length property to set +| `theLength` | 設定する配列のlengthプロパティ -Creates an array instance, and returns a reference to the new array instance +配列インスタンスを作成し、新しい配列インスタンスへの参照を返します -##### In ECMAScript: +##### ECMAScriptで: ```javascript new Array(5); ``` -##### In C: +##### Cで: ```c xsNewArray(5); @@ -600,15 +600,15 @@ xsNewArray(5); **`xsSlot xsNewObject()`**
**`xsSlot xsmcNewObject()`** -Creates an object instance, and returns a reference to the new object instance +オブジェクトインスタンスを作成し、新しいオブジェクトインスタンスへの参照を返します -##### In ECMAScript: +##### ECMAScriptでは: ```javascript new Object(); ``` -##### In C: +##### Cでは: ```c xsNewObject(); @@ -618,19 +618,19 @@ xsNewObject(); **`void xsmcSetNewObject(theSlot theSlot)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The result slot +| `theSlot` | 結果スロット -The `xsmcSetNewObject` macro is functionally equivalent to the `xsNewObject` macro. The property is returned in the slot provided. +`xsmcSetNewObject`マクロは`xsNewObject`マクロと機能的に同等です。プロパティは提供されたスロットに返されます。 -##### In ECMAScript: +##### ECMAScriptでは: ```javascript new Object(); ``` -##### In C: +##### Cでは: ```c xsmcVars(1); @@ -642,23 +642,23 @@ xsmcSetNewObject(xsVar(0)); **`xsBooleanValue xsIsInstanceOf(xsSlot theInstance, xsSlot thePrototype)`**
**`xsBooleanValue xsmcIsInstanceOf(xsSlot theInstance, xsSlot thePrototype)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theInstance` | A reference to the instance to test -| `thePrototype` | A reference to the prototype to test +| `theInstance` | テストするインスタンスへの参照 +| `thePrototype` | テストするプロトタイプへの参照 -Tests whether an instance has a particular prototype, directly or indirectly (that is, one or more levels up in the prototype hierarchy). Returns `true` if the instance has the prototype, `false` otherwise. +インスタンスが特定のプロトタイプを持っているかどうかを、直接的または間接的に(つまり、プロトタイプ階層の1つまたは複数のレベル上で)テストします。インスタンスがプロトタイプを持っている場合は`true`、そうでなければ`false`を返します。 -The `xsIsInstanceOf` macro has no equivalent in ECMAScript; scripts test instances through *constructors* rather than directly through prototypes. A constructor is a function that has a `prototype` property that is used to test instances with `isPrototypeOf`. +`xsIsInstanceOf`マクロにはECMAScriptでの同等のものがありません。スクリプトは、プロトタイプを直接使用するのではなく、*コンストラクタ*を通じてインスタンスをテストします。コンストラクタは、`isPrototypeOf`でインスタンスをテストするために使用される`prototype`プロパティを持つ関数です。 -##### In ECMAScript: +##### ECMAScriptでは: ```javascript if (Object.prototype.isPrototypeOf(this)) return new Object(); ``` -##### In C: +##### Cでは: ```c if (xsIsInstanceOf(xsThis, xsObjectPrototype)) @@ -668,45 +668,45 @@ if (xsIsInstanceOf(xsThis, xsObjectPrototype)) *** -### Keys, Identifiers and Indexes +### キー、識別子、インデックス -In ECMAScript, the properties of an object are identified by number, string or symbol values – a.k.a. the property **key**. In XS in C you can access properties with property keys through the `xsGetAt`, `xsSetAt`, etc macros described below. +ECMAScriptでは、オブジェクトのプロパティは数値、文字列、またはシンボル値(プロパティ**キー**)によって識別されます。XS in Cでは、以下で説明する`xsGetAt`、`xsSetAt`などのマクロを通じて、プロパティキーでプロパティにアクセスできます。 -If the number or string value of a property key can be converted into a 32-bit unsigned integer, XS uses the result of the conversion – a.k.a. the property **index** — to identify the property. In XS in C, you can access properties directy with property indexes through the `xsGetIndex`, `xsSetIndex`, etc macros described below. A property index can be used with all instances but is typically used to access items of `Array` instances. +プロパティキーの数値または文字列値が32ビット符号なし整数に変換できる場合、XSは変換の結果(プロパティ**インデックス**)を使用してプロパティを識別します。XS in Cでは、以下で説明する`xsGetIndex`、`xsSetIndex`などのマクロを通じて、プロパティインデックスで直接プロパティにアクセスできます。プロパティインデックスはすべてのインスタンスで使用できますが、通常は`Array`インスタンスの項目にアクセスするために使用されます。 ```c typedef uint32_t xsIndex; ``` -Otherwise the string or symbol value of a property key is stored into a table and XS uses the resulting table index – a.k.a. the property **identifier** — to identify the property. In XS in C, you can access properties directy with property identifiers through the `xsGet`, `xsSet` etc macros described below. +それ以外の場合、プロパティキーの文字列またはシンボル値がテーブルに格納され、XSは結果のテーブルインデックス(プロパティ**識別子**)を使用してプロパティを識別します。XS in Cでは、以下で説明する`xsGet`、`xsSet`などのマクロを通じて、プロパティ識別子で直接プロパティにアクセスできます。 ```c typedef uint16_t xsIdentifier; ``` -On 64-bit platforms, the number of available identifiers can be extended to 32-bit and `xsIdentifier` becomes `uint32_t`. +64ビットプラットフォームでは、利用可能な識別子の数を32ビットまで拡張でき、`xsIdentifier`は`uint32_t`になります。 -#### Macros +#### マクロ **`xsIdentifier xsID(xsStringValue theValue)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theValue` | The string to convert +| `theValue` | 変換する文字列 -Converts a string value into an identifier and returns the identifier. For a given virtual machine, the same string value is always converted to the same identifier, so you can cache frequently used identifiers by virtual machine. +文字列値を識別子に変換し、識別子を返します。特定の仮想マシンについて、同じ文字列値は常に同じ識別子に変換されるため、頻繁に使用される識別子を仮想マシンごとにキャッシュできます。 -For performance, XS in C also supports accessing properties by identifiers generated by the XS compiler, e.g. `xsID_property`. The type of the `xsID_*` identifiers is `xsIdentifier`. These identifiers provide an optimization that can be used by the `xsGet`, `xsSet`, etc macros described below. the `xsID_*` properties are functionally equivalent to using the `xsID()` macro and used in all the examples. +パフォーマンスのため、XS in CはXSコンパイラによって生成された識別子(例:`xsID_property`)によるプロパティアクセスもサポートしています。`xsID_*`識別子の型は`xsIdentifier`です。これらの識別子は、以下で説明する`xsGet`、`xsSet`などのマクロで使用できる最適化を提供します。`xsID_*`プロパティは`xsID()`マクロの使用と機能的に同等であり、すべての例で使用されています。 -In the C examples below, the `xsGet` macro (discussed in the next section) takes as its second argument the identifier of the property or item to get. +以下のCの例では、`xsGet`マクロ(次のセクションで説明)は、取得するプロパティまたは項目の識別子を2番目の引数として受け取ります。 -##### In ECMAScript: +##### ECMAScriptでは: ```javascript this.foo ``` -##### In C: +##### Cでは: ```c xsGet(xsThis, xsID("foo")); @@ -717,119 +717,119 @@ xsGet(xsThis, xsID_foo); **`xsBooleanValue xsIsID(xsStringValue theValue)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theValue` | The string to test +| `theValue` | テストする文字列 -Tests whether a given string corresponds to an existing property identifier. Returns `true` if the string is a property identifier, `false` otherwise. +指定された文字列が既存のプロパティ識別子に対応するかどうかをテストします。文字列がプロパティ識別子である場合は`true`、そうでなければ`false`を返します。 *** -### Properties +### プロパティ -This section describes the macros related to accessing properties of objects (or items of arrays), as summarized in Table 1. +このセクションでは、表1にまとめられているように、オブジェクトのプロパティ(または配列の項目)にアクセスするためのマクロについて説明します。 -**Table 1.** Property-Related Macros +**表1.** プロパティ関連マクロ - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - +
MacroDescriptionマクロ説明
xsGlobalReturns a special instance made of global properties available to scriptsスクリプトで利用可能なグローバルプロパティで構成される特別なインスタンスを返します
xsDefine, xsmcDefineDefines a new property of an instance with an identifier and attributes識別子と属性を使用してインスタンスの新しいプロパティを定義します
xsDefineAtDefines a new property or item of an instance with a key and attributesキーと属性を使用してインスタンスの新しいプロパティまたは項目を定義します
xsHas, xsmcHasTests whether an instance has a property corresponding to a particular identifierインスタンスが特定の識別子に対応するプロパティを持っているかどうかをテストします
xsHasAtTests whether an instance has a property corresponding to a particular keyインスタンスが特定のキーに対応するプロパティを持っているかどうかをテストします
xsHasIndex, xsmcHasIndexTests whether an instance has a property corresponding to a particular indexインスタンスが特定のインデックスに対応するプロパティを持っているかどうかをテストします
xsGet, xsmcGetGets a property of an instance by identifier識別子によってインスタンスのプロパティを取得します
xsGetAt, xsmcGetAtGets a property or an instance by keyキーによってプロパティまたはインスタンスを取得します
xsGetIndex, xsmcGetIndexGets a property or an instance by indexインデックスによってプロパティまたはインスタンスを取得します
xsSet, xsmcSetSets a property of an instance with an identifier識別子を使用してインスタンスのプロパティを設定します
xsSetAt, xsmcSetAtSets a property of an instance with a key キーを使用してインスタンスのプロパティを設定します
xsSetIndex, xsmcSetIndexSets an property of an instance with an indexインデックスを使用してインスタンスのプロパティを設定します
xsDelete, xsmcDeleteDeletes a property corresponding to a particular identifier 特定の識別子に対応するプロパティを削除します
xsDeleteAt, xsmcDeleteAtDeletes a property corresponding to a particular key特定のキーに対応するプロパティを削除します
xsCall0 ... xsCall7, xsmcCallCalls the function referred to by a property of an instanceインスタンスのプロパティによって参照される関数を呼び出します
xsNew0 ... xsNew7, xsmcNewCalls the constructor referred to by a property of an instanceインスタンスのプロパティによって参照されるコンストラクタを呼び出します
xsTest, xsmcTestTakes a value of any type and determines whether it is true or false任意の型の値を受け取り、それがtrueかfalseかを判定します
xsEnumerateEnumerates the properties of an instanceインスタンスのプロパティを列挙します
-> Some of the examples below use variable slots reserved on the stack with the `xsVars` macro; See [`Arguments and Variables`](#xsvars). +> 以下の例の一部では、`xsVars`マクロでスタックに確保された変数スロットを使用します。[`引数と変数`](#xsvars)を参照してください。 #### xsGlobal -Globals available to scripts are properties of a special instance referred to using the `xsGlobal` macro in XS in C. +スクリプトで利用可能なグローバルは、XS in Cで`xsGlobal`マクロを使用して参照される特別なインスタンスのプロパティです。 **`xsSlot xsGlobal`** -Returns a reference to the special instance made of globals +グローバルで構成される特別なインスタンスへの参照を返します -You can use the `xsGet`, `xsSet`, `xsDelete`, `xsCall*`, and `xsNew*` macros with the `xsGlobal` macro as the first parameter. Examples are shown in the sections describing those macros. +`xsGlobal`マクロを最初のパラメータとして、`xsGet`、`xsSet`、`xsDelete`、`xsCall*`、`xsNew*`マクロを使用できます。これらのマクロを説明するセクションで例を示します。 *** #### xsDefine -To define a new property of an instance with an identifier and attributes, use the `xsDefine` macro. The attributes of the property are set using one or more of the following constants. +識別子と属性を使用してインスタンスの新しいプロパティを定義するには、`xsDefine`マクロを使用します。プロパティの属性は、以下の定数の1つまたは複数を使用して設定されます。 ```c enum { @@ -848,26 +848,26 @@ typedef unsigned char xsAttribute; **`void xsDefine(xsSlot theThis, xsIdentifier theID, xsSlot theParam, xsAttribute theAttributes)`** **`void xsmcDefine(xsSlot theThis, xsIdentifier theID, xsSlot theParam, xsAttribute theAttributes)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theThis` | A reference to the instance that will have the property -| `theID` | The identifier of the property to define -| `theParam` | The value of the property to define -| `theAttributes` | A combination of attributes to set. +| `theThis` | プロパティを持つインスタンスへの参照 +| `theID` | 定義するプロパティの識別子 +| `theParam` | 定義するプロパティの値 +| `theAttributes` | 設定する属性の組み合わせ -For `theAttributes`, specify the constants corresponding to the attributes you want to set (the others being cleared). +`theAttributes`については、設定したい属性に対応する定数を指定します(その他はクリアされます)。 -The `xsDontDelete`, `xsDontEnum`, and `xsDontSet` attributes correspond to the ECMAScript `configurable`, `enumerable`, and `writable` attributes. By default a property can be deleted, enumerated, and set. +`xsDontDelete`、`xsDontEnum`、`xsDontSet`属性は、ECMAScriptの`configurable`、`enumerable`、`writable`属性に対応します。デフォルトでは、プロパティは削除、列挙、設定が可能です。 -When a property is created, if the prototype of the instance has a property with the same name, its attributes are inherited; otherwise, by default, a property can be deleted, enumerated, and set, and can be used by scripts. +プロパティが作成されるとき、インスタンスのプロトタイプに同じ名前のプロパティがある場合、その属性が継承されます。そうでなければ、デフォルトで、プロパティは削除、列挙、設定が可能で、スクリプトで使用できます。 -##### In ECMAScript: +##### ECMAScriptでは: ```javascript Object.defineProperty(this, "foo", 7, { writable: true, enumerable: true, configurable: true }); ``` -##### In C: +##### Cでは: ```c xsDefine(xsThis, xsID{"foo"), xsInteger(7), xsDefault); @@ -877,25 +877,25 @@ xsDefine(xsThis, xsID{"foo"), xsInteger(7), xsDefault); #### xsDefineAt -To define a new property or item of an instance with a key and attributes, use the `xsDefineAt` macro. The `xsDefineAt` macro is functionally equivalent to the `xsDefine` macro, except that a slot is used to identify the property or item to define. +キーと属性を使用してインスタンスの新しいプロパティまたは項目を定義するには、`xsDefineAt`マクロを使用します。`xsDefineAt`マクロは`xsDefine`マクロと機能的に同等ですが、定義するプロパティまたは項目を識別するためにスロットが使用される点が異なります。 **`void xsDefineAt(xsSlot theThis, xsSlot theSlot, xsSlot theParam, xsAttribute theAttributes)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theThis` | A reference to the instance that will have the property -| `theKey` | The key of the property to define -| `theParam` | The value of the property to define -| `theAttributes` | A combination of attributes to set. +| `theThis` | プロパティを持つインスタンスへの参照 +| `theKey` | 定義するプロパティのキー +| `theParam` | 定義するプロパティの値 +| `theAttributes` | 設定する属性の組み合わせ -##### In ECMAScript: +##### ECMAScriptでは: ```javascript Object.defineProperty(this, "foo", 7, { writable: true, enumerable: true, configurable: true }); Object.defineProperty(this, 5, 7, { writable: true, enumerable: true, configurable: true }); ``` -##### In C: +##### Cでは: ```c xsDefineAt(xsThis, xsString("foo"), xsInteger(7), xsDefault); @@ -905,26 +905,26 @@ xsDefineAt(xsThis, xsInteger(5), xsInteger(7), xsDefault); #### xsHas -To test whether an instance has a property corresponding to a particular identifier, use the `xsHas` macro. This macro is similar to the ECMAScript `in` keyword. +インスタンスが特定の識別子に対応するプロパティを持っているかどうかをテストするには、`xsHas`マクロを使用します。このマクロはECMAScriptの`in`キーワードに似ています。 **`xsBooleanValue xsHas(xsSlot theThis, xsIdentifier theID)`**
**`xsBooleanValue xsmcHas(xsSlot theThis, xsIdentifier theID)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theThis` | A reference to the instance to test -| `theID` | The identifier of the property to test +| `theThis` | テストするインスタンスへの参照 +| `theID` | テストするプロパティの識別子 -Returns `true` if the instance has the property, `false` otherwise +インスタンスがプロパティを持っている場合は`true`、そうでなければ`false`を返します -##### In ECMAScript: +##### ECMAScriptでは: ```javascript if ("foo" in this) ; ``` -##### In C: +##### Cでは: ```c if (xsHas(xsThis, xsID("foo")) @@ -935,19 +935,19 @@ if (xsHas(xsThis, xsID("foo")) #### xsHasAt -To test whether an instance has a property corresponding to a particular key, use the `xsHasAt` macro. +インスタンスが特定のキーに対応するプロパティを持っているかどうかをテストするには、`xsHasAt`マクロを使用します。 **`xsBooleanValue xsmcHasAt(xsSlot theThis, xsSlot theKey)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theThis` | A reference to the instance to test -| `theKey` | The key of the property to test +| `theThis` | テストするインスタンスへの参照 +| `theKey` | テストするプロパティのキー -Returns `true` if the instance has the property, `false` otherwise +インスタンスがプロパティを持っている場合は`true`、そうでなければ`false`を返します -##### In ECMAScript: +##### ECMAScriptでは: ```javascript if ("foo" in this) @@ -956,7 +956,7 @@ if (5 in this) ; ``` -##### In C: +##### Cでは: ```c if (xsHasAt(xsThis, xsString("foo")) @@ -969,26 +969,26 @@ if (xsHasAt(xsThis, xsInteger(5)) #### xsHasIndex -To test whether an instance has a property corresponding to a particular index, use the `xsHasIndex` macro. This macro is similar to the ECMAScript `in` keyword. +インスタンスが特定のインデックスに対応するプロパティを持っているかどうかをテストするには、`xsHasIndex`マクロを使用します。このマクロはECMAScriptの`in`キーワードに似ています。 **`xsBooleanValue xsHasIndex(xsSlot theThis, xsIndex theIndex)`**
**`xsBooleanValue xsmcHasIndex(xsSlot theThis, xsIndex theIndex)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theThis` | A reference to the instance to test -| `theIndex` | The index of the property to test +| `theThis` | テストするインスタンスへの参照 +| `theIndex` | テストするプロパティのインデックス -Returns `true` if the instance has the property, `false` otherwise +インスタンスがプロパティを持っている場合は`true`、そうでなければ`false`を返します -##### In ECMAScript: +##### ECMAScriptでは: ```javascript if (7 in this) ; ``` -##### In C: +##### Cでは: ```c if (xsHasIndex(xsThis, 7)); @@ -999,25 +999,25 @@ if (xsHasIndex(xsThis, 7)); #### xsGet -To get a property of an instance by identifer, use the `xsGet` macro. +識別子によってインスタンスのプロパティを取得するには、`xsGet`マクロを使用します。 **`xsSlot xsGet(xsSlot theThis, xsIdentifier theID)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theThis` | A reference to the instance that has the property -| `theID` | The identifier of the property to get +| `theThis` | プロパティを持つインスタンスへの参照 +| `theID` | 取得するプロパティの識別子 -Returns a slot containing what is contained in the property, or `xsUndefined` if the property is not defined by the instance or its prototypes +プロパティに含まれる内容を含むスロットを返します。インスタンスまたはそのプロトタイプによってプロパティが定義されていない場合は`xsUndefined`を返します -##### In ECMAScript: +##### ECMAScriptでは: ```javascript foo this.foo ``` -##### In C: +##### Cでは: ```c xsVars(1);) @@ -1030,24 +1030,24 @@ xsVar(0) = xsGet(xsThis, xsID("foo")); #### xsmcGet -The `xsmcGet` macro is functionally equivalent to the `xsGet` macro. The property is returned in the slot provided. +`xsmcGet`マクロは`xsGet`マクロと機能的に同等です。プロパティは提供されたスロットに返されます。 **`void xsmcGet(xsSlot theSlot, xsSlot theThis, xsIdentifier theID)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The slot to contain the property or item -| `theThis` | A reference to the instance that has the property -| `theID` | The identifier of the property to get +| `theSlot` | プロパティまたは項目を含むスロット +| `theThis` | プロパティを持つインスタンスへの参照 +| `theID` | 取得するプロパティの識別子 -##### In ECMAScript: +##### ECMAScriptでは: ```javascript foo this.foo ``` -##### In C: +##### Cでは: ```c xsmcVars(1); @@ -1059,25 +1059,25 @@ xsmcGet(xsVar(0), xsThis, xsID("foo")); #### xsGetAt -To get a property of an instance by key, use the `xsGetAt` macro. +キーによってインスタンスのプロパティを取得するには、`xsGetAt`マクロを使用します。 **`xsSlot xsGetAt(xsSlot theThis, xsSlot theKey)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theThis` | A reference to the instance that has the property -| `theKey` | The key of the property to get +| `theThis` | プロパティを持つインスタンスへの参照 +| `theKey` | 取得するプロパティのキー -Returns a slot containing what is contained in the property, or `xsUndefined` if the property is not defined by the instance or its prototypes +プロパティに含まれる内容を含むスロットを返します。インスタンスまたはそのプロトタイプによってプロパティが定義されていない場合は`xsUndefined`を返します -##### In ECMAScript: +##### ECMAScriptでは: ```javascript this["foo"] this[5] ``` -##### In C: +##### Cでは: ```c xsGetAt(xsThis, xsString("foo")); @@ -1088,24 +1088,24 @@ xsGetAt(xsVar(0), xsInteger(5)); #### xsmcGetAt -The `xsmcGetAt` macro is functionally equivalent to the `xsGetAt` macro. The property is returned in the slot provided. +`xsmcGetAt`マクロは`xsGetAt`マクロと機能的に同等です。プロパティは提供されたスロットに返されます。 **`void xsmcGetAt(xsSlot theSlot, xsSlot theThis, xsSlot theKey)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The slot to contain the property -| `theThis` | A reference to the instance that has the property -| `theKey` | The key of the property to get +| `theSlot` | プロパティを含むスロット +| `theThis` | プロパティを持つインスタンスへの参照 +| `theKey` | 取得するプロパティのキー -##### In ECMAScript: +##### ECMAScriptでは: ```javascript this["foo"] this[5] ``` -##### In C: +##### Cでは: ```c xsmcVars(1); @@ -1116,24 +1116,24 @@ xsmcGetAt(xsVar(0), xsThis, xsInteger(5)); #### xsGetIndex -To get a property of an instance by index, use the `xsGetIndex` macro. +インデックスによってインスタンスのプロパティを取得するには、`xsGetIndex`マクロを使用します。 **`xsSlot xsGetIndex(xsSlot theThis, xsIndex theIndex)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theThis` | A reference to the instance that has the property -| `theIndex` | The index of the property to get +| `theThis` | プロパティを持つインスタンスへの参照 +| `theIndex` | 取得するプロパティのインデックス -Returns a slot containing what is contained in the property, or `xsUndefined` if the item is not defined by the instance or its prototypes +プロパティに含まれる内容を含むスロットを返します。インスタンスまたはそのプロトタイプによって項目が定義されていない場合は`xsUndefined`を返します -##### In ECMAScript: +##### ECMAScriptでは: ```javascript this[0] ``` -##### In C: +##### Cでは: ```c xsGetIndex(xsThis, 0); @@ -1143,23 +1143,23 @@ xsGetIndex(xsThis, 0); #### xsmcGetIndex -The `xsmcGetIndex` macro is functionally equivalent to the `xsGetIndex` macro. The property is returned in the slot provided. +`xsmcGetIndex`マクロは`xsGetIndex`マクロと機能的に同等です。プロパティは提供されたスロットに返されます。 **`void xsmcGetIndex(xsSlot theSlot, xsSlot theThis, xsIndex theIndex)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The slot to contain the property -| `theThis` | A reference to the instance that has the item -| `theIndex` | The index of the item to get +| `theSlot` | プロパティを含むスロット +| `theThis` | 項目を持つインスタンスへの参照 +| `theIndex` | 取得する項目のインデックス -##### In ECMAScript: +##### ECMAScriptでは: ```javascript this[0] ``` -##### In C: +##### Cでは: ```c xsmcVars(1); @@ -1170,25 +1170,25 @@ xsmcGetIndex(xsVar(0), xsThis, 0); #### xsSet -To set a property of an instance with an identifier, use the `xsSet` macro. If the property is not defined by the instance, this macro inserts it into the instance. +識別子を使用してインスタンスのプロパティを設定するには、`xsSet`マクロを使用します。インスタンスによってプロパティが定義されていない場合、このマクロはプロパティをインスタンスに挿入します。 **`void xsSet(xsSlot theThis, xsIdentifier theID, xsSlot theParam)`**
**`void xsmcSet(xsSlot theThis, xsIdentifier theID, xsSlot theParam)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theThis` | A reference to the instance that will have the property -| `theID` | The identifier of the property to set -| `theParam` | The value of the property to set +| `theThis` | プロパティを持つインスタンスへの参照 +| `theID` | 設定するプロパティの識別子 +| `theParam` | 設定するプロパティの値 -##### In ECMAScript: +##### ECMAScriptでは: ```javascript foo = 0 this.foo = 1 ``` -##### In C: +##### Cでは: ```c xsSet(xsGlobal, xsID("foo"), xsInteger(0)); @@ -1200,25 +1200,25 @@ xsSet(xsThis, xsID_foo, xsInteger(1)); #### xsSetAt -To set a property of an instance with a key, use the `xsSetAt` macro. If the property or item is not defined by the instance, this macro inserts it into the instance. +キーを使用してインスタンスのプロパティを設定するには、`xsSetAt`マクロを使用します。インスタンスによってプロパティまたは項目が定義されていない場合、このマクロはそれをインスタンスに挿入します。 **`void xsSetAt(xsSlot theThis, xsSlot theKey, xsSlot theValue)`**
**`void xsmcSetAt(xsSlot theThis, xsSlot theKey, xsSlot theValue)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theThis` | A reference to the instance that will have the property -| `theKey` | The key of the property to set -| `theValue` | The value of the property to set +| `theThis` | プロパティを持つインスタンスへの参照 +| `theKey` | 設定するプロパティのキー +| `theValue` | 設定するプロパティの値 -##### In ECMAScript: +##### ECMAScriptでは: ```javascript this["foo"] = 0 this[3] = 1 ``` -##### In C: +##### Cでは: ```c xsSetAt(xsThis, xsString("foo"), xsInteger(0)); @@ -1229,24 +1229,24 @@ xsSetAt(xsThis, xsInteger(3), xsInteger(1)); #### xsSetIndex -To set a property of an instance with an index, use the `xsSetIndex` macro. If the property is not defined by the instance, this macro inserts it into the instance. +インデックスを使用してインスタンスのプロパティを設定するには、`xsSetIndex`マクロを使用します。インスタンスによってプロパティが定義されていない場合、このマクロはプロパティをインスタンスに挿入します。 **`void xsSetIndex(xsSlot theThis, xsIndex theIndex, xsSlot theParam)`**
**`void xsmcSetIndex(xsSlot theThis, xsIndex theIndex, xsSlot theParam)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theThis` | A reference to the instance that will have the property -| `theIndex` | The index of the property to set -| `theParam` | The value of the property to set +| `theThis` | プロパティを持つインスタンスへの参照 +| `theIndex` | 設定するプロパティのインデックス +| `theParam` | 設定するプロパティの値 -##### In ECMAScript: +##### ECMAScriptでは: ```javascript this[3] = 1 ``` -##### In C: +##### Cでは: ```c xsSetIndex(xsThis, 3, xsInteger(1)); @@ -1256,24 +1256,24 @@ xsSetIndex(xsThis, 3, xsInteger(1)); #### xsDelete -To delete a property of an instance corresponding to a particular identifier, use the `xsDelete` macro. If the property is not defined by the instance, this macro has no effect. +特定の識別子に対応するインスタンスのプロパティを削除するには、`xsDelete`マクロを使用します。インスタンスによってプロパティが定義されていない場合、このマクロは何も効果がありません。 **`void xsDelete(xsSlot theThis, xsIdentifier theID)`**
**`void xsmcDelete(xsSlot theThis, xsIdentifier theID)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theThis` | A reference to the instance that has the property -| `theID` | The identifier of the property to delete +| `theThis` | プロパティを持つインスタンスへの参照 +| `theID` | 削除するプロパティの識別子 -##### In ECMAScript: +##### ECMAScriptでは: ```javascript delete globalThis.foo delete this.foo ``` -##### In C: +##### Cでは: ```c xsDelete(xsGlobal, xsID("foo")); @@ -1284,24 +1284,24 @@ xsDelete(xsThis, xsID_foo); #### xsDeleteAt, xsmcDeleteAt -To delete a property of an instance corresponding to a particular key, use the `xsDeleteAt` macro. If the property is not defined by the instance, this macro has no effect. +特定のキーに対応するインスタンスのプロパティを削除するには、`xsDeleteAt`マクロを使用します。インスタンスによってプロパティが定義されていない場合、このマクロは何も効果がありません。 **`void xsDeleteAt(xsSlot theThis, xsSlot theKey)`**
**`void xsmcDeleteAt(xsSlot theThis, xsSlot theKey)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theThis ` | A reference to the instance that has the property -| `theKey` | The key of the property to delete +| `theThis ` | プロパティを持つインスタンスへの参照 +| `theKey` | 削除するプロパティのキー -##### In ECMAScript: +##### ECMAScriptでは: ```javascript delete this["foo"] delete this[3] ``` -##### In C: +##### Cでは: ```c xsDeleteAt(xsThis, xsString("foo")); @@ -1312,7 +1312,7 @@ xsDeleteAt(xsThis, xsInteger(3)); #### xsCall* -When a property or item of an instance is a reference to a function, you can call the function with one of the `xsCall*` macros (where `*` is `0` through `7`, representing the number of parameter slots passed). If the property or item is not defined by the instance or its prototypes or is not a reference to a function, the `xsCall*` macro throws an exception. +インスタンスのプロパティまたは項目が関数への参照である場合、`xsCall*`マクロの1つで関数を呼び出すことができます(`*`は`0`から`7`で、渡されるパラメータスロットの数を表します)。プロパティまたは項目がインスタンスまたはそのプロトタイプによって定義されていない、または関数への参照でない場合、`xsCall*`マクロは例外をスローします。 **`xsSlot xsCall0(xsSlot theThis, xsIdentifier theID)`**
**`xsSlot xsCall1(xsSlot theThis, xsIdentifier theID, xsSlot theParam0)`**
@@ -1323,15 +1323,15 @@ When a property or item of an instance is a reference to a function, you can cal **`xsSlot xsCall6(xsSlot theThis, xsIdentifier theID, xsSlot theParam0, xsSlot theParam1, xsSlot theParam2, xsSlot theParam3, xsSlot theParam4, xsSlot theParam5)`**
**`xsSlot xsCall7(xsSlot theThis, xsIdentifier theID, xsSlot theParam0, xsSlot theParam1, xsSlot theParam2, xsSlot theParam3, xsSlot theParam4, xsSlot theParam5, xsSlot theParam6)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theThis` | A reference to the instance that will have the property or item -| `theID` | The identifier of the property or item to call -| `theParam0` ... `theParam6` | The parameter slots to pass to the function +| `theThis` | プロパティまたは項目を持つインスタンスへの参照 +| `theID` | 呼び出すプロパティまたは項目の識別子 +| `theParam0` ... `theParam6` | 関数に渡すパラメータスロット -Returns the result slot of the function +関数の結果スロットを返します -##### In ECMAScript: +##### ECMAScriptでは: ```javascript foo() @@ -1339,7 +1339,7 @@ this.foo(1) this[0](2, 3) ``` -##### In C: +##### Cでは: ``` xsCall0(xsGlobal, xsID_foo); @@ -1349,18 +1349,18 @@ xsCall2(xsThis, 0, xsInteger(2), xsInteger(3)); #### xsmcCall -The `xsmcCall` macro is functionally equivalent to the `xsCall*` macros. The result and parameter slots are provided as function parameters. +`xsmcCall`マクロは`xsCall*`マクロと機能的に同等です。結果とパラメータスロットは関数パラメータとして提供されます。 **`void xsmcCall(xsSlot xsSlot, xsSlot theThis, xsIdentifier theID, ...)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The result slot -| `theThis` | A reference to the instance that will have the property or item -| `theID` | The identifier of the property or item to call -| ... | Pointers to the slots that are passed as arguments to the constructor followed by a null pointer +| `theSlot` | 結果スロット +| `theThis` | プロパティまたは項目を持つインスタンスへの参照 +| `theID` | 呼び出すプロパティまたは項目の識別子 +| ... | コンストラクタに引数として渡されるスロットへのポインタの後にnullポインタ -##### In ECMAScript: +##### ECMAScriptでは: ```javascript foo(1) @@ -1368,7 +1368,7 @@ this.foo(1) this[0](2, 3) ``` -##### In C: +##### Cでは: ```c xsmcVars(3); @@ -1385,7 +1385,7 @@ xsmcCall(xsResult, xsThis, 0, &xsVar(1), &xsVar(2), NULL); #### xsNew* -When a property or item of an instance is a reference to a constructor, you can call the constructor with one of the `xsNew*` macros (where `*` is `0` through `7`, representing the number of parameter slots passed). If the property or item is not defined by the instance or its prototypes or is not a reference to a constructor, the `xsNew*` macro throws an exception. +インスタンスのプロパティまたは項目がコンストラクタへの参照である場合、`xsNew*`マクロの1つでコンストラクタを呼び出すことができます(`*`は`0`から`7`で、渡されるパラメータスロットの数を表します)。プロパティまたは項目がインスタンスまたはそのプロトタイプによって定義されていない、またはコンストラクタへの参照でない場合、`xsNew*`マクロは例外をスローします。 **`xsSlot xsNew0(xsSlot theThis, xsIdentifier theID)`**
**`xsSlot xsNew1(xsSlot theThis, xsIdentifier theID, xsSlot theParam0)`**
@@ -1396,16 +1396,16 @@ When a property or item of an instance is a reference to a constructor, you can **`xsSlot xsNew6(xsSlot theThis, xsIdentifier theID, xsSlot theParam0, xsSlot theParam1, xsSlot theParam2, xsSlot theParam3, xsSlot theParam4, xsSlot theParam5)`**
**`xsSlot xsNew7(xsSlot theThis, xsIdentifier theID, xsSlot theParam0, xsSlot theParam1, xsSlot theParam2, xsSlot theParam3, xsSlot theParam4, xsSlot theParam5, xsSlot theParam6)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theThis` | A reference to the instance that has the property or item -| `theID` | The identifier of the property or item to call -| `theParam0` ... `theParam6` | The parameter slots to pass to the constructor +| `theThis` | プロパティまたは項目を持つインスタンスへの参照 +| `theID` | 呼び出すプロパティまたは項目の識別子 +| `theParam0` ... `theParam6` | コンストラクタに渡すパラメータスロット -Returns the result slot of the constructor +コンストラクタの結果スロットを返します -##### In ECMAScript: +##### ECMAScriptでは: ```javascript new foo() @@ -1413,7 +1413,7 @@ new this.foo(1) new this[0](2, 3) ``` -##### In C: +##### Cでは: ```c xsNew0(xsGlobal, xsID("foo")); @@ -1425,19 +1425,19 @@ xsNew2(xsThis, 0, xsInteger(2), xsInteger(3)); #### xsmcNew -The `xsmcNew` macro is functionally equivalent to the `xsNew*` macros. The result and parameter slots are provided as function parameters. +`xsmcNew`マクロは`xsNew*`マクロと機能的に同等です。結果とパラメータスロットは関数パラメータとして提供されます。 **`void xsmcNew(xsSlot theSlot, xsSlot theThis, xsIdentifier theID, ...)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The result slot of the constructor -| `theThis` | A reference to the instance that has the property or item -| `theID` | The identifier of the property or item to call -| ... | Pointers to the slots that are passed as arguments to the constructor followed by a null pointer +| `theSlot` | コンストラクタの結果スロット +| `theThis` | プロパティまたは項目を持つインスタンスへの参照 +| `theID` | 呼び出すプロパティまたは項目の識別子 +| ... | コンストラクタに引数として渡されるスロットへのポインタの後にnullポインタ -##### In ECMAScript: +##### ECMAScriptでは: ```javascript new foo(1) @@ -1445,7 +1445,7 @@ new this.foo(1) new this[0](2, 3) ``` -##### In C: +##### Cでは: ```c xsmcVars(3); @@ -1461,25 +1461,25 @@ xsmcNew(xsResult, xsThis, 0, &xsVar(1), &xsVar(2), NULL); #### xsTest -Like an `if` clause in ECMAScript, the `xsTest` macro takes a value of any type and determines whether it is true or false. This macro applies the same rules as in ECMAScript (per the ECMA-262 specification, section 12.5). +ECMAScriptの`if`節のように、`xsTest`マクロは任意の型の値を受け取り、それがtrueかfalseかを判定します。このマクロはECMAScriptと同じルール(ECMA-262仕様のセクション12.5)を適用します。 **`xsBooleanValue xsTest(xsSlot theValue)`**
**`xsBooleanValue xsmcTest(xsSlot theValue)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theValue` | The value to test +| `theValue` | テストする値 -Returns `true` if the value is true, `false` otherwise +値がtrueの場合は`true`、そうでなければ`false`を返します -##### In ECMAScript: +##### ECMAScriptでは: ```javascript if (foo) {} ``` -##### In C: +##### Cでは: ```c if (xsTest(xsGet(xsGlobal, xsID_foo)) {} @@ -1489,17 +1489,17 @@ if (xsTest(xsGet(xsGlobal, xsID_foo)) {} #### xsEnumerate -Use the `xsEnumerate` macro to get an iterator for enumerable instance properties. The iterator provides `next`, `value` and `done` functions to iterate the properties. +`xsEnumerate`マクロを使用して、列挙可能なインスタンスプロパティのイテレータを取得します。イテレータは、プロパティを反復処理するための`next`、`value`、`done`関数を提供します。 **`xsSlot xsEnumerate(xsSlot theObject)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theObject` | A reference to the object that has enumerable properties +| `theObject` | 列挙可能なプロパティを持つオブジェクトへの参照 -Returns a slot containing the iterator +イテレータを含むスロットを返します -##### In ECMAScript: +##### ECMAScriptでは: ```javascript rectangle = { x:0, y:0, width:200, height:100 }; @@ -1507,7 +1507,7 @@ for (let prop in rectangle) trace(`${prop}: ${rectangle[prop]}\n`); ``` -##### In C: +##### Cでは: ```c xsVars(5); @@ -1527,89 +1527,89 @@ for (;;) { *** -### Arguments and Variables +### 引数と変数 -The XS runtime virtual machine uses a heap and a stack of slots. With XS in C, you can access stack slots directly and heap slots indirectly, through references. +XSランタイム仮想マシンは、ヒープとスロットのスタックを使用します。XS in Cでは、スタックスロットに直接アクセスし、ヒープスロットには参照を通して間接的にアクセスできます。 -When a C callback is executed, the stack contains its argument slots, its `this` slot, and its result slot, but no variable slots. To use variable slots, you have to reserve them on the stack with the `xsVars` or `xsmcVars` macros. The `xsVars` macro can only be used once at the beginning of the callback execution. The `xsmcVars` macro can be used multiple times within a callback. Using `xsmcVars`, the callback can use a different number of variables in different branches of the code, to reduce the XS stack size. +Cコールバックが実行されるとき、スタックには引数スロット、`this`スロット、結果スロットが含まれますが、変数スロットは含まれません。変数スロットを使用するには、`xsVars`または`xsmcVars`マクロでスタックに予約する必要があります。`xsVars`マクロはコールバック実行の開始時に一度だけ使用できます。`xsmcVars`マクロはコールバック内で複数回使用できます。`xsmcVars`を使用することで、コールバックはコードの異なる分岐で異なる数の変数を使用でき、XSスタックサイズを削減できます。 **`void xsVars(xsIntegerValue theCount)`**
**`void xsmcVars(xsIntegerValue theCount)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theCount` | The number of variable slots to reserve +| `theCount` | 予約する変数スロットの数 *** -Argument and variable slots are accessed and assigned by index. An exception is thrown if the index is invalid. +引数スロットと変数スロットは、インデックスによってアクセスおよび割り当てされます。インデックスが無効な場合、例外がスローされます。 -Initially: +初期状態では: -- The argument slots are the parameter slots passed to the function or constructor. +- 引数スロットは、関数またはコンストラクタに渡されるパラメータスロットです。 -- If the callback is a function, the `this` slot refers to the instance being called and the result slot is undefined. +- コールバックが関数の場合、`this`スロットは呼び出されるインスタンスを参照し、結果スロットはundefinedです。 -- If the callback is a constructor, the `this` and result slots refer to the instance being created. +- コールバックがコンストラクタの場合、`this`と結果スロットは作成されるインスタンスを参照します。 -- The variable slots are undefined. +- 変数スロットはundefinedです。 -Scripts can call a constructor as a function or a function as a constructor. To find out whether the C callback is executed as a constructor or as a function, you can check whether the result slot is initially undefined. +スクリプトは、コンストラクタを関数として、または関数をコンストラクタとして呼び出すことができます。Cコールバックがコンストラクタとして実行されるか関数として実行されるかを確認するには、結果スロットが最初にundefinedかどうかをチェックできます。 *** **`xsSlot xsArgc`
`int xsmcArgc`** -Returns an integer slot that contains the number of arguments +引数の数を含む整数スロットを返します *** **`xsSlot xsArg(xsIntegerValue theIndex)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theIndex` | The index of the argument, from 0 to `xsArgc-1` +| `theIndex` | 引数のインデックス、0から`xsArgc-1`まで -Returns the argument slot +引数スロットを返します *** **`xsSlot xsThis`** -Returns the `this` slot +`this`スロットを返します *** **`xsSlot xsResult`** -Returns the result slot +結果スロットを返します *** **`xsSlot xsVarc`** -Returns an integer slot that contains the number of variables +変数の数を含む整数スロットを返します *** **`xsSlot xsVar(xsIntegerValue theIndex)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theIndex` | The index of the variable, from 0 to `xsVarc-1` +| `theIndex` | 変数のインデックス、0から`xsVarc-1`まで -Returns the variable slot +変数スロットを返します *** -#### Example +#### 例 -Usually you access the argument, `this`, result, and variable slots but you assign only the result and variable slots. Whatever is in the result slot at the end of the callback execution is returned to scripts by the function or constructor. +通常、引数、`this`、結果、変数スロットにアクセスしますが、結果と変数スロットのみを割り当てます。コールバック実行の終了時に結果スロットにあるものが、関数またはコンストラクタによってスクリプトに返されます。 -In the C example in this section (and the next one), `xsMachine` is the virtual machine structure, as shown in the section [Machine](#machine). +このセクション(および次のセクション)のCの例では、`xsMachine`は仮想マシン構造体です。[マシン](#machine)セクションに示されています。 -##### In ECMAScript: +##### ECMAScriptでは: ```javascript function foo() { @@ -1622,7 +1622,7 @@ function foo() { } ``` -##### In C: +##### Cでは: ```c void xs_foo(xsMachine* the) { @@ -1637,44 +1637,44 @@ void xs_foo(xsMachine* the) { ``` -### Garbage Collector +### ガベージコレクタ -When the XS runtime needs to allocate slots and there is not enough memory, it automatically deletes unused slots. The runtime garbage collector uses a mark and sweep algorithm. To force the runtime to delete unused slots, you can use the `xsCollectGarbage` macro. +XSランタイムがスロットを割り当てる必要があり、十分なメモリがない場合、未使用のスロットが自動的に削除されます。ランタイムガベージコレクタは、マークアンドスイープアルゴリズムを使用します。ランタイムに未使用のスロットを強制的に削除させるには、`xsCollectGarbage`マクロを使用できます。 **`void xsCollectGarbage()`** *** -If you store slots in memory that is no managed by the garbage collector, such as a C global or a C allocated structure, use the `xsRemember` and `xsForget` macros to inform the runtime. +Cグローバルやc割り当て構造体など、ガベージコレクタによって管理されていないメモリにスロットを格納する場合は、`xsRemember`および`xsForget`マクロを使用してランタイムに通知します。 **`void xsRemember(xsSlot theSlot)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The slot to remember +| `theSlot` | 記憶するスロット **`void xsForget(xsSlot theSlot)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The slot to forget +| `theSlot` | 忘れるスロット -`xsRemember` links and `xsForget` unlinks a slot to and from a chain of slots which the garbage collector scans to mark the slots that the C global or the C allocated structure references. +`xsRemember`はスロットをリンクし、`xsForget`はスロットのリンクを解除して、ガベージコレクタがCグローバルやC割り当て構造体が参照するスロットをマークするためにスキャンするスロットのチェーンに対して操作を行います。 *** -Use `xsAccess` to get the value of a slot previously linked to the chain of slots. +以前にスロットのチェーンにリンクされたスロットの値を取得するには、`xsAccess`を使用します。 **`xsSlot xsAccess(xsSlot theSlot)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theSlot` | The slot to access +| `theSlot` | アクセスするスロット -Returns the value of the slot +スロットの値を返します -##### In C: +##### Cでは: ```c xsSlot gFooSlot; @@ -1695,20 +1695,20 @@ void xsCleanupFoo(xsMachine* the) { *** -The garbage collector is enabled by default. Use `xsEnableGarbageCollection` to enable or disable the garbage collector. +ガベージコレクタはデフォルトで有効になっています。ガベージコレクタを有効または無効にするには、`xsEnableGarbageCollection`を使用します。 **`xsSlot xsEnableGarbageCollection(xsBooleanValue enable)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `enable` | Set `true` to enable garbage collection or `false` to disable garbage collection +| `enable` | ガベージコレクションを有効にするには`true`、無効にするには`false`を設定 *** -### Exceptions +### 例外 -To handle exceptions in C, the XS runtime uses `setjmp`, `longjmp`, and a chain of `jmp_buf` buffers, defined as follows: +Cで例外を処理するために、XSランタイムは`setjmp`、`longjmp`、および`jmp_buf`バッファのチェーンを使用し、以下のように定義されています: ```c typedef struct xsJumpRecord xsJump @@ -1720,29 +1720,29 @@ struct xsJumpRecord { }; ``` -However, you do not need to use this directly, because XS in C defines macros for throwing and catching exceptions. +ただし、XS in Cが例外をスローおよびキャッチするためのマクロを定義しているため、これを直接使用する必要はありません。 -To throw an exception, use the `xsThrow` macro. +例外をスローするには、`xsThrow`マクロを使用します。 **`void xsThrow(xsSlot theException)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theException` | The exception slot +| `theException` | 例外スロット -Assigns the current exception +現在の例外を割り当てます *** **`xsSlot xsException`** -Accesses the current exception and returns the exception slot +現在の例外にアクセスし、例外スロットを返します *** -As shown in the following example, the `xsTry` and `xsCatch` macros are used together to catch exceptions. If you catch an exception in your C callback and you want to propagate the exception to the script that calls your function or constructor, throw the exception again. +以下の例に示すように、`xsTry`および`xsCatch`マクロは一緒に使用して例外をキャッチします。Cコールバックで例外をキャッチし、その例外を関数またはコンストラクタを呼び出すスクリプトに伝播させたい場合は、例外を再度スローします。 -##### In ECMAScript: +##### ECMAScriptでは: ```javascript { @@ -1756,7 +1756,7 @@ As shown in the following example, the `xsTry` and `xsCatch` macros are used tog } ``` -##### In C: +##### Cでは: ```c { @@ -1771,11 +1771,11 @@ As shown in the following example, the `xsTry` and `xsCatch` macros are used tog ``` -### Errors +### エラー -Exceptions may be thrown by C callbacks. C callbacks are often provide the interface between scripts and systems. Many system calls can fail, and they have a way to return an error to the application which can be propagated as an exception. +例外はCコールバックによってスローされることがあります。Cコールバックは、多くの場合、スクリプトとシステム間のインターフェースを提供します。多くのシステムコールは失敗する可能性があり、例外として伝播できるエラーをアプリケーションに返す方法があります。 -For specific errors, the XS runtime provides error types and prototypes. +特定のエラーについて、XSランタイムはエラータイプとプロトタイプを提供します。 ```c enum { @@ -1791,7 +1791,7 @@ enum { }; ``` -XS in C defines the following macros to throw specific exceptions. +XS in Cは、特定の例外をスローするために以下のマクロを定義しています。 **`void xsUnknownError(...)`
`void xsEvalError(...)`
@@ -1801,11 +1801,11 @@ XS in C defines the following macros to throw specific exceptions. `void xsTypeError(...)`
`void xsURIError(...)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| ... | The message and optional arguments to display when throwing the exception +| ... | 例外をスローするときに表示するメッセージとオプション引数 -##### In C: +##### Cでは: ``` xpt2046 xpt = calloc(1, sizeof(xpt2046Record)); @@ -1821,16 +1821,16 @@ if (!slash) *** -The `xsErrorPrintf` macro is a shortcut for `xsUnknownError` when only a message parameter is required. +`xsErrorPrintf`マクロは、メッセージパラメータのみが必要な場合の`xsUnknownError`のショートカットです。 **`xsErrorPrintf(xsStringValue theMessage)`
`xsUnknownError("%s", theMessage)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| theMessage | The message to display when throwing the exception +| theMessage | 例外をスローするときに表示するメッセージ -##### In C: +##### Cでは: ```c if (rotation != requestedRotation) @@ -1840,32 +1840,32 @@ if (rotation != requestedRotation) *** -### Debugger +### デバッガ -XS in C provides two macros to help you debug your C callbacks. +XS in Cは、Cコールバックのデバッグを支援する2つのマクロを提供します。 -The `xsDebugger` macro is equivalent to the ECMAScript `debugger` keyword. +`xsDebugger`マクロは、ECMAScriptの`debugger`キーワードと同等です。 **`void xsDebugger()`** *** -The `xsTrace` macro is equivalent to the global `trace` function. +`xsTrace`マクロは、グローバル`trace`関数と同等です。 **`void xsTrace(xsStringValue theMessage)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theMessage` | The message to log in the debugger +| `theMessage` | デバッガでログに記録するメッセージ -##### In ECMAScript: +##### ECMAScriptでは: ```javascript debugger; trace("Hello xsbug!\n"); ``` -##### In C: +##### Cでは: ```c xsDebugger(); @@ -1874,14 +1874,14 @@ xsTrace("Hello xsbug!\n"); **`void xsLog(xsStringValue format, ...)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `format` | A printf-style format string -| `...` | Items to referenced by the format string +| `format` | printf形式のフォーマット文字列 +| `...` | フォーマット文字列によって参照される項目 -The support formatting options are %c, %hd, %d, %ld, %g, and %s. +サポートされているフォーマットオプションは%c、%hd、%d、%ld、%g、%sです。 -##### In C: +##### Cでは: ```c int err = -108; @@ -1890,9 +1890,9 @@ xsLog("The error is %d (%s)\n", err, msg); ``` -## Machine +## マシン -The main structure of the XS runtime is its virtual machine, which is what parses, compiles, links, and executes scripts. A virtual machine is an opaque structure though some members of the structure are available to optimize the macros of XS in C; you never need to use them directly. +XSランタイムの主要な構造は仮想マシンで、これがスクリプトを解析、コンパイル、リンク、実行します。仮想マシンは不透明な構造ですが、構造の一部のメンバーはXS in Cのマクロを最適化するために利用でき、直接使用する必要はありません。 ```c typedef struct xsMachineRecord xsMachine @@ -1908,14 +1908,14 @@ struct xsMachineRecord { }; ``` -A single machine does not support multiple threads. To work with multiple threads, create one XS runtime machine for each thread, with the host optionally providing a way for the machines to communicate. +単一のマシンは複数のスレッドをサポートしません。複数のスレッドで作業するには、スレッドごとに1つのXSランタイムマシンを作成し、ホストがオプションでマシン間の通信方法を提供します。 -### Machine Allocation +### マシンの割り当て -To use the XS runtime you have to create a machine with the `xsCreateMachine` macro, allocating memory for it as required. Its parameters are: +XSランタイムを使用するには、`xsCreateMachine`マクロでマシンを作成し、必要に応じてメモリを割り当てる必要があります。そのパラメータは: -- A structure with members that are essentially parameters specifying what to allocate for the machine. Pass `NULL` if you want to use the defaults. +- マシンに割り当てるものを指定する本質的にパラメータであるメンバーを持つ構造体。デフォルトを使用する場合は`NULL`を渡します。 ```c typedef struct { @@ -1934,48 +1934,48 @@ typedef struct { } xsCreation; ``` -- The name of the machine +- マシンの名前 -- A context you can set and get in your callbacks (as discussed in the next section). Pass `NULL` if you do not want an initial context. +- コールバックで設定および取得できるコンテキスト(次のセクションで説明)。初期コンテキストが不要な場合は`NULL`を渡します。 **`xsMachine* xsCreateMachine(xsCreation* theCreation, xsStringValue theName, void* theContext)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theCreation` | The parameters of the machine -| `theName` | The name of the machine as a string -| `theContext` | The initial context of the machine, or `NULL` +| `theCreation` | マシンのパラメータ +| `theName` | 文字列としてのマシンの名前 +| `theContext` | マシンの初期コンテキスト、または`NULL` -Returns a machine if successful, otherwise `NULL` +成功した場合はマシンを返し、そうでなければ`NULL`を返します -Regarding the parameters of the machine that are specified in the `xsCreation` structure: +`xsCreation`構造体で指定されるマシンのパラメータについて: -- A machine uses chunks to store strings, bytecodes, array buffers, big int values, and others. The `initialChunkSize` is the initial size of the memory allocated to chunks. The `incrementalChunkSize` tells the runtime how to expand the memory allocated to chunks. +- マシンは文字列、バイトコード、配列バッファ、big int値などを格納するためにチャンクを使用します。`initialChunkSize`はチャンクに割り当てられるメモリの初期サイズです。`incrementalChunkSize`は、チャンクに割り当てられるメモリをランタイムがどのように拡張するかを指示します。 -- A machine uses a heap and a stack of slots. The `initialHeapCount` is the initial number of slots allocated to the heap. The `incrementalHeapCount` tells the runtime how to increase the number of slots allocated to the heap. The `stackCount` is the number of slots allocated to the stack. Note that these values are all slots, not bytes. +- マシンはヒープとスロットのスタックを使用します。`initialHeapCount`はヒープに割り当てられるスロットの初期数です。`incrementalHeapCount`は、ヒープに割り当てられるスロット数をランタイムがどのように増加させるかを指示します。`stackCount`はスタックに割り当てられるスロット数です。これらの値はすべてスロットであり、バイトではないことに注意してください。 -- A symbol binds a string value and an identifier; see [`xsID`](#xs-id). The `initialKeyCount` is the number of symbols the machine will allocate at initialization. When the keys are exhausted `incrementalKeyCount` keys are added; if `incrementalKeyCount` is 0, the VM aborts when the keys are exhausted. `symbolModulo` is the size of the hash table the machine will use for symbols. The `nameModulo` is the size of the hash table the machine will use for symbol names. +- シンボルは文字列値と識別子を結合します。[`xsID`](#xs-id)を参照してください。`initialKeyCount`は、マシンが初期化時に割り当てるシンボルの数です。キーが枯渇すると`incrementalKeyCount`個のキーが追加されます。`incrementalKeyCount`が0の場合、キーが枯渇するとVMは中止します。`symbolModulo`は、マシンがシンボルに使用するハッシュテーブルのサイズです。`nameModulo`は、マシンがシンボル名に使用するハッシュテーブルのサイズです。 -- Some XS hosts attempt to grow the slot and chunk heaps without limit at runtime to accommodate the memory needs of the hosted scripts; others limit the maximum memory that may be allocated to the machine. For the latter, the `staticSize` defines the total number of bytes that may be allocated for the combination of chunks and slots, which includes the stack. In general, only hosts running on resource constrained devices implement `staticSize`. +- 一部のXSホストは、ホストされるスクリプトのメモリニーズに対応するためにランタイムでスロットとチャンクヒープを無制限に拡張しようとします。他のホストは、マシンに割り当てられる最大メモリを制限します。後者の場合、`staticSize`は、スタックを含むチャンクとスロットの組み合わせに割り当てられる総バイト数を定義します。一般的に、リソース制約のあるデバイスで実行されるホストのみが`staticSize`を実装します。 *** -When you are done with a machine, you free it with the `xsDeleteMachine` macro. The destructors of all the host objects are executed, and all the memory allocated by the machine is freed. +マシンが完了したら、`xsDeleteMachine`マクロでそれを解放します。すべてのホストオブジェクトのデストラクタが実行され、マシンによって割り当てられたすべてのメモリが解放されます。 **`void xsDeleteMachine(xsMachine* the)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `the` | A machine +| `the` | マシン -The `xsDeleteMachine` macro is one of a number of macros described in this document that have an explicit machine parameter named `the`, for which the value returned by `xsCreateMachine` is passed. (The other such macros are `xsGetContext`, `xsSetContext`, `xsBeginHost`, and `xsEndHost`.) Only those macros have an explicit `the` parameter because they are the only ones that can be used outside a callback and cannot throw exceptions. Callbacks must name their machine parameter `the` because all other macros have an implicit parameter named `the`; the primary reason for this convention is terseness, but it also emphasizes the fact that these other macros can be used only inside a callback and can throw exceptions. +`xsDeleteMachine`マクロは、このドキュメントで説明されている多くのマクロの1つで、`the`という名前の明示的なマシンパラメータを持ち、`xsCreateMachine`によって返される値が渡されます。(他のそのようなマクロは`xsGetContext`、`xsSetContext`、`xsBeginHost`、`xsEndHost`です。)これらのマクロのみが明示的な`the`パラメータを持つのは、コールバック外で使用でき、例外をスローできない唯一のマクロだからです。コールバックは、他のすべてのマクロが`the`という名前の暗黙のパラメータを持つため、マシンパラメータを`the`と名前付けする必要があります。この規則の主な理由は簡潔性ですが、これらの他のマクロがコールバック内でのみ使用でき、例外をスローできるという事実も強調しています。 -#### Example +#### 例 -The following example illustrates the use of `xsCreateMachine` and `xsDeleteMachine`. The `xsMainContext` function called in the example is defined in the next section. +以下の例は、`xsCreateMachine`と`xsDeleteMachine`の使用を示しています。例で呼び出される`xsMainContext`関数は、次のセクションで定義されています。 ```c int main(int argc, char* argv[]) @@ -2004,33 +2004,33 @@ int main(int argc, char* argv[]) ``` -### Context +### コンテキスト -The machine will call your C code primarily through callbacks. In your callbacks, you can set and get a *context*: a pointer to an area where you can store and retrieve information for the machine. +マシンは主にコールバックを通してCコードを呼び出します。コールバックでは、*コンテキスト*を設定および取得できます。これは、マシンの情報を格納および取得できる領域へのポインタです。 **`void xsSetContext(xsMachine* the, void* theContext)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `the` | A machine -| `theContext` | A context +| `the` | マシン +| `theContext` | コンテキスト -Sets a context +コンテキストを設定します *** **`void* xsGetContext(xsMachine* the)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `the` | A machine +| `the` | マシン -Returns a context +コンテキストを返します *** -#### Example -The following code shows a context being set in the `xsMainContext` function, which was called in the preceding section's example. +#### 例 +以下のコードは、前のセクションの例で呼び出された`xsMainContext`関数でコンテキストが設定される様子を示しています。 ```c typedef struct { @@ -2056,244 +2056,244 @@ void xsMainContext(xsMachine* theMachine, int argc, char* argv[]) ``` -### Host +### ホスト -This section describes the host-related macros of XS in C (see Table 2). An annotated example that uses the host-related macros follows. +このセクションでは、XS in Cのホスト関連マクロについて説明します(表2を参照)。ホスト関連マクロを使用する注釈付きの例が続きます。 -A host object is an XS object that has a data pointer that can only be accessed in C and a native destructor that is invoked when the host object is garbage collected. Host objects are created in C using `xsNewHostObject` and in JavaScript using the [XS `@` syntax](#syntax-extension) in JavaScript `(class Foo @ "aDestructorFunction" {}`. Internally, a host object has a dedicated slot to hold its destructor and a data pointer; non-host objects don't have this slot. Consequently, only host objects have a native destructor and data pointer that is accessible only from C. This data pointer is either host data or a host chunk. +ホストオブジェクトは、Cでのみアクセスできるデータポインタと、ホストオブジェクトがガベージコレクションされるときに呼び出されるネイティブデストラクタを持つXSオブジェクトです。ホストオブジェクトは、Cで`xsNewHostObject`を使用して作成され、JavaScriptで[XS `@`構文](#syntax-extension)を使用してJavaScript `(class Foo @ "aDestructorFunction" {}`で作成されます。内部的に、ホストオブジェクトにはデストラクタとデータポインタを保持する専用スロットがあります。非ホストオブジェクトにはこのスロットがありません。したがって、ホストオブジェクトのみがネイティブデストラクタとCからのみアクセス可能なデータポインタを持ちます。このデータポインタは、ホストデータまたはホストチャンクのいずれかです。 -Host data is a pointer stored by XS in a host object. The pointer and data it points to are managed entirely by the host object's C code. XS stores the pointer but does not access it in any way. Host data is usually allocated with `malloc`/`calloc`, but this isn't required. Host data is disposed by the host object's destructor. +ホストデータは、XSがホストオブジェクトに格納するポインタです。ポインタとそれが指すデータは、完全にホストオブジェクトのCコードによって管理されます。XSはポインタを格納しますが、いかなる方法でもアクセスしません。ホストデータは通常`malloc`/`calloc`で割り当てられますが、これは必須ではありません。ホストデータは、ホストオブジェクトのデストラクタによって破棄されます。 -A host chunk is memory allocated by XS in its chunk heap for use by a host object from its native C code. XS garbage collects this storage when the host object is garbage collected. The memory is relocatable (like all XS chunks), so unlike Host Data it avoids losing memory to fragmentation. However, it requires some extra attention because the pointer may be invalidated when the garbage collector compacts memory. Therefore, C code needs to refetch the pointer after any operation which might trigger a garbage collection. Because the chunk pointer can move, it can only be used inside an XS callback; accessing it from an interrupt, for example, is unsafe because it could be moving. The [Rectangle example](#rectangle-example) shows how to use a host chunk. +ホストチャンクは、ホストオブジェクトがネイティブCコードから使用するために、XSがチャンクヒープに割り当てるメモリです。XSは、ホストオブジェクトがガベージコレクションされるときにこのストレージをガベージコレクションします。メモリは再配置可能(すべてのXSチャンクと同様)なので、ホストデータとは異なり、断片化によるメモリ損失を回避します。ただし、ガベージコレクタがメモリを圧縮するときにポインタが無効になる可能性があるため、追加の注意が必要です。したがって、Cコードは、ガベージコレクションをトリガーする可能性のある操作の後にポインタを再取得する必要があります。チャンクポインタは移動する可能性があるため、XSコールバック内でのみ使用できます。たとえば、割り込みからアクセスすることは、移動している可能性があるため安全ではありません。[Rectangleの例](#rectangle-example)では、ホストチャンクの使用方法を示しています。 -Implementing a host object using host data is easier than a host chunk, but potentially less memory efficient. +ホストデータを使用してホストオブジェクトを実装する方が、ホストチャンクよりも簡単ですが、メモリ効率が劣る可能性があります。 -> Note that an object has either host data or a host chunk but never both. +> オブジェクトはホストデータまたはホストチャンクのいずれかを持ちますが、両方を持つことはありません。 -**Table 2.** Host-Related Macros +**表2.** ホスト関連マクロ - - + + - + - + - + - + - + - + - +
MacroDescriptionマクロ説明

xsNewHostFunction

xsNewHostConstructor

Creates a host function or host constructorホスト関数またはホストコンストラクタを作成します
xsNewHostObjectCreates a host objectホストオブジェクトを作成します
xsNewHostInstance, xsmcNewHostInstanceCreates a host object instanceホストオブジェクトインスタンスを作成します

xsGetHostData, xsmcGetHostData

xsSetHostData, xsmcSetHostData

Gets or sets the data in a host objectホストオブジェクト内のデータを取得または設定します

xsGetHostChunk, xsmcGetHostChunk

xsSetHostChunk, xsmcSetHostChunk

Gets or sets the data as a chunk in a host objectホストオブジェクト内のデータをチャンクとして取得または設定します
xsSetHostDestructorSets the destructor for a host objectホストオブジェクトのデストラクタを設定します

xsBeginHost

xsEndHost

Used together to set up and clean up a stack frame, so that you can use all the macros of XS in C in betweenスタックフレームを設定およびクリーンアップするために一緒に使用され、その間にXS in Cのすべてのマクロを使用できます
-#### xsNewHostFunction and xsNewHostConstructor +#### xsNewHostFunctionとxsNewHostConstructor -A *host function* is a special kind of function, one whose implementation is in C rather than ECMAScript. For a script, a host function is just like a function; however, when a script invokes a host function, a C callback is executed. The same is true for *host constructors*, which are constructors implemented in C. +*ホスト関数*は特別な種類の関数で、その実装がECMAScriptではなくCにあります。スクリプトにとって、ホスト関数は通常の関数と同じです。ただし、スクリプトがホスト関数を呼び出すと、Cコールバックが実行されます。Cで実装されたコンストラクタである*ホストコンストラクタ*についても同じことが言えます。 ```c typedef void (*xsCallback)(xsMachine* the); ``` -To create a host function, use the `xsNewHostFunction` macro. +ホスト関数を作成するには、`xsNewHostFunction`マクロを使用します。 **`xsSlot xsNewHostFunction(xsCallback theCallback, xsIntegerValue theLength)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theCallback` | The callback to execute -| `theLength` | The number of parameters expected by the callback +| `theCallback` | 実行するコールバック +| `theLength` | コールバックが期待するパラメータの数 -Creates a host function, and returns a reference to the new host function +ホスト関数を作成し、新しいホスト関数への参照を返します *** **`xsSlot xsNewHostConstructor(xsCallback theCallback, xsIntegerValue theLength, xsSlot thePrototype)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theCallback` | The callback to execute -| `theLength` | The number of parameters expected by the callback -| `thePrototype` | A reference to the prototype of the instance to create +| `theCallback` | 実行するコールバック +| `theLength` | コールバックが期待するパラメータの数 +| `thePrototype` | 作成するインスタンスのプロトタイプへの参照 -Creates a host constructor, and returns a reference to the new host constructor +ホストコンストラクタを作成し、新しいホストコンストラクタへの参照を返します *** #### xsNewHostObject -A *host object* is a special kind of object with data that can be directly accessed only in C. The data in a host object is invisible to scripts. +*ホストオブジェクト*は、Cでのみ直接アクセスできるデータを持つ特別な種類のオブジェクトです。ホストオブジェクト内のデータは、スクリプトからは見えません。 -When the garbage collector is about to get rid of a host object, it executes the host object's destructor, if any. No reference to the host object is passed to the destructor: a destructor can only destroy data. +ガベージコレクタがホストオブジェクトを削除しようとするとき、ホストオブジェクトのデストラクタがあれば実行します。ホストオブジェクトへの参照はデストラクタに渡されません。デストラクタはデータを破棄することのみができます。 ```c typedef void (xsDestructor)(void* theData); ``` -To create a host object, use the `xsNewHostObject` macro. +ホストオブジェクトを作成するには、`xsNewHostObject`マクロを使用します。 **`xsSlot xsNewHostObject(xsDestructor theDestructor)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theDestructor` | The destructor to be executed by the garbage collector. Pass the host object's destructor, or `NULL` if it does not need a destructor. +| `theDestructor` | ガベージコレクタによって実行されるデストラクタ。ホストオブジェクトのデストラクタを渡すか、デストラクタが不要な場合は`NULL`を渡します。 -Creates a host object, and returns a reference to the new host object +ホストオブジェクトを作成し、新しいホストオブジェクトへの参照を返します *** #### xsNewHostInstance -Use the `xsNewHostInstance` macro to create an instance of a host object. +ホストオブジェクトのインスタンスを作成するには、`xsNewHostInstance`マクロを使用します。 **`xsSlot xsNewHostInstance(xsSlot thePrototype)`** **`xsSlot xsmcNewHostInstance(xsSlot thePrototype)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `thePrototype` | A reference to the prototype of the instance to create. This argument must be host object. +| `thePrototype` | 作成するインスタンスのプロトタイプへの参照。この引数はホストオブジェクトでなければなりません。 -Creates a host object instance, and returns a reference to the new host object instance +ホストオブジェクトインスタンスを作成し、新しいホストオブジェクトインスタンスへの参照を返します *** -#### xsGetHostData and xsSetHostData +#### xsGetHostDataとxsSetHostData -To get and set the data of a host object, use the `xsGetHostData` and `xsSetHostData` macros. Both throw an exception if the `theThis` parameter does not refer to a host object. +ホストオブジェクトのデータを取得および設定するには、`xsGetHostData`および`xsSetHostData`マクロを使用します。`theThis`パラメータがホストオブジェクトを参照していない場合、両方とも例外をスローします。 **`void* xsGetHostData(xsSlot theThis)`**
**`void* xsmcGetHostData(xsSlot theThis)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theThis` | A reference to a host object +| `theThis` | ホストオブジェクトへの参照 -Returns the host data pointer. +ホストデータポインタを返します。 *** **`void xsSetHostData(xsSlot theThis, void* theData)`
`void xsmcSetHostData(xsSlot theThis, void* theData)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theThis` | A reference to a host object -| `theData` | The data to set +| `theThis` | ホストオブジェクトへの参照 +| `theData` | 設定するデータ -Sets the host data pointer. +ホストデータポインタを設定します。 *** -#### xsGetHostChunk and xsSetHostChunk +#### xsGetHostChunkとxsSetHostChunk -To get and set the data of a host object as a chunk, use the `xsGetHostChunk` and `xsSetHostChunk` macros. Both throw an exception if the `theThis` parameter does not refer to a host object. Like the memory used by ArrayBuffer and String, chunk memory is allocated and managed by the XS runtime; see the [handle](./handle.md) document for details. +ホストオブジェクトのデータをチャンクとして取得および設定するには、`xsGetHostChunk`および`xsSetHostChunk`マクロを使用します。`theThis`パラメータがホストオブジェクトを参照していない場合、両方とも例外をスローします。ArrayBufferとStringが使用するメモリと同様に、チャンクメモリはXSランタイムによって割り当てられ管理されます。詳細については、[handle](./handle.md)ドキュメントを参照してください。 **`void* xsGetHostChunk(xsSlot theThis)`
`void* xsmcGetHostChunk(xsSlot theThis)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theThis` | A reference to a host object +| `theThis` | ホストオブジェクトへの参照 -Returns a pointer to the host chunk data +ホストチャンクデータへのポインタを返します *** **`void xsSetHostChunk(xsSlot theThis, void* theData, xsIntegerValue theSize)`
`void xsmcSetHostChunk(xsSlot theThis, void* theData, xsIntegerValue theSize)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theThis` | A reference to a host object -| `theData` | The data to set or `NULL` to leave the chunk data uninitialized -| `theSize` | The size of the data in bytes +| `theThis` | ホストオブジェクトへの参照 +| `theData` | 設定するデータ、またはチャンクデータを未初期化のままにする場合は`NULL` +| `theSize` | データのサイズ(バイト単位) -Allocates chunks to store the data and optionally initializes it. +データを格納するチャンクを割り当て、オプションで初期化します。 *** #### xsSetHostDestructor -To set the destructor of a host object (or to clear the destructor, by passing `NULL`), use the `xsSetHostDestructor` macro. This macro throws an exception if the `theThis` parameter does not refer to a host object. +ホストオブジェクトのデストラクタを設定する(または`NULL`を渡してデストラクタをクリアする)には、`xsSetHostDestructor`マクロを使用します。`theThis`パラメータがホストオブジェクトを参照していない場合、このマクロは例外をスローします。 **`void xsSetHostDestructor(xsSlot theThis, xsDestructor theDestructor)`
`void xsmcSetHostDestructor(xsSlot theThis, xsDestructor theDestructor)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `theThis` | A reference to a host object -| `theDestructor` | The destructor to be executed by the garbage collector, or `NULL` to clear the destructor +| `theThis` | ホストオブジェクトへの参照 +| `theDestructor` | ガベージコレクタによって実行されるデストラクタ、またはデストラクタをクリアする場合は`NULL` *** -#### xsBeginHost and xsEndHost +#### xsBeginHostとxsEndHost -Use the `xsBeginHost` macro to establish a new stack frame and the `xsEndHost` macro to remove it. +新しいスタックフレームを確立するには`xsBeginHost`マクロを使用し、それを削除するには`xsEndHost`マクロを使用します。 **`void xsBeginHost(xsMachine* the)`**
**`void xsEndHost(xsMachine* the)`** -| Arguments | Description | +| 引数 | 説明 | | --- | :-- | -| `the` | A machine +| `the` | マシン -The `xsBeginHost` macro sets up the stack, and the `xsEndHost` macro cleans up the stack, so that you can use all the macros of XS in C in the block between `xsBeginHost` and `xsEndHost`. +`xsBeginHost`マクロはスタックを設定し、`xsEndHost`マクロはスタックをクリーンアップするため、`xsBeginHost`と`xsEndHost`の間のブロックでXS in Cのすべてのマクロを使用できます。 -Uncaught exceptions that occur between the calls the `xsBeginHost` and `xsEndHost `do not propagate beyond `xsEndHost`. +`xsBeginHost`と`xsEndHost`の呼び出し間で発生するキャッチされない例外は、`xsEndHost`を超えて伝播しません。 -##### Example +##### 例 -This example creates a `File` class using the host macros of XS in C. This is a low-level technique that provides the most flexibility. Most projects do not create classes directly using XS in C, but instead use the [`@` syntax extension](#syntax-extension) to declare classes because it is simpler. +この例では、XS in Cのホストマクロを使用して`File`クラスを作成します。これは最も柔軟性を提供する低レベルの技術です。ほとんどのプロジェクトは、XS in Cを使用して直接クラスを作成するのではなく、より簡単な[`@`構文拡張](#syntax-extension)を使用してクラスを宣言します。 -This code uses the `File` class from JavaScript to open and close a file: +このコードは、JavaScriptから`File`クラスを使用してファイルを開いたり閉じたりします: ```c const f = new File("/Users/user/test.js", "rb"); f.close(); ``` -The following code builds the `File` class. The XS in C host macro calls appear in the block between `xsBeginHost` and `xsEndHost`. Two variable slots are used to store the `File` host object and constructor. The `File` object includes a single host function, `close`, that has no arguments. +以下のコードは`File`クラスを構築します。XS in Cホストマクロ呼び出しは、`xsBeginHost`と`xsEndHost`の間のブロックに表示されます。2つの変数スロットが`File`ホストオブジェクトとコンストラクタを格納するために使用されます。`File`オブジェクトには、引数を持たない単一のホスト関数`close`が含まれます。 -The `prototype` is a host object which includes the native destructor `xs_file_destructor` to be invoked when the object is garbage collected. This prototype is provided to `xsNewHostConstructor` along with the native constructor `xs_file_constructor`. +`prototype`は、オブジェクトがガベージコレクションされるときに呼び出されるネイティブデストラクタ`xs_file_destructor`を含むホストオブジェクトです。このプロトタイプは、ネイティブコンストラクタ`xs_file_constructor`とともに`xsNewHostConstructor`に提供されます。 -This example adds the `close` function to the prototype after creating the constructor. It may be added before instead. +この例では、コンストラクタを作成した後に`close`関数をプロトタイプに追加しています。代わりに前に追加することもできます。 -This example also adds a getter accessor function for the property `isOpen`. +この例では、プロパティ`isOpen`のゲッターアクセサ関数も追加しています。 ```c #define kPrototype (0) @@ -2309,9 +2309,9 @@ xsBeginHost(the); xsEndHost(the); ``` -The `xs_file_constructor` function implements the host constructor. The constructor instantiates an instance of the `File` object prototype, opens the requested file, and stores the associated `xsFileRecord`, containing the stdio `FILE` pointer, as host data. +`xs_file_constructor`関数はホストコンストラクタを実装します。コンストラクタは`File`オブジェクトプロトタイプのインスタンスをインスタンス化し、要求されたファイルを開き、stdio `FILE`ポインタを含む関連する`xsFileRecord`をホストデータとして格納します。 -Note that the implementation of a constructor created by calling `xsNewHostConstructor` is slightly different from one created using the `@` syntax. Specifically, the constructor created by `xsNewHostConstructor` must create the instance whereas XS creates the instance for constructors declared with the `@` syntax. Here the constructor uses `xsNewHostInstance` to create the instance and assign it to the return value `xsResult`. The prototype passed to `xsNewHostInstance` is taken from the prototype of the constructor, accessed through `xsTarget`. The `xsTarget` value is the XS in C equivalent to the [`new.target`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new.target) pseudo-property in JavaScript. +`xsNewHostConstructor`を呼び出して作成されたコンストラクタの実装は、`@`構文を使用して作成されたものと若干異なることに注意してください。具体的には、`xsNewHostConstructor`によって作成されたコンストラクタはインスタンスを作成する必要がありますが、XSは`@`構文で宣言されたコンストラクタのインスタンスを作成します。ここでコンストラクタは`xsNewHostInstance`を使用してインスタンスを作成し、戻り値`xsResult`に割り当てます。`xsNewHostInstance`に渡されるプロトタイプは、`xsTarget`を通してアクセスされるコンストラクタのプロトタイプから取得されます。`xsTarget`値は、JavaScriptの[`new.target`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new.target)疑似プロパティのXS in C同等物です。 ```c typedef struct { @@ -2337,7 +2337,7 @@ static void xs_file_constructor(xsMachine *the) } ``` -The `xs_file_destructor` function implements the host object's destructor. The destructor closes the file and frees the host data: +`xs_file_destructor`関数はホストオブジェクトのデストラクタを実装します。デストラクタはファイルを閉じ、ホストデータを解放します: ```c static void xs_file_destructor(void *data) @@ -2350,9 +2350,9 @@ static void xs_file_destructor(void *data) } ``` -> Note: The destructor function is called by XS when the `File` instance is garbage collected. +> 注意:デストラクタ関数は、`File`インスタンスがガベージコレクションされるときにXSによって呼び出されます。 -The `xs_file_close` function closes the file immediately, rather than waiting for the instance to be freed by the garbage collector. The function retrieves the associated `xsFileRecord` record from the object instance host data and calls the host object destructor to close the file. +`xs_file_close`関数は、インスタンスがガベージコレクタによって解放されるのを待つのではなく、ファイルをすぐに閉じます。この関数は、オブジェクトインスタンスホストデータから関連する`xsFileRecord`レコードを取得し、ホストオブジェクトデストラクタを呼び出してファイルを閉じます。 ```c static void xs_file_close(xsMachine *the) @@ -2364,7 +2364,7 @@ static void xs_file_close(xsMachine *the) } ``` -The `xs_file_get_isOpen` getter accessor function sets the result to `true` or `false` depending on whether the file is open. +`xs_file_get_isOpen`ゲッターアクセサ関数は、ファイルが開いているかどうかに応じて結果を`true`または`false`に設定します。 ```c static void xs_file_get_isOpen(xsMachine *the) @@ -2377,9 +2377,9 @@ static void xs_file_get_isOpen(xsMachine *the) *** -### JavaScript `@` language syntax extension +### JavaScript `@`言語構文拡張 -XS provides the `@` language syntax extension to implement JavaScript functions in C. The language extension is only recognized by the XS compiler. This section introduces the language extension with a JavaScript class that implements methods with C functions. +XSは、CでJavaScript関数を実装するための`@`言語構文拡張を提供します。言語拡張はXSコンパイラによってのみ認識されます。このセクションでは、C関数でメソッドを実装するJavaScriptクラスを使用して言語拡張を紹介します。 @@ -2403,7 +2403,7 @@ class Rectangle @ "xs_rectangle_destructor" { export default Rectangle; ``` -The `Rectangle` class is completely implemented in C using callbacks specified by `@` functions. For example, the `contains` method is implemented by the `xs_rectangle_contains` C function. The C functions use XS in C macros to access properties, host data, and return results. JavaScript applications import the `Rectangle` class and access the methods. +`Rectangle`クラスは、`@`関数で指定されたコールバックを使用してCで完全に実装されています。たとえば、`contains`メソッドは`xs_rectangle_contains` C関数によって実装されます。C関数は、プロパティへのアクセス、ホストデータ、結果の返却にXS in Cマクロを使用します。JavaScriptアプリケーションは`Rectangle`クラスをインポートし、メソッドにアクセスします。 ```javascript import Rectangle from "rectangle"; @@ -2414,7 +2414,7 @@ let r3 = new Rectangle(); r3.union(r1, r2); ``` -The `Rectangle` constructor `xs_rectangle` function stores the parameters in a host chunk. The constructor accepts either a single `Rectangle` instance or the individual `x`, `y`, `w` and `h` values. The function uses the `xsmcArgc` macro to count the function parameters and the `xsmcIsInstanceOf` macro to determine if the first parameter is an object. +`Rectangle`コンストラクタ`xs_rectangle`関数は、パラメータをホストチャンクに格納します。コンストラクタは、単一の`Rectangle`インスタンスまたは個別の`x`、`y`、`w`、`h`値のいずれかを受け入れます。この関数は、`xsmcArgc`マクロを使用して関数パラメータをカウントし、`xsmcIsInstanceOf`マクロを使用して最初のパラメータがオブジェクトかどうかを判定します。 ```c typedef struct { @@ -2443,21 +2443,21 @@ void xs_rectangle(xsMachine *the) xsmcSetHostChunk(xsThis, &r, sizeof(r)); } ``` -The destructor function `xs_rectangle_destructor` is called when the object instance is deleted or garbage collected. Any memory or resources allocated by the instance should be freed in the destructor. Because the XS runtime manages host chunk memory, the destructor doesn't need to dispose the chunk. +デストラクタ関数`xs_rectangle_destructor`は、オブジェクトインスタンスが削除またはガベージコレクションされるときに呼び出されます。インスタンスによって割り当てられたメモリやリソースは、デストラクタで解放する必要があります。XSランタイムがホストチャンクメモリを管理するため、デストラクタはチャンクを破棄する必要がありません。 ```c void xs_rectangle_destructor(void *data) { } ``` -The `Rectangle` class provides getters and setters for class properties. +`Rectangle`クラスは、クラスプロパティのゲッターとセッターを提供します。 ```javascript get x() @ "xs_rectangle_get_x"; set x() @ "xs_rectangle_set_x"; ``` -The `get` functions read the corresponding field from the host chunk and return the property to the caller by setting `xsResult`. The `set` functions store the value provided into the host chunk. +`get`関数は、ホストチャンクから対応するフィールドを読み取り、`xsResult`を設定して呼び出し元にプロパティを返します。`set`関数は、提供された値をホストチャンクに格納します。 ```c void xs_rectangle_get_x(xsMachine *the) @@ -2473,7 +2473,7 @@ void xs_rectangle_set_x(xsMachine *the) } ``` -The `union` method returns the union of all the rectangles passed to the function. The `xs_rectangle_union` function uses the `xsmcArgc` macro to count the number or `Rectangle` instances. The union result is stored back into calling instance's host chunk. JavaScript applications read the result rectangle properties using the `get *()` methods. +`union`メソッドは、関数に渡されたすべての矩形の合併を返します。`xs_rectangle_union`関数は、`xsmcArgc`マクロを使用して`Rectangle`インスタンスの数をカウントします。合併結果は、呼び出しインスタンスのホストチャンクに格納し直されます。JavaScriptアプリケーションは、`get *()`メソッドを使用して結果の矩形プロパティを読み取ります。 ```c void xs_rectangle_union(xsMachine *the) @@ -2490,42 +2490,42 @@ void xs_rectangle_union(xsMachine *the) } ``` -Standalone functions -- functions that are not part of a class -- can also be implemented in C. The `@` syntax extension is used where the function body normally appears. +スタンドアロン関数 -- クラスの一部ではない関数 -- もCで実装できます。`@`構文拡張は、通常関数本体が表示される場所で使用されます。 ```c function restart() @ "xs_restart"; ``` -The value of `xsThis` in the implementation of `xs_restart` matches the receiver, which is `xsGlobal` in the following invocation. +`xs_restart`の実装における`xsThis`の値は、以下の呼び出しでは`xsGlobal`であるレシーバと一致します。 ```javascript restart(); ``` -## Glossary +## 用語集 -| Term | Definition | +| 用語 | 定義 | | :--- | :-- | -| constructor | In ECMAScript, a function that has a `prototype` property and that the `new` operator invokes to build an instance. The value of the `prototype` property becomes the prototype of the instances that the constructor builds. -| context | A pointer to an area where you can store and retrieve information for the XS runtime virtual machine in your callbacks. -| direct slot | One of the slot types that correspond to the ECMAScript primitive types (undefined, null, boolean, number, string, and symbol), plus an integer and stringx slot provided as an optimization. -| ECMAScript | An object-oriented, prototype-based language for implementing application logic and control. -| host | In ECMAScript terminology, an application that uses the XS runtime. -| host constructor | In XS, a constructor whose implementation is in C rather than ECMAScript. -| host function | In XS, a function whose implementation is in C rather than ECMAScript. -| host object | In XS, an object with data that can be directly accessed only in C. -| indirect slot | A type of slot that contains a reference to an instance of an object, function, array, and so on; corresponds to the ECMAScript `reference` type. -| instance | An object that inherits properties from another object, which is called its *prototype*. -| property | In ECMAScript, a value accessed by name within an object (in contrast to items accessed by index within an array); in XS in C, a slot accessed by index within an object (just as an item is accessed by index within an array). -| prototype | An object from which another object (called an instance) inherits properties. -| sandbox | An environment that is restricted to prevent untrusted code from harming the device on which the code is running. The sandbox for XS application scripts includes the standard features defined in the ECMAScript specification plus additional features as defined and permitted by the XS modules. -| slot | An opaque structure in which everything in the XS runtime is stored, and which is manipulated only through XS in C. -| XS | A toolkit, consisting of a runtime library and a command-line tool, that is designed for developing standards-based, networked, interactive multimedia applications (GUI-based runtimes) or command-line tools for various devices. See also xsruntime and xsc. -| XS runtime | The runtime library part of XS. -| XS in C | The C interface of the XS runtime. -| xsbug | The XS debugger, used to debug applications, modules, and scripts. -| xsc | The command-line tool part of XS. It compiles JavaScript files into XS binary files containing symbols and bytecodes, which is executed by the XS virtual machine that is contained within the XS runtime. +| constructor | ECMAScriptにおいて、`prototype`プロパティを持ち、`new`演算子がインスタンスを構築するために呼び出す関数。`prototype`プロパティの値は、コンストラクタが構築するインスタンスのプロトタイプになります。 +| context | コールバックでXSランタイム仮想マシンの情報を格納および取得できる領域へのポインタ。 +| direct slot | ECMAScriptプリミティブ型(undefined、null、boolean、number、string、symbol)に対応するスロット型の1つ。最適化として提供される整数と文字列スロットもあります。 +| ECMAScript | アプリケーションロジックと制御を実装するためのオブジェクト指向、プロトタイプベースの言語。 +| host | ECMAScript用語において、XSランタイムを使用するアプリケーション。 +| host constructor | XSにおいて、ECMAScriptではなくCで実装されたコンストラクタ。 +| host function | XSにおいて、ECMAScriptではなくCで実装された関数。 +| host object | XSにおいて、Cでのみ直接アクセスできるデータを持つオブジェクト。 +| indirect slot | オブジェクト、関数、配列などのインスタンスへの参照を含むスロットの型。ECMAScript `reference`型に対応します。 +| instance | 別のオブジェクト(*プロトタイプ*と呼ばれる)からプロパティを継承するオブジェクト。 +| property | ECMAScriptにおいて、オブジェクト内で名前によってアクセスされる値(配列内でインデックスによってアクセスされる項目とは対照的)。XS in Cにおいて、オブジェクト内でインデックスによってアクセスされるスロット(配列内で項目がインデックスによってアクセスされるのと同様)。 +| prototype | 別のオブジェクト(インスタンスと呼ばれる)がプロパティを継承する元となるオブジェクト。 +| sandbox | 信頼できないコードがコードを実行しているデバイスに害を与えることを防ぐために制限された環境。XSアプリケーションスクリプトのサンドボックスには、ECMAScript仕様で定義された標準機能と、XSモジュールによって定義および許可された追加機能が含まれます。 +| slot | XSランタイムですべてが格納される不透明な構造で、XS in Cを通してのみ操作されます。 +| XS | 標準ベースのネットワーク対応インタラクティブマルチメディアアプリケーション(GUIベースランタイム)または様々なデバイス用のコマンドラインツールを開発するために設計された、ランタイムライブラリとコマンドラインツールで構成されるツールキット。xsruntimeとxscも参照。 +| XS runtime | XSのランタイムライブラリ部分。 +| XS in C | XSランタイムのCインターフェース。 +| xsbug | アプリケーション、モジュール、スクリプトをデバッグするために使用されるXSデバッガ。 +| xsc | XSのコマンドラインツール部分。JavaScriptファイルをシンボルとバイトコードを含むXSバイナリファイルにコンパイルし、XSランタイム内に含まれるXS仮想マシンによって実行されます。 -## License +## ライセンス Copyright (c) 2016-2023 Moddable Tech, Inc. This file is part of the Moddable SDK Runtime. diff --git a/documentation/xs/handle.md b/documentation/xs/handle.md index 109bfcadb..c84421c57 100644 --- a/documentation/xs/handle.md +++ b/documentation/xs/handle.md @@ -1,58 +1,58 @@ -# Handle +# ハンドル Copyright 2016-17 Moddable Tech, Inc.
-Revised: May 17, 2017 +更新日: 2017年5月17日 -## Objective +## 目的 -To develop frameworks for microcontrollers with XS, the most significant constraint is RAM. +XSでマイクロコントローラ用のフレームワークを開発する際に、最も重要な制約はRAMです。 -The XS linker prepares most classes, prototypes, functions and byte codes to be accessed straightly from ROM. All the ECMAScript 2017 features, and most modules composing the frameworks are there, instantaneously available and requiring just a few KB of RAM. +XSリンカーは、ほとんどのクラス、プロトタイプ、関数、バイトコードをROMから直接アクセスできるように準備します。ECMAScript 2017のすべての機能と、フレームワークを構成するほとんどのモジュールがそこにあり、瞬時に利用可能で、わずか数KBのRAMしか必要としません。 -For everything that is created at runtime, applications rely on the XS garbage collector to manage memory. XS divides memory into two zones: the slots and the chunks. +実行時に作成されるすべてのものについて、アプリケーションはメモリを管理するためにXSガベージコレクタに依存します。XSはメモリを2つのゾーンに分割します:スロットとチャンクです。 -Slots have a fixed size (16 bytes on a 32-bit processor) and cannot move. Chunks have a variable size and can move. The XS garbage collector can compact chunks when necessary, which is a life saver for processors without an MMU. +スロットは固定サイズ(32ビットプロセッサでは16バイト)で移動できません。チャンクは可変サイズで移動できます。XSガベージコレクタは必要に応じてチャンクを圧縮でき、これはMMUを持たないプロセッサにとって救世主です。 -Slots are used for anything that fits: booleans, dates, instances, numbers, properties, references, symbols, etc. Chunks are used for everything else: byte codes, arrays, strings, etc. +スロットは、適合するすべてのものに使用されます:ブール値、日付、インスタンス、数値、プロパティ、参照、シンボルなど。チャンクは他のすべてに使用されます:バイトコード、配列、文字列など。 -In practice, the slot and chunk heaps works so well for reducing peak memory use that it is tempting to use JavaScript for everything. But, for critical operations, like the layout and the update of the screen, there is a second constraint: performance. +実際には、スロットとチャンクヒープは、ピークメモリ使用量を削減するのに非常によく機能するため、すべてにJavaScriptを使用したくなります。しかし、画面のレイアウトや更新などの重要な操作では、2つ目の制約があります:パフォーマンスです。 -Accessing properties to get and set their values, to call functions, etc., can have significant performance overhead when it is happening at every frame (30 or 60 fps). Even in the world of web browsers, where JavaScript engines sacrifice MB of RAM to optimize such dispatching and the layout and update of the screen are implemented in C or C++. +プロパティにアクセスして値を取得・設定したり、関数を呼び出したりすることは、フレームごと(30または60 fps)に発生すると、大きなパフォーマンスオーバーヘッドを生じることがあります。Webブラウザの世界でも、JavaScriptエンジンがそのようなディスパッチを最適化するためにMBのRAMを犠牲にし、画面のレイアウトと更新はCまたはC++で実装されています。 -XS handles allow C based objects implementations to access properties and to dispatch functions with native performance, while using the memory managed by XS, i.e. slots and chunks. +XSハンドルは、Cベースのオブジェクト実装が、XSが管理するメモリ(つまり、スロットとチャンク)を使用しながら、ネイティブパフォーマンスでプロパティにアクセスし、関数をディスパッチできるようにします。 -## Definition +## 定義 -As in the early days of macOS a handle is a pointer to a pointer to a memory block. A handle allows the system to move memory blocks to coalesce free space. Applications store the handle, instead of address of the pointer block, and deference the handle to access memory blocks. The value of the handle never changes, but the address of the memory block may. +macOSの初期の頃のように、ハンドルはメモリブロックへのポインタのポインタです。ハンドルにより、システムは空きスペースを結合するためにメモリブロックを移動できます。アプリケーションは、ポインタブロックのアドレスの代わりにハンドルを格納し、メモリブロックにアクセスするためにハンドルを逆参照します。ハンドルの値は変わりませんが、メモリブロックのアドレスは変わる可能性があります。 -In XS, it is similar: a handle is a pointer to a pointer to a chunk. Here is a schema: +XSでは同様です:ハンドルはチャンクへのポインタのポインタです。スキーマは以下の通りです: ![](./../assets/handle/handle.png) -The `HANDLE` is a pointer to the `DATA` part of a `HOST` slot. The `DATA` part of a `HOST` slot is a pointer to a chunk. Since slots do not move, a handle remains valid across garbage collections. The XS garbage collector updates the `DATA` part of a `HOST` slot when sweeping chunks. +`HANDLE`は`HOST`スロットの`DATA`部分へのポインタです。`HOST`スロットの`DATA`部分はチャンクへのポインタです。スロットは移動しないため、ハンドルはガベージコレクション間で有効なままです。XSガベージコレクタは、チャンクをスイープするときに`HOST`スロットの`DATA`部分を更新します。 -C based objects are chunks. They can contain anything, for instance colors, coordinates, dimensions, etc. Notice that for such values, C based objects are also saving memory since they can pack several values into one chunk instead of using one slot for each value. The memory savings by applying this approach can be considerable as a JavaScript property requires a slot (16 bytes on a typical MCU) which is larger than a native boolean (1 byte), integer (2 or 4 bytes), or even a floating point double (8 bytes). +Cベースのオブジェクトはチャンクです。色、座標、次元などの何でも含むことができます。そのような値について、Cベースのオブジェクトは、各値に1つのスロットを使用する代わりに複数の値を1つのチャンクにパックできるため、メモリも節約していることに注意してください。JavaScriptプロパティには、ネイティブブール値(1バイト)、整数(2または4バイト)、または浮動小数点double(8バイト)よりも大きいスロット(典型的なMCUでは16バイト)が必要であるため、このアプローチを適用することによるメモリ節約は相当なものになります。 -From JavaScript, C based objects are just host objects and are accessed thru the `INSTANCE` slot like any host objects. Thru the `PROTOTYPE` part of the `INSTANCE` slot, frameworks provides getters, setters and methods so applications can access and manipulate values as usual. +JavaScriptから、Cベースのオブジェクトは単なるホストオブジェクトであり、他のホストオブジェクトと同様に`INSTANCE`スロットを介してアクセスされます。`INSTANCE`スロットの`PROTOTYPE`部分を介して、フレームワークはゲッター、セッター、メソッドを提供し、アプリケーションが通常通り値にアクセスして操作できるようにします。 -## Implementation +## 実装 -C based objects reference other C based object thru handles, i.e. a chunk can contain a handle to another chunk. For instance a content accesses its container with +Cベースのオブジェクトは、ハンドルを介して他のCベースのオブジェクトを参照します。つまり、チャンクは別のチャンクへのハンドルを含むことができます。例えば、コンテンツは以下でそのコンテナにアクセスします: (*content)->container -That is essential for to achieve maximum performance. For instance, the layout hierarchy is traversed a lot when animating a screen at 30 fps. +これは、最大のパフォーマンスを達成するために不可欠です。例えば、30 fpsで画面をアニメーション化するときに、レイアウト階層が多く走査されます。 -What happens when XS collects garbage if a handle inside a chunk is the only reference to a C based object? +チャンク内のハンドルがCベースのオブジェクトへの唯一の参照である場合、XSがガベージコレクションを行うとどうなるでしょうか? -By convention, at the beginning of each chunk corresponding to a C based object there is a pointer that is a `REFERENCE` to the `INSTANCE` slot. +慣例により、Cベースのオブジェクトに対応する各チャンクの開始時に、`INSTANCE`スロットへの`REFERENCE`であるポインタがあります。 -C based objects implement host `HOOKS`, which are XS garbage collector callbacks. It is the responsibility of the C based object to use such callbacks to mark its references +Cベースのオブジェクトは、XSガベージコレクタコールバックであるホスト`HOOKS`を実装します。Cベースのオブジェクトは、そのようなコールバックを使用してその参照をマークする責任があります: xsMarkSlot(the, (*((*content)->container))->reference); -## Example +## 例 -Please look at the *Piu* sources, which implement part of the *KinomaJS* programming interface on microcontrollers using the *Commodetto* graphics library. +*Commodetto*グラフィックスライブラリを使用してマイクロコントローラ上で*KinomaJS*プログラミングインターフェースの一部を実装する*Piu*ソースを参照してください。 diff --git a/documentation/xs/xst.md b/documentation/xs/xst.md index 4bf39576a..049a55cbe 100644 --- a/documentation/xs/xst.md +++ b/documentation/xs/xst.md @@ -1,9 +1,9 @@ # xst -Updated: June 3, 2024 +更新日: 2024年6月3日 -`xst` is the XS test engine, a JavaScript engine to test XS on Linux, macOS and Windows. +`xst`はXSテストエンジンで、Linux、macOS、WindowsでXSをテストするためのJavaScriptエンジンです。 -## Build +## ビルド ### Linux @@ -20,45 +20,44 @@ Updated: June 3, 2024 cd %MODDABLE%\xs\makefiles\win build -## Download +## ダウンロード -You can use the [jsvu CLI](https://github.com/GoogleChromeLabs/jsvu) to install or update **xst**. +[jsvu CLI](https://github.com/GoogleChromeLabs/jsvu)を使用して**xst**をインストールまたは更新できます。 -You can also download the latest versions of `xst` -from the [moddable-xst](https://github.com/Moddable-OpenSource/moddable-xst/releases) repository into a directory that is on your `PATH` +`PATH`上のディレクトリに[moddable-xst](https://github.com/Moddable-OpenSource/moddable-xst/releases)リポジトリから`xst`の最新版をダウンロードすることもできます。 -## Usage +## 使用方法 xst [-h] [-e] [-m] [-s] [-v] [-l] [-lc] [-b] [-j] strings... -- `-h`: print this help message -- `-e`: eval `strings` -- `-m`: `strings` are paths to modules -- `-s`: `strings` are paths to scripts -- `-v`: print XS version and configuration (slot and ID sizes) -- `-l`: execute scripts under Hardened JavaScript's `lockdown` -- `-lc`: execute scripts inside a `Compartment` under Hardened JavaScript's `lockdown`` -- `-b` - scripts are binary buffers of UTF-8 data. Will be paassed through TextDecoder before parsing -- `-j` - scripts are JSON and will be passed to `JSON.parse()` instead of executed +- `-h`: このヘルプメッセージを表示 +- `-e`: `strings`を評価 +- `-m`: `strings`はモジュールへのパス +- `-s`: `strings`はスクリプトへのパス +- `-v`: XSバージョンと設定(スロットとIDサイズ)を表示 +- `-l`: Hardened JavaScriptの`lockdown`下でスクリプトを実行 +- `-lc`: Hardened JavaScriptの`lockdown`下で`Compartment`内でスクリプトを実行 +- `-b` - スクリプトはUTF-8データのバイナリバッファ。パース前にTextDecoderを通す +- `-j` - スクリプトはJSONで、実行する代わりに`JSON.parse()`に渡す -Without the `-e`, `-m` or `-s` options, `strings` are paths to **test262** cases or directories. +`-e`、`-m`、または`-s`オプションがない場合、`strings`は**test262**ケースまたはディレクトリへのパスです。 ### eshost -To test XS with **eshost**, install the [eshost CLI](https://github.com/bterlson/eshost-cli). Then add XS to the hosts: +**eshost**でXSをテストするには、[eshost CLI](https://github.com/bterlson/eshost-cli)をインストールします。その後、XSをホストに追加します: eshost --add 'XS' xs ~/.jsvu/xst -**eshost** uses the `-s` option of **xst**. +**eshost**は**xst**の`-s`オプションを使用します。 ### test262 -To test XS with **test262**, clone [test262](https://github.com/tc39/test262) and change the directory to the `test` directory inside the `test262` directory. For instance: +**test262**でXSをテストするには、[test262](https://github.com/tc39/test262)をクローンし、`test262`ディレクトリ内の`test`ディレクトリに移動します。例えば: cd ~/test262/test xst language/block-scope xst built-ins/TypedArrays/buffer-arg-* -See [XS Conformance](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/xs/XS%20Conformance.md) for details about how **XS** currently passes **test262** cases. +**XS**が現在**test262**ケースをどのようにパスしているかの詳細については、[XS準拠性](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/xs/XS%20Conformance.md)を参照してください。