SIMPOL Documentation

Chapter 3. The Superbase NG Project

This chapter briefly covers what a Superbase NG project is and what are its components.

Introduction

Source code files in SIMPOL are stored with one of two file extensions: sma or smu. The first extension indicates that the file content is stored in an ASCII format (1 byte per character) and the second one indicates that the file content is stored in Unicode format. Unicode can be stored in a number of different formats. SIMPOL Unicode source files currently must be stored in UCS-2 and should begin with what is known as a byte-order mark (BOM). UCS-2 format stores characters using two bytes per character. It is considered good form to also use the byte order mark (0xFEFF) as the first character. This allows the reading program to determine whether the characters are stored with the least significant byte or with the most significant byte first.

Here is an example of SIMPOL source code:

function main()
  string s
  s = "Hello"
end function s

After compiling a SIMPOL source code file the result is a byte-code file. SIMPOL byte-code files come in two flavors: programs and libraries. These are distinguished by the file extensions smp and sml respectively. The only difference between them is that the program files are produced from projects that contain a main() function. That is the entry point for a SIMPOL program. Compiled programs that do not include a main() function can not be executed but can be linked to other programs to provide functions and data types that can be called or used. They can also be loaded dynamically.

Here are two examples of the compilation process:

  1. MySIMPOLFile1.sma —> MySIMPOLFile1.smp

  2. MySIMPOLFile2.sma —> MySIMPOLFile2.sml

After the compilation process, if multiple source files are used to produce the resulting program, the smp file is joined with each of the sml files in a linking type of process in order to produce the final program.

Here is an example of the linking process:

  1. MySIMPOLFile1.smp + MySIMPOLFile2.sml —> MyProgram.smp

Following the linking process, we can execute the SIMPOL program file in the IDE or depending on the type of program from the command line or as the result of entering a URL in a web browser. The IDE will call the SIMPOL virtual machine (SVM)and pass it the program and any command line arguments that have been defined. The SVM then executes the program file. SIMPOL programs usually return a result string, which will be displayed in the IDE or if called from the command line will be sent to standard out. In the case of a web server program, the result is normally a web page.

A SIMPOL project is a group of sma and/or smu files and the description of how the compilation and link is to be done. It also includes a definition of which directories to search in for included files and potentially one or more targets to be created from the final result. It also includes the list of pre-compiled libraries to link with, in addition to any library modules that are produced as part of the project itself. SIMPOL source code files can also include any number of other SIMPOL source code files which themselves may include yet others. Typically a project may consist of a main source code file that then includes other source code files, which may then include others. This results in a tree of files below the main file and this is shown in the project window to the left of the area where the source files are edited. For each module in the project, there is a main source file. Each main source code file is the top of a tree of included source code files. The SIMPOL language statement to include a file is include followed by the file name as a string.

It is not possible to simply compile and execute any source code file (if it has a main() function) using the IDE. Changes that were made to dynamically load the required components mean that the component information is added to the project by the IDE build process. Whether for a simple or complex project, the Superbase NG IDE's real strength is in compiling and linking complex projects. The normal approach to working with the IDE is to create a project and then to build it. This results in either a program or library that can be either executed or loaded into the SVM.

The following is an example of building a project:

  1. Project's main source code files: MyFile1.sma, MyFile2.sma

  2. MyFile1.sma — includes —> MyFile1a.sma, MyFile1b.sma

  3. MyFile2.sma — includes —> MyFile2a.sma

  4. MyFile1.sma — compiles to —> MyFile1.smp

  5. MyFile2.sma — compiles to —> MyFile2.sml

  6. MyFile1.smp + MyFile2.sml — links to —> MyFile1.smp located in the bin directory of the project.

The SIMPOL IDE manages the time dependencies between SIMPOL files, so if in the previous example, we update the file MyFile2a.sma, the only file that is going to be compiled when we do a build, is MyFile2.sma, because it is the only main source code file affected.

The project description is stored in a file with the extension smj. For example, in the previous example the project file name would have been MyFile2.smj.