Aug 13, 2022Kuina-chan
This is the language specification 11 of Kuin Programming Language, and is about the compiler and the IDE.
There are two types of Kuin compilers: kuin.exe, which comes with an editor and debugger, and kuincl.exe, which can compile on the command line.
The compilation options for kuincl.exe are shown in Table 2-1.
|Compilation Option||Description||Behavior When Omitted|
|-i file||Specify the .kn file to compile.||Show help on how to use the compiler.|
|-o file||Specify the .exe file to output.||Generate out.exe in the same directory as the .kn file specified by -i.|
|-s directory||Specify the system directory.||directory where the compiler is located/sys/|
|-c file||Specify the .ico file to be set as the icon.||Default icon.|
|-p directory||Specify the location of the resource directory (/res/).||The same directory as the .kn file specified by -i.|
|-f directory||Specify a text file with the related file names.||None.|
|-e execution environment||Specify the execution environment.||exe (executable file for windows)|
|-x additional option||Additional options defined for each execution environment.||None.|
|-r||Do a release build.||Do a debug build.|
|-h||Show help on how to use the compiler.||None.|
|-v||Show compiler version.||None.|
|-q||Suppress output other than errors and warnings.||None.|
Either option can be omitted. Each compilation option is explained in detail below.
It's an acronym for input. Specify the .kn file where the main function exists.
It's an acronym for output. Specify the executable file to output. If you omit it, an executable file with the name out.exe will be generated in the same directory as the .kn file specified by -i.
It's an acronym for system. Specify the system directory. Usually, you can omit it.
It's the second letter of icon. If you specify an .ico file, that icon will be used for the executable and window icons. If you omit it, the default icon prepared by Kuin will be set.
It's an acronym for pack. Specify the location of the resource directory (/res/). If you omit it, "/res/" will be assumed to exist in the same directory as the .kn file specified by -i.
It's an acronym for files. Specify a text file with the related file names to be copied in the output directory.
Write the contents of the text file one line at a time, repeating "full path of the source file" and "relative path of the destination file from the destination directory".
It's an acronym for environment. Specify the execution environment shown in Table 2-2. If you omit it, it is regarded as "-e exe".
|Compilation Option||Execution Environment|
|-e exe||Generate an executable file for Windows.|
|-e cpp||Generate source code for C++.|
The specified value can be referenced in the program as a char type using 'env("e")'. For example, if you specify "-e exe," you can write 'env("e")' in the program to get the value of '"exe"' as a constant.
It's an acronym for extra. Specify the additional options defined for each execution environment specified by -e. You can specify more than one of them (Table 2-3).
|-e Specification||Compilation Option||Description|
|Any Specification||-x binary||(Use of this function is prohibited during implementation.)|
|Any Specification||-x hint||Generate hint information for Kuin Editor (advanced feature).|
|exe||-x dbgbreak||To make it easier for the debugger to attach, a breakpoint exception (INT3) is raised after a message box is displayed immediately after the program starts.|
|exe||-x pause||Valid only when "-x wnd" is not specified. Execute the "pause" command at the end of the program (advanced feature).|
|exe||-x wnd||Make it a window application. If omitted, it becomes a console application.|
|cpp||-x lib||Generate an entry point for the library.|
|cpp||-x nogc||Disable garbage collection (GC) and release the allocated heap at the end of the program.|
|cpp||-x nogcdb||Valid only when "-x nogc" is specified. Double-buffering the heap (advanced feature).|
Users are free to create their own compilation options. The specified value can be referenced in the program as a char type using "env()". For example, if you specify "-x option", you can write 'env("option")' in the program to get the value of '"true"' as a constant. As you can see, '"true"' will be returned if the option is defined, and the empty string '""' will be returned if it is not defined.
You can also specify the value of a compile option, as in "-x option=abc". In this case, the value of '"abc"' can be obtained as a constant by writing 'env("option")' in the program.
It's an acronym for release. If this option is specified, a release build will be performed; if it is omitted, a debug build will be performed.
The specified value can be referenced as a bool type from the dbg constant in the program. If you specify "-r", you can get the value of false by writing "dbg" in the program. If you do not specify "-r", then dbg will be true.
It's an acronym for help. This option will show you how to use kuincl.exe.
It's an acronym for version. This option will display the compiler version.
It's an acronym for quiet. This option suppresses all output except errors and warnings. Specify this option if you do not want to output anything as a log when the process succeeds.
The following is a summary of the compile-time specification of Kuin.
The special specification of the file to be compiled is shown in Figure 3-1.
The difference between a debug build and a release build is shown in Table 3-1.
|Matter||Debug Build||Release Build|
|Usage||Use routinely during development.||Use only once upon completion.|
|Optimization||No optimization, prioritize compilation speed.||Optimize and prioritize execution speed.|
|Encryption Pack For Resource Data||None||Encryption packing.|
|Value Of dbg Constant||dbg will be true.||dbg will be false.|
|assert||Check for assertions at runtime.||Remove assert statements.|
|Array Out-of-range Access Check||Raising an exception for out-of-range access.||Do not check for out-of-range access.|
Many other exceptions raised by the standard library and built-in functions will not be raised at release build time.
In general, development is done in a flow where a debugging build with fast compilation is used for careful verification, and a release build is used to generate files for distribution upon completion.
The environment in which the executable generated by the compiler runs is shown in Table 3-2.
|-e exe -x wnd||A window application that runs on Windows 7 or later (Windows 10, etc.) in a 64-bit environment and can utilize graphics functions.|
|-e exe||A console application that runs on Windows 7 or later (Windows 10, etc.) in a 64-bit environment and runs on the command prompt.|
|-e cpp||C++ source code that can be built with Visual C++, g++, clang++, etc.|