- Const Generics is finally here. Now generic parameters can expect either a type or a constant expression. Currently, signed & unsigned integers, booleans, string slices, choice types and arrays of these types can be part of a normal constant expression used in a generic entity. The new type wrapping feature can be used to have a constant expression that holds a type. Currently only the specified types can be part of const generics, but theoretically a value of any type that is const constructible, that has the const equality operator and that is const-convertible to a string slice can be used in const generics. This makes the language so much more powerful. The generics is compile time and "zero cost". There can be a default expression for a const generic parameter, and a default type for a generic type parameter. If all generic parameters have default values, the generic entity can be default instantiated, by providing an empty list of generic parameter values.
type SomeTy'<T = i64, const K :: i32 = 10> { pub a :: T. } main -> i32 () [ new s = SomeTy'<>{ 20_i64 }. new s2 = SomeTy'<i32, 35>{ 40 }. give 0. ]
region
is finally here. Regions provide memory safe pointers without having to deal with lifetime issues. The constructors are called when the data is owned and the destructors are called when the program ends. This uses an arena allocator that requests memory at least as big as PAGE_SIZE, and only makes another request if the current block doesn't have any more unused memory. The memory is deallocated only at the end of the program. Regions are part of the type system. New regions with custom names can be createdregion MyRegion.
- Constant
default
expression. This is primarily intended to be used with const generics, but will also support const construction of types in the future.// Both sentences below results in the same type, in the const-generic example SomeTy'<i32, default>{ 40 }. SomeTy'<i32, 10>{ 40 }.
- Type Wrapping concept has been added.
IR::TypedType
is used to represent/hold another type, which can be used in constant expressions - Modular destruction for all types in the IR, that ensures that no values are left undestroyed.
- Pattern matching for string slices. The comparisons are done inline to prevent additional allocations. Now multiple values can be matched for a match case, for all types supported
- Added
bool
type to the IR, which is a specialisation of the 1-bit unsigned integer type - Conditions provided in if-else is now expected to be of
bool
type - Added
==
and!=
operator for string slices. Also supports constant string slices, that are done in compile time if both strings are constants. - Significant updates for pattern matching to support compile time comparisons and const expressions. This is taken advantage of in
if
-else
andmatch
blocks to emit only the branches that will be executed. - If
else
case is not present inmatch
block, the user is now warned. Previously an errow was thrown - Accessing member fields now has optimisations, mostly for constant values
- Fixed constant issue in global declarations. If the declaration had variability, the exact opposite value was used. This caused crash when the global variable was reassigned.
- AST and IR representation for member functions have been updated so that both core types and mix types can be used in the future. Now only core types can be used.
- Pointers now have region ownership. Pointers of this ownership can be used without checking for lifetime as they are guaranteed to be safe.
- Now tags of loops are checked against other tags and also local values. Previously only existing tags were checked.
- Binary expressions now supports multipointers
- Fixed issue while converting
FileRange
toJson
. Any exception will cause an empty file path to be used in the Json representation. - Entity names and symbols were previously represented using
std::string
, but it is now represented using theIdentifier
datatype. This concept is integrated in the entire codebase now. - New
EntityOverview
system used for IDE integration. AddedIR::Mention
which is used in IDEs for tracking entity references, displaying hover information and providing document links - Added
--export-code-info
option to export metadata about the code, which is meant to be used by IDE tooling - Unified name checking system. Previously name conflict checks were performed independenly for each entity in different parts of the codebase, but now it is done in a unified way
- Fixed issue while creating directories.
fs::create_directory
was used which did not do it recursively, thereby causing problems. The function has been changed tofs::create_directories
- Errors happening during CLI configuration is now reported by
IR::Context
, which makes it easily recognisable by IDEs --keep-llvm
option to prevent deletion of generated llvm files.--export-ast
is now an option instead of a command to be more flexible and useful. The AST files are now exported inside the AST folder in the build directory- CLI display now by default doesn't have colors. In further stages, it is checked if the
--no-colors
option is provided, and the behaviour is changed accordingly - Fixed naming issues while creating llvm equivalents for multipointers
- Updates to support compatibility between pointers with specific ownership and pointers with anonymous ownership. While anonymous pointers cannot be converted to any other type of ownership, the opposite is always possible.
- Removed unnecessary loading for multipointers in the
[ ]
operator - Type Inference has been added to
ast::TernaryExpression
and it supports type inference for signed and unsigned integer literals, null pointers, default expression & none expression. Fixed loading issue for local values - Type inference checks for integer and unsigned integer literals
- Owned pointers are properly freed in return sites of a function. This also happens in the destructor of core types if the member field is an owned pointer
- Optimisation to avoid multiple allocations are now present for owned constructor call. This even works if the type is a
maybe
- Fixed minor issue in conditional branches that the rest block was not linked and was incorrectly placed in the block tree
- Improved binary expression parsing. While parsing a binary expression, the LHS and the binary operator were stored separately, which might cause ordering issues and incorrect access to the expressions. That was a hacky way to maintain parser state. Now, the LHS and the binary operator are stored as one, thereby making the system less fragile
none
expression support type inference. This makes the compiler more user friendly and intuitive. Previously, the type had to be manually provided- Since
future
&maybe
are built-in types, better type inference is required to avoid incorrect errors. Now, type inference fordefault
,none
, signed & unsigned integers has been updated to be compatible withfuture
andmaybe
datatypes - Compiler version is set in
llvm::Module
instances usingllvm::VersionTuple
which is created in the CLI configuration stage - Fixed issue #6 where doing
qat run
command to build and run the executable, did not execute the built binary. - Support for multiple executables is there when you do the command
qat run
IR::Context
stores paths to all executables built by the compiler. This is then used when the executables have to be run, if the user ran theqat run
command- Cleaned up the information displayed when the user ran the
qat version
command - Fixed issue that the logic for
&&
and||
were missing in the parser - If the output directory provided to the compiler did not exits, previously an error was thrown. Now an attempt is made to create the directory, if not possible an error is thrown.
heap
expressions are updated to use multipointers- No more third party output in any compiler stage, besides that of the built executables.
- So many more updates, improvements and additions under the hood...
- Significant changes to the parser logic for expressions. The changes are related to the caching of symbols and expressions.
- Parser logic cleanup - removed a lot of legacy logic that caused old syntax to be still valid. Parsing of expressions is now handled totally