Getting Started
Installation
Type-C setup currently involves manual work as the the language has not been officially release yet. Hence, we will need to manually install the following:
- Type-C Compiler: A typescript project, requires node & npm
- Type-V: Type-C Virtual Machine, built in C11 requires GCC/Clang, CMake
- Standard Library: Type-C stdlib lib, no requirements.
1. Install Type-V
Prerequisite:
MacOS:
Ubuntu:
On ubuntu you need to add the following compiler directive to the CMakeLists.txt file in the root type-v directory:
The reason for this, is the VM using C11 features such as aligned_alloc and strdup. This will be replace with mi_malloc soon enough, but for now, they cause sanitizers errors so i had it off.
clang is recommended over gcc as the performance gains tested on Linux are significant.
Windows:
Untested.
Postrequisite:
Export the path to the type-v folder as TYPE_V_PATH in your environment.
2. Install stdlib
Export the path to the stdlib folder as TYPE_C_STDLIB in your environment.
3: Install Type-C
Either clone this repo
with dist/index.js being the entry point for the CLI
Or
You can now use the typec command in your terminal. Type typec --help for more information.
Remember you need to have both TYPE_V_PATH and TYPE_C_STDLIB exported in your environment.
Both TYPE_V_PATH and TYPE_C_STDLIB should point to directories
Creating a Project
Use CLI:
If you have installed the CLI, you can create a new project with the following command:
This will create the folder if needed, and create a module.json and main.tc files in the folder.
Manual:
To create a new project, we will need to create a new folder, and create a module.json file. This file contains the project compiler settings, dependencies, search path, etc.
As for now, only the compiler.entry field is used. This field specifies the entry point of the project.
Running the project:
First compiling the project with type-c compiler: node outs/index.js -c [path-to-module.json folder] -o [output-directory] Then run the output with the type-v virtual machine: ./type-v [output-directory]/bin.tvb [output-directory]/src_map.map.txt
The src_map.map.txt file is generated by the compiler and contains the source map to be able to trace crashes.