Veil is planned to be a gradually typed, and multi-paradigm programming language supports both object-oriented & functional programming.
This project serves as an exercise on C++
and a way to learn how a programming language with a runtime could work under the hood.
My current goal of this project is to complete the runtime, then implement a simple compiler in whatever language I feel comfortable in
(Python
or Java
), and re-implement the compiler in Veil language as a proof of principle.
Ofcoz there is a much harder quest to implement a just-in-time compiler targeting branches (or I should say it is a trace JIT), which
based on a exposed compiler interface in the runtime, so that we can support any type of compiler backend. The JIT will most likely be
built with a language with memory-safety, maybe in Rust
or even in Veil
itself...
The Fabric runtime is for running the Fabric bytecode generated by a compiler from the Veil code, and is implemented
by C++, is designed from the ground up to support multi-threaded environment. And to be fully embeddable into other C++
projects, there will be no globally defined states.
To keep the code structure as clear as possible, I planned to use the fully power of OOP provided by C++
, and leave all rooms of
performance enhancements & optimizations to the JIT compiler.
Future prospects includes adding a JIT compiler, rewrite part of the VM service code base using Veil... etc.
- Namespaces:
lowercase
single word. - Class:
CamelCase
- Methods:
snake_case
, with single words for public action methods; multi-word for private methods or methods that are not supposed to be used or exposed outside of class scope. - Variables:
snake_case
and better to be verbose with at least one_
to avoid collision with comments. - Attributes:
snake_case
and better to be verbose with at least one_
to avoid collision with comments. - Constants:
ALL_CAPS
and use keywordconst
but not macros. - Structs:
CamelCase
as a multi-part wrapper;snake_case_t
as a primitive capsule. - Macros:
CamelCase
- Labels:
CamelCase
- Integer like types in the code should use the
typedef
defined types infabric/src/typedefs.hpp
. - All error code of the VM runtime should be type
uint32
and reside in a namespace specific for their usage, and defined only infabric/src/errors.hpp
. - Except for special header files, all code under a subdirectory of
fabric/src
should be defined in a specificnamespace
. - All native or OS related platform specific code of a subdirectory of
fabric/src
should all be placed withinos.hpp
&os.cpp
, and reside in the namespace ofveil::os
. - Platform specific methods under the namespace of
veil::os
should all contain an error return parameter:some_native_method(..., uint32 &error)
. - All
class
that will be part of the VM structure should either be a subtype ofHeapObject
,Arenaobject
orValueObject
.
-
Implement utility structures.
-
ArrayList
-
-
Implement the memory management.
- Implement the core modules.
-
Management
-
Pointer
-
Allocator
- Interface of
Algorithm
-
- Implement the standard management algorithm.
- Implement the core modules.
-
Implement all encapsulations of OS specific threading primitives.
-
Thread
- Implement the basic encapsulations.
- Able to execute a
VMService
. - Priority settings for all OS threads.
-
Mutex
-
ConditionVariable
- Atomics
- Add handling for spurious wakeup of
ConditionVariable
.
-
-
Implement VM specific threading primitives.
- A low object memory footprint queue-based thread synchronization primitive
OrderedQueue
.
- A low object memory footprint queue-based thread synchronization primitive
-
Exchange all existing usage of
<atomic>
and<condition_variable>
to the encapsulations.-
OrderedQueue
-
-
Implement the thread management.
- All management's functionality should be protected by a mutex.
- This is a legacy requirement, since the management (aka. scheduler) is running a single threaded loop to process all thread controls.
- Service spawning & termination using the underlying thread.
- Thread sleep & wake.
- Thread interrupt.
- Thread pause & resume.
-
VMService
joining with anotherVMService
. - Scheduler termination.
- All management's functionality should be protected by a mutex.
-
Implement the Veil execution environment.
- Design the Veil VM bytecode specifications.
- Implement the Veil bytecode interpreter.
- Implement
VeilThread
.