Moai+Easter Advanced Manual

Moai Manual Advanced Manual Annoucement FAQ
ご案内 Moaiエンジン CustomBoyエンジン HowToコンパイル Moai CGI Developers Raraku言語
Raraku言語マニュアル(前編) Raraku言語マニュアル(後編) Raraku Advanced document

はじめに

This article summarizes the specifications for the Raraku virtual machine.

目次



Specifications of RRKX format

Begining


The first 4 bytes of an RRKX file are "RRKX". The next 4 bytes are the version number, with the first 2 bytes being the major version and the last 2 bytes being the minor version. In the RRKX format, numbers are always big-endian. The latest version of RRKX at this stage is 1.0, so this 4 byte would be 0x00 0x01 0x00 0x00.

Header Section


The next section is the header section. This section is mandatory. The header section begins with HDRB and ends with HDRE.

The first section in the header is the UST (USeType) section. This declares a list of keywords (4 bytes each) indicating the type used in the header. This section starts with USTB (4 bytes), followed by 4 bytes indicating the number of elements in this list. This section ends with "USTE" (4 bytes). For example, in the case of "USTBLLLXDLLX_ECHOUNKNUSTE", the four keywords "LLXD", "LLX_", "ECHO", and "UNKN" are declared in this section. These lists are in case future versions of Raraku add new keywords to the headers. That is, if an older version of Raraku reads the RRKX format of a newer version of Raraku, these are to be recognizable as legitimate keywords (In this way, it can be expected that older versions will have some reasonable error handling and alternative processing).

The next section in the header is optional and is a sequence of one of the following keys.
  1. "LLXD" Section:
  2. This section starts with "LLXD" (4 bytes), followed by 4 bytes indicating the size of string value. This size is the size of the C string including the null character. For example, if the value is the string "hello" (which has a strlen value of 5), the size is 6. This is followed by the actual string, but since RRKX is basically specified in 4-byte alignment, the following string is also aligned with this and any fraction less than a multiple of 4 is filled with 0x00. For example, in the case of "hello", three 0x00 actually follows after the "hello" because it needs to fit into 8 bytes.

    This value is the path to the libraries that RRKX automatically imports upon loading. This path is specified without extension. At this time, the native DLib (Dynamic link Library) associated with this library is also loaded. For example, if the path to this library is "extens/kau/kau", the appropriate extension is automatically appended to it and "extens/kau/kau.rrkx" and the corresponding native DLibs "extens/kau/kau.dll" (for Windows) or extens/kau/kau.so" (for Linux systems) are loaded.

  3. "LLX_" Section:
  4. This section starts with "LLX_" (4 bytes), followed by 4 bytes indicating the size of string value. The method of specifying the size and string that follows is the same as for LLDX. The meaning of the value specified in this key is almost the same as in LLDX. The only difference is that native DLibs are not loaded. In other words, for libraries consisting only of RRKX files, this key is used to specify their paths.

  5. "ECHO" Section:
  6. This section starts with "ECHO" (4 bytes), followed by 4 bytes indicating the size of string value. The method of specifying the size and string that follows is the same as for LLDX. This keyword outputs the string specified as the value as an error/report message in RarakuVM. It can be used for debugging purposes by developers involved in generating RRKX.

  7. "ALTB"-"ALTE"(ALTernative) Section:
  8. This section starts with "ALTB" (4 bytes), followed by 4 bytes indicating the number of this list. The elements of this list must always begin with the keyword (4 bytes) followed by the size of the element. The keyword for each element may be an unknown keyword that will be introduced in a future version of Raraku. In this case, however, the keywords must always be those specified in the USTB-USTE list.

    The RarakuVM first reads the elements in this list in order from the beginning, skipping any unsupported keywords (hence the size specification is mandatory for each element). Then, if it reads a supporting element, it executes that element and skips the rest. If there is no supported element, nothing is executed. For example, the sequence would be as follows.

    ALTB + 3(num) + VER3 + 6(size) + "hello" 0x00 0x00 0x00 + VER2 + 5(size) + "rrkx" + 0x00 0x00 0x00 0x00 + LLX_ + 15(size) + "extens/kau/kau" 0x00 + ALTE

    This example specifies an ALTB-ALTE list with three elements. Each element is aligned in the following order: a keyword indicating its type, the size of its entity, and its entity. The last entity is aligned with the 4-byte alignment as in LLXD, and the extra bytes are filled with 0x00. In this example, VER3 is first checked to see if it is supported, and if so, it is executed. If not, it checks if VER2 is supported, and if so, it executes it. If not, the last LLX_ is executed. In other words, it is executed selectively, like an if-else statement.

EMDS Section


The next section is the EMDS section. This section is mandatory. This section starts with "EMDS" (4 bytes), followed by 4 bytes indicating the number of this list. The elements of this list must always begin with the size of the element entity, and followed by its entity. The entity of this element is currently a name to identify each RrkExe. RrkExe is a single unit containing the execution instructions for the Raraku virtual machine, originally derived from a single rrks source code or rrkh header file.

SECB-SECE Sections


The next section is a sequence of SECB-SECE Sections. These section start with "SECB" (4-byte), followed by "KIND", "PKGN", "FILE", "IMPT", "EXPT", "ISGM", "CNST", "ENUM" and "TYPE. These section end with "SECE" (4-byte).




目次に戻る

Raraku Activate from C-Language

Introduction




目次に戻る

Extens of Raraku

Introduction




目次に戻る

This article was written by:
none image

Mr.Moai

@znk project