Issues that must be concerned for pre-compiling library code
Library code should be pre-compiled into binary to ensure quick loading when imported as a module. Since the BlueScript VM dynamically assigns unique identifiers to various type-related components on demand for distinction, the following issues must be considered.
-
module ID. When a program is imported as a module, a module identifier is attached to global symbols in the C program after translation. A module identifier is a sequence of digits. Because the BlueScript VM does not generate a module identifier starting with the digit 0, library code must be precompiled with a unique module identifier starting wth the digit 0. The BlueScript developers must ensure that a unique module identifier is given to every library code (source file).
-
array of class types. When library code declares a class type and it is pre-compiled, an array type of that class type must not be used in the library code. This restriction is because the BlueScript VM dynamically gives every array type an unique identifier for distinction. It also generates a unique global data structure for every array type in the C language. The BlueScript VM currently cannot reserve an array-type identifier for library code.
-
property/method names. When library code including class declarations is pre-compiled, the property and method names in the class declarations must be collected and they must be registered when the BlueScript VM restarts with the pre-compiled library code. This is because all property and method names are encoded into unique integers and the unique integers are dynamically assigned to the names.
- See
propertyNames() and addPropertyName() in the ClassTable class.
Issues that must be concerned for pre-compiling library code
Library code should be pre-compiled into binary to ensure quick loading when imported as a module. Since the BlueScript VM dynamically assigns unique identifiers to various type-related components on demand for distinction, the following issues must be considered.
module ID. When a program is imported as a module, a module identifier is attached to global symbols in the C program after translation. A module identifier is a sequence of digits. Because the BlueScript VM does not generate a module identifier starting with the digit 0, library code must be precompiled with a unique module identifier starting wth the digit 0. The BlueScript developers must ensure that a unique module identifier is given to every library code (source file).
array of class types. When library code declares a class type and it is pre-compiled, an array type of that class type must not be used in the library code. This restriction is because the BlueScript VM dynamically gives every array type an unique identifier for distinction. It also generates a unique global data structure for every array type in the C language. The BlueScript VM currently cannot reserve an array-type identifier for library code.
property/method names. When library code including class declarations is pre-compiled, the property and method names in the class declarations must be collected and they must be registered when the BlueScript VM restarts with the pre-compiled library code. This is because all property and method names are encoded into unique integers and the unique integers are dynamically assigned to the names.
propertyNames()andaddPropertyName()in theClassTableclass.